mirror of
https://github.com/3proxy/3proxy.git
synced 2026-06-13 11:00:11 +08:00
Compare commits
8 Commits
6c3c5f31a2
...
b1ac46da79
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b1ac46da79 | ||
|
|
d125261e8c | ||
|
|
a4527783d6 | ||
|
|
fb70d06d3e | ||
|
|
57d687fcb8 | ||
|
|
ada24a98ec | ||
|
|
ba2584cebf | ||
|
|
05096c222a |
4
.github/workflows/build-watcom.yml
vendored
4
.github/workflows/build-watcom.yml
vendored
@ -45,7 +45,7 @@ jobs:
|
|||||||
mkdir dist\3proxy\doc\ru
|
mkdir dist\3proxy\doc\ru
|
||||||
mkdir dist\3proxy\doc\html
|
mkdir dist\3proxy\doc\html
|
||||||
mkdir dist\3proxy\doc\html\plugins
|
mkdir dist\3proxy\doc\html\plugins
|
||||||
mkdir dist\3proxy\doc\html\man3
|
mkdir dist\3proxy\doc\html\man5
|
||||||
mkdir dist\3proxy\doc\html\man8
|
mkdir dist\3proxy\doc\html\man8
|
||||||
mkdir dist\3proxy\doc\devel
|
mkdir dist\3proxy\doc\devel
|
||||||
copy bin\3proxy.exe dist\3proxy\bin\
|
copy bin\3proxy.exe dist\3proxy\bin\
|
||||||
@ -57,7 +57,7 @@ jobs:
|
|||||||
copy doc\html\*.* dist\3proxy\doc\html\
|
copy doc\html\*.* dist\3proxy\doc\html\
|
||||||
copy doc\html\plugins\*.* dist\3proxy\doc\html\plugins\
|
copy doc\html\plugins\*.* dist\3proxy\doc\html\plugins\
|
||||||
copy doc\html\man8\*.* dist\3proxy\doc\html\man8\
|
copy doc\html\man8\*.* dist\3proxy\doc\html\man8\
|
||||||
copy doc\html\man3\*.* dist\3proxy\doc\html\man3\
|
copy doc\html\man5\*.* dist\3proxy\doc\html\man5\
|
||||||
copy doc\devel\*.rtf dist\3proxy\doc\devel\
|
copy doc\devel\*.rtf dist\3proxy\doc\devel\
|
||||||
copy copying dist\3proxy\
|
copy copying dist\3proxy\
|
||||||
copy authors dist\3proxy\
|
copy authors dist\3proxy\
|
||||||
|
|||||||
4
.github/workflows/build-win32.yml
vendored
4
.github/workflows/build-win32.yml
vendored
@ -51,7 +51,7 @@ jobs:
|
|||||||
mkdir dist\3proxy\doc\ru
|
mkdir dist\3proxy\doc\ru
|
||||||
mkdir dist\3proxy\doc\html
|
mkdir dist\3proxy\doc\html
|
||||||
mkdir dist\3proxy\doc\html\plugins
|
mkdir dist\3proxy\doc\html\plugins
|
||||||
mkdir dist\3proxy\doc\html\man3
|
mkdir dist\3proxy\doc\html\man5
|
||||||
mkdir dist\3proxy\doc\html\man8
|
mkdir dist\3proxy\doc\html\man8
|
||||||
mkdir dist\3proxy\doc\devel
|
mkdir dist\3proxy\doc\devel
|
||||||
copy bin\3proxy.exe dist\3proxy\bin\
|
copy bin\3proxy.exe dist\3proxy\bin\
|
||||||
@ -63,7 +63,7 @@ jobs:
|
|||||||
copy doc\html\*.* dist\3proxy\doc\html\
|
copy doc\html\*.* dist\3proxy\doc\html\
|
||||||
copy doc\html\plugins\*.* dist\3proxy\doc\html\plugins\
|
copy doc\html\plugins\*.* dist\3proxy\doc\html\plugins\
|
||||||
copy doc\html\man8\*.* dist\3proxy\doc\html\man8\
|
copy doc\html\man8\*.* dist\3proxy\doc\html\man8\
|
||||||
copy doc\html\man3\*.* dist\3proxy\doc\html\man3\
|
copy doc\html\man5\*.* dist\3proxy\doc\html\man5\
|
||||||
copy doc\devel\*.rtf dist\3proxy\doc\devel\
|
copy doc\devel\*.rtf dist\3proxy\doc\devel\
|
||||||
copy copying dist\3proxy\
|
copy copying dist\3proxy\
|
||||||
copy authors dist\3proxy\
|
copy authors dist\3proxy\
|
||||||
|
|||||||
4
.github/workflows/build-win64.yml
vendored
4
.github/workflows/build-win64.yml
vendored
@ -53,7 +53,7 @@ jobs:
|
|||||||
mkdir dist\3proxy\doc\ru
|
mkdir dist\3proxy\doc\ru
|
||||||
mkdir dist\3proxy\doc\html
|
mkdir dist\3proxy\doc\html
|
||||||
mkdir dist\3proxy\doc\html\plugins
|
mkdir dist\3proxy\doc\html\plugins
|
||||||
mkdir dist\3proxy\doc\html\man3
|
mkdir dist\3proxy\doc\html\man5
|
||||||
mkdir dist\3proxy\doc\html\man8
|
mkdir dist\3proxy\doc\html\man8
|
||||||
mkdir dist\3proxy\doc\devel
|
mkdir dist\3proxy\doc\devel
|
||||||
copy bin\3proxy.exe dist\3proxy\bin64\
|
copy bin\3proxy.exe dist\3proxy\bin64\
|
||||||
@ -65,7 +65,7 @@ jobs:
|
|||||||
copy doc\html\*.* dist\3proxy\doc\html\
|
copy doc\html\*.* dist\3proxy\doc\html\
|
||||||
copy doc\html\plugins\*.* dist\3proxy\doc\html\plugins\
|
copy doc\html\plugins\*.* dist\3proxy\doc\html\plugins\
|
||||||
copy doc\html\man8\*.* dist\3proxy\doc\html\man8\
|
copy doc\html\man8\*.* dist\3proxy\doc\html\man8\
|
||||||
copy doc\html\man3\*.* dist\3proxy\doc\html\man3\
|
copy doc\html\man5\*.* dist\3proxy\doc\html\man5\
|
||||||
copy doc\devel\*.rtf dist\3proxy\doc\devel\
|
copy doc\devel\*.rtf dist\3proxy\doc\devel\
|
||||||
copy copying dist\3proxy\
|
copy copying dist\3proxy\
|
||||||
copy authors dist\3proxy\
|
copy authors dist\3proxy\
|
||||||
|
|||||||
4
.github/workflows/build-winarm64.yml
vendored
4
.github/workflows/build-winarm64.yml
vendored
@ -51,7 +51,7 @@ jobs:
|
|||||||
mkdir dist\3proxy\doc\ru
|
mkdir dist\3proxy\doc\ru
|
||||||
mkdir dist\3proxy\doc\html
|
mkdir dist\3proxy\doc\html
|
||||||
mkdir dist\3proxy\doc\html\plugins
|
mkdir dist\3proxy\doc\html\plugins
|
||||||
mkdir dist\3proxy\doc\html\man3
|
mkdir dist\3proxy\doc\html\man5
|
||||||
mkdir dist\3proxy\doc\html\man8
|
mkdir dist\3proxy\doc\html\man8
|
||||||
mkdir dist\3proxy\doc\devel
|
mkdir dist\3proxy\doc\devel
|
||||||
copy bin\3proxy.exe dist\3proxy\bin64\
|
copy bin\3proxy.exe dist\3proxy\bin64\
|
||||||
@ -63,7 +63,7 @@ jobs:
|
|||||||
copy doc\html\*.* dist\3proxy\doc\html\
|
copy doc\html\*.* dist\3proxy\doc\html\
|
||||||
copy doc\html\plugins\*.* dist\3proxy\doc\html\plugins\
|
copy doc\html\plugins\*.* dist\3proxy\doc\html\plugins\
|
||||||
copy doc\html\man8\*.* dist\3proxy\doc\html\man8\
|
copy doc\html\man8\*.* dist\3proxy\doc\html\man8\
|
||||||
copy doc\html\man3\*.* dist\3proxy\doc\html\man3\
|
copy doc\html\man5\*.* dist\3proxy\doc\html\man5\
|
||||||
copy doc\devel\*.rtf dist\3proxy\doc\devel\
|
copy doc\devel\*.rtf dist\3proxy\doc\devel\
|
||||||
copy copying dist\3proxy\
|
copy copying dist\3proxy\
|
||||||
copy authors dist\3proxy\
|
copy authors dist\3proxy\
|
||||||
|
|||||||
8
.gitignore
vendored
8
.gitignore
vendored
@ -259,3 +259,11 @@ pip-log.txt
|
|||||||
.mr.developer.cfg
|
.mr.developer.cfg
|
||||||
CLAUDE.md
|
CLAUDE.md
|
||||||
bin/3proxy_crypt
|
bin/3proxy_crypt
|
||||||
|
bin/3proxy_ftppr
|
||||||
|
bin/3proxy_pop3p
|
||||||
|
bin/3proxy_proxy
|
||||||
|
bin/3proxy_smtpp
|
||||||
|
bin/3proxy_socks
|
||||||
|
bin/3proxy_tcppm
|
||||||
|
bin/3proxy_tlspr
|
||||||
|
bin/3proxy_udppm
|
||||||
|
|||||||
103
CMakeLists.txt
103
CMakeLists.txt
@ -56,6 +56,27 @@ option(3PROXY_USE_WSAPOLL "Use WSAPoll instead of select() (Windows only)" ON)
|
|||||||
option(3PROXY_USE_NETFILTER "Enable Linux netfilter support (Linux only)" ON)
|
option(3PROXY_USE_NETFILTER "Enable Linux netfilter support (Linux only)" ON)
|
||||||
option(3PROXY_USE_UNIX_SOCKETS "Enable Unix domain socket support (Unix only)" ON)
|
option(3PROXY_USE_UNIX_SOCKETS "Enable Unix domain socket support (Unix only)" ON)
|
||||||
|
|
||||||
|
# Binary name prefix for standalone modules and crypt (default: 3proxy_)
|
||||||
|
# For crypt: if prefix is empty, "my" is used instead (→ mycrypt)
|
||||||
|
set(3PROXY_BINARY_PREFIX "3proxy_" CACHE STRING "Prefix for standalone module and crypt binary names")
|
||||||
|
|
||||||
|
# Standalone module build options (OFF by default)
|
||||||
|
option(3PROXY_BUILD_ALL "Build all standalone binaries" OFF)
|
||||||
|
option(3PROXY_BUILD_PROXY "Build standalone proxy binary" OFF)
|
||||||
|
option(3PROXY_BUILD_SOCKS "Build standalone socks binary" OFF)
|
||||||
|
option(3PROXY_BUILD_POP3P "Build standalone pop3p binary" OFF)
|
||||||
|
option(3PROXY_BUILD_SMTPP "Build standalone smtpp binary" OFF)
|
||||||
|
option(3PROXY_BUILD_FTPPR "Build standalone ftppr binary" OFF)
|
||||||
|
option(3PROXY_BUILD_TCPPM "Build standalone tcppm binary" OFF)
|
||||||
|
option(3PROXY_BUILD_UDPPM "Build standalone udppm binary" OFF)
|
||||||
|
option(3PROXY_BUILD_TLSPR "Build standalone tlspr binary" OFF)
|
||||||
|
|
||||||
|
if(3PROXY_BUILD_ALL)
|
||||||
|
foreach(_M PROXY SOCKS POP3P SMTPP FTPPR TCPPM UDPPM TLSPR)
|
||||||
|
set(3PROXY_BUILD_${_M} ON)
|
||||||
|
endforeach()
|
||||||
|
endif()
|
||||||
|
|
||||||
# Output directory
|
# Output directory
|
||||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
|
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
|
||||||
|
|
||||||
@ -290,6 +311,7 @@ set(3PROXY_CORE_SOURCES
|
|||||||
src/redirect.c
|
src/redirect.c
|
||||||
src/authradius.c
|
src/authradius.c
|
||||||
src/hash.c
|
src/hash.c
|
||||||
|
src/hashtables.c
|
||||||
src/resolve.c
|
src/resolve.c
|
||||||
src/sql.c
|
src/sql.c
|
||||||
src/conf.c
|
src/conf.c
|
||||||
@ -327,7 +349,7 @@ target_include_directories(base64_obj PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src)
|
|||||||
# These are used by the main 3proxy executable
|
# These are used by the main 3proxy executable
|
||||||
# ============================================================================
|
# ============================================================================
|
||||||
|
|
||||||
# Server modules object library (without WITHMAIN)
|
# Server modules object library (without WITHMAIN, without UDP)
|
||||||
add_library(srv_modules OBJECT
|
add_library(srv_modules OBJECT
|
||||||
src/proxy.c
|
src/proxy.c
|
||||||
src/pop3p.c
|
src/pop3p.c
|
||||||
@ -338,13 +360,17 @@ add_library(srv_modules OBJECT
|
|||||||
src/auto.c
|
src/auto.c
|
||||||
src/socks.c
|
src/socks.c
|
||||||
src/webadmin.c
|
src/webadmin.c
|
||||||
src/udppm.c
|
|
||||||
src/dnspr.c
|
src/dnspr.c
|
||||||
)
|
)
|
||||||
|
|
||||||
target_include_directories(srv_modules PRIVATE
|
target_include_directories(srv_modules PRIVATE
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/src
|
${CMAKE_CURRENT_SOURCE_DIR}/src
|
||||||
)
|
)
|
||||||
|
# UDP port mapper server module (without WITHMAIN)
|
||||||
|
add_library(srvudppm_obj OBJECT src/udppm.c)
|
||||||
|
target_include_directories(srvudppm_obj PRIVATE
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/src
|
||||||
|
)
|
||||||
|
|
||||||
# mainfunc object (proxymain.c compiled with MODULEMAINFUNC=mainfunc for 3proxy)
|
# mainfunc object (proxymain.c compiled with MODULEMAINFUNC=mainfunc for 3proxy)
|
||||||
add_library(mainfunc OBJECT src/proxymain.c)
|
add_library(mainfunc OBJECT src/proxymain.c)
|
||||||
@ -368,6 +394,7 @@ add_executable(3proxy
|
|||||||
${3PROXY_CORE_SOURCES}
|
${3PROXY_CORE_SOURCES}
|
||||||
${MD_SOURCES}
|
${MD_SOURCES}
|
||||||
$<TARGET_OBJECTS:srv_modules>
|
$<TARGET_OBJECTS:srv_modules>
|
||||||
|
$<TARGET_OBJECTS:srvudppm_obj>
|
||||||
$<TARGET_OBJECTS:mainfunc>
|
$<TARGET_OBJECTS:mainfunc>
|
||||||
$<TARGET_OBJECTS:common_obj>
|
$<TARGET_OBJECTS:common_obj>
|
||||||
$<TARGET_OBJECTS:base64_obj>
|
$<TARGET_OBJECTS:base64_obj>
|
||||||
@ -417,9 +444,19 @@ target_include_directories(3proxy_crypt PRIVATE
|
|||||||
${CMAKE_CURRENT_SOURCE_DIR}/src/libs
|
${CMAKE_CURRENT_SOURCE_DIR}/src/libs
|
||||||
)
|
)
|
||||||
target_link_libraries(3proxy_crypt PRIVATE Threads::Threads)
|
target_link_libraries(3proxy_crypt PRIVATE Threads::Threads)
|
||||||
|
if("${3PROXY_BINARY_PREFIX}" STREQUAL "")
|
||||||
|
set_target_properties(3proxy_crypt PROPERTIES OUTPUT_NAME "mycrypt")
|
||||||
|
else()
|
||||||
|
set_target_properties(3proxy_crypt PROPERTIES OUTPUT_NAME "${3PROXY_BINARY_PREFIX}crypt")
|
||||||
|
endif()
|
||||||
|
|
||||||
# Build standalone proxy executables
|
# Build standalone proxy executables
|
||||||
foreach(PROXY_NAME proxy socks pop3p smtpp ftppr tcppm tlspr)
|
foreach(PROXY_NAME proxy socks pop3p smtpp ftppr tcppm udppm tlspr)
|
||||||
|
string(TOUPPER "${PROXY_NAME}" _MODULE_OPT)
|
||||||
|
if(NOT 3PROXY_BUILD_${_MODULE_OPT})
|
||||||
|
continue()
|
||||||
|
endif()
|
||||||
|
|
||||||
if(PROXY_NAME STREQUAL "ftppr" OR PROXY_NAME STREQUAL "proxy")
|
if(PROXY_NAME STREQUAL "ftppr" OR PROXY_NAME STREQUAL "proxy")
|
||||||
# ftppr and proxy use ftp_obj
|
# ftppr and proxy use ftp_obj
|
||||||
add_executable(${PROXY_NAME}
|
add_executable(${PROXY_NAME}
|
||||||
@ -434,6 +471,10 @@ foreach(PROXY_NAME proxy socks pop3p smtpp ftppr tcppm tlspr)
|
|||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
set_target_properties(${PROXY_NAME} PROPERTIES
|
||||||
|
OUTPUT_NAME "${3PROXY_BINARY_PREFIX}${PROXY_NAME}"
|
||||||
|
)
|
||||||
|
|
||||||
target_include_directories(${PROXY_NAME} PRIVATE
|
target_include_directories(${PROXY_NAME} PRIVATE
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/src
|
${CMAKE_CURRENT_SOURCE_DIR}/src
|
||||||
)
|
)
|
||||||
@ -443,6 +484,10 @@ foreach(PROXY_NAME proxy socks pop3p smtpp ftppr tcppm tlspr)
|
|||||||
NOPORTMAP
|
NOPORTMAP
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if(NOT PROXY_NAME STREQUAL "udppm")
|
||||||
|
target_compile_definitions(${PROXY_NAME} PRIVATE NOUDPMAIN)
|
||||||
|
endif()
|
||||||
|
|
||||||
target_link_libraries(${PROXY_NAME} PRIVATE Threads::Threads)
|
target_link_libraries(${PROXY_NAME} PRIVATE Threads::Threads)
|
||||||
|
|
||||||
if(PROXY_NAME STREQUAL "proxy")
|
if(PROXY_NAME STREQUAL "proxy")
|
||||||
@ -460,6 +505,10 @@ foreach(PROXY_NAME proxy socks pop3p smtpp ftppr tcppm tlspr)
|
|||||||
if(PROXY_NAME STREQUAL "proxy" OR PROXY_NAME STREQUAL "smtpp")
|
if(PROXY_NAME STREQUAL "proxy" OR PROXY_NAME STREQUAL "smtpp")
|
||||||
target_sources(${PROXY_NAME} PRIVATE $<TARGET_OBJECTS:base64_obj>)
|
target_sources(${PROXY_NAME} PRIVATE $<TARGET_OBJECTS:base64_obj>)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if(PROXY_NAME STREQUAL "udppm")
|
||||||
|
target_sources(${PROXY_NAME} PRIVATE src/hash.c)
|
||||||
|
endif()
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
# Plugin output directory
|
# Plugin output directory
|
||||||
@ -503,10 +552,19 @@ if(PAM_FOUND)
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Installation rules
|
# Installation rules
|
||||||
install(TARGETS 3proxy 3proxy_crypt proxy socks pop3p smtpp ftppr tcppm tlspr
|
install(TARGETS 3proxy 3proxy_crypt
|
||||||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
foreach(PROXY_NAME proxy socks pop3p smtpp ftppr tcppm udppm tlspr)
|
||||||
|
string(TOUPPER "${PROXY_NAME}" _MODULE_OPT)
|
||||||
|
if(3PROXY_BUILD_${_MODULE_OPT})
|
||||||
|
install(TARGETS ${PROXY_NAME}
|
||||||
|
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
endforeach()
|
||||||
|
|
||||||
# Install plugins
|
# Install plugins
|
||||||
file(GLOB PLUGINFILES "${PLUGIN_OUTPUT_DIR}/*${PLUGIN_SUFFIX}")
|
file(GLOB PLUGINFILES "${PLUGIN_OUTPUT_DIR}/*${PLUGIN_SUFFIX}")
|
||||||
if(WIN32)
|
if(WIN32)
|
||||||
@ -640,10 +698,32 @@ endif()
|
|||||||
|
|
||||||
# Install man pages
|
# Install man pages
|
||||||
if(NOT WIN32)
|
if(NOT WIN32)
|
||||||
file(GLOB MAN3_FILES "${CMAKE_CURRENT_SOURCE_DIR}/man/*.3")
|
# Config man page (section 5) — no prefix
|
||||||
file(GLOB MAN8_FILES "${CMAKE_CURRENT_SOURCE_DIR}/man/*.8")
|
file(GLOB MAN5_FILES "${CMAKE_CURRENT_SOURCE_DIR}/man/*.5")
|
||||||
install(FILES ${MAN3_FILES} DESTINATION ${CMAKE_INSTALL_MANDIR}/man3)
|
install(FILES ${MAN5_FILES} DESTINATION ${CMAKE_INSTALL_MANDIR}/man5)
|
||||||
install(FILES ${MAN8_FILES} DESTINATION ${CMAKE_INSTALL_MANDIR}/man8)
|
# Main 3proxy man page — no prefix
|
||||||
|
install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/man/3proxy.8"
|
||||||
|
DESTINATION ${CMAKE_INSTALL_MANDIR}/man8
|
||||||
|
)
|
||||||
|
# 3proxy_crypt man page — no prefix (already has 3proxy_)
|
||||||
|
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/man/3proxy_crypt.8")
|
||||||
|
install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/man/3proxy_crypt.8"
|
||||||
|
DESTINATION ${CMAKE_INSTALL_MANDIR}/man8
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
# Module man pages — installed with binary prefix only if module is built
|
||||||
|
foreach(_MAN proxy socks pop3p smtpp ftppr tcppm udppm tlspr)
|
||||||
|
string(TOUPPER "${_MAN}" _MODULE_OPT)
|
||||||
|
if(3PROXY_BUILD_${_MODULE_OPT})
|
||||||
|
set(_MAN_SRC "${CMAKE_CURRENT_SOURCE_DIR}/man/${_MAN}.8")
|
||||||
|
if(EXISTS "${_MAN_SRC}")
|
||||||
|
install(FILES "${_MAN_SRC}"
|
||||||
|
DESTINATION ${CMAKE_INSTALL_MANDIR}/man8
|
||||||
|
RENAME "${3PROXY_BINARY_PREFIX}${_MAN}.8"
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
endforeach()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Summary
|
# Summary
|
||||||
@ -677,3 +757,10 @@ message(STATUS " ODBC: ${ODBC_FOUND}")
|
|||||||
message(STATUS "")
|
message(STATUS "")
|
||||||
message(STATUS " Plugins to build: ${ALL_PLUGINS}")
|
message(STATUS " Plugins to build: ${ALL_PLUGINS}")
|
||||||
message(STATUS "")
|
message(STATUS "")
|
||||||
|
message(STATUS " Standalone modules:")
|
||||||
|
message(STATUS " Binary prefix: \"${3PROXY_BINARY_PREFIX}\"")
|
||||||
|
foreach(_M proxy socks pop3p smtpp ftppr tcppm udppm tlspr)
|
||||||
|
string(TOUPPER "${_M}" _MO)
|
||||||
|
message(STATUS " BUILD_${_MO}: ${3PROXY_BUILD_${_MO}}")
|
||||||
|
endforeach()
|
||||||
|
message(STATUS "")
|
||||||
|
|||||||
@ -5,6 +5,9 @@
|
|||||||
# library support. Add -DSAFESQL for poorely written ODBC library / drivers.
|
# library support. Add -DSAFESQL for poorely written ODBC library / drivers.
|
||||||
|
|
||||||
BUILDDIR = ../bin/
|
BUILDDIR = ../bin/
|
||||||
|
PREFIX ?= 3proxy_
|
||||||
|
CRYPT_PREFIX ?= $(PREFIX)
|
||||||
|
MANDIR ?= /usr/share/man
|
||||||
CC ?= cc
|
CC ?= cc
|
||||||
|
|
||||||
CFLAGS := -c -fno-strict-aliasing -DNOODBC -DFD_SETSIZE=4096 -DWITH_POLL -DWITH_UN $(CFLAGS)
|
CFLAGS := -c -fno-strict-aliasing -DNOODBC -DFD_SETSIZE=4096 -DWITH_POLL -DWITH_UN $(CFLAGS)
|
||||||
@ -49,14 +52,25 @@ include Makefile.inc
|
|||||||
install: all
|
install: all
|
||||||
if [ ! -d "/usr/local/3proxy/bin" ]; then mkdir -p /usr/local/3proxy/bin/; fi
|
if [ ! -d "/usr/local/3proxy/bin" ]; then mkdir -p /usr/local/3proxy/bin/; fi
|
||||||
install bin/3proxy /usr/local/3proxy/bin/3proxy
|
install bin/3proxy /usr/local/3proxy/bin/3proxy
|
||||||
install bin/3proxy_crypt /usr/local/3proxy/bin/3proxy_crypt
|
install bin/$(CRYPT_PREFIX)crypt /usr/local/3proxy/bin/$(CRYPT_PREFIX)crypt
|
||||||
|
for f in proxy socks pop3p smtpp ftppr tcppm udppm tlspr; do \
|
||||||
|
if [ -f bin/$(PREFIX)$$f ]; then install bin/$(PREFIX)$$f /usr/local/3proxy/bin/$(PREFIX)$$f; fi; \
|
||||||
|
done
|
||||||
install scripts/rc.d/3proxy /usr/local/etc/rc.d/3proxy
|
install scripts/rc.d/3proxy /usr/local/etc/rc.d/3proxy
|
||||||
install scripts/add3proxyuser.sh /usr/local/3proxy/bin/
|
install scripts/add3proxyuser.sh /usr/local/3proxy/bin/
|
||||||
if [ -s /usr/local/etc/3proxy/3proxy.cfg ]; then /usr/local/3proxy/3proxy.cfg already exists ; else install scripts/3proxy.cfg /usr/local/etc/3proxy/; fi
|
if [ -s /usr/local/etc/3proxy/3proxy.cfg ]; then echo /usr/local/3proxy/3proxy.cfg already exists; else install scripts/3proxy.cfg /usr/local/etc/3proxy/; fi
|
||||||
if [ ! -d /var/log/3proxy/ ]; then mkdir /var/log/3proxy/; fi
|
if [ ! -d /var/log/3proxy/ ]; then mkdir /var/log/3proxy/; fi
|
||||||
touch /usr/local/3proxy/passwd
|
touch /usr/local/3proxy/passwd
|
||||||
touch /usr/local/3proxy/counters
|
touch /usr/local/3proxy/counters
|
||||||
touch /usr/local/3proxy/bandlimiters
|
touch /usr/local/3proxy/bandlimiters
|
||||||
|
install -d $(MANDIR)/man8
|
||||||
|
install -m 644 man/3proxy.8 $(MANDIR)/man8/3proxy.8
|
||||||
|
for f in proxy socks pop3p smtpp ftppr tcppm udppm tlspr; do \
|
||||||
|
if [ -f man/$$f.8 ]; then install -m 644 man/$$f.8 $(MANDIR)/man8/$(PREFIX)$$f.8; fi; \
|
||||||
|
done
|
||||||
|
install -m 644 man/3proxy_crypt.8 $(MANDIR)/man8
|
||||||
|
install -d $(MANDIR)/man5
|
||||||
|
install -m 644 man/3proxy.cfg.5 $(MANDIR)/man5/3proxy.cfg.5
|
||||||
echo Run /usr/local/3proxy/bin/add3proxyuser.sh to add \'admin\' user
|
echo Run /usr/local/3proxy/bin/add3proxyuser.sh to add \'admin\' user
|
||||||
|
|
||||||
allplugins:
|
allplugins:
|
||||||
|
|||||||
@ -5,6 +5,8 @@
|
|||||||
# library support. Add -DSAFESQL for poorely written ODBC library / drivers.
|
# library support. Add -DSAFESQL for poorely written ODBC library / drivers.
|
||||||
|
|
||||||
BUILDDIR = ../bin/
|
BUILDDIR = ../bin/
|
||||||
|
PREFIX ?= 3proxy_
|
||||||
|
CRYPT_PREFIX ?= $(PREFIX)
|
||||||
CC ?= gcc
|
CC ?= gcc
|
||||||
|
|
||||||
CFLAGS := -g -fPIC -O2 -fno-strict-aliasing -c -pthread -DWITHSPLICE -D_GNU_SOURCE -DGETHOSTBYNAME_R -D_THREAD_SAFE -D_REENTRANT -DNOODBC -DFD_SETSIZE=4096 -DWITH_POLL -DWITH_NETFILTER -D WITH_UN $(CFLAGS)
|
CFLAGS := -g -fPIC -O2 -fno-strict-aliasing -c -pthread -DWITHSPLICE -D_GNU_SOURCE -DGETHOSTBYNAME_R -D_THREAD_SAFE -D_REENTRANT -DNOODBC -DFD_SETSIZE=4096 -DWITH_POLL -DWITH_NETFILTER -D WITH_UN $(CFLAGS)
|
||||||
@ -61,13 +63,15 @@ INSTALL = /usr/bin/install
|
|||||||
INSTALL_BIN = $(INSTALL) -m 755
|
INSTALL_BIN = $(INSTALL) -m 755
|
||||||
INSTALL_DATA = $(INSTALL) -m 644
|
INSTALL_DATA = $(INSTALL) -m 644
|
||||||
INSTALL_OBJS = bin/3proxy \
|
INSTALL_OBJS = bin/3proxy \
|
||||||
bin/ftppr \
|
bin/$(CRYPT_PREFIX)crypt \
|
||||||
bin/3proxy_crypt \
|
bin/$(PREFIX)ftppr \
|
||||||
bin/pop3p \
|
bin/$(PREFIX)pop3p \
|
||||||
bin/proxy \
|
bin/$(PREFIX)proxy \
|
||||||
bin/socks \
|
bin/$(PREFIX)smtpp \
|
||||||
bin/tcppm \
|
bin/$(PREFIX)socks \
|
||||||
bin/tlspr
|
bin/$(PREFIX)tcppm \
|
||||||
|
bin/$(PREFIX)tlspr \
|
||||||
|
bin/$(PREFIX)udppm
|
||||||
|
|
||||||
|
|
||||||
INSTALL_CFG = scripts/3proxy.cfg.chroot
|
INSTALL_CFG = scripts/3proxy.cfg.chroot
|
||||||
@ -81,7 +85,7 @@ INSTALL_SYSTEMD_SCRIPT = scripts/3proxy.service
|
|||||||
|
|
||||||
CHROOTDIR = $(DESTDIR)$(chroot_prefix)/3proxy
|
CHROOTDIR = $(DESTDIR)$(chroot_prefix)/3proxy
|
||||||
CHROOTREL = ../..$(chroot_prefix)/3proxy
|
CHROOTREL = ../..$(chroot_prefix)/3proxy
|
||||||
MANDIR3 = $(DESTDIR)$(man_prefix)/man/man3
|
MANDIR5 = $(DESTDIR)$(man_prefix)/man/man5
|
||||||
MANDIR8 = $(DESTDIR)$(man_prefix)/man/man8
|
MANDIR8 = $(DESTDIR)$(man_prefix)/man/man8
|
||||||
BINDIR = $(DESTDIR)$(exec_prefix)/bin
|
BINDIR = $(DESTDIR)$(exec_prefix)/bin
|
||||||
ETCDIR = $(DESTDIR)/etc/3proxy
|
ETCDIR = $(DESTDIR)/etc/3proxy
|
||||||
@ -124,10 +128,14 @@ install-etc: install-etc-dir install-etc-default-config
|
|||||||
done;
|
done;
|
||||||
|
|
||||||
install-man:
|
install-man:
|
||||||
$(INSTALL_BIN) -d $(MANDIR3)
|
$(INSTALL_BIN) -d $(MANDIR5)
|
||||||
$(INSTALL_BIN) -d $(MANDIR8)
|
$(INSTALL_BIN) -d $(MANDIR8)
|
||||||
$(INSTALL_DATA) man/*.3 $(MANDIR3)
|
$(INSTALL_DATA) man/3proxy.cfg.5 $(MANDIR5)
|
||||||
$(INSTALL_DATA) man/*.8 $(MANDIR8)
|
$(INSTALL_DATA) man/3proxy.8 $(MANDIR8)
|
||||||
|
for f in proxy socks pop3p smtpp ftppr tcppm udppm tlspr; do \
|
||||||
|
if [ -f man/$$f.8 ]; then $(INSTALL_DATA) man/$$f.8 $(MANDIR8)/$(PREFIX)$$f.8; fi; \
|
||||||
|
done
|
||||||
|
$(INSTALL_DATA) man/3proxy_crypt.8 $(MANDIR8)
|
||||||
|
|
||||||
install-init:
|
install-init:
|
||||||
$(INSTALL_BIN) -d $(INITDDIR)
|
$(INSTALL_BIN) -d $(INITDDIR)
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
# library support. Add -DSAFESQL for poorely written ODBC library / drivers.
|
# library support. Add -DSAFESQL for poorely written ODBC library / drivers.
|
||||||
|
|
||||||
BUILDDIR = ../bin/
|
BUILDDIR = ../bin/
|
||||||
CC = cc
|
CC ?= cc
|
||||||
CFLAGS = -xO3 -c -D_SOLARIS -D_THREAD_SAFE -DGETHOSTBYNAME_R -D_REENTRANT -DNOODBC -DFD_SETSIZE=4096 -DWITH_POLL
|
CFLAGS = -xO3 -c -D_SOLARIS -D_THREAD_SAFE -DGETHOSTBYNAME_R -D_REENTRANT -DNOODBC -DFD_SETSIZE=4096 -DWITH_POLL
|
||||||
COUT = -o ./
|
COUT = -o ./
|
||||||
LN = $(CC)
|
LN = $(CC)
|
||||||
|
|||||||
@ -1,36 +0,0 @@
|
|||||||
#
|
|
||||||
# 3 proxy Makefile for Solaris/gcc
|
|
||||||
#
|
|
||||||
#
|
|
||||||
# remove -DNOODBC from CFLAGS and add -lodbc to LDFLAGS to compile with ODBC
|
|
||||||
# library support. Add -DSAFESQL for poorely written ODBC library / drivers.
|
|
||||||
|
|
||||||
|
|
||||||
BUILDDIR = ../bin/
|
|
||||||
CC = gcc
|
|
||||||
CFLAGS = -O2 -fno-strict-aliasing -c -D_SOLARIS -D_THREAD_SAFE -DGETHOSTBYNAME_R -D_REENTRANT -DNOODBC -DFD_SETSIZE=4096 -DWITH_POLL
|
|
||||||
COUT = -o ./
|
|
||||||
LN = $(CC)
|
|
||||||
LDFLAGS = -O3
|
|
||||||
DCFLAGS = -fPIC
|
|
||||||
DLFLAGS = -shared
|
|
||||||
DLSUFFICS = .ld.so
|
|
||||||
LIBS = -lpthread -lsocket -lnsl -lresolv -ldl
|
|
||||||
LIBSPREFIX = -l
|
|
||||||
LIBSSUFFIX =
|
|
||||||
LNOUT = -o ./
|
|
||||||
EXESUFFICS =
|
|
||||||
OBJSUFFICS = .o
|
|
||||||
DEFINEOPTION = -D
|
|
||||||
COMPFILES = *~
|
|
||||||
REMOVECOMMAND = rm -f
|
|
||||||
AFTERCLEAN = (find . -type f -name "*.o" -delete && find src/ -type f -name "Makefile.var" -delete && find bin/ -type f -executable -delete) || true
|
|
||||||
TYPECOMMAND = cat
|
|
||||||
COMPATLIBS =
|
|
||||||
MAKEFILE = Makefile.Solaris-gcc
|
|
||||||
PLUGINS = StringsPlugin TrafficPlugin
|
|
||||||
|
|
||||||
include Makefile.inc
|
|
||||||
|
|
||||||
allplugins:
|
|
||||||
@list='$(PLUGINS)'; for p in $$list; do cp Makefile Makefile.var plugins/$$p; cd plugins/$$p ; make ; cd ../.. ; done
|
|
||||||
@ -1,2 +0,0 @@
|
|||||||
SUBDIRS = src man
|
|
||||||
EXTRA_DIST = doc cfg
|
|
||||||
@ -1,24 +0,0 @@
|
|||||||
#
|
|
||||||
# 3 proxy Makefile for Microsoft Visual C compiler (for both make and nmake)
|
|
||||||
#
|
|
||||||
|
|
||||||
BUILDDIR = ../bin/
|
|
||||||
CC = cl
|
|
||||||
CFLAGS = /FD /MDd /nologo /W3 /ZI /Wp64 /GS /Gs /RTCsu /EHs- /GA /GF /DEBUG /D "_DEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "_WIN32" /c
|
|
||||||
COUT = /Fo
|
|
||||||
LN = link
|
|
||||||
LDFLAGS = /nologo /subsystem:console /machine:I386 /DEBUG
|
|
||||||
LIBS = ws2_32.lib advapi32.lib odbc32.lib user32.lib
|
|
||||||
LNOUT = /out:
|
|
||||||
EXESUFFICS = .exe
|
|
||||||
OBJSUFFICS = .obj
|
|
||||||
DEFINEOPTION = /D
|
|
||||||
COMPFILES = *.pch *.idb
|
|
||||||
REMOVECOMMAND = del 2>NUL >NUL
|
|
||||||
TYPECOMMAND = type
|
|
||||||
COMPATLIBS =
|
|
||||||
MAKEFILE = Makefile.debug
|
|
||||||
|
|
||||||
include Makefile.inc
|
|
||||||
|
|
||||||
allplugins:
|
|
||||||
@ -1,111 +0,0 @@
|
|||||||
#
|
|
||||||
# 3 proxy Makefile for GCC/Linux/Cygwin
|
|
||||||
#
|
|
||||||
#
|
|
||||||
# remove -DNOODBC from CFLAGS and add -lodbc to LIBS to compile with ODBC
|
|
||||||
# library support. Add -DSAFESQL for poorely written ODBC library / drivers.
|
|
||||||
|
|
||||||
BUILDDIR = ../bin/
|
|
||||||
CC = mips-openwrt-linux-gcc
|
|
||||||
|
|
||||||
CFLAGS ?= -g -O2 -fno-strict-aliasing -c -pthread -DGETHOSTBYNAME_R -D_THREAD_SAFE -D_REENTRANT -DNOODBC -DFD_SETSIZE=4096 -DWITH_POLL -DWITH_NETFILTER
|
|
||||||
COUT = -o
|
|
||||||
LN = $(CC)
|
|
||||||
DCFLAGS = -fPIC
|
|
||||||
LDFLAGS ?= -O2 -fno-strict-aliasing -pthread -s
|
|
||||||
DLFLAGS = -shared
|
|
||||||
DLSUFFICS = .ld.so
|
|
||||||
# -lpthreads may be reuqired on some platforms instead of -pthreads
|
|
||||||
LIBSPREFIX = -l
|
|
||||||
LIBSSUFFIX =
|
|
||||||
LNOUT = -o
|
|
||||||
EXESUFFICS =
|
|
||||||
OBJSUFFICS = .o
|
|
||||||
DEFINEOPTION = -D
|
|
||||||
COMPFILES = *~
|
|
||||||
REMOVECOMMAND = rm -f
|
|
||||||
AFTERCLEAN = (find . -type f -name "*.o" -delete && find src/ -type f -name "Makefile.var" -delete && find bin/ -type f -executable -delete) || true
|
|
||||||
TYPECOMMAND = cat
|
|
||||||
COMPATLIBS =
|
|
||||||
MAKEFILE = Makefile.openwrt-mips
|
|
||||||
# PamAuth requires libpam, you may require pam-devel package to be installed
|
|
||||||
# SSLPlugin requires -lcrypto -lssl
|
|
||||||
#LIBS = -lcrypto -lssl -ldl
|
|
||||||
LIBS ?= -ldl
|
|
||||||
#PLUGINS = SSLPlugin StringsPlugin TrafficPlugin PCREPlugin TransparentPlugin PamAuth
|
|
||||||
PLUGINS ?= StringsPlugin TrafficPlugin TransparentPlugin
|
|
||||||
OPENSSL_CHECK = $(shell echo "\#include <openssl/ssl.h>\\n int main(){return 0;}" | tr -d \\\\ | cc -x c $(CFLAGS) $(LDFLAGS) -l crypto -l ssl -o testssl - 2>/dev/null && rm testssl && echo true||echo false)
|
|
||||||
ifeq ($(OPENSSL_CHECK), true)
|
|
||||||
LIBS += -l crypto -l ssl
|
|
||||||
PLUGINS += SSLPlugin
|
|
||||||
endif
|
|
||||||
PCRE_CHECK = $(shell echo "\#define PCRE2_CODE_UNIT_WIDTH 8\\n\#include <pcre2.h>\\n int main(){return 0;}" | tr -d \\\\ | cc -x c $(CFLAGS) $(LDFLAGS) -l pcre2-8 -o testpcre - 2>/dev/null && rm testpcre && echo true||echo false)
|
|
||||||
ifeq ($(PCRE_CHECK), true)
|
|
||||||
PLUGINS += PCREPlugin
|
|
||||||
endif
|
|
||||||
PAM_CHECK = $(shell echo "\#include <security/pam_appl.h>\\n int main(){return 0;}" | tr -d \\\\ | cc -x c $(CFLAGS) $(LDFLAGS) -l pam -o testpam - 2>/dev/null && rm testpam && echo true||echo false)
|
|
||||||
ifeq ($(PAM_CHECK), true)
|
|
||||||
PLUGINS += PamAuth
|
|
||||||
endif
|
|
||||||
|
|
||||||
include Makefile.inc
|
|
||||||
|
|
||||||
allplugins:
|
|
||||||
@list='$(PLUGINS)'; for p in $$list; do cp Makefile Makefile.var plugins/$$p; cd plugins/$$p ; make ; cd ../.. ; done
|
|
||||||
|
|
||||||
DESTDIR =
|
|
||||||
prefix = /usr/local
|
|
||||||
exec_prefix = $(prefix)
|
|
||||||
man_prefix = $(prefix)/share
|
|
||||||
|
|
||||||
INSTALL = /usr/bin/install
|
|
||||||
INSTALL_BIN = $(INSTALL) -m 755
|
|
||||||
INSTALL_DATA = $(INSTALL) -m 644
|
|
||||||
INSTALL_OBJS = src/3proxy \
|
|
||||||
src/ftppr \
|
|
||||||
src/3proxy_crypt \
|
|
||||||
src/pop3p \
|
|
||||||
src/proxy \
|
|
||||||
src/socks \
|
|
||||||
src/tcppm
|
|
||||||
|
|
||||||
|
|
||||||
INSTALL_CFG_OBJS = scripts/3proxy.cfg \
|
|
||||||
scripts/add3proxyuser.sh
|
|
||||||
INSTALL_CFG_DEST = config
|
|
||||||
|
|
||||||
INSTALL_CFG_OBJS2 = passwd counters bandlimiters
|
|
||||||
|
|
||||||
MANDIR3 = $(DESTDIR)$(man_prefix)/man/man3
|
|
||||||
MANDIR8 = $(DESTDIR)$(man_prefix)/man/man8
|
|
||||||
BINDIR = $(DESTDIR)$(exec_prefix)/bin
|
|
||||||
ETCDIR = $(DESTDIR)$(prefix)/etc/3proxy
|
|
||||||
|
|
||||||
install-bin:
|
|
||||||
$(INSTALL_BIN) -d $(BINDIR)
|
|
||||||
$(INSTALL_BIN) -s $(INSTALL_OBJS) $(BINDIR)
|
|
||||||
|
|
||||||
install-etc-dir:
|
|
||||||
$(INSTALL_BIN) -d $(ETCDIR)
|
|
||||||
|
|
||||||
install-etc-default-config:
|
|
||||||
if [ -f $(ETCDIR)/$(INSTALL_CFG_DEST) ]; then \
|
|
||||||
: ; \
|
|
||||||
else \
|
|
||||||
$(INSTALL_DATA) $(INSTALL_CFG_OBJS) $(ETCDIR)/$(INSTALL_CFG_DEST) \
|
|
||||||
fi
|
|
||||||
|
|
||||||
install-etc: install-etc-dir
|
|
||||||
for file in $(INSTALL_CFG_OBJS2); \
|
|
||||||
do \
|
|
||||||
touch $(ETCDIR)/$$file; chmod 0600 $(ETCDIR)/$$file; \
|
|
||||||
done;
|
|
||||||
|
|
||||||
install-man:
|
|
||||||
$(INSTALL_BIN) -d $(MANDIR3)
|
|
||||||
$(INSTALL_BIN) -d $(MANDIR8)
|
|
||||||
$(INSTALL_DATA) man/*.3 $(MANDIR3)
|
|
||||||
$(INSTALL_DATA) man/*.8 $(MANDIR8)
|
|
||||||
|
|
||||||
install: install-bin install-etc install-man
|
|
||||||
|
|
||||||
@ -6,6 +6,9 @@
|
|||||||
# library support. Add -DSAFESQL for poorely written ODBC library / drivers.
|
# library support. Add -DSAFESQL for poorely written ODBC library / drivers.
|
||||||
|
|
||||||
BUILDDIR = ../bin/
|
BUILDDIR = ../bin/
|
||||||
|
PREFIX ?= 3proxy_
|
||||||
|
CRYPT_PREFIX ?= $(PREFIX)
|
||||||
|
MANDIR ?= /usr/share/man
|
||||||
CC ?= gcc
|
CC ?= gcc
|
||||||
|
|
||||||
# you may need -L/usr/pkg/lib for older NetBSD versions
|
# you may need -L/usr/pkg/lib for older NetBSD versions
|
||||||
@ -49,17 +52,28 @@ endif
|
|||||||
include Makefile.inc
|
include Makefile.inc
|
||||||
|
|
||||||
install: all
|
install: all
|
||||||
if [ ! -d "/usr/local/3proxy/bin" ]; then mkdir -p /usr/local/3proxy/bin/; fi
|
if [ ! -d "/usr/local/3proxy/bin" ]; then mkdir -p /usr/local/3proxy/bin/; fi
|
||||||
install bin/3proxy /usr/local/3proxy/bin/3proxy
|
install bin/3proxy /usr/local/3proxy/bin/3proxy
|
||||||
install bin/3proxy_crypt /usr/local/3proxy/bin/3proxy_crypt
|
install bin/$(CRYPT_PREFIX)crypt /usr/local/3proxy/bin/$(CRYPT_PREFIX)crypt
|
||||||
install scripts/rc.d/3proxy /usr/local/etc/rc.d/3proxy
|
for f in proxy socks pop3p smtpp ftppr tcppm udppm tlspr; do \
|
||||||
install scripts/add3proxyuser.sh /usr/local/3proxy/bin/
|
if [ -f bin/$(PREFIX)$$f ]; then install bin/$(PREFIX)$$f /usr/local/3proxy/bin/$(PREFIX)$$f; fi; \
|
||||||
if [ -s /usr/local/etc/3proxy/3proxy.cfg ]; then /usr/local/3proxy/3proxy.cfg already exists ; else install scripts/3proxy.cfg /usr/local/etc/3proxy/; fi
|
done
|
||||||
if [ ! -d /var/log/3proxy/ ]; then mkdir /var/log/3proxy/; fi
|
install scripts/rc.d/3proxy /usr/local/etc/rc.d/3proxy
|
||||||
touch /usr/local/3proxy/passwd
|
install scripts/add3proxyuser.sh /usr/local/3proxy/bin/
|
||||||
touch /usr/local/3proxy/counters
|
if [ -s /usr/local/etc/3proxy/3proxy.cfg ]; then echo /usr/local/3proxy/3proxy.cfg already exists; else install scripts/3proxy.cfg /usr/local/etc/3proxy/; fi
|
||||||
touch /usr/local/3proxy/bandlimiters
|
if [ ! -d /var/log/3proxy/ ]; then mkdir /var/log/3proxy/; fi
|
||||||
echo Run /usr/local/3proxy/bin/add3proxyuser.sh to add \'admin\' user
|
touch /usr/local/3proxy/passwd
|
||||||
|
touch /usr/local/3proxy/counters
|
||||||
|
touch /usr/local/3proxy/bandlimiters
|
||||||
|
install -d $(MANDIR)/man8
|
||||||
|
install -m 644 man/3proxy.8 $(MANDIR)/man8/3proxy.8
|
||||||
|
for f in proxy socks pop3p smtpp ftppr tcppm udppm tlspr; do \
|
||||||
|
if [ -f man/$$f.8 ]; then install -m 644 man/$$f.8 $(MANDIR)/man8/$(PREFIX)$$f.8; fi; \
|
||||||
|
done
|
||||||
|
install -m 644 man/3proxy_crypt.8 $(MANDIR)/man8
|
||||||
|
install -d $(MANDIR)/man5
|
||||||
|
install -m 644 man/3proxy.cfg.5 $(MANDIR)/man5/3proxy.cfg.5
|
||||||
|
echo Run /usr/local/3proxy/bin/add3proxyuser.sh to add \'admin\' user
|
||||||
|
|
||||||
allplugins:
|
allplugins:
|
||||||
@list='$(PLUGINS)'; for p in $$list; do cp Makefile Makefile.var plugins/$$p; cd plugins/$$p ; make ; cd ../.. ; done
|
@list='$(PLUGINS)'; for p in $$list; do cp Makefile Makefile.var plugins/$$p; cd plugins/$$p ; make ; cd ../.. ; done
|
||||||
|
|||||||
19
debian/3proxy.manpages
vendored
19
debian/3proxy.manpages
vendored
@ -1,10 +1,11 @@
|
|||||||
man/3proxy.8
|
man/3proxy.8
|
||||||
man/3proxy.cfg.3
|
man/3proxy.cfg.5
|
||||||
man/ftppr.8
|
man/3proxy_ftppr.8
|
||||||
man/pop3p.8
|
man/3proxy_pop3p.8
|
||||||
man/tlspr.8
|
man/3proxy_tlspr.8
|
||||||
man/proxy.8
|
man/3proxy_proxy.8
|
||||||
man/smtpp.8
|
man/3proxy_smtpp.8
|
||||||
man/socks.8
|
man/3proxy_socks.8
|
||||||
man/tcppm.8
|
man/3proxy_tcppm.8
|
||||||
man/udppm.8
|
man/3proxy_udppm.8
|
||||||
|
man/3proxy_crypt.8
|
||||||
|
|||||||
@ -4,6 +4,7 @@
|
|||||||
<a href="howtoe.html">How To (English, very incomplete)</a><br>
|
<a href="howtoe.html">How To (English, very incomplete)</a><br>
|
||||||
<a href="howtor.html">How To (Russian)</a><br>
|
<a href="howtor.html">How To (Russian)</a><br>
|
||||||
<h3>Man pages:</h3>
|
<h3>Man pages:</h3>
|
||||||
|
<br><A HREF="man8/3proxy_crypt.8.html">3proxy_crypt.8</A>
|
||||||
<br><A HREF="man8/3proxy.8.html">3proxy.8</A>
|
<br><A HREF="man8/3proxy.8.html">3proxy.8</A>
|
||||||
<br><A HREF="man8/ftppr.8.html">ftppr.8</A>
|
<br><A HREF="man8/ftppr.8.html">ftppr.8</A>
|
||||||
<br><A HREF="man8/pop3p.8.html">pop3p.8</A>
|
<br><A HREF="man8/pop3p.8.html">pop3p.8</A>
|
||||||
@ -13,5 +14,5 @@
|
|||||||
<br><A HREF="man8/tcppm.8.html">tcppm.8</A>
|
<br><A HREF="man8/tcppm.8.html">tcppm.8</A>
|
||||||
<br><A HREF="man8/tlspr.8.html">tlspr.8</A>
|
<br><A HREF="man8/tlspr.8.html">tlspr.8</A>
|
||||||
<br><A HREF="man8/udppm.8.html">udppm.8</A>
|
<br><A HREF="man8/udppm.8.html">udppm.8</A>
|
||||||
<br><A HREF="man3/3proxy.cfg.3.html">3proxy.cfg.3</A>
|
<br><A HREF="man5/3proxy.cfg.5.html">3proxy.cfg.5</A>
|
||||||
</body></html>
|
</body></html>
|
||||||
|
|||||||
@ -930,8 +930,10 @@ users test1:CL:password1
|
|||||||
"test2:CR:$1$lFDGlder$pLRb4cU2D7GAT58YQvY49." <br>
|
"test2:CR:$1$lFDGlder$pLRb4cU2D7GAT58YQvY49." <br>
|
||||||
users test3:NT:BD7DFBF29A93F93C63CB84790DA00E63 <br>
|
users test3:NT:BD7DFBF29A93F93C63CB84790DA00E63 <br>
|
||||||
Note: double quotes are required because the password
|
Note: double quotes are required because the password
|
||||||
contains a $ sign. <b><br>
|
contains a $ sign.</p>
|
||||||
flush</b> <br>
|
|
||||||
|
<p style="margin-left:6%; margin-top: 1em"><b>flush</b>
|
||||||
|
<br>
|
||||||
empty the active access list. The access list must be
|
empty the active access list. The access list must be
|
||||||
flushed every time you create a new access list for a new
|
flushed every time you create a new access list for a new
|
||||||
service. For example: <br>
|
service. For example: <br>
|
||||||
@ -195,7 +195,7 @@ to <b>3proxy@3proxy.org</b></p>
|
|||||||
</h2>
|
</h2>
|
||||||
|
|
||||||
|
|
||||||
<p style="margin-left:6%; margin-top: 1em">3proxy.cfg(3),
|
<p style="margin-left:6%; margin-top: 1em">3proxy.cfg(5),
|
||||||
proxy(8), ftppr(8), socks(8), pop3p(8), tcppm(8), udppm(8),
|
proxy(8), ftppr(8), socks(8), pop3p(8), tcppm(8), udppm(8),
|
||||||
kill(1), syslogd(8), <br>
|
kill(1), syslogd(8), <br>
|
||||||
https://3proxy.org/</p>
|
https://3proxy.org/</p>
|
||||||
|
|||||||
168
doc/html/man8/3proxy_crypt.8.html
Normal file
168
doc/html/man8/3proxy_crypt.8.html
Normal file
@ -0,0 +1,168 @@
|
|||||||
|
<!-- Creator : groff version 1.24.1 -->
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<h1 align="center">3proxy_crypt</h1>
|
||||||
|
|
||||||
|
<a href="#NAME">NAME</a><br>
|
||||||
|
<a href="#SYNOPSIS">SYNOPSIS</a><br>
|
||||||
|
<a href="#DESCRIPTION">DESCRIPTION</a><br>
|
||||||
|
<a href="#OPTIONS">OPTIONS</a><br>
|
||||||
|
<a href="#EXAMPLE">EXAMPLE</a><br>
|
||||||
|
<a href="#NOTES">NOTES</a><br>
|
||||||
|
<a href="#BUGS">BUGS</a><br>
|
||||||
|
<a href="#SEE ALSO">SEE ALSO</a><br>
|
||||||
|
<a href="#AUTHORS">AUTHORS</a><br>
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
|
||||||
|
|
||||||
|
<h2>NAME
|
||||||
|
<a name="NAME"></a>
|
||||||
|
</h2>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<p style="margin-left:6%; margin-top: 1em"><b>3proxy_crypt</b>
|
||||||
|
- utility to generate encrypted passwords for 3proxy</p>
|
||||||
|
|
||||||
|
<h2>SYNOPSIS
|
||||||
|
<a name="SYNOPSIS"></a>
|
||||||
|
</h2>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<p style="margin-left:6%; margin-top: 1em"><b>3proxy_crypt</b>
|
||||||
|
<i>password</i> <b><br>
|
||||||
|
3proxy_crypt</b> <i>salt password</i></p>
|
||||||
|
|
||||||
|
<h2>DESCRIPTION
|
||||||
|
<a name="DESCRIPTION"></a>
|
||||||
|
</h2>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<p style="margin-left:6%; margin-top: 1em"><i><b>3proxy_crypt</b></i>
|
||||||
|
is a utility to generate encrypted password hashes for use
|
||||||
|
with 3proxy configuration. Encrypted passwords allow the
|
||||||
|
system to avoid storing passwords in cleartext in
|
||||||
|
configuration files.</p>
|
||||||
|
|
||||||
|
<p style="margin-left:6%; margin-top: 1em">When invoked
|
||||||
|
with a single argument, it produces an NT password hash
|
||||||
|
(MD4-based, suitable for NTLM authentication). The output is
|
||||||
|
prefixed with <b>NT:</b>.</p>
|
||||||
|
|
||||||
|
<p style="margin-left:6%; margin-top: 1em">When invoked
|
||||||
|
with two arguments (salt and password), it produces a
|
||||||
|
BLAKE2b password hash. The salt length is limited to 64
|
||||||
|
characters. The output is prefixed with <b>CR:</b>.</p>
|
||||||
|
|
||||||
|
<p style="margin-left:6%; margin-top: 1em">The resulting
|
||||||
|
hash can be used in the 3proxy configuration file with the
|
||||||
|
<b>users</b> directive instead of a cleartext password.</p>
|
||||||
|
|
||||||
|
<h2>OPTIONS
|
||||||
|
<a name="OPTIONS"></a>
|
||||||
|
</h2>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<p style="margin-left:6%; margin-top: 1em"><i>password</i></p>
|
||||||
|
|
||||||
|
<p style="margin-left:15%;">Cleartext password to
|
||||||
|
encrypt.</p>
|
||||||
|
|
||||||
|
<table width="100%" border="0" rules="none" frame="void"
|
||||||
|
cellspacing="0" cellpadding="0">
|
||||||
|
<tr valign="top" align="left">
|
||||||
|
<td width="6%"></td>
|
||||||
|
<td width="5%">
|
||||||
|
|
||||||
|
|
||||||
|
<p><i>salt</i></p></td>
|
||||||
|
<td width="4%"></td>
|
||||||
|
<td width="65%">
|
||||||
|
|
||||||
|
|
||||||
|
<p>Salt string for BLAKE2b hashing (max 64 characters).</p></td>
|
||||||
|
<td width="20%">
|
||||||
|
</td></tr>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<h2>EXAMPLE
|
||||||
|
<a name="EXAMPLE"></a>
|
||||||
|
</h2>
|
||||||
|
|
||||||
|
|
||||||
|
<p style="margin-left:6%; margin-top: 1em">Generate NT
|
||||||
|
password hash:</p>
|
||||||
|
|
||||||
|
<p style="margin-left:15%;">3proxy_crypt
|
||||||
|
MySecretPassword</p>
|
||||||
|
|
||||||
|
<p style="margin-left:6%;">Result:</p>
|
||||||
|
|
||||||
|
|
||||||
|
<p style="margin-left:15%;">NT:3F7E6D8D96E8E7A9B0C1D2E3F4A5B6C7</p>
|
||||||
|
|
||||||
|
<p style="margin-left:6%;">Generate BLAKE2b password hash
|
||||||
|
with salt:</p>
|
||||||
|
|
||||||
|
<p style="margin-left:15%;">3proxy_crypt MySalt
|
||||||
|
MySecretPassword</p>
|
||||||
|
|
||||||
|
<p style="margin-left:6%;">Result:</p>
|
||||||
|
|
||||||
|
<p style="margin-left:15%;">CR:$3$MySalt$...</p>
|
||||||
|
|
||||||
|
<p style="margin-left:6%;">Using in 3proxy.cfg:</p>
|
||||||
|
|
||||||
|
<p style="margin-left:15%;">users
|
||||||
|
user1:CR:$3$MySalt$...</p>
|
||||||
|
|
||||||
|
<h2>NOTES
|
||||||
|
<a name="NOTES"></a>
|
||||||
|
</h2>
|
||||||
|
|
||||||
|
|
||||||
|
<p style="margin-left:6%; margin-top: 1em">The NT hash uses
|
||||||
|
the RSA MD4 Message-Digest Algorithm. The BLAKE2b hash uses
|
||||||
|
the BLAKE2 cryptographic hash function.</p>
|
||||||
|
|
||||||
|
<p style="margin-left:6%; margin-top: 1em">When a password
|
||||||
|
hash is prefixed with <b>NT:</b> or <b>CR:</b>, 3proxy uses
|
||||||
|
the corresponding algorithm to verify passwords instead of
|
||||||
|
comparing cleartext strings.</p>
|
||||||
|
|
||||||
|
<h2>BUGS
|
||||||
|
<a name="BUGS"></a>
|
||||||
|
</h2>
|
||||||
|
|
||||||
|
|
||||||
|
<p style="margin-left:6%; margin-top: 1em">Report all bugs
|
||||||
|
to <b>3proxy@3proxy.org</b></p>
|
||||||
|
|
||||||
|
<h2>SEE ALSO
|
||||||
|
<a name="SEE ALSO"></a>
|
||||||
|
</h2>
|
||||||
|
|
||||||
|
|
||||||
|
<p style="margin-left:6%; margin-top: 1em">3proxy(8),
|
||||||
|
3proxy.cfg(5), <br>
|
||||||
|
https://3proxy.org/</p>
|
||||||
|
|
||||||
|
<h2>AUTHORS
|
||||||
|
<a name="AUTHORS"></a>
|
||||||
|
</h2>
|
||||||
|
|
||||||
|
|
||||||
|
<p style="margin-left:6%; margin-top: 1em">3proxy is
|
||||||
|
designed by Vladimir 3APA3A Dubrovin
|
||||||
|
(<i>3proxy@3proxy.org</i>)</p>
|
||||||
|
<hr>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@ -140,7 +140,7 @@ configuration file
|
|||||||
Report all bugs to
|
Report all bugs to
|
||||||
.BR 3proxy@3proxy.org
|
.BR 3proxy@3proxy.org
|
||||||
.SH SEE ALSO
|
.SH SEE ALSO
|
||||||
3proxy.cfg(3), proxy(8), ftppr(8), socks(8), pop3p(8), tcppm(8), udppm(8),
|
3proxy.cfg(5), proxy(8), ftppr(8), socks(8), pop3p(8), tcppm(8), udppm(8),
|
||||||
kill(1), syslogd(8),
|
kill(1), syslogd(8),
|
||||||
.br
|
.br
|
||||||
https://3proxy.org/
|
https://3proxy.org/
|
||||||
|
|||||||
81
man/3proxy_crypt.8
Normal file
81
man/3proxy_crypt.8
Normal file
@ -0,0 +1,81 @@
|
|||||||
|
.TH 3proxy_crypt "8" "April 2026" "3proxy 0.9" "Universal proxy server"
|
||||||
|
.SH NAME
|
||||||
|
.B 3proxy_crypt
|
||||||
|
\- utility to generate encrypted passwords for 3proxy
|
||||||
|
.SH SYNOPSIS
|
||||||
|
.B 3proxy_crypt
|
||||||
|
.I password
|
||||||
|
.br
|
||||||
|
.B 3proxy_crypt
|
||||||
|
.I salt password
|
||||||
|
.SH DESCRIPTION
|
||||||
|
.B 3proxy_crypt
|
||||||
|
is a utility to generate encrypted password hashes for use with 3proxy
|
||||||
|
configuration. Encrypted passwords allow the system to avoid storing
|
||||||
|
passwords in cleartext in configuration files.
|
||||||
|
.PP
|
||||||
|
When invoked with a single argument, it produces an NT password hash
|
||||||
|
(MD4-based, suitable for NTLM authentication). The output is prefixed with
|
||||||
|
.BR NT: .
|
||||||
|
.PP
|
||||||
|
When invoked with two arguments (salt and password), it produces a BLAKE2b
|
||||||
|
password hash. The salt length is limited to 64 characters. The output is
|
||||||
|
prefixed with
|
||||||
|
.BR CR: .
|
||||||
|
.PP
|
||||||
|
The resulting hash can be used in the 3proxy configuration file with the
|
||||||
|
.B users
|
||||||
|
directive instead of a cleartext password.
|
||||||
|
.SH OPTIONS
|
||||||
|
.TP
|
||||||
|
.I password
|
||||||
|
Cleartext password to encrypt.
|
||||||
|
.TP
|
||||||
|
.I salt
|
||||||
|
Salt string for BLAKE2b hashing (max 64 characters).
|
||||||
|
.SH EXAMPLE
|
||||||
|
.TP
|
||||||
|
Generate NT password hash:
|
||||||
|
.RS
|
||||||
|
3proxy_crypt MySecretPassword
|
||||||
|
.RE
|
||||||
|
.TP
|
||||||
|
Result:
|
||||||
|
.RS
|
||||||
|
NT:3F7E6D8D96E8E7A9B0C1D2E3F4A5B6C7
|
||||||
|
.RE
|
||||||
|
.TP
|
||||||
|
Generate BLAKE2b password hash with salt:
|
||||||
|
.RS
|
||||||
|
3proxy_crypt MySalt MySecretPassword
|
||||||
|
.RE
|
||||||
|
.TP
|
||||||
|
Result:
|
||||||
|
.RS
|
||||||
|
CR:$3$MySalt$...
|
||||||
|
.RE
|
||||||
|
.TP
|
||||||
|
Using in 3proxy.cfg:
|
||||||
|
.RS
|
||||||
|
users user1:CR:$3$MySalt$...
|
||||||
|
.RE
|
||||||
|
.SH NOTES
|
||||||
|
The NT hash uses the RSA MD4 Message-Digest Algorithm. The BLAKE2b hash
|
||||||
|
uses the BLAKE2 cryptographic hash function.
|
||||||
|
.PP
|
||||||
|
When a password hash is prefixed with
|
||||||
|
.B NT:
|
||||||
|
or
|
||||||
|
.BR CR: ,
|
||||||
|
3proxy uses the corresponding algorithm to verify passwords instead of
|
||||||
|
comparing cleartext strings.
|
||||||
|
.SH BUGS
|
||||||
|
Report all bugs to
|
||||||
|
.BR 3proxy@3proxy.org
|
||||||
|
.SH SEE ALSO
|
||||||
|
3proxy(8), 3proxy.cfg(5),
|
||||||
|
.br
|
||||||
|
https://3proxy.org/
|
||||||
|
.SH AUTHORS
|
||||||
|
3proxy is designed by Vladimir 3APA3A Dubrovin
|
||||||
|
.RI ( 3proxy@3proxy.org )
|
||||||
@ -32,13 +32,15 @@ make clean
|
|||||||
|
|
||||||
%files
|
%files
|
||||||
/bin/3proxy
|
/bin/3proxy
|
||||||
/bin/ftppr
|
|
||||||
/bin/3proxy_crypt
|
/bin/3proxy_crypt
|
||||||
/bin/pop3p
|
/bin/3proxy_ftppr
|
||||||
/bin/proxy
|
/bin/3proxy_pop3p
|
||||||
/bin/socks
|
/bin/3proxy_proxy
|
||||||
/bin/tcppm
|
/bin/3proxy_smtpp
|
||||||
/bin/tlspr
|
/bin/3proxy_socks
|
||||||
|
/bin/3proxy_tcppm
|
||||||
|
/bin/3proxy_tlspr
|
||||||
|
/bin/3proxy_udppm
|
||||||
%config(noreplace) /etc/3proxy/3proxy.cfg
|
%config(noreplace) /etc/3proxy/3proxy.cfg
|
||||||
/etc/3proxy/conf
|
/etc/3proxy/conf
|
||||||
/etc/init.d/3proxy
|
/etc/init.d/3proxy
|
||||||
@ -48,7 +50,7 @@ make clean
|
|||||||
%config(noreplace) /usr/local/3proxy/conf/bandlimiters
|
%config(noreplace) /usr/local/3proxy/conf/bandlimiters
|
||||||
%config(noreplace) /usr/local/3proxy/conf/counters
|
%config(noreplace) /usr/local/3proxy/conf/counters
|
||||||
/usr/local/3proxy/libexec/*.ld.so
|
/usr/local/3proxy/libexec/*.ld.so
|
||||||
/usr/share/man/man3/*
|
/usr/share/man/man5/3proxy.cfg.5
|
||||||
/usr/share/man/man8/*
|
/usr/share/man/man8/*
|
||||||
/var/log/3proxy
|
/var/log/3proxy
|
||||||
|
|
||||||
|
|||||||
36
src/3proxy.c
36
src/3proxy.c
@ -66,9 +66,9 @@ void __stdcall CommandHandler( DWORD dwCommand )
|
|||||||
Sleep(2000);
|
Sleep(2000);
|
||||||
SetStatus( SERVICE_STOPPED, 0, 0 );
|
SetStatus( SERVICE_STOPPED, 0, 0 );
|
||||||
#ifndef NOODBC
|
#ifndef NOODBC
|
||||||
pthread_mutex_lock(&log_mutex);
|
_3proxy_mutex_lock(&log_mutex);
|
||||||
close_sql();
|
close_sql();
|
||||||
pthread_mutex_unlock(&log_mutex);
|
_3proxy_mutex_unlock(&log_mutex);
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
case SERVICE_CONTROL_PAUSE:
|
case SERVICE_CONTROL_PAUSE:
|
||||||
@ -118,13 +118,6 @@ void mysigpause (int sig){
|
|||||||
|
|
||||||
void mysigterm (int sig){
|
void mysigterm (int sig){
|
||||||
conf.paused++;
|
conf.paused++;
|
||||||
usleep(999*SLEEPTIME);
|
|
||||||
usleep(999*SLEEPTIME);
|
|
||||||
#ifndef NOODBC
|
|
||||||
pthread_mutex_lock(&log_mutex);
|
|
||||||
close_sql();
|
|
||||||
pthread_mutex_unlock(&log_mutex);
|
|
||||||
#endif
|
|
||||||
conf.timetoexit = 1;
|
conf.timetoexit = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -512,22 +505,23 @@ int WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
pthread_mutex_init(&config_mutex, NULL);
|
_3proxy_mutex_init(&config_mutex);
|
||||||
pthread_mutex_init(&bandlim_mutex, NULL);
|
_3proxy_mutex_init(&bandlim_mutex);
|
||||||
pthread_mutex_init(&connlim_mutex, NULL);
|
_3proxy_mutex_init(&connlim_mutex);
|
||||||
pthread_mutex_init(&tc_mutex, NULL);
|
_3proxy_mutex_init(&tc_mutex);
|
||||||
pthread_mutex_init(&log_mutex, NULL);
|
_3proxy_mutex_init(&log_mutex);
|
||||||
#ifndef NORADIUS
|
#ifndef NORADIUS
|
||||||
pthread_mutex_init(&rad_mutex, NULL);
|
_3proxy_mutex_init(&rad_mutex);
|
||||||
#endif
|
#endif
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
if(!CreatePipe(&conf.threadinit[0], &conf.threadinit[1], NULL, 1)){
|
conf.threadinit = CreateSemaphore(NULL, 0, 1, NULL);
|
||||||
#else
|
if(!conf.threadinit){
|
||||||
if(pipe(conf.threadinit)) {
|
fprintf(stderr, "semaphore init failed\n");
|
||||||
#endif
|
|
||||||
fprintf(stderr, "CreatePipe failed\n");
|
|
||||||
return 1;
|
return 1;
|
||||||
};
|
}
|
||||||
|
#else
|
||||||
|
_3proxy_mutex_init(&conf.threadinit);
|
||||||
|
#endif
|
||||||
|
|
||||||
freeconf(&conf);
|
freeconf(&conf);
|
||||||
res = readconfig(fp);
|
res = readconfig(fp);
|
||||||
|
|||||||
@ -2,8 +2,7 @@
|
|||||||
# 3 proxy common Makefile
|
# 3 proxy common Makefile
|
||||||
#
|
#
|
||||||
|
|
||||||
all: $(BUILDDIR)3proxy$(EXESUFFICS) $(BUILDDIR)3proxy_crypt$(EXESUFFICS) $(BUILDDIR)pop3p$(EXESUFFICS) $(BUILDDIR)smtpp$(EXESUFFICS) $(BUILDDIR)ftppr$(EXESUFFICS) $(BUILDDIR)tcppm$(EXESUFFICS) $(BUILDDIR)tlspr$(EXESUFFICS) $(BUILDDIR)socks$(EXESUFFICS) $(BUILDDIR)proxy$(EXESUFFICS) allplugins
|
all: $(BUILDDIR)3proxy$(EXESUFFICS) $(BUILDDIR)$(CRYPT_PREFIX)crypt$(EXESUFFICS) $(BUILDDIR)$(PREFIX)pop3p$(EXESUFFICS) $(BUILDDIR)$(PREFIX)smtpp$(EXESUFFICS) $(BUILDDIR)$(PREFIX)ftppr$(EXESUFFICS) $(BUILDDIR)$(PREFIX)tcppm$(EXESUFFICS) $(BUILDDIR)$(PREFIX)udppm$(EXESUFFICS) $(BUILDDIR)$(PREFIX)tlspr$(EXESUFFICS) $(BUILDDIR)$(PREFIX)socks$(EXESUFFICS) $(BUILDDIR)$(PREFIX)proxy$(EXESUFFICS) allplugins
|
||||||
|
|
||||||
|
|
||||||
sockmap$(OBJSUFFICS): sockmap.c proxy.h structures.h
|
sockmap$(OBJSUFFICS): sockmap.c proxy.h structures.h
|
||||||
$(CC) $(CFLAGS) sockmap.c
|
$(CC) $(CFLAGS) sockmap.c
|
||||||
@ -27,50 +26,56 @@ sockgetchar$(OBJSUFFICS): sockgetchar.c proxy.h structures.h
|
|||||||
$(CC) $(CFLAGS) sockgetchar.c
|
$(CC) $(CFLAGS) sockgetchar.c
|
||||||
|
|
||||||
proxy$(OBJSUFFICS): proxy.c proxy.h structures.h proxymain.c
|
proxy$(OBJSUFFICS): proxy.c proxy.h structures.h proxymain.c
|
||||||
$(CC) $(CFLAGS) $(DEFINEOPTION)WITHMAIN $(DEFINEOPTION)NOPORTMAP $(DEFINEOPTION)ANONYMOUS proxy.c
|
$(CC) $(CFLAGS) $(DEFINEOPTION)WITHMAIN $(DEFINEOPTION)NOPORTMAP $(DEFINEOPTION)ANONYMOUS $(DEFINEOPTION)NOUDPMAIN proxy.c
|
||||||
|
|
||||||
pop3p$(OBJSUFFICS): pop3p.c proxy.h structures.h proxymain.c
|
pop3p$(OBJSUFFICS): pop3p.c proxy.h structures.h proxymain.c
|
||||||
$(CC) $(CFLAGS) $(DEFINEOPTION)WITHMAIN $(DEFINEOPTION)NOPORTMAP pop3p.c
|
$(CC) $(CFLAGS) $(DEFINEOPTION)WITHMAIN $(DEFINEOPTION)NOPORTMAP $(DEFINEOPTION)NOUDPMAIN pop3p.c
|
||||||
|
|
||||||
smtpp$(OBJSUFFICS): smtpp.c proxy.h structures.h proxymain.c
|
smtpp$(OBJSUFFICS): smtpp.c proxy.h structures.h proxymain.c
|
||||||
$(CC) $(CFLAGS) $(DEFINEOPTION)WITHMAIN $(DEFINEOPTION)NOPORTMAP smtpp.c
|
$(CC) $(CFLAGS) $(DEFINEOPTION)WITHMAIN $(DEFINEOPTION)NOPORTMAP $(DEFINEOPTION)NOUDPMAIN smtpp.c
|
||||||
|
|
||||||
ftppr$(OBJSUFFICS): ftppr.c proxy.h structures.h proxymain.c
|
ftppr$(OBJSUFFICS): ftppr.c proxy.h structures.h proxymain.c
|
||||||
$(CC) $(CFLAGS) $(DEFINEOPTION)WITHMAIN $(DEFINEOPTION)NOPORTMAP ftppr.c
|
$(CC) $(CFLAGS) $(DEFINEOPTION)WITHMAIN $(DEFINEOPTION)NOPORTMAP $(DEFINEOPTION)NOUDPMAIN ftppr.c
|
||||||
|
|
||||||
tcppm$(OBJSUFFICS): tcppm.c proxy.h structures.h proxymain.c
|
tcppm$(OBJSUFFICS): tcppm.c proxy.h structures.h proxymain.c
|
||||||
$(CC) $(CFLAGS) $(DEFINEOPTION)WITHMAIN $(DEFINEOPTION)PORTMAP tcppm.c
|
$(CC) $(CFLAGS) $(DEFINEOPTION)WITHMAIN $(DEFINEOPTION)PORTMAP $(DEFINEOPTION)NOUDPMAIN tcppm.c
|
||||||
|
|
||||||
|
udppm$(OBJSUFFICS): udppm.c proxy.h structures.h proxymain.c
|
||||||
|
$(CC) $(CFLAGS) $(DEFINEOPTION)WITHMAIN $(DEFINEOPTION)PORTMAP udppm.c
|
||||||
|
|
||||||
tlspr$(OBJSUFFICS): tlspr.c proxy.h structures.h proxymain.c
|
tlspr$(OBJSUFFICS): tlspr.c proxy.h structures.h proxymain.c
|
||||||
$(CC) $(CFLAGS) $(DEFINEOPTION)WITHMAIN $(DEFINEOPTION)PORTMAP tlspr.c
|
$(CC) $(CFLAGS) $(DEFINEOPTION)WITHMAIN $(DEFINEOPTION)PORTMAP $(DEFINEOPTION)NOUDPMAIN tlspr.c
|
||||||
|
|
||||||
|
|
||||||
socks$(OBJSUFFICS): socks.c proxy.h structures.h proxymain.c
|
socks$(OBJSUFFICS): socks.c proxy.h structures.h proxymain.c
|
||||||
$(CC) $(CFLAGS) $(DEFINEOPTION)WITHMAIN $(DEFINEOPTION)NOPORTMAP socks.c
|
$(CC) $(CFLAGS) $(DEFINEOPTION)WITHMAIN $(DEFINEOPTION)NOPORTMAP $(DEFINEOPTION)NOUDPMAIN socks.c
|
||||||
|
|
||||||
3proxy$(OBJSUFFICS): 3proxy.c proxy.h structures.h
|
3proxy$(OBJSUFFICS): 3proxy.c proxy.h structures.h
|
||||||
$(CC) $(CFLAGS) 3proxy.c
|
$(CC) $(CFLAGS) 3proxy.c
|
||||||
|
|
||||||
$(BUILDDIR)proxy$(EXESUFFICS): sockmap$(OBJSUFFICS) proxy$(OBJSUFFICS) sockgetchar$(OBJSUFFICS) common$(OBJSUFFICS) log$(OBJSUFFICS) base64$(OBJSUFFICS) ftp$(OBJSUFFICS) $(COMPATLIBS)
|
$(BUILDDIR)$(PREFIX)proxy$(EXESUFFICS): sockmap$(OBJSUFFICS) proxy$(OBJSUFFICS) sockgetchar$(OBJSUFFICS) common$(OBJSUFFICS) log$(OBJSUFFICS) base64$(OBJSUFFICS) ftp$(OBJSUFFICS) $(COMPATLIBS)
|
||||||
$(LN) $(LNOUT)$(BUILDDIR)proxy$(EXESUFFICS) $(LDFLAGS) sockmap$(OBJSUFFICS) proxy$(OBJSUFFICS) sockgetchar$(OBJSUFFICS) log$(OBJSUFFICS) common$(OBJSUFFICS) base64$(OBJSUFFICS) ftp$(OBJSUFFICS) $(COMPATLIBS) $(LIBS)
|
$(LN) $(LNOUT)$(BUILDDIR)$(PREFIX)proxy$(EXESUFFICS) $(LDFLAGS) sockmap$(OBJSUFFICS) proxy$(OBJSUFFICS) sockgetchar$(OBJSUFFICS) log$(OBJSUFFICS) common$(OBJSUFFICS) base64$(OBJSUFFICS) ftp$(OBJSUFFICS) $(COMPATLIBS) $(LIBS)
|
||||||
|
|
||||||
$(BUILDDIR)pop3p$(EXESUFFICS): sockmap$(OBJSUFFICS) pop3p$(OBJSUFFICS) sockgetchar$(OBJSUFFICS) common$(OBJSUFFICS) log$(OBJSUFFICS) $(COMPATLIBS)
|
$(BUILDDIR)$(PREFIX)pop3p$(EXESUFFICS): sockmap$(OBJSUFFICS) pop3p$(OBJSUFFICS) sockgetchar$(OBJSUFFICS) common$(OBJSUFFICS) log$(OBJSUFFICS) $(COMPATLIBS)
|
||||||
$(LN) $(LNOUT)$(BUILDDIR)pop3p$(EXESUFFICS) $(LDFLAGS) sockmap$(OBJSUFFICS) pop3p$(OBJSUFFICS) sockgetchar$(OBJSUFFICS) log$(OBJSUFFICS) common$(OBJSUFFICS) $(COMPATLIBS) $(LIBS)
|
$(LN) $(LNOUT)$(BUILDDIR)$(PREFIX)pop3p$(EXESUFFICS) $(LDFLAGS) sockmap$(OBJSUFFICS) pop3p$(OBJSUFFICS) sockgetchar$(OBJSUFFICS) log$(OBJSUFFICS) common$(OBJSUFFICS) $(COMPATLIBS) $(LIBS)
|
||||||
|
|
||||||
$(BUILDDIR)smtpp$(EXESUFFICS): sockmap$(OBJSUFFICS) smtpp$(OBJSUFFICS) sockgetchar$(OBJSUFFICS) common$(OBJSUFFICS) log$(OBJSUFFICS) base64$(OBJSUFFICS) $(COMPATLIBS)
|
$(BUILDDIR)$(PREFIX)smtpp$(EXESUFFICS): sockmap$(OBJSUFFICS) smtpp$(OBJSUFFICS) sockgetchar$(OBJSUFFICS) common$(OBJSUFFICS) log$(OBJSUFFICS) base64$(OBJSUFFICS) $(COMPATLIBS)
|
||||||
$(LN) $(LNOUT)$(BUILDDIR)smtpp$(EXESUFFICS) $(LDFLAGS) sockmap$(OBJSUFFICS) smtpp$(OBJSUFFICS) sockgetchar$(OBJSUFFICS) base64$(OBJSUFFICS) log$(OBJSUFFICS) common$(OBJSUFFICS) $(COMPATLIBS) $(LIBS)
|
$(LN) $(LNOUT)$(BUILDDIR)$(PREFIX)smtpp$(EXESUFFICS) $(LDFLAGS) sockmap$(OBJSUFFICS) smtpp$(OBJSUFFICS) sockgetchar$(OBJSUFFICS) base64$(OBJSUFFICS) log$(OBJSUFFICS) common$(OBJSUFFICS) $(COMPATLIBS) $(LIBS)
|
||||||
|
|
||||||
$(BUILDDIR)ftppr$(EXESUFFICS): sockmap$(OBJSUFFICS) ftppr$(OBJSUFFICS) ftp$(OBJSUFFICS) sockgetchar$(OBJSUFFICS) common$(OBJSUFFICS) log$(OBJSUFFICS) $(COMPATLIBS)
|
$(BUILDDIR)$(PREFIX)ftppr$(EXESUFFICS): sockmap$(OBJSUFFICS) ftppr$(OBJSUFFICS) ftp$(OBJSUFFICS) sockgetchar$(OBJSUFFICS) common$(OBJSUFFICS) log$(OBJSUFFICS) $(COMPATLIBS)
|
||||||
$(LN) $(LNOUT)$(BUILDDIR)ftppr$(EXESUFFICS) $(LDFLAGS) sockmap$(OBJSUFFICS) ftppr$(OBJSUFFICS) sockgetchar$(OBJSUFFICS) common$(OBJSUFFICS) log$(OBJSUFFICS) ftp$(OBJSUFFICS) $(COMPATLIBS) $(LIBS)
|
$(LN) $(LNOUT)$(BUILDDIR)$(PREFIX)ftppr$(EXESUFFICS) $(LDFLAGS) sockmap$(OBJSUFFICS) ftppr$(OBJSUFFICS) sockgetchar$(OBJSUFFICS) common$(OBJSUFFICS) log$(OBJSUFFICS) ftp$(OBJSUFFICS) $(COMPATLIBS) $(LIBS)
|
||||||
|
|
||||||
$(BUILDDIR)socks$(EXESUFFICS): sockmap$(OBJSUFFICS) socks$(OBJSUFFICS) sockgetchar$(OBJSUFFICS) common$(OBJSUFFICS) log$(OBJSUFFICS)
|
$(BUILDDIR)$(PREFIX)socks$(EXESUFFICS): sockmap$(OBJSUFFICS) socks$(OBJSUFFICS) sockgetchar$(OBJSUFFICS) common$(OBJSUFFICS) log$(OBJSUFFICS)
|
||||||
$(LN) $(LNOUT)$(BUILDDIR)socks$(EXESUFFICS) $(LDFLAGS) sockmap$(OBJSUFFICS) socks$(OBJSUFFICS) sockgetchar$(OBJSUFFICS) log$(OBJSUFFICS) common$(OBJSUFFICS) $(LIBS)
|
$(LN) $(LNOUT)$(BUILDDIR)$(PREFIX)socks$(EXESUFFICS) $(LDFLAGS) sockmap$(OBJSUFFICS) socks$(OBJSUFFICS) sockgetchar$(OBJSUFFICS) log$(OBJSUFFICS) common$(OBJSUFFICS) $(LIBS)
|
||||||
|
|
||||||
$(BUILDDIR)tcppm$(EXESUFFICS): sockmap$(OBJSUFFICS) sockgetchar$(OBJSUFFICS) tcppm$(OBJSUFFICS) common$(OBJSUFFICS) log$(OBJSUFFICS)
|
$(BUILDDIR)$(PREFIX)tcppm$(EXESUFFICS): sockmap$(OBJSUFFICS) sockgetchar$(OBJSUFFICS) tcppm$(OBJSUFFICS) common$(OBJSUFFICS) log$(OBJSUFFICS)
|
||||||
$(LN) $(LNOUT)$(BUILDDIR)tcppm$(EXESUFFICS) $(LDFLAGS) sockmap$(OBJSUFFICS) sockgetchar$(OBJSUFFICS) tcppm$(OBJSUFFICS) log$(OBJSUFFICS) common$(OBJSUFFICS) $(LIBS)
|
$(LN) $(LNOUT)$(BUILDDIR)$(PREFIX)tcppm$(EXESUFFICS) $(LDFLAGS) sockmap$(OBJSUFFICS) sockgetchar$(OBJSUFFICS) tcppm$(OBJSUFFICS) log$(OBJSUFFICS) common$(OBJSUFFICS) $(LIBS)
|
||||||
|
|
||||||
$(BUILDDIR)tlspr$(EXESUFFICS): sockmap$(OBJSUFFICS) sockgetchar$(OBJSUFFICS) tlspr$(OBJSUFFICS) common$(OBJSUFFICS) log$(OBJSUFFICS)
|
$(BUILDDIR)$(PREFIX)udppm$(EXESUFFICS): sockmap$(OBJSUFFICS) sockgetchar$(OBJSUFFICS) udppm$(OBJSUFFICS) common$(OBJSUFFICS) log$(OBJSUFFICS) hash$(OBJSUFFICS)
|
||||||
$(LN) $(LNOUT)$(BUILDDIR)tlspr$(EXESUFFICS) $(LDFLAGS) sockmap$(OBJSUFFICS) sockgetchar$(OBJSUFFICS) tlspr$(OBJSUFFICS) log$(OBJSUFFICS) common$(OBJSUFFICS) $(LIBS)
|
$(LN) $(LNOUT)$(BUILDDIR)$(PREFIX)udppm$(EXESUFFICS) $(LDFLAGS) sockmap$(OBJSUFFICS) sockgetchar$(OBJSUFFICS) udppm$(OBJSUFFICS) log$(OBJSUFFICS) common$(OBJSUFFICS) hash$(OBJSUFFICS) $(LIBS)
|
||||||
|
|
||||||
|
$(BUILDDIR)$(PREFIX)tlspr$(EXESUFFICS): sockmap$(OBJSUFFICS) sockgetchar$(OBJSUFFICS) tlspr$(OBJSUFFICS) common$(OBJSUFFICS) log$(OBJSUFFICS)
|
||||||
|
$(LN) $(LNOUT)$(BUILDDIR)$(PREFIX)tlspr$(EXESUFFICS) $(LDFLAGS) sockmap$(OBJSUFFICS) sockgetchar$(OBJSUFFICS) tlspr$(OBJSUFFICS) log$(OBJSUFFICS) common$(OBJSUFFICS) $(LIBS)
|
||||||
|
|
||||||
mainfunc$(OBJSUFFICS): proxy.h structures.h proxymain.c
|
mainfunc$(OBJSUFFICS): proxy.h structures.h proxymain.c
|
||||||
$(CC) $(COUT)mainfunc$(OBJSUFFICS) $(CFLAGS) $(DEFINEOPTION)MODULEMAINFUNC=mainfunc proxymain.c
|
$(CC) $(COUT)mainfunc$(OBJSUFFICS) $(CFLAGS) $(DEFINEOPTION)MODULEMAINFUNC=mainfunc proxymain.c
|
||||||
@ -123,6 +128,9 @@ redirect$(OBJSUFFICS): redirect.c proxy.h structures.h
|
|||||||
hash$(OBJSUFFICS): hash.c proxy.h structures.h
|
hash$(OBJSUFFICS): hash.c proxy.h structures.h
|
||||||
$(CC) $(COUT)hash$(OBJSUFFICS) $(CFLAGS) hash.c
|
$(CC) $(COUT)hash$(OBJSUFFICS) $(CFLAGS) hash.c
|
||||||
|
|
||||||
|
hashtables$(OBJSUFFICS): hashtables.c proxy.h structures.h
|
||||||
|
$(CC) $(COUT)hashtables$(OBJSUFFICS) $(CFLAGS) hashtables.c
|
||||||
|
|
||||||
resolve$(OBJSUFFICS): resolve.c proxy.h structures.h
|
resolve$(OBJSUFFICS): resolve.c proxy.h structures.h
|
||||||
$(CC) $(COUT)resolve$(OBJSUFFICS) $(CFLAGS) resolve.c
|
$(CC) $(COUT)resolve$(OBJSUFFICS) $(CFLAGS) resolve.c
|
||||||
|
|
||||||
@ -153,12 +161,12 @@ md5$(OBJSUFFICS): libs/md5.h libs/md5.c
|
|||||||
blake2$(OBJSUFFICS): libs/blake2.h libs/blake2-impl.h libs/blake2b-ref.c
|
blake2$(OBJSUFFICS): libs/blake2.h libs/blake2-impl.h libs/blake2b-ref.c
|
||||||
$(CC) $(COUT)blake2$(OBJSUFFICS) $(CFLAGS) libs/blake2b-ref.c
|
$(CC) $(COUT)blake2$(OBJSUFFICS) $(CFLAGS) libs/blake2b-ref.c
|
||||||
|
|
||||||
$(BUILDDIR)3proxy_crypt$(EXESUFFICS): md4$(OBJSUFFICS) blake2$(OBJSUFFICS) 3proxy_cryptmain$(OBJSUFFICS) base64$(OBJSUFFICS)
|
$(BUILDDIR)$(CRYPT_PREFIX)crypt$(EXESUFFICS): md4$(OBJSUFFICS) blake2$(OBJSUFFICS) 3proxy_cryptmain$(OBJSUFFICS) base64$(OBJSUFFICS)
|
||||||
$(LN) $(LNOUT)$(BUILDDIR)3proxy_crypt$(EXESUFFICS) $(LDFLAGS) md4$(OBJSUFFICS) blake2$(OBJSUFFICS) base64$(OBJSUFFICS) 3proxy_cryptmain$(OBJSUFFICS)
|
$(LN) $(LNOUT)$(BUILDDIR)$(CRYPT_PREFIX)crypt$(EXESUFFICS) $(LDFLAGS) md4$(OBJSUFFICS) blake2$(OBJSUFFICS) base64$(OBJSUFFICS) 3proxy_cryptmain$(OBJSUFFICS)
|
||||||
|
|
||||||
stringtable$(OBJSUFFICS): stringtable.c
|
stringtable$(OBJSUFFICS): stringtable.c
|
||||||
$(CC) $(COUT)stringtable$(OBJSUFFICS) $(CFLAGS) stringtable.c
|
$(CC) $(COUT)stringtable$(OBJSUFFICS) $(CFLAGS) stringtable.c
|
||||||
|
|
||||||
$(BUILDDIR)3proxy$(EXESUFFICS): 3proxy$(OBJSUFFICS) mainfunc$(OBJSUFFICS) srvproxy$(OBJSUFFICS) srvpop3p$(OBJSUFFICS) srvsmtpp$(OBJSUFFICS) srvftppr$(OBJSUFFICS) srvsocks$(OBJSUFFICS) srvtcppm$(OBJSUFFICS) srvtlspr$(OBJSUFFICS) srvauto$(OBJSUFFICS) srvudppm$(OBJSUFFICS) sockmap$(OBJSUFFICS) sockgetchar$(OBJSUFFICS) common$(OBJSUFFICS) auth$(OBJSUFFICS) acl$(OBJSUFFICS) limiter$(OBJSUFFICS) redirect$(OBJSUFFICS) authradius$(OBJSUFFICS) hash$(OBJSUFFICS) resolve$(OBJSUFFICS) sql$(OBJSUFFICS) conf$(OBJSUFFICS) log$(OBJSUFFICS) datatypes$(OBJSUFFICS) md4$(OBJSUFFICS) md5$(OBJSUFFICS) blake2$(OBJSUFFICS) 3proxy_crypt$(OBJSUFFICS) base64$(OBJSUFFICS) ftp$(OBJSUFFICS) stringtable$(OBJSUFFICS) srvwebadmin$(OBJSUFFICS) srvdnspr$(OBJSUFFICS) plugins$(OBJSUFFICS) $(COMPATLIBS) $(VERSIONDEP)
|
$(BUILDDIR)3proxy$(EXESUFFICS): 3proxy$(OBJSUFFICS) mainfunc$(OBJSUFFICS) srvproxy$(OBJSUFFICS) srvpop3p$(OBJSUFFICS) srvsmtpp$(OBJSUFFICS) srvftppr$(OBJSUFFICS) srvsocks$(OBJSUFFICS) srvtcppm$(OBJSUFFICS) srvtlspr$(OBJSUFFICS) srvauto$(OBJSUFFICS) srvudppm$(OBJSUFFICS) sockmap$(OBJSUFFICS) sockgetchar$(OBJSUFFICS) common$(OBJSUFFICS) auth$(OBJSUFFICS) acl$(OBJSUFFICS) limiter$(OBJSUFFICS) redirect$(OBJSUFFICS) authradius$(OBJSUFFICS) hash$(OBJSUFFICS) hashtables$(OBJSUFFICS) resolve$(OBJSUFFICS) sql$(OBJSUFFICS) conf$(OBJSUFFICS) log$(OBJSUFFICS) datatypes$(OBJSUFFICS) md4$(OBJSUFFICS) md5$(OBJSUFFICS) blake2$(OBJSUFFICS) 3proxy_crypt$(OBJSUFFICS) base64$(OBJSUFFICS) ftp$(OBJSUFFICS) stringtable$(OBJSUFFICS) srvwebadmin$(OBJSUFFICS) srvdnspr$(OBJSUFFICS) plugins$(OBJSUFFICS) $(COMPATLIBS) $(VERSIONDEP)
|
||||||
$(LN) $(LNOUT)$(BUILDDIR)3proxy$(EXESUFFICS) $(LDFLAGS) $(VERFILE) 3proxy$(OBJSUFFICS) mainfunc$(OBJSUFFICS) auth$(OBJSUFFICS) acl$(OBJSUFFICS) limiter$(OBJSUFFICS) redirect$(OBJSUFFICS) authradius$(OBJSUFFICS) hash$(OBJSUFFICS) resolve$(OBJSUFFICS) sql$(OBJSUFFICS) conf$(OBJSUFFICS) datatypes$(OBJSUFFICS) srvauto$(OBJSUFFICS) srvproxy$(OBJSUFFICS) srvpop3p$(OBJSUFFICS) srvsmtpp$(OBJSUFFICS) srvftppr$(OBJSUFFICS) srvsocks$(OBJSUFFICS) srvtcppm$(OBJSUFFICS) srvtlspr$(OBJSUFFICS) srvudppm$(OBJSUFFICS) sockmap$(OBJSUFFICS) sockgetchar$(OBJSUFFICS) common$(OBJSUFFICS) log$(OBJSUFFICS) 3proxy_crypt$(OBJSUFFICS) md5$(OBJSUFFICS) blake2$(OBJSUFFICS) md4$(OBJSUFFICS) base64$(OBJSUFFICS) ftp$(OBJSUFFICS) stringtable$(OBJSUFFICS) srvwebadmin$(OBJSUFFICS) srvdnspr$(OBJSUFFICS) plugins$(OBJSUFFICS) $(COMPATLIBS) $(LIBS)
|
$(LN) $(LNOUT)$(BUILDDIR)3proxy$(EXESUFFICS) $(LDFLAGS) $(VERFILE) 3proxy$(OBJSUFFICS) mainfunc$(OBJSUFFICS) auth$(OBJSUFFICS) acl$(OBJSUFFICS) limiter$(OBJSUFFICS) redirect$(OBJSUFFICS) authradius$(OBJSUFFICS) hash$(OBJSUFFICS) hashtables$(OBJSUFFICS) resolve$(OBJSUFFICS) sql$(OBJSUFFICS) conf$(OBJSUFFICS) datatypes$(OBJSUFFICS) srvauto$(OBJSUFFICS) srvproxy$(OBJSUFFICS) srvpop3p$(OBJSUFFICS) srvsmtpp$(OBJSUFFICS) srvftppr$(OBJSUFFICS) srvsocks$(OBJSUFFICS) srvtcppm$(OBJSUFFICS) srvtlspr$(OBJSUFFICS) srvudppm$(OBJSUFFICS) sockmap$(OBJSUFFICS) sockgetchar$(OBJSUFFICS) common$(OBJSUFFICS) log$(OBJSUFFICS) 3proxy_crypt$(OBJSUFFICS) md5$(OBJSUFFICS) blake2$(OBJSUFFICS) md4$(OBJSUFFICS) base64$(OBJSUFFICS) ftp$(OBJSUFFICS) stringtable$(OBJSUFFICS) srvwebadmin$(OBJSUFFICS) srvdnspr$(OBJSUFFICS) plugins$(OBJSUFFICS) $(COMPATLIBS) $(LIBS)
|
||||||
|
|
||||||
|
|||||||
12
src/auth.c
12
src/auth.c
@ -20,13 +20,13 @@ int alwaysauth(struct clientparam * param){
|
|||||||
res = doconnect(param);
|
res = doconnect(param);
|
||||||
if(!res){
|
if(!res){
|
||||||
if(conf.bandlimfunc && (conf.bandlimiter||conf.bandlimiterout)){
|
if(conf.bandlimfunc && (conf.bandlimiter||conf.bandlimiterout)){
|
||||||
pthread_mutex_lock(&bandlim_mutex);
|
_3proxy_mutex_lock(&bandlim_mutex);
|
||||||
initbandlims(param);
|
initbandlims(param);
|
||||||
pthread_mutex_unlock(&bandlim_mutex);
|
_3proxy_mutex_unlock(&bandlim_mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(conf.trafcountfunc && conf.trafcounter) {
|
if(conf.trafcountfunc && conf.trafcounter) {
|
||||||
pthread_mutex_lock(&tc_mutex);
|
_3proxy_mutex_lock(&tc_mutex);
|
||||||
for(tc = conf.trafcounter; tc; tc = tc->next) {
|
for(tc = conf.trafcounter; tc; tc = tc->next) {
|
||||||
if(tc->disabled) continue;
|
if(tc->disabled) continue;
|
||||||
if(ACLmatches(tc->ace, param)){
|
if(ACLmatches(tc->ace, param)){
|
||||||
@ -40,7 +40,7 @@ int alwaysauth(struct clientparam * param){
|
|||||||
if(tc->ace->action != COUNTALL) continue;
|
if(tc->ace->action != COUNTALL) continue;
|
||||||
}
|
}
|
||||||
if(tc->traflim64 <= tc->traf64) {
|
if(tc->traflim64 <= tc->traf64) {
|
||||||
pthread_mutex_unlock(&tc_mutex);
|
_3proxy_mutex_unlock(&tc_mutex);
|
||||||
return 10;
|
return 10;
|
||||||
}
|
}
|
||||||
param->trafcountfunc = conf.trafcountfunc;
|
param->trafcountfunc = conf.trafcountfunc;
|
||||||
@ -55,14 +55,14 @@ int alwaysauth(struct clientparam * param){
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if(tc->traflim64 <= tc->traf64) {
|
if(tc->traflim64 <= tc->traf64) {
|
||||||
pthread_mutex_unlock(&tc_mutex);
|
_3proxy_mutex_unlock(&tc_mutex);
|
||||||
return 10;
|
return 10;
|
||||||
}
|
}
|
||||||
param->trafcountfunc = conf.trafcountfunc;
|
param->trafcountfunc = conf.trafcountfunc;
|
||||||
param->maxtrafout64 = tc->traflim64 - tc->traf64;
|
param->maxtrafout64 = tc->traflim64 - tc->traf64;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pthread_mutex_unlock(&tc_mutex);
|
_3proxy_mutex_unlock(&tc_mutex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
|
|||||||
@ -166,7 +166,7 @@ static int ntry = 0;
|
|||||||
int nradservers = 0;
|
int nradservers = 0;
|
||||||
char radiussecret[64]="";
|
char radiussecret[64]="";
|
||||||
|
|
||||||
pthread_mutex_t rad_mutex;
|
_3proxy_mutex_t rad_mutex;
|
||||||
|
|
||||||
void md5_calc(unsigned char *output, unsigned char *input,
|
void md5_calc(unsigned char *output, unsigned char *input,
|
||||||
unsigned int inputlen);
|
unsigned int inputlen);
|
||||||
@ -327,11 +327,11 @@ int radsend(struct clientparam * param, int auth, int stop){
|
|||||||
memset(&packet, 0, sizeof(packet));
|
memset(&packet, 0, sizeof(packet));
|
||||||
|
|
||||||
|
|
||||||
pthread_mutex_lock(&rad_mutex);
|
_3proxy_mutex_lock(&rad_mutex);
|
||||||
if(auth)random_vector(packet.vector, param);
|
if(auth)random_vector(packet.vector, param);
|
||||||
|
|
||||||
id = ((ntry++) & 0xff);
|
id = ((ntry++) & 0xff);
|
||||||
pthread_mutex_unlock(&rad_mutex);
|
_3proxy_mutex_unlock(&rad_mutex);
|
||||||
|
|
||||||
packet.code = auth?PW_AUTHENTICATION_REQUEST:PW_ACCOUNTING_REQUEST;
|
packet.code = auth?PW_AUTHENTICATION_REQUEST:PW_ACCOUNTING_REQUEST;
|
||||||
packet.id=id;
|
packet.id=id;
|
||||||
|
|||||||
43
src/common.c
43
src/common.c
@ -38,35 +38,6 @@ int randomizer = 1;
|
|||||||
|
|
||||||
unsigned char **stringtable = NULL;
|
unsigned char **stringtable = NULL;
|
||||||
|
|
||||||
#ifdef WITH_LINUX_FUTEX
|
|
||||||
int sys_futex(void *addr1, int op, int val1, struct timespec *timeout, void *addr2, int val3)
|
|
||||||
{
|
|
||||||
return syscall(SYS_futex, addr1, op, val1, timeout, addr2, val3);
|
|
||||||
}
|
|
||||||
int mutex_lock(int *val)
|
|
||||||
{
|
|
||||||
int c;
|
|
||||||
if ((c = __sync_val_compare_and_swap(val, 0, 1)) != 0)
|
|
||||||
do {
|
|
||||||
if(c == 2 || __sync_val_compare_and_swap(val, 1, 2) != 0)
|
|
||||||
sys_futex(val, FUTEX_WAIT_PRIVATE, 2, NULL, NULL, 0);
|
|
||||||
} while ((c = __sync_val_compare_and_swap(val, 0, 2)) != 0);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int mutex_unlock(int *val)
|
|
||||||
{
|
|
||||||
if(__sync_fetch_and_sub (val, 1) != 1){
|
|
||||||
*val = 0;
|
|
||||||
sys_futex(val, FUTEX_WAKE_PRIVATE, 1, NULL, NULL, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef WITH_UN
|
#ifdef WITH_UN
|
||||||
void make_un(const unsigned char *path, struct sockaddr_un * sun){
|
void make_un(const unsigned char *path, struct sockaddr_un * sun){
|
||||||
memset(sun, 0, sizeof(*sun));
|
memset(sun, 0, sizeof(*sun));
|
||||||
@ -144,7 +115,11 @@ int timeouts[12] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct extparam conf = {
|
struct extparam conf = {
|
||||||
.threadinit = {0, 0},
|
#ifdef _WIN32
|
||||||
|
.threadinit = NULL,
|
||||||
|
#else
|
||||||
|
.threadinit = 0,
|
||||||
|
#endif
|
||||||
.timeouts = timeouts,
|
.timeouts = timeouts,
|
||||||
.acl = NULL,
|
.acl = NULL,
|
||||||
.conffile = NULL,
|
.conffile = NULL,
|
||||||
@ -687,7 +662,7 @@ int scanaddr(const unsigned char *s, uint32_t * ip, uint32_t * mask) {
|
|||||||
|
|
||||||
RESOLVFUNC resolvfunc = NULL;
|
RESOLVFUNC resolvfunc = NULL;
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
pthread_mutex_t gethostbyname_mutex;
|
_3proxy_mutex_t gethostbyname_mutex;
|
||||||
int ghbn_init = 0;
|
int ghbn_init = 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -743,10 +718,10 @@ uint32_t getip(unsigned char *name){
|
|||||||
#ifndef NOSTDRESOLVE
|
#ifndef NOSTDRESOLVE
|
||||||
#if !defined(_WIN32) && !defined(GETHOSTBYNAME_R)
|
#if !defined(_WIN32) && !defined(GETHOSTBYNAME_R)
|
||||||
if(!ghbn_init){
|
if(!ghbn_init){
|
||||||
pthread_mutex_init(&gethostbyname_mutex, NULL);
|
_3proxy_mutex_init(&gethostbyname_mutex);
|
||||||
ghbn_init++;
|
ghbn_init++;
|
||||||
}
|
}
|
||||||
pthread_mutex_lock(&gethostbyname_mutex);
|
_3proxy_mutex_lock(&gethostbyname_mutex);
|
||||||
#endif
|
#endif
|
||||||
hp=gethostbyname((char *)name);
|
hp=gethostbyname((char *)name);
|
||||||
if (!hp && conf.demanddialprog) {
|
if (!hp && conf.demanddialprog) {
|
||||||
@ -755,7 +730,7 @@ uint32_t getip(unsigned char *name){
|
|||||||
}
|
}
|
||||||
retval = hp?*(uint32_t *)hp->h_addr:0;
|
retval = hp?*(uint32_t *)hp->h_addr:0;
|
||||||
#if !defined(_WIN32) && !defined(GETHOSTBYNAME_R)
|
#if !defined(_WIN32) && !defined(GETHOSTBYNAME_R)
|
||||||
pthread_mutex_unlock(&gethostbyname_mutex);
|
_3proxy_mutex_unlock(&gethostbyname_mutex);
|
||||||
#endif
|
#endif
|
||||||
#ifdef GETHOSTBYNAME_R
|
#ifdef GETHOSTBYNAME_R
|
||||||
#undef gethostbyname
|
#undef gethostbyname
|
||||||
|
|||||||
51
src/conf.c
51
src/conf.c
@ -20,10 +20,10 @@
|
|||||||
#define DEFAULTCONFIG conf.stringtable[25]
|
#define DEFAULTCONFIG conf.stringtable[25]
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
pthread_mutex_t bandlim_mutex;
|
_3proxy_mutex_t bandlim_mutex;
|
||||||
pthread_mutex_t connlim_mutex;
|
_3proxy_mutex_t connlim_mutex;
|
||||||
pthread_mutex_t tc_mutex;
|
_3proxy_mutex_t tc_mutex;
|
||||||
pthread_mutex_t config_mutex;
|
_3proxy_mutex_t config_mutex;
|
||||||
|
|
||||||
int haveerror = 0;
|
int haveerror = 0;
|
||||||
int linenum = 0;
|
int linenum = 0;
|
||||||
@ -151,9 +151,7 @@ int start_proxy_thread(struct child * chp){
|
|||||||
pthread_t thread;
|
pthread_t thread;
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
HANDLE h;
|
HANDLE h;
|
||||||
DWORD num;
|
|
||||||
#endif
|
#endif
|
||||||
char r[1];
|
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#ifndef _WINCE
|
#ifndef _WINCE
|
||||||
@ -166,16 +164,15 @@ int start_proxy_thread(struct child * chp){
|
|||||||
pthread_attr_init(&pa);
|
pthread_attr_init(&pa);
|
||||||
pthread_attr_setstacksize(&pa,PTHREAD_STACK_MIN + (32768+conf.stacksize));
|
pthread_attr_setstacksize(&pa,PTHREAD_STACK_MIN + (32768+conf.stacksize));
|
||||||
pthread_attr_setdetachstate(&pa,PTHREAD_CREATE_DETACHED);
|
pthread_attr_setdetachstate(&pa,PTHREAD_CREATE_DETACHED);
|
||||||
|
_3proxy_mutex_lock(&conf.threadinit);
|
||||||
pthread_create(&thread, &pa, startsrv, (void *)chp);
|
pthread_create(&thread, &pa, startsrv, (void *)chp);
|
||||||
pthread_attr_destroy(&pa);
|
pthread_attr_destroy(&pa);
|
||||||
#endif
|
#endif
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
ReadFile(conf.threadinit[0], r, 1, &num, NULL);
|
WaitForSingleObject(conf.threadinit, INFINITE);
|
||||||
#else
|
#else
|
||||||
while(read(conf.threadinit[0], r, 1) !=1) if(errno != EINTR) {
|
_3proxy_mutex_lock(&conf.threadinit);
|
||||||
fprintf(stderr, "pipe failed\n");
|
_3proxy_mutex_unlock(&conf.threadinit);
|
||||||
return 40;
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
if(haveerror) {
|
if(haveerror) {
|
||||||
fprintf(stderr, "Service not started on line: %d%s\n", linenum, haveerror == 2? ": insufficient memory":"");
|
fprintf(stderr, "Service not started on line: %d%s\n", linenum, haveerror == 2? ": insufficient memory":"");
|
||||||
@ -340,10 +337,10 @@ static int h_log(int argc, unsigned char ** argv){
|
|||||||
else if(*argv[1]=='&'){
|
else if(*argv[1]=='&'){
|
||||||
conf.logfunc = logsql;
|
conf.logfunc = logsql;
|
||||||
if(notchanged) return 0;
|
if(notchanged) return 0;
|
||||||
pthread_mutex_lock(&log_mutex);
|
_3proxy_mutex_lock(&log_mutex);
|
||||||
close_sql();
|
close_sql();
|
||||||
init_sql((char *)argv[1]+1);
|
init_sql((char *)argv[1]+1);
|
||||||
pthread_mutex_unlock(&log_mutex);
|
_3proxy_mutex_unlock(&log_mutex);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#ifndef NORADIUS
|
#ifndef NORADIUS
|
||||||
@ -1260,7 +1257,7 @@ static int h_ace(int argc, unsigned char **argv){
|
|||||||
sscanf((char *)argv[1], "%u", &ncl->rate);
|
sscanf((char *)argv[1], "%u", &ncl->rate);
|
||||||
sscanf((char *)argv[2], "%u", &ncl->period);
|
sscanf((char *)argv[2], "%u", &ncl->period);
|
||||||
}
|
}
|
||||||
pthread_mutex_lock(&connlim_mutex);
|
_3proxy_mutex_lock(&connlim_mutex);
|
||||||
if(!conf.connlimiter){
|
if(!conf.connlimiter){
|
||||||
conf.connlimiter = ncl;
|
conf.connlimiter = ncl;
|
||||||
}
|
}
|
||||||
@ -1270,7 +1267,7 @@ static int h_ace(int argc, unsigned char **argv){
|
|||||||
for(cli = conf.connlimiter; cli->next; cli = cli->next);
|
for(cli = conf.connlimiter; cli->next; cli = cli->next);
|
||||||
cli->next = ncl;
|
cli->next = ncl;
|
||||||
}
|
}
|
||||||
pthread_mutex_unlock(&connlim_mutex);
|
_3proxy_mutex_unlock(&connlim_mutex);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case BANDLIM:
|
case BANDLIM:
|
||||||
@ -1292,7 +1289,7 @@ static int h_ace(int argc, unsigned char **argv){
|
|||||||
return(4);
|
return(4);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pthread_mutex_lock(&bandlim_mutex);
|
_3proxy_mutex_lock(&bandlim_mutex);
|
||||||
if(!strcmp((char *)argv[0], "bandlimin") || !strcmp((char *)argv[0], "nobandlimin")){
|
if(!strcmp((char *)argv[0], "bandlimin") || !strcmp((char *)argv[0], "nobandlimin")){
|
||||||
if(!conf.bandlimiter){
|
if(!conf.bandlimiter){
|
||||||
conf.bandlimiter = nbl;
|
conf.bandlimiter = nbl;
|
||||||
@ -1316,7 +1313,7 @@ static int h_ace(int argc, unsigned char **argv){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
conf.bandlimver++;
|
conf.bandlimver++;
|
||||||
pthread_mutex_unlock(&bandlim_mutex);
|
_3proxy_mutex_unlock(&bandlim_mutex);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case COUNTIN:
|
case COUNTIN:
|
||||||
@ -1368,7 +1365,7 @@ static int h_ace(int argc, unsigned char **argv){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pthread_mutex_lock(&tc_mutex);
|
_3proxy_mutex_lock(&tc_mutex);
|
||||||
if(!conf.trafcounter){
|
if(!conf.trafcounter){
|
||||||
conf.trafcounter = tl;
|
conf.trafcounter = tl;
|
||||||
}
|
}
|
||||||
@ -1378,7 +1375,7 @@ static int h_ace(int argc, unsigned char **argv){
|
|||||||
for(ntl = conf.trafcounter; ntl->next; ntl = ntl->next);
|
for(ntl = conf.trafcounter; ntl->next; ntl = ntl->next);
|
||||||
ntl->next = tl;
|
ntl->next = tl;
|
||||||
}
|
}
|
||||||
pthread_mutex_unlock(&tc_mutex);
|
_3proxy_mutex_unlock(&tc_mutex);
|
||||||
|
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
@ -1859,27 +1856,27 @@ void freeconf(struct extparam *confp){
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
pthread_mutex_lock(&tc_mutex);
|
_3proxy_mutex_lock(&tc_mutex);
|
||||||
confp->trafcountfunc = NULL;
|
confp->trafcountfunc = NULL;
|
||||||
tc = confp->trafcounter;
|
tc = confp->trafcounter;
|
||||||
confp->trafcounter = NULL;
|
confp->trafcounter = NULL;
|
||||||
counterd = confp->counterd;
|
counterd = confp->counterd;
|
||||||
confp->counterd = -1;
|
confp->counterd = -1;
|
||||||
confp->countertype = NONE;
|
confp->countertype = NONE;
|
||||||
pthread_mutex_unlock(&tc_mutex);
|
_3proxy_mutex_unlock(&tc_mutex);
|
||||||
|
|
||||||
pthread_mutex_lock(&bandlim_mutex);
|
_3proxy_mutex_lock(&bandlim_mutex);
|
||||||
bl = confp->bandlimiter;
|
bl = confp->bandlimiter;
|
||||||
blout = confp->bandlimiterout;
|
blout = confp->bandlimiterout;
|
||||||
confp->bandlimiter = NULL;
|
confp->bandlimiter = NULL;
|
||||||
confp->bandlimiterout = NULL;
|
confp->bandlimiterout = NULL;
|
||||||
confp->bandlimfunc = NULL;
|
confp->bandlimfunc = NULL;
|
||||||
confp->bandlimver++;
|
confp->bandlimver++;
|
||||||
pthread_mutex_unlock(&bandlim_mutex);
|
_3proxy_mutex_unlock(&bandlim_mutex);
|
||||||
pthread_mutex_lock(&connlim_mutex);
|
_3proxy_mutex_lock(&connlim_mutex);
|
||||||
cl = confp->connlimiter;
|
cl = confp->connlimiter;
|
||||||
confp->connlimiter = NULL;
|
confp->connlimiter = NULL;
|
||||||
pthread_mutex_unlock(&connlim_mutex);
|
_3proxy_mutex_unlock(&connlim_mutex);
|
||||||
|
|
||||||
destroyhashtable(&pw_table);
|
destroyhashtable(&pw_table);
|
||||||
destroyhashtable(&pwnt_table);
|
destroyhashtable(&pwnt_table);
|
||||||
@ -1952,7 +1949,7 @@ int reload (void){
|
|||||||
FILE *fp;
|
FILE *fp;
|
||||||
int error = -2;
|
int error = -2;
|
||||||
|
|
||||||
pthread_mutex_lock(&config_mutex);
|
_3proxy_mutex_lock(&config_mutex);
|
||||||
conf.paused++;
|
conf.paused++;
|
||||||
freeconf(&conf);
|
freeconf(&conf);
|
||||||
conf.paused++;
|
conf.paused++;
|
||||||
@ -1966,6 +1963,6 @@ int reload (void){
|
|||||||
}
|
}
|
||||||
if(!writable)fclose(fp);
|
if(!writable)fclose(fp);
|
||||||
}
|
}
|
||||||
pthread_mutex_unlock(&config_mutex);
|
_3proxy_mutex_unlock(&config_mutex);
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|||||||
167
src/hash.c
167
src/hash.c
@ -1,5 +1,4 @@
|
|||||||
#include "proxy.h"
|
#include "proxy.h"
|
||||||
#include "libs/blake2.h"
|
|
||||||
|
|
||||||
struct hashentry {
|
struct hashentry {
|
||||||
time_t expires;
|
time_t expires;
|
||||||
@ -13,7 +12,7 @@ static uint32_t hashindex(unsigned tablesize, const uint8_t* hash){
|
|||||||
|
|
||||||
|
|
||||||
void destroyhashtable(struct hashtable *ht){
|
void destroyhashtable(struct hashtable *ht){
|
||||||
pthread_mutex_lock(&ht->hash_mutex);
|
_3proxy_mutex_lock(&ht->hash_mutex);
|
||||||
if(ht->ihashtable){
|
if(ht->ihashtable){
|
||||||
myfree(ht->ihashtable);
|
myfree(ht->ihashtable);
|
||||||
ht->ihashtable = NULL;
|
ht->ihashtable = NULL;
|
||||||
@ -29,8 +28,8 @@ void destroyhashtable(struct hashtable *ht){
|
|||||||
ht->poolsize = 0;
|
ht->poolsize = 0;
|
||||||
ht->tablesize = 0;
|
ht->tablesize = 0;
|
||||||
ht->ihashempty = 0;
|
ht->ihashempty = 0;
|
||||||
pthread_mutex_unlock(&ht->hash_mutex);
|
_3proxy_mutex_unlock(&ht->hash_mutex);
|
||||||
pthread_mutex_destroy(&ht->hash_mutex);
|
_3proxy_mutex_destroy(&ht->hash_mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
#define hvalue(ht,I) ((struct hashentry *)(ht->hashvalues + (I-1)*(sizeof(struct hashentry) + ht->recsize - 4)))
|
#define hvalue(ht,I) ((struct hashentry *)(ht->hashvalues + (I-1)*(sizeof(struct hashentry) + ht->recsize - 4)))
|
||||||
@ -54,7 +53,7 @@ int inithashtable(struct hashtable *ht, unsigned tablesize, unsigned poolsize, u
|
|||||||
|
|
||||||
if(tablesize < 2 || poolsize < tablesize || growlimit < poolsize) return 1;
|
if(tablesize < 2 || poolsize < tablesize || growlimit < poolsize) return 1;
|
||||||
if(ht->ihashtable){
|
if(ht->ihashtable){
|
||||||
pthread_mutex_lock(&ht->hash_mutex);
|
_3proxy_mutex_lock(&ht->hash_mutex);
|
||||||
if(ht->ihashtable){
|
if(ht->ihashtable){
|
||||||
myfree(ht->ihashtable);
|
myfree(ht->ihashtable);
|
||||||
ht->ihashtable = NULL;
|
ht->ihashtable = NULL;
|
||||||
@ -71,18 +70,18 @@ int inithashtable(struct hashtable *ht, unsigned tablesize, unsigned poolsize, u
|
|||||||
ht->tablesize = 0;
|
ht->tablesize = 0;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
pthread_mutex_init(&ht->hash_mutex, NULL);
|
_3proxy_mutex_init(&ht->hash_mutex);
|
||||||
pthread_mutex_lock(&ht->hash_mutex);
|
_3proxy_mutex_lock(&ht->hash_mutex);
|
||||||
}
|
}
|
||||||
if(!(ht->ihashtable = myalloc(tablesize * sizeof(uint32_t)))
|
if(!(ht->ihashtable = myalloc(tablesize * sizeof(uint32_t)))
|
||||||
|| !(ht->hashvalues = myalloc(poolsize * (sizeof(struct hashentry) + (ht->recsize-4))))
|
|| !(ht->hashvalues = myalloc(poolsize * (sizeof(struct hashentry) + ht->recsize - 4)))
|
||||||
|| !(ht->hashhashvalues = myalloc(poolsize * ht->hash_size))
|
|| !(ht->hashhashvalues = myalloc(poolsize * ht->hash_size))
|
||||||
){
|
){
|
||||||
myfree(ht->ihashtable);
|
myfree(ht->ihashtable);
|
||||||
ht->ihashtable = NULL;
|
ht->ihashtable = NULL;
|
||||||
myfree(ht->hashvalues);
|
myfree(ht->hashvalues);
|
||||||
ht->hashvalues = NULL;
|
ht->hashvalues = NULL;
|
||||||
pthread_mutex_unlock(&ht->hash_mutex);
|
_3proxy_mutex_unlock(&ht->hash_mutex);
|
||||||
return 3;
|
return 3;
|
||||||
}
|
}
|
||||||
ht->poolsize = poolsize;
|
ht->poolsize = poolsize;
|
||||||
@ -95,7 +94,7 @@ int inithashtable(struct hashtable *ht, unsigned tablesize, unsigned poolsize, u
|
|||||||
hvalue(ht,i)->inext = i+1;
|
hvalue(ht,i)->inext = i+1;
|
||||||
}
|
}
|
||||||
ht->ihashempty = 1;
|
ht->ihashempty = 1;
|
||||||
pthread_mutex_unlock(&ht->hash_mutex);
|
_3proxy_mutex_unlock(&ht->hash_mutex);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -180,7 +179,7 @@ void hashadd(struct hashtable *ht, void* name, void* value, time_t expires){
|
|||||||
}
|
}
|
||||||
|
|
||||||
ht->index2hash_add(ht, name, hash);
|
ht->index2hash_add(ht, name, hash);
|
||||||
pthread_mutex_lock(&ht->hash_mutex);
|
_3proxy_mutex_lock(&ht->hash_mutex);
|
||||||
index = hashindex(ht->tablesize, hash);
|
index = hashindex(ht->tablesize, hash);
|
||||||
|
|
||||||
for(hep = ht->ihashtable + index; (he = *hep)!=0; ){
|
for(hep = ht->ihashtable + index; (he = *hep)!=0; ){
|
||||||
@ -215,7 +214,7 @@ void hashadd(struct hashtable *ht, void* name, void* value, time_t expires){
|
|||||||
hvalue(ht,hen)->expires = expires;
|
hvalue(ht,hen)->expires = expires;
|
||||||
}
|
}
|
||||||
|
|
||||||
pthread_mutex_unlock(&ht->hash_mutex);
|
_3proxy_mutex_unlock(&ht->hash_mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
int hashresolv(struct hashtable *ht, void* name, void* value, uint32_t *ttl){
|
int hashresolv(struct hashtable *ht, void* name, void* value, uint32_t *ttl){
|
||||||
@ -228,7 +227,7 @@ int hashresolv(struct hashtable *ht, void* name, void* value, uint32_t *ttl){
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
ht->index2hash_search(ht,name, hash);
|
ht->index2hash_search(ht,name, hash);
|
||||||
pthread_mutex_lock(&ht->hash_mutex);
|
_3proxy_mutex_lock(&ht->hash_mutex);
|
||||||
index = hashindex(ht->tablesize, hash);
|
index = hashindex(ht->tablesize, hash);
|
||||||
for(hep = ht->ihashtable + index; (he = *hep)!=0; ){
|
for(hep = ht->ihashtable + index; (he = *hep)!=0; ){
|
||||||
if(hvalue(ht, he)->expires < conf.time) {
|
if(hvalue(ht, he)->expires < conf.time) {
|
||||||
@ -240,12 +239,12 @@ int hashresolv(struct hashtable *ht, void* name, void* value, uint32_t *ttl){
|
|||||||
else if(!memcmp(hash, hhash(ht,he), ht->hash_size)){
|
else if(!memcmp(hash, hhash(ht,he), ht->hash_size)){
|
||||||
if(ttl) *ttl = (uint32_t)(hvalue(ht,he)->expires - conf.time);
|
if(ttl) *ttl = (uint32_t)(hvalue(ht,he)->expires - conf.time);
|
||||||
memcpy(value, hvalue(ht,he)->value, ht->recsize);
|
memcpy(value, hvalue(ht,he)->value, ht->recsize);
|
||||||
pthread_mutex_unlock(&ht->hash_mutex);
|
_3proxy_mutex_unlock(&ht->hash_mutex);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
else hep=&(hvalue(ht,he)->inext);
|
else hep=&(hvalue(ht,he)->inext);
|
||||||
}
|
}
|
||||||
pthread_mutex_unlock(&ht->hash_mutex);
|
_3proxy_mutex_unlock(&ht->hash_mutex);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -259,7 +258,7 @@ void hashdelete(struct hashtable *ht, void *name){
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ht->index2hash_search(ht, name, hash);
|
ht->index2hash_search(ht, name, hash);
|
||||||
pthread_mutex_lock(&ht->hash_mutex);
|
_3proxy_mutex_lock(&ht->hash_mutex);
|
||||||
index = hashindex(ht->tablesize, hash);
|
index = hashindex(ht->tablesize, hash);
|
||||||
for(hep = ht->ihashtable + index; (he = *hep) != 0; ){
|
for(hep = ht->ihashtable + index; (he = *hep) != 0; ){
|
||||||
if((hvalue(ht, he)->expires && hvalue(ht, he)->expires < conf.time) || !memcmp(hash, hhash(ht, he), ht->hash_size)) {
|
if((hvalue(ht, he)->expires && hvalue(ht, he)->expires < conf.time) || !memcmp(hash, hhash(ht, he), ht->hash_size)) {
|
||||||
@ -270,102 +269,48 @@ void hashdelete(struct hashtable *ht, void *name){
|
|||||||
}
|
}
|
||||||
else hep = &(hvalue(ht, he)->inext);
|
else hep = &(hvalue(ht, he)->inext);
|
||||||
}
|
}
|
||||||
pthread_mutex_unlock(&ht->hash_mutex);
|
_3proxy_mutex_unlock(&ht->hash_mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void char_index2hash(const struct hashtable *ht, void *index, uint8_t *hash){
|
#define MURMUR_C1 0xcc9e2d51u
|
||||||
char* name = index;
|
#define MURMUR_C2 0x1b873593u
|
||||||
|
|
||||||
blake2b(hash, ht->hash_size, index, strlen((const char*)index), NULL, 0);
|
uint32_t murmurhash3(const void *key, int len, uint32_t seed) {
|
||||||
|
const uint8_t *data = (const uint8_t *)key;
|
||||||
|
const int nblocks = len / 4;
|
||||||
|
uint32_t h = seed;
|
||||||
|
int i;
|
||||||
|
const uint32_t *blocks = (const uint32_t *)(data);
|
||||||
|
const uint8_t *tail = data + nblocks * 4;
|
||||||
|
uint32_t k;
|
||||||
|
|
||||||
|
for (i = 0; i < nblocks; i++) {
|
||||||
|
memcpy(&k, blocks + i, sizeof(k));
|
||||||
|
k *= MURMUR_C1;
|
||||||
|
k = (k << 15) | (k >> 17);
|
||||||
|
k *= MURMUR_C2;
|
||||||
|
h ^= k;
|
||||||
|
h = (h << 13) | (h >> 19);
|
||||||
|
h = h * 5 + 0xe6546b64u;
|
||||||
|
}
|
||||||
|
|
||||||
|
k = 0;
|
||||||
|
switch (len & 3) {
|
||||||
|
case 3: k ^= (uint32_t)tail[2] << 16; /* fall through */
|
||||||
|
case 2: k ^= (uint32_t)tail[1] << 8; /* fall through */
|
||||||
|
case 1: k ^= (uint32_t)tail[0];
|
||||||
|
k *= MURMUR_C1;
|
||||||
|
k = (k << 15) | (k >> 17);
|
||||||
|
k *= MURMUR_C2;
|
||||||
|
h ^= k;
|
||||||
|
}
|
||||||
|
|
||||||
|
h ^= (uint32_t)len;
|
||||||
|
h ^= h >> 16;
|
||||||
|
h *= 0x85ebca6bu;
|
||||||
|
h ^= h >> 13;
|
||||||
|
h *= 0xc2b2ae35u;
|
||||||
|
h ^= h >> 16;
|
||||||
|
|
||||||
|
return h;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void param2hash_add(const struct hashtable *ht, void *index, uint8_t *hash){
|
|
||||||
blake2b_state S;
|
|
||||||
struct clientparam *param = (struct clientparam *)index;
|
|
||||||
unsigned type = param->srv->authcachetype;
|
|
||||||
|
|
||||||
blake2b_init(&S, ht->hash_size);
|
|
||||||
if((type & 2) && param->username)blake2b_update(&S, param->username, strlen((const char *)param->username) + 1);
|
|
||||||
if((type & 4) && param->password)blake2b_update(&S, param->password, strlen((const char *)param->password) + 1);
|
|
||||||
if((type & 1) && !(type & 8))blake2b_update(&S, SAADDR(¶m->sincr), SAADDRLEN(¶m->sincr));
|
|
||||||
if((type & 16))blake2b_update(&S, ¶m->srv->acl, sizeof(param->srv->acl));
|
|
||||||
if((type & 64))blake2b_update(&S, SAADDR(¶m->req), SAADDRLEN(¶m->req));
|
|
||||||
if((type & 128))blake2b_update(&S, SAPORT(¶m->req), 2);
|
|
||||||
if((type & 256) && param->hostname)blake2b_update(&S, param->hostname, strlen((const char *)param->hostname) + 1);
|
|
||||||
if((type & 512))blake2b_update(&S, ¶m->operation, sizeof(param->operation));
|
|
||||||
if((type & 1024))blake2b_update(&S, SAADDR(¶m->srv->intsa), SAADDRLEN(¶m->srv->intsa));
|
|
||||||
if((type & 2048))blake2b_update(&S, SAPORT(¶m->srv->intsa), 2);
|
|
||||||
blake2b_final(&S, hash, ht->hash_size);
|
|
||||||
memcpy(param->hash, hash, ht->hash_size);
|
|
||||||
}
|
|
||||||
|
|
||||||
void param2hash_search(const struct hashtable *ht, void *index, uint8_t *hash){
|
|
||||||
struct clientparam *param = (struct clientparam *)index;
|
|
||||||
|
|
||||||
memcpy(hash, param->hash, ht->hash_size);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void user2hash_search(const struct hashtable *ht, void *index, uint8_t *hash){
|
|
||||||
struct clientparam *param = (struct clientparam *)index;
|
|
||||||
blake2b(hash, ht->hash_size, param->username, strlen((const char *)param->username), NULL, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void udpparam2hash(const struct hashtable *ht, void *index, uint8_t *hash){
|
|
||||||
struct clientparam *param = (struct clientparam *)index;
|
|
||||||
blake2b_state S;
|
|
||||||
blake2b_init(&S, ht->hash_size);
|
|
||||||
blake2b_update(&S, SAADDR(¶m->srv->intsa), SAADDRLEN(¶m->srv->intsa));
|
|
||||||
blake2b_update(&S, SAPORT(¶m->srv->intsa), 2);
|
|
||||||
blake2b_update(&S, SAADDR(¶m->sincr), SAADDRLEN(¶m->sincr));
|
|
||||||
blake2b_update(&S, SAPORT(¶m->sincr), 2);
|
|
||||||
blake2b_final(&S, hash, ht->hash_size);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void pw2hash_add(const struct hashtable *ht, void *index, uint8_t *hash){
|
|
||||||
char ** pw = (char **)index;
|
|
||||||
blake2b_state S;
|
|
||||||
|
|
||||||
blake2b_init(&S, ht->hash_size);
|
|
||||||
if(pw[0])blake2b_update(&S, pw[0], strlen(pw[0]) + 1);
|
|
||||||
if(pw[1])blake2b_update(&S, pw[1], strlen(pw[1]) + 1);
|
|
||||||
blake2b_final(&S, hash, ht->hash_size);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static void pw2hash_search(const struct hashtable *ht, void *index, uint8_t *hash){
|
|
||||||
struct clientparam *param = (struct clientparam *)index;
|
|
||||||
|
|
||||||
char *pw[2] = {(char *)param->username, (char *)param->password};
|
|
||||||
|
|
||||||
pw2hash_add(ht, pw, hash);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void pwnt2hash_add(const struct hashtable *ht, void *index, uint8_t *hash){
|
|
||||||
char ** pw = (char **)index;
|
|
||||||
blake2b_state S;
|
|
||||||
|
|
||||||
blake2b_init(&S, ht->hash_size);
|
|
||||||
if(pw[0])blake2b_update(&S, pw[0], strlen(pw[0]) + 1);
|
|
||||||
if(pw[1])blake2b_update(&S, pw[1], strlen(pw[1]) + 1);
|
|
||||||
blake2b_final(&S, hash, ht->hash_size);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static void pwnt2hash_search(const struct hashtable *ht, void *index, uint8_t *hash){
|
|
||||||
struct clientparam *param = (struct clientparam *)index;
|
|
||||||
unsigned char pass[40];
|
|
||||||
char *pw[2] = {(char *)param->username, (char *)pass};
|
|
||||||
|
|
||||||
ntpwdhash(pass, param->password, 1);
|
|
||||||
pwnt2hash_add(ht, pw, hash);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
struct hashtable dns_table = {char_index2hash, char_index2hash, 4, 12};
|
|
||||||
struct hashtable dns6_table = {char_index2hash, char_index2hash, 16, 12};
|
|
||||||
struct hashtable auth_table = {param2hash_add, param2hash_search, sizeof(struct authcache), 12};
|
|
||||||
struct hashtable pw_table = {pw2hash_add, pw2hash_search, 0, 12};
|
|
||||||
struct hashtable pwnt_table = {pwnt2hash_add, pwnt2hash_search, 0, 12};
|
|
||||||
struct hashtable pwcr_table = {char_index2hash, user2hash_search, 64, 12};
|
|
||||||
struct hashtable udp_table = {udpparam2hash, udpparam2hash, sizeof(struct clientparam *), 12};
|
|
||||||
|
|||||||
99
src/hashtables.c
Normal file
99
src/hashtables.c
Normal file
@ -0,0 +1,99 @@
|
|||||||
|
#include "proxy.h"
|
||||||
|
#include "libs/blake2.h"
|
||||||
|
|
||||||
|
|
||||||
|
static void char_index2hash(const struct hashtable *ht, void *index, uint8_t *hash){
|
||||||
|
char* name = index;
|
||||||
|
|
||||||
|
blake2b(hash, ht->hash_size, index, strlen((const char*)index), NULL, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void param2hash_add(const struct hashtable *ht, void *index, uint8_t *hash){
|
||||||
|
blake2b_state S;
|
||||||
|
struct clientparam *param = (struct clientparam *)index;
|
||||||
|
unsigned type = param->srv->authcachetype;
|
||||||
|
|
||||||
|
blake2b_init(&S, ht->hash_size);
|
||||||
|
if((type & 2) && param->username)blake2b_update(&S, param->username, strlen((const char *)param->username) + 1);
|
||||||
|
if((type & 4) && param->password)blake2b_update(&S, param->password, strlen((const char *)param->password) + 1);
|
||||||
|
if((type & 1) && !(type & 8))blake2b_update(&S, SAADDR(¶m->sincr), SAADDRLEN(¶m->sincr));
|
||||||
|
if((type & 16))blake2b_update(&S, ¶m->srv->acl, sizeof(param->srv->acl));
|
||||||
|
if((type & 64))blake2b_update(&S, SAADDR(¶m->req), SAADDRLEN(¶m->req));
|
||||||
|
if((type & 128))blake2b_update(&S, SAPORT(¶m->req), 2);
|
||||||
|
if((type & 256) && param->hostname)blake2b_update(&S, param->hostname, strlen((const char *)param->hostname) + 1);
|
||||||
|
if((type & 512))blake2b_update(&S, ¶m->operation, sizeof(param->operation));
|
||||||
|
if((type & 1024))blake2b_update(&S, SAADDR(¶m->srv->intsa), SAADDRLEN(¶m->srv->intsa));
|
||||||
|
if((type & 2048))blake2b_update(&S, SAPORT(¶m->srv->intsa), 2);
|
||||||
|
blake2b_final(&S, hash, ht->hash_size);
|
||||||
|
memcpy(param->hash, hash, ht->hash_size);
|
||||||
|
}
|
||||||
|
|
||||||
|
void param2hash_search(const struct hashtable *ht, void *index, uint8_t *hash){
|
||||||
|
struct clientparam *param = (struct clientparam *)index;
|
||||||
|
|
||||||
|
memcpy(hash, param->hash, ht->hash_size);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void user2hash_search(const struct hashtable *ht, void *index, uint8_t *hash){
|
||||||
|
struct clientparam *param = (struct clientparam *)index;
|
||||||
|
blake2b(hash, ht->hash_size, param->username, strlen((const char *)param->username), NULL, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void udpparam2hash(const struct hashtable *ht, void *index, uint8_t *hash){
|
||||||
|
struct clientparam *param = (struct clientparam *)index;
|
||||||
|
blake2b_state S;
|
||||||
|
blake2b_init(&S, ht->hash_size);
|
||||||
|
blake2b_update(&S, SAADDR(¶m->srv->intsa), SAADDRLEN(¶m->srv->intsa));
|
||||||
|
blake2b_update(&S, SAPORT(¶m->srv->intsa), 2);
|
||||||
|
blake2b_update(&S, SAADDR(¶m->sincr), SAADDRLEN(¶m->sincr));
|
||||||
|
blake2b_update(&S, SAPORT(¶m->sincr), 2);
|
||||||
|
blake2b_final(&S, hash, ht->hash_size);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void pw2hash_add(const struct hashtable *ht, void *index, uint8_t *hash){
|
||||||
|
char ** pw = (char **)index;
|
||||||
|
blake2b_state S;
|
||||||
|
|
||||||
|
blake2b_init(&S, ht->hash_size);
|
||||||
|
if(pw[0])blake2b_update(&S, pw[0], strlen(pw[0]) + 1);
|
||||||
|
if(pw[1])blake2b_update(&S, pw[1], strlen(pw[1]) + 1);
|
||||||
|
blake2b_final(&S, hash, ht->hash_size);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void pw2hash_search(const struct hashtable *ht, void *index, uint8_t *hash){
|
||||||
|
struct clientparam *param = (struct clientparam *)index;
|
||||||
|
|
||||||
|
char *pw[2] = {(char *)param->username, (char *)param->password};
|
||||||
|
|
||||||
|
pw2hash_add(ht, pw, hash);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void pwnt2hash_add(const struct hashtable *ht, void *index, uint8_t *hash){
|
||||||
|
char ** pw = (char **)index;
|
||||||
|
blake2b_state S;
|
||||||
|
|
||||||
|
blake2b_init(&S, ht->hash_size);
|
||||||
|
if(pw[0])blake2b_update(&S, pw[0], strlen(pw[0]) + 1);
|
||||||
|
if(pw[1])blake2b_update(&S, pw[1], strlen(pw[1]) + 1);
|
||||||
|
blake2b_final(&S, hash, ht->hash_size);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void pwnt2hash_search(const struct hashtable *ht, void *index, uint8_t *hash){
|
||||||
|
struct clientparam *param = (struct clientparam *)index;
|
||||||
|
unsigned char pass[40];
|
||||||
|
char *pw[2] = {(char *)param->username, (char *)pass};
|
||||||
|
|
||||||
|
ntpwdhash(pass, param->password, 1);
|
||||||
|
pwnt2hash_add(ht, pw, hash);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
struct hashtable dns_table = {char_index2hash, char_index2hash, 4, 12};
|
||||||
|
struct hashtable dns6_table = {char_index2hash, char_index2hash, 16, 12};
|
||||||
|
struct hashtable auth_table = {param2hash_add, param2hash_search, sizeof(struct authcache), 12};
|
||||||
|
struct hashtable pw_table = {pw2hash_add, pw2hash_search, 0, 12};
|
||||||
|
struct hashtable pwnt_table = {pwnt2hash_add, pwnt2hash_search, 0, 12};
|
||||||
|
struct hashtable pwcr_table = {char_index2hash, user2hash_search, 64, 12};
|
||||||
@ -15,7 +15,7 @@ int startconnlims (struct clientparam *param){
|
|||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
param->connlim = 1;
|
param->connlim = 1;
|
||||||
pthread_mutex_lock(&connlim_mutex);
|
_3proxy_mutex_lock(&connlim_mutex);
|
||||||
for(ce = conf.connlimiter; ce; ce = ce->next) {
|
for(ce = conf.connlimiter; ce; ce = ce->next) {
|
||||||
if(ACLmatches(ce->ace, param)){
|
if(ACLmatches(ce->ace, param)){
|
||||||
if(ce->ace->action == NOCONNLIM)break;
|
if(ce->ace->action == NOCONNLIM)break;
|
||||||
@ -51,14 +51,14 @@ int startconnlims (struct clientparam *param){
|
|||||||
}
|
}
|
||||||
param->connlim = 0;
|
param->connlim = 0;
|
||||||
}
|
}
|
||||||
pthread_mutex_unlock(&connlim_mutex);
|
_3proxy_mutex_unlock(&connlim_mutex);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
void stopconnlims (struct clientparam *param){
|
void stopconnlims (struct clientparam *param){
|
||||||
struct connlim * ce;
|
struct connlim * ce;
|
||||||
|
|
||||||
pthread_mutex_lock(&connlim_mutex);
|
_3proxy_mutex_lock(&connlim_mutex);
|
||||||
for(ce = conf.connlimiter; ce; ce = ce->next) {
|
for(ce = conf.connlimiter; ce; ce = ce->next) {
|
||||||
if(ACLmatches(ce->ace, param)){
|
if(ACLmatches(ce->ace, param)){
|
||||||
if(ce->ace->action == NOCONNLIM)break;
|
if(ce->ace->action == NOCONNLIM)break;
|
||||||
@ -68,7 +68,7 @@ void stopconnlims (struct clientparam *param){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pthread_mutex_unlock(&connlim_mutex);
|
_3proxy_mutex_unlock(&connlim_mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
void initbandlims (struct clientparam *param){
|
void initbandlims (struct clientparam *param){
|
||||||
@ -124,7 +124,7 @@ unsigned bandlimitfunc(struct clientparam *param, unsigned nbytesin, unsigned nb
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
if(!nbytesin && !nbytesout) return 0;
|
if(!nbytesin && !nbytesout) return 0;
|
||||||
pthread_mutex_lock(&bandlim_mutex);
|
_3proxy_mutex_lock(&bandlim_mutex);
|
||||||
if(param->bandlimver != conf.bandlimver){
|
if(param->bandlimver != conf.bandlimver){
|
||||||
initbandlims(param);
|
initbandlims(param);
|
||||||
param->bandlimver = conf.bandlimver;
|
param->bandlimver = conf.bandlimver;
|
||||||
@ -163,7 +163,7 @@ unsigned bandlimitfunc(struct clientparam *param, unsigned nbytesin, unsigned nb
|
|||||||
param->bandlimsout[i]->basetime = sec;
|
param->bandlimsout[i]->basetime = sec;
|
||||||
param->bandlimsout[i]->nexttime = msec + nsleeptime + ((nbytesout > 512)? ((nbytesout+32)/64)*((64*8*1000000)/param->bandlimsout[i]->rate) : ((nbytesout+1)* (8*1000000))/param->bandlimsout[i]->rate);
|
param->bandlimsout[i]->nexttime = msec + nsleeptime + ((nbytesout > 512)? ((nbytesout+32)/64)*((64*8*1000000)/param->bandlimsout[i]->rate) : ((nbytesout+1)* (8*1000000))/param->bandlimsout[i]->rate);
|
||||||
}
|
}
|
||||||
pthread_mutex_unlock(&bandlim_mutex);
|
_3proxy_mutex_unlock(&bandlim_mutex);
|
||||||
return sleeptime/1000;
|
return sleeptime/1000;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -171,7 +171,7 @@ void trafcountfunc(struct clientparam *param){
|
|||||||
struct trafcount * tc;
|
struct trafcount * tc;
|
||||||
int countout = 0;
|
int countout = 0;
|
||||||
|
|
||||||
pthread_mutex_lock(&tc_mutex);
|
_3proxy_mutex_lock(&tc_mutex);
|
||||||
for(tc = conf.trafcounter; tc; tc = tc->next) {
|
for(tc = conf.trafcounter; tc; tc = tc->next) {
|
||||||
if(ACLmatches(tc->ace, param)){
|
if(ACLmatches(tc->ace, param)){
|
||||||
|
|
||||||
@ -199,6 +199,6 @@ void trafcountfunc(struct clientparam *param){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pthread_mutex_unlock(&tc_mutex);
|
_3proxy_mutex_unlock(&tc_mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -10,7 +10,7 @@
|
|||||||
|
|
||||||
|
|
||||||
#include "proxy.h"
|
#include "proxy.h"
|
||||||
pthread_mutex_t log_mutex;
|
_3proxy_mutex_t log_mutex;
|
||||||
int havelog = 0;
|
int havelog = 0;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -45,7 +45,7 @@ extern "C" {
|
|||||||
|
|
||||||
static struct pluginlink * pl;
|
static struct pluginlink * pl;
|
||||||
|
|
||||||
static pthread_mutex_t file_mutex;
|
static _3proxy_mutex_t file_mutex;
|
||||||
|
|
||||||
unsigned long preview = 0;
|
unsigned long preview = 0;
|
||||||
|
|
||||||
@ -207,7 +207,7 @@ static void closefiles(struct fp_stream *fps){
|
|||||||
static int searchsocket(SOCKET s, struct fp_stream **pfps){
|
static int searchsocket(SOCKET s, struct fp_stream **pfps){
|
||||||
struct fp_stream *fps = NULL;
|
struct fp_stream *fps = NULL;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
pthread_mutex_lock(&file_mutex);
|
_3proxy_mutex_lock(&file_mutex);
|
||||||
for(fps = fp_streams; fps; fps = fps->next){
|
for(fps = fp_streams; fps; fps = fps->next){
|
||||||
if(fps->fpd.cp->clisock == s) {
|
if(fps->fpd.cp->clisock == s) {
|
||||||
ret = 1;
|
ret = 1;
|
||||||
@ -222,7 +222,7 @@ static int searchsocket(SOCKET s, struct fp_stream **pfps){
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pthread_mutex_unlock(&file_mutex);
|
_3proxy_mutex_unlock(&file_mutex);
|
||||||
*pfps = fps;
|
*pfps = fps;
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -235,7 +235,7 @@ static void freecallback(struct fp_stream * fps, struct fp_callback * fpc){
|
|||||||
|
|
||||||
static void removefps(struct fp_stream * fps){
|
static void removefps(struct fp_stream * fps){
|
||||||
if(!fp_streams) return;
|
if(!fp_streams) return;
|
||||||
pthread_mutex_lock(&file_mutex);
|
_3proxy_mutex_lock(&file_mutex);
|
||||||
if(fp_streams == fps)fp_streams = fps->next;
|
if(fp_streams == fps)fp_streams = fps->next;
|
||||||
else {
|
else {
|
||||||
struct fp_stream *fps2;
|
struct fp_stream *fps2;
|
||||||
@ -248,7 +248,7 @@ static void removefps(struct fp_stream * fps){
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
pthread_mutex_unlock(&file_mutex);
|
_3proxy_mutex_unlock(&file_mutex);
|
||||||
if(fps->callbacks){
|
if(fps->callbacks){
|
||||||
freecallback(fps, fps->callbacks);
|
freecallback(fps, fps->callbacks);
|
||||||
fps->callbacks = 0;
|
fps->callbacks = 0;
|
||||||
@ -754,7 +754,7 @@ static int fp_registercallback (int what, int max_size, int preview_size, struct
|
|||||||
fpc->max_size = max_size;
|
fpc->max_size = max_size;
|
||||||
fpc->data = data;
|
fpc->data = data;
|
||||||
fpc->callback = cb;
|
fpc->callback = cb;
|
||||||
pthread_mutex_lock(&file_mutex);
|
_3proxy_mutex_lock(&file_mutex);
|
||||||
fps = addfps(cp);
|
fps = addfps(cp);
|
||||||
if(fps){
|
if(fps){
|
||||||
fpc->next = fps->callbacks;
|
fpc->next = fps->callbacks;
|
||||||
@ -763,7 +763,7 @@ static int fp_registercallback (int what, int max_size, int preview_size, struct
|
|||||||
if(preview_size > fps->preview_size) fps->preview_size = preview_size;
|
if(preview_size > fps->preview_size) fps->preview_size = preview_size;
|
||||||
}
|
}
|
||||||
else free(fpc);
|
else free(fpc);
|
||||||
pthread_mutex_unlock(&file_mutex);
|
_3proxy_mutex_unlock(&file_mutex);
|
||||||
return fps?1:0;
|
return fps?1:0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -777,9 +777,9 @@ static void * fp_open(void * idata, struct srvparam * param){
|
|||||||
|
|
||||||
static FILTER_ACTION fp_client(void *fo, struct clientparam * param, void** fc){
|
static FILTER_ACTION fp_client(void *fo, struct clientparam * param, void** fc){
|
||||||
|
|
||||||
pthread_mutex_lock(&file_mutex);
|
_3proxy_mutex_lock(&file_mutex);
|
||||||
(*fc) = (void *)addfps(param);
|
(*fc) = (void *)addfps(param);
|
||||||
pthread_mutex_unlock(&file_mutex);
|
_3proxy_mutex_unlock(&file_mutex);
|
||||||
return CONTINUE;
|
return CONTINUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -913,7 +913,7 @@ static int file_loaded=0;
|
|||||||
int argc, char** argv){
|
int argc, char** argv){
|
||||||
|
|
||||||
if(!file_loaded){
|
if(!file_loaded){
|
||||||
pthread_mutex_init(&file_mutex, NULL);
|
_3proxy_mutex_init(&file_mutex);
|
||||||
file_loaded = 1;
|
file_loaded = 1;
|
||||||
pl = pluginlink;
|
pl = pluginlink;
|
||||||
memcpy(&sso, pl->so, sizeof(struct sockfuncs));
|
memcpy(&sso, pl->so, sizeof(struct sockfuncs));
|
||||||
|
|||||||
@ -21,7 +21,7 @@ extern "C" {
|
|||||||
|
|
||||||
static struct pluginlink * pl;
|
static struct pluginlink * pl;
|
||||||
|
|
||||||
static pthread_mutex_t pcre_mutex;
|
static _3proxy_mutex_t pcre_mutex;
|
||||||
|
|
||||||
|
|
||||||
static struct filter pcre_first_filter = {
|
static struct filter pcre_first_filter = {
|
||||||
@ -112,7 +112,7 @@ struct pcre_filter_data {
|
|||||||
};
|
};
|
||||||
|
|
||||||
static void pcre_data_free(struct pcre_filter_data *pcrefd){
|
static void pcre_data_free(struct pcre_filter_data *pcrefd){
|
||||||
pthread_mutex_lock(&pcre_mutex);
|
_3proxy_mutex_lock(&pcre_mutex);
|
||||||
pcrefd->users--;
|
pcrefd->users--;
|
||||||
if(!pcrefd->users){
|
if(!pcrefd->users){
|
||||||
if(pcrefd->match_data) pcre2_match_data_free(pcrefd->match_data);
|
if(pcrefd->match_data) pcre2_match_data_free(pcrefd->match_data);
|
||||||
@ -121,7 +121,7 @@ static void pcre_data_free(struct pcre_filter_data *pcrefd){
|
|||||||
if(pcrefd->replace) pl->freefunc(pcrefd->replace);
|
if(pcrefd->replace) pl->freefunc(pcrefd->replace);
|
||||||
pl->freefunc(pcrefd);
|
pl->freefunc(pcrefd);
|
||||||
}
|
}
|
||||||
pthread_mutex_unlock(&pcre_mutex);
|
_3proxy_mutex_unlock(&pcre_mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -130,9 +130,9 @@ static void pcre_data_free(struct pcre_filter_data *pcrefd){
|
|||||||
static void* pcre_filter_open(void * idata, struct srvparam * param){
|
static void* pcre_filter_open(void * idata, struct srvparam * param){
|
||||||
#define pcrefd ((struct pcre_filter_data *)idata)
|
#define pcrefd ((struct pcre_filter_data *)idata)
|
||||||
if(idata){
|
if(idata){
|
||||||
pthread_mutex_lock(&pcre_mutex);
|
_3proxy_mutex_lock(&pcre_mutex);
|
||||||
pcrefd->users++;
|
pcrefd->users++;
|
||||||
pthread_mutex_unlock(&pcre_mutex);
|
_3proxy_mutex_unlock(&pcre_mutex);
|
||||||
}
|
}
|
||||||
#undef pcrefd
|
#undef pcrefd
|
||||||
return idata;
|
return idata;
|
||||||
@ -517,7 +517,7 @@ PLUGINAPI int PLUGINCALL pcre_plugin (struct pluginlink * pluginlink,
|
|||||||
pcre_options = 0;
|
pcre_options = 0;
|
||||||
if(!pcre_loaded){
|
if(!pcre_loaded){
|
||||||
pcre_loaded = 1;
|
pcre_loaded = 1;
|
||||||
pthread_mutex_init(&pcre_mutex, NULL);
|
_3proxy_mutex_init(&pcre_mutex);
|
||||||
regexp_symbols[2].next = pl->symbols.next;
|
regexp_symbols[2].next = pl->symbols.next;
|
||||||
pl->symbols.next = regexp_symbols;
|
pl->symbols.next = regexp_symbols;
|
||||||
pcre_commandhandlers[3].next = pl->commandhandlers->next;
|
pcre_commandhandlers[3].next = pl->commandhandlers->next;
|
||||||
|
|||||||
@ -12,7 +12,7 @@ Kirill Lopuchov <lopuchov@mail.ru>
|
|||||||
#include <security/pam_appl.h>
|
#include <security/pam_appl.h>
|
||||||
|
|
||||||
|
|
||||||
pthread_mutex_t pam_mutex;
|
_3proxy_mutex_t pam_mutex;
|
||||||
|
|
||||||
static int already_loaded = 0;
|
static int already_loaded = 0;
|
||||||
|
|
||||||
@ -89,7 +89,7 @@ static int pamfunc(struct clientparam *param)
|
|||||||
/*start process auth */
|
/*start process auth */
|
||||||
conv.appdata_ptr = (char *) param->password;
|
conv.appdata_ptr = (char *) param->password;
|
||||||
|
|
||||||
pthread_mutex_lock(&pam_mutex);
|
_3proxy_mutex_lock(&pam_mutex);
|
||||||
if (!pamh)
|
if (!pamh)
|
||||||
{
|
{
|
||||||
retval = pam_start ((char *)service, (char *)param->username, &conv, &pamh);
|
retval = pam_start ((char *)service, (char *)param->username, &conv, &pamh);
|
||||||
@ -113,7 +113,7 @@ static int pamfunc(struct clientparam *param)
|
|||||||
retval = pam_end (pamh, retval);
|
retval = pam_end (pamh, retval);
|
||||||
if (retval != PAM_SUCCESS)
|
if (retval != PAM_SUCCESS)
|
||||||
{ pamh = NULL; }
|
{ pamh = NULL; }
|
||||||
pthread_mutex_unlock(&pam_mutex);
|
_3proxy_mutex_unlock(&pam_mutex);
|
||||||
|
|
||||||
return rc;
|
return rc;
|
||||||
|
|
||||||
@ -140,7 +140,7 @@ PLUGINAPI int PLUGINCALL start(struct pluginlink * pluginlink, int argc, unsigne
|
|||||||
|
|
||||||
already_loaded = 1;
|
already_loaded = 1;
|
||||||
|
|
||||||
pthread_mutex_init(&pam_mutex, NULL);
|
_3proxy_mutex_init(&pam_mutex);
|
||||||
pamauth.authenticate = pamfunc;
|
pamauth.authenticate = pamfunc;
|
||||||
pamauth.authorize = pluginlink->checkACL;
|
pamauth.authorize = pluginlink->checkACL;
|
||||||
pamauth.desc = "pam";
|
pamauth.desc = "pam";
|
||||||
|
|||||||
@ -32,7 +32,7 @@ typedef struct _ssl_conn {
|
|||||||
SSL *ssl;
|
SSL *ssl;
|
||||||
} ssl_conn;
|
} ssl_conn;
|
||||||
|
|
||||||
pthread_mutex_t ssl_file_mutex;
|
_3proxy_mutex_t ssl_file_mutex;
|
||||||
|
|
||||||
|
|
||||||
static char errbuf[256];
|
static char errbuf[256];
|
||||||
@ -229,15 +229,15 @@ void _ssl_cert_free(SSL_CERT cert)
|
|||||||
|
|
||||||
|
|
||||||
/* This array will store all of the mutexes available to OpenSSL. */
|
/* This array will store all of the mutexes available to OpenSSL. */
|
||||||
static pthread_mutex_t *mutex_buf= NULL;
|
static _3proxy_mutex_t *mutex_buf= NULL;
|
||||||
|
|
||||||
|
|
||||||
static void locking_function(int mode, int n, const char * file, int line)
|
static void locking_function(int mode, int n, const char * file, int line)
|
||||||
{
|
{
|
||||||
if (mode & CRYPTO_LOCK)
|
if (mode & CRYPTO_LOCK)
|
||||||
pthread_mutex_lock(mutex_buf + n);
|
_3proxy_mutex_lock(mutex_buf + n);
|
||||||
else
|
else
|
||||||
pthread_mutex_unlock(mutex_buf + n);
|
_3proxy_mutex_unlock(mutex_buf + n);
|
||||||
}
|
}
|
||||||
|
|
||||||
static unsigned long id_function(void)
|
static unsigned long id_function(void)
|
||||||
@ -253,11 +253,11 @@ int thread_setup(void)
|
|||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
mutex_buf = malloc(CRYPTO_num_locks( ) * sizeof(pthread_mutex_t));
|
mutex_buf = malloc(CRYPTO_num_locks( ) * sizeof(_3proxy_mutex_t));
|
||||||
if (!mutex_buf)
|
if (!mutex_buf)
|
||||||
return 0;
|
return 0;
|
||||||
for (i = 0; i < CRYPTO_num_locks( ); i++)
|
for (i = 0; i < CRYPTO_num_locks( ); i++)
|
||||||
pthread_mutex_init(mutex_buf +i, NULL);
|
_3proxy_mutex_init(mutex_buf +i);
|
||||||
CRYPTO_set_id_callback(id_function);
|
CRYPTO_set_id_callback(id_function);
|
||||||
CRYPTO_set_locking_callback(locking_function);
|
CRYPTO_set_locking_callback(locking_function);
|
||||||
return 1;
|
return 1;
|
||||||
@ -272,7 +272,7 @@ int thread_cleanup(void)
|
|||||||
CRYPTO_set_id_callback(NULL);
|
CRYPTO_set_id_callback(NULL);
|
||||||
CRYPTO_set_locking_callback(NULL);
|
CRYPTO_set_locking_callback(NULL);
|
||||||
for (i = 0; i < CRYPTO_num_locks( ); i++)
|
for (i = 0; i < CRYPTO_num_locks( ); i++)
|
||||||
pthread_mutex_destroy(mutex_buf +i);
|
_3proxy_mutex_destroy(mutex_buf +i);
|
||||||
free(mutex_buf);
|
free(mutex_buf);
|
||||||
mutex_buf = NULL;
|
mutex_buf = NULL;
|
||||||
return 1;
|
return 1;
|
||||||
@ -291,7 +291,7 @@ void ssl_init()
|
|||||||
thread_setup();
|
thread_setup();
|
||||||
SSLeay_add_ssl_algorithms();
|
SSLeay_add_ssl_algorithms();
|
||||||
SSL_load_error_strings();
|
SSL_load_error_strings();
|
||||||
pthread_mutex_init(&ssl_file_mutex, NULL);
|
_3proxy_mutex_init(&ssl_file_mutex);
|
||||||
bio_err=BIO_new_fp(stderr,BIO_NOCLOSE);
|
bio_err=BIO_new_fp(stderr,BIO_NOCLOSE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
13
src/proxy.h
13
src/proxy.h
@ -299,6 +299,7 @@ int connectwithpoll(struct clientparam *param, SOCKET sock, struct sockaddr *sa,
|
|||||||
|
|
||||||
|
|
||||||
int myrand(void * entropy, int len);
|
int myrand(void * entropy, int len);
|
||||||
|
uint32_t murmurhash3(const void *key, int len, uint32_t seed);
|
||||||
|
|
||||||
extern char *copyright;
|
extern char *copyright;
|
||||||
|
|
||||||
@ -322,12 +323,12 @@ struct datatype;
|
|||||||
struct dictionary;
|
struct dictionary;
|
||||||
struct node;
|
struct node;
|
||||||
struct property;
|
struct property;
|
||||||
extern pthread_mutex_t config_mutex;
|
extern _3proxy_mutex_t config_mutex;
|
||||||
extern pthread_mutex_t bandlim_mutex;
|
extern _3proxy_mutex_t bandlim_mutex;
|
||||||
extern pthread_mutex_t connlim_mutex;
|
extern _3proxy_mutex_t connlim_mutex;
|
||||||
extern pthread_mutex_t tc_mutex;
|
extern _3proxy_mutex_t tc_mutex;
|
||||||
extern pthread_mutex_t log_mutex;
|
extern _3proxy_mutex_t log_mutex;
|
||||||
extern pthread_mutex_t rad_mutex;
|
extern _3proxy_mutex_t rad_mutex;
|
||||||
extern struct datatype datatypes[64];
|
extern struct datatype datatypes[64];
|
||||||
|
|
||||||
extern struct commands commandhandlers[];
|
extern struct commands commandhandlers[];
|
||||||
|
|||||||
@ -117,10 +117,10 @@ void * threadfunc (void *p) {
|
|||||||
|
|
||||||
int pushthreadinit(){
|
int pushthreadinit(){
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
DWORD n;
|
return ReleaseSemaphore(conf.threadinit, 1, NULL) ? 1 : 0;
|
||||||
return WriteFile(conf.threadinit[1], "1", 1, &n, NULL);
|
|
||||||
#else
|
#else
|
||||||
return write(conf.threadinit[1], "1", 1);
|
_3proxy_mutex_unlock(&conf.threadinit);
|
||||||
|
return 1;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -261,8 +261,10 @@ int MODULEMAINFUNC (int argc, char** argv){
|
|||||||
unsigned char buf[256];
|
unsigned char buf[256];
|
||||||
char *hostname=NULL;
|
char *hostname=NULL;
|
||||||
int opt = 1, isudp = 0, iscbl = 0, iscbc = 0;
|
int opt = 1, isudp = 0, iscbl = 0, iscbc = 0;
|
||||||
|
#ifndef NOUDPMAIN
|
||||||
unsigned char udpbuf[UDPBUFSIZE];
|
unsigned char udpbuf[UDPBUFSIZE];
|
||||||
int udplen = 0;
|
int udplen = 0;
|
||||||
|
#endif
|
||||||
unsigned char *cbc_string = NULL, *cbl_string = NULL;
|
unsigned char *cbc_string = NULL, *cbl_string = NULL;
|
||||||
PROXYSOCKADDRTYPE cbsa;
|
PROXYSOCKADDRTYPE cbsa;
|
||||||
FILE *fp = NULL;
|
FILE *fp = NULL;
|
||||||
@ -348,7 +350,7 @@ int MODULEMAINFUNC (int argc, char** argv){
|
|||||||
srvinit(&srv, &defparam);
|
srvinit(&srv, &defparam);
|
||||||
srv.pf = childdef.pf;
|
srv.pf = childdef.pf;
|
||||||
isudp = childdef.isudp;
|
isudp = childdef.isudp;
|
||||||
#ifndef STDMAIN
|
#ifndef NOUDPMAIN
|
||||||
if(isudp) {
|
if(isudp) {
|
||||||
if(!udp_table.ihashtable)inithashtable(&udp_table, 64, 256, 65536);
|
if(!udp_table.ihashtable)inithashtable(&udp_table, 64, 256, 65536);
|
||||||
}
|
}
|
||||||
@ -381,7 +383,7 @@ int MODULEMAINFUNC (int argc, char** argv){
|
|||||||
#endif
|
#endif
|
||||||
#else
|
#else
|
||||||
srv.needuser = 0;
|
srv.needuser = 0;
|
||||||
pthread_mutex_init(&log_mutex, NULL);
|
_3proxy_mutex_init(&log_mutex);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
for (i=1; i<argc; i++) {
|
for (i=1; i<argc; i++) {
|
||||||
@ -680,9 +682,11 @@ int MODULEMAINFUNC (int argc, char** argv){
|
|||||||
IPPROTO_TCP
|
IPPROTO_TCP
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
#ifndef NOUDPMAIN
|
||||||
else {
|
else {
|
||||||
sock=srv.so._socket(srv.so.state, SASOCK(&srv.intsa), SOCK_DGRAM, IPPROTO_UDP);
|
sock=srv.so._socket(srv.so.state, SASOCK(&srv.intsa), SOCK_DGRAM, IPPROTO_UDP);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
if( sock == INVALID_SOCKET) {
|
if( sock == INVALID_SOCKET) {
|
||||||
perror("socket()");
|
perror("socket()");
|
||||||
return -2;
|
return -2;
|
||||||
@ -753,8 +757,10 @@ int MODULEMAINFUNC (int argc, char** argv){
|
|||||||
return -4;
|
return -4;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#ifndef NOUDPMAIN
|
||||||
else
|
else
|
||||||
defparam.clisock = sock;
|
defparam.clisock = sock;
|
||||||
|
#endif
|
||||||
|
|
||||||
if(!srv.silent && !iscbc){
|
if(!srv.silent && !iscbc){
|
||||||
sprintf((char *)buf, "Accepting connections [%"PRIu64"/%"PRIu64"]", (uint64_t)getpid(), (uint64_t)pthread_self());
|
sprintf((char *)buf, "Accepting connections [%"PRIu64"/%"PRIu64"]", (uint64_t)getpid(), (uint64_t)pthread_self());
|
||||||
@ -926,20 +932,20 @@ int MODULEMAINFUNC (int argc, char** argv){
|
|||||||
srv.so._setsockopt(srv.so.state, new_sock, SOL_SOCKET, SO_LINGER, (char *)&lg, sizeof(lg));
|
srv.so._setsockopt(srv.so.state, new_sock, SOL_SOCKET, SO_LINGER, (char *)&lg, sizeof(lg));
|
||||||
srv.so._setsockopt(srv.so.state, new_sock, SOL_SOCKET, SO_OOBINLINE, (char *)&opt, sizeof(int));
|
srv.so._setsockopt(srv.so.state, new_sock, SOL_SOCKET, SO_OOBINLINE, (char *)&opt, sizeof(int));
|
||||||
}
|
}
|
||||||
#ifndef STDMAIN
|
#ifndef NOUDPMAIN
|
||||||
else {
|
else {
|
||||||
struct clientparam *toparam;
|
struct clientparam *toparam;
|
||||||
udplen = sockrecvfrom(NULL, srv.srvsock, (struct sockaddr *)&defparam.sincr, udpbuf, UDPBUFSIZE, 0);
|
udplen = sockrecvfrom(NULL, srv.srvsock, (struct sockaddr *)&defparam.sincr, udpbuf, UDPBUFSIZE, 0);
|
||||||
if(udplen <= 0) continue;
|
if(udplen <= 0) continue;
|
||||||
pthread_mutex_lock(&srv.counter_mutex);
|
_3proxy_mutex_lock(&srv.counter_mutex);
|
||||||
if(hashresolv(&udp_table, &defparam, &toparam, NULL)) {
|
if(hashresolv(&udp_table, &defparam, &toparam, NULL)) {
|
||||||
socksendto(toparam, toparam->remsock, (struct sockaddr *)&toparam->sinsr, udpbuf, udplen, 0);
|
socksendto(toparam, toparam->remsock, (struct sockaddr *)&toparam->sinsr, udpbuf, udplen, 0);
|
||||||
toparam->statscli64 += udplen;
|
toparam->statscli64 += udplen;
|
||||||
toparam->nwrites++;
|
toparam->nwrites++;
|
||||||
pthread_mutex_unlock(&srv.counter_mutex);
|
_3proxy_mutex_unlock(&srv.counter_mutex);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
pthread_mutex_unlock(&srv.counter_mutex);
|
_3proxy_mutex_unlock(&srv.counter_mutex);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
if(! (newparam = myalloc (sizeof(defparam)))){
|
if(! (newparam = myalloc (sizeof(defparam)))){
|
||||||
@ -958,6 +964,8 @@ int MODULEMAINFUNC (int argc, char** argv){
|
|||||||
freeparam(newparam);
|
freeparam(newparam);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
#ifndef NOUDPMAIN
|
||||||
if(isudp) {
|
if(isudp) {
|
||||||
int authres;
|
int authres;
|
||||||
|
|
||||||
@ -988,7 +996,7 @@ int MODULEMAINFUNC (int argc, char** argv){
|
|||||||
#endif
|
#endif
|
||||||
newparam->prev = newparam->next = NULL;
|
newparam->prev = newparam->next = NULL;
|
||||||
error = 0;
|
error = 0;
|
||||||
pthread_mutex_lock(&srv.counter_mutex);
|
_3proxy_mutex_lock(&srv.counter_mutex);
|
||||||
if(!srv.child){
|
if(!srv.child){
|
||||||
srv.child = newparam;
|
srv.child = newparam;
|
||||||
}
|
}
|
||||||
@ -1012,7 +1020,7 @@ int MODULEMAINFUNC (int argc, char** argv){
|
|||||||
if(!srv.silent)dolog(&defparam, buf);
|
if(!srv.silent)dolog(&defparam, buf);
|
||||||
error = 1;
|
error = 1;
|
||||||
}
|
}
|
||||||
pthread_mutex_unlock(&srv.counter_mutex);
|
_3proxy_mutex_unlock(&srv.counter_mutex);
|
||||||
if(error) freeparam(newparam);
|
if(error) freeparam(newparam);
|
||||||
#else
|
#else
|
||||||
|
|
||||||
@ -1023,14 +1031,14 @@ int MODULEMAINFUNC (int argc, char** argv){
|
|||||||
if(newparam->prev) newparam->prev->next = newparam->next;
|
if(newparam->prev) newparam->prev->next = newparam->next;
|
||||||
else srv.child = newparam->next;
|
else srv.child = newparam->next;
|
||||||
if(newparam->next) newparam->next->prev = newparam->prev;
|
if(newparam->next) newparam->next->prev = newparam->prev;
|
||||||
pthread_mutex_unlock(&srv.counter_mutex);
|
_3proxy_mutex_unlock(&srv.counter_mutex);
|
||||||
newparam->srv = NULL;
|
newparam->srv = NULL;
|
||||||
freeparam(newparam);
|
freeparam(newparam);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
srv.childcount++;
|
srv.childcount++;
|
||||||
newparam->threadid = (uint64_t)thread;
|
newparam->threadid = (uint64_t)thread;
|
||||||
pthread_mutex_unlock(&srv.counter_mutex);
|
_3proxy_mutex_unlock(&srv.counter_mutex);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -1040,11 +1048,11 @@ int MODULEMAINFUNC (int argc, char** argv){
|
|||||||
|
|
||||||
|
|
||||||
#ifndef STDMAIN
|
#ifndef STDMAIN
|
||||||
pthread_mutex_lock(&config_mutex);
|
_3proxy_mutex_lock(&config_mutex);
|
||||||
if(srv.next)srv.next->prev = srv.prev;
|
if(srv.next)srv.next->prev = srv.prev;
|
||||||
if(srv.prev)srv.prev->next = srv.next;
|
if(srv.prev)srv.prev->next = srv.next;
|
||||||
else conf.services = srv.next;
|
else conf.services = srv.next;
|
||||||
pthread_mutex_unlock(&config_mutex);
|
_3proxy_mutex_unlock(&config_mutex);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if(!srv.silent) srv.logfunc(&defparam, (unsigned char *)"Exiting thread");
|
if(!srv.silent) srv.logfunc(&defparam, (unsigned char *)"Exiting thread");
|
||||||
@ -1093,7 +1101,7 @@ void srvinit(struct srvparam * srv, struct clientparam *param){
|
|||||||
param->paused = srv->paused;
|
param->paused = srv->paused;
|
||||||
param->remsock = param->clisock = param->ctrlsock = param->ctrlsocksrv = INVALID_SOCKET;
|
param->remsock = param->clisock = param->ctrlsock = param->ctrlsocksrv = INVALID_SOCKET;
|
||||||
*SAFAMILY(¶m->req) = *SAFAMILY(¶m->sinsl) = *SAFAMILY(¶m->sinsr) = *SAFAMILY(¶m->sincr) = *SAFAMILY(¶m->sincl) = AF_INET;
|
*SAFAMILY(¶m->req) = *SAFAMILY(¶m->sinsl) = *SAFAMILY(¶m->sinsr) = *SAFAMILY(¶m->sincr) = *SAFAMILY(¶m->sincl) = AF_INET;
|
||||||
pthread_mutex_init(&srv->counter_mutex, NULL);
|
_3proxy_mutex_init(&srv->counter_mutex);
|
||||||
srv->intsa = conf.intsa;
|
srv->intsa = conf.intsa;
|
||||||
srv->extsa = conf.extsa;
|
srv->extsa = conf.extsa;
|
||||||
#ifndef NOIPV6
|
#ifndef NOIPV6
|
||||||
@ -1158,7 +1166,7 @@ void srvfree(struct srvparam * srv){
|
|||||||
if(srv->acl)freeacl(srv->acl);
|
if(srv->acl)freeacl(srv->acl);
|
||||||
if(srv->authfuncs)freeauth(srv->authfuncs);
|
if(srv->authfuncs)freeauth(srv->authfuncs);
|
||||||
#endif
|
#endif
|
||||||
pthread_mutex_destroy(&srv->counter_mutex);
|
_3proxy_mutex_destroy(&srv->counter_mutex);
|
||||||
if(srv->target) myfree(srv->target);
|
if(srv->target) myfree(srv->target);
|
||||||
if(srv->logtarget) myfree(srv->logtarget);
|
if(srv->logtarget) myfree(srv->logtarget);
|
||||||
if(srv->logformat) myfree(srv->logformat);
|
if(srv->logformat) myfree(srv->logformat);
|
||||||
@ -1175,7 +1183,7 @@ void freeparam(struct clientparam * param) {
|
|||||||
if(param->res == 2) return;
|
if(param->res == 2) return;
|
||||||
if(param->srv){
|
if(param->srv){
|
||||||
if(param->srv->so.freefunc) param->srv->so.freefunc(param->sostate);
|
if(param->srv->so.freefunc) param->srv->so.freefunc(param->sostate);
|
||||||
pthread_mutex_lock(¶m->srv->counter_mutex);
|
_3proxy_mutex_lock(¶m->srv->counter_mutex);
|
||||||
#ifndef STDMAIN
|
#ifndef STDMAIN
|
||||||
if(param->srv->service == S_UDPPM) hashdelete(&udp_table, param);
|
if(param->srv->service == S_UDPPM) hashdelete(&udp_table, param);
|
||||||
#endif
|
#endif
|
||||||
@ -1188,7 +1196,7 @@ void freeparam(struct clientparam * param) {
|
|||||||
param->next->prev = param->prev;
|
param->next->prev = param->prev;
|
||||||
}
|
}
|
||||||
(param->srv->childcount)--;
|
(param->srv->childcount)--;
|
||||||
pthread_mutex_unlock(¶m->srv->counter_mutex);
|
_3proxy_mutex_unlock(¶m->srv->counter_mutex);
|
||||||
}
|
}
|
||||||
if(param->clibuf) myfree(param->clibuf);
|
if(param->clibuf) myfree(param->clibuf);
|
||||||
if(param->srvbuf) myfree(param->srvbuf);
|
if(param->srvbuf) myfree(param->srvbuf);
|
||||||
|
|||||||
134
src/sockmap.c
134
src/sockmap.c
@ -50,7 +50,7 @@ int sockmap(struct clientparam * param, int timeo, int usesplice){
|
|||||||
int FROMCLIENT = 1, TOCLIENTBUF = 1, FROMCLIENTBUF = 1, TOSERVER = 1,
|
int FROMCLIENT = 1, TOCLIENTBUF = 1, FROMCLIENTBUF = 1, TOSERVER = 1,
|
||||||
FROMSERVER = 1, TOSERVERBUF = 1, FROMSERVERBUF = 1, TOCLIENT = 1;
|
FROMSERVER = 1, TOSERVERBUF = 1, FROMSERVERBUF = 1, TOCLIENT = 1;
|
||||||
int HASERROR=0;
|
int HASERROR=0;
|
||||||
int CLIENTTERM = 0, SERVERTERM = 0;
|
int CLIENTTERMREAD = 0, CLIENTTERMWRITE = 0, SERVERTERMREAD = 0, SERVERTERMWRITE = 0;
|
||||||
int after = 0;
|
int after = 0;
|
||||||
struct pollfd fds[6];
|
struct pollfd fds[6];
|
||||||
struct pollfd *fdsp = fds;
|
struct pollfd *fdsp = fds;
|
||||||
@ -62,6 +62,8 @@ int sockmap(struct clientparam * param, int timeo, int usesplice){
|
|||||||
int needaction = 0;
|
int needaction = 0;
|
||||||
int graceclinum=0, gracesrvnum=0, graceclitraf=0, gracesrvtraf=0;
|
int graceclinum=0, gracesrvnum=0, graceclitraf=0, gracesrvtraf=0;
|
||||||
time_t gracetime = 0;
|
time_t gracetime = 0;
|
||||||
|
int cli_events = 0;
|
||||||
|
int srv_events = 0;
|
||||||
|
|
||||||
#ifdef WITHSPLICE
|
#ifdef WITHSPLICE
|
||||||
uint64_t inclientpipe = 0, inserverpipe = 0;
|
uint64_t inclientpipe = 0, inserverpipe = 0;
|
||||||
@ -121,24 +123,24 @@ int sockmap(struct clientparam * param, int timeo, int usesplice){
|
|||||||
if(action != PASS) RETURN(19);
|
if(action != PASS) RETURN(19);
|
||||||
|
|
||||||
while(
|
while(
|
||||||
((!CLIENTTERM) && fromserver && (inserverbuf
|
((!CLIENTTERMWRITE) && fromserver && (inserverbuf
|
||||||
#ifdef WITHSPLICE
|
#ifdef WITHSPLICE
|
||||||
|| inserverpipe
|
|| inserverpipe
|
||||||
#endif
|
#endif
|
||||||
|| (!SERVERTERM )))
|
|| (!SERVERTERMREAD )))
|
||||||
||
|
||
|
||||||
((!SERVERTERM) && fromclient && (inclientbuf
|
((!SERVERTERMWRITE) && fromclient && (inclientbuf
|
||||||
#ifdef WITHSPLICE
|
#ifdef WITHSPLICE
|
||||||
|| inclientpipe
|
|| inclientpipe
|
||||||
#endif
|
#endif
|
||||||
|| (!CLIENTTERM )))
|
|| (!CLIENTTERMREAD )))
|
||||||
){
|
){
|
||||||
|
|
||||||
|
|
||||||
#if WITHLOG > 1
|
#if WITHLOG > 1
|
||||||
sprintf(logbuf, "int FROMCLIENT = %d, TOCLIENTBUF = %d, FROMCLIENTBUF = %d, TOSERVER = %d, "
|
sprintf(logbuf, "int FROMCLIENT = %d, TOCLIENTBUF = %d, FROMCLIENTBUF = %d, TOSERVER = %d, "
|
||||||
"FROMSERVER = %d, TOSERVERBUF = %d, FROMSERVERBUF = %d, TOCLIENT = %d; inclientbuf=%d; "
|
"FROMSERVER = %d, TOSERVERBUF = %d, FROMSERVERBUF = %d, TOCLIENT = %d; inclientbuf=%d; "
|
||||||
"inserverbuf=%d, CLIENTTERM = %d, SERVERTERM =%d, fromserver=%u, fromclient=%u"
|
"inserverbuf=%d, CLIENTTERMREAD=%d CLIENTTERMWRITE=%d SERVERTERMREAD=%d SERVERTERMWRITE=%d fromserver=%u, fromclient=%u"
|
||||||
#ifdef WITHSPLICE
|
#ifdef WITHSPLICE
|
||||||
", inserverpipe=%d, inclentpipe=%d "
|
", inserverpipe=%d, inclentpipe=%d "
|
||||||
"TOCLIENTPIPE=%d FROMCLIENTPIPE==%d TOSERVERPIPE==%d FROMSERVERPIPE=%d"
|
"TOCLIENTPIPE=%d FROMCLIENTPIPE==%d TOSERVERPIPE==%d FROMSERVERPIPE=%d"
|
||||||
@ -146,7 +148,7 @@ sprintf(logbuf, "int FROMCLIENT = %d, TOCLIENTBUF = %d, FROMCLIENTBUF = %d, TOSE
|
|||||||
,
|
,
|
||||||
FROMCLIENT, TOCLIENTBUF, FROMCLIENTBUF, TOSERVER,
|
FROMCLIENT, TOCLIENTBUF, FROMCLIENTBUF, TOSERVER,
|
||||||
FROMSERVER, TOSERVERBUF, FROMSERVERBUF, TOCLIENT,
|
FROMSERVER, TOSERVERBUF, FROMSERVERBUF, TOCLIENT,
|
||||||
(int)inclientbuf, (int)inserverbuf, CLIENTTERM, SERVERTERM,
|
(int)inclientbuf, (int)inserverbuf, CLIENTTERMREAD, CLIENTTERMWRITE, SERVERTERMREAD, SERVERTERMWRITE,
|
||||||
(unsigned)fromserver, (unsigned)fromclient
|
(unsigned)fromserver, (unsigned)fromclient
|
||||||
#ifdef WITHSPLICE
|
#ifdef WITHSPLICE
|
||||||
,(int)inserverpipe, (int)inclientpipe,
|
,(int)inserverpipe, (int)inclientpipe,
|
||||||
@ -215,7 +217,8 @@ log("send to server from buf");
|
|||||||
if(res <= 0) {
|
if(res <= 0) {
|
||||||
TOSERVER = 0;
|
TOSERVER = 0;
|
||||||
if(errno && errno != EAGAIN && errno != EINTR){
|
if(errno && errno != EAGAIN && errno != EINTR){
|
||||||
SERVERTERM = 1;
|
SERVERTERMREAD = 1;
|
||||||
|
SERVERTERMWRITE = 1;
|
||||||
HASERROR |= 2;
|
HASERROR |= 2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -260,7 +263,8 @@ log("send to client from buf");
|
|||||||
if(res <= 0) {
|
if(res <= 0) {
|
||||||
TOCLIENT = 0;
|
TOCLIENT = 0;
|
||||||
if(errno && errno != EAGAIN && errno != EINTR){
|
if(errno && errno != EAGAIN && errno != EINTR){
|
||||||
CLIENTTERM = 1;
|
CLIENTTERMREAD = 1;
|
||||||
|
CLIENTTERMWRITE = 1;
|
||||||
HASERROR |= 1;
|
HASERROR |= 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -357,7 +361,7 @@ log(logbuf);
|
|||||||
if(res <= 0) {
|
if(res <= 0) {
|
||||||
FROMCLIENT = TOCLIENTPIPE = 0;
|
FROMCLIENT = TOCLIENTPIPE = 0;
|
||||||
if(res == 0 && !errno) {
|
if(res == 0 && !errno) {
|
||||||
CLIENTTERM = 1;
|
CLIENTTERMREAD = 1;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -394,7 +398,7 @@ log(logbuf);
|
|||||||
if(res <= 0) {
|
if(res <= 0) {
|
||||||
FROMSERVER = TOSERVERPIPE = 0;
|
FROMSERVER = TOSERVERPIPE = 0;
|
||||||
if(res == 0 && !errno) {
|
if(res == 0 && !errno) {
|
||||||
SERVERTERM = 1;
|
SERVERTERMREAD = 1;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -430,8 +434,13 @@ log("read from client to buf");
|
|||||||
res = param->srv->so._recvfrom(param->sostate, param->clisock, (char *)param->clibuf + param->cliinbuf, (int)MIN((uint64_t)param->clibufsize - param->cliinbuf, fromclient-inclientbuf), 0, (struct sockaddr *)¶m->sincr, &sasize);
|
res = param->srv->so._recvfrom(param->sostate, param->clisock, (char *)param->clibuf + param->cliinbuf, (int)MIN((uint64_t)param->clibufsize - param->cliinbuf, fromclient-inclientbuf), 0, (struct sockaddr *)¶m->sincr, &sasize);
|
||||||
if(res <= 0) {
|
if(res <= 0) {
|
||||||
FROMCLIENT = 0;
|
FROMCLIENT = 0;
|
||||||
if(res == 0 || (errno && errno != EINTR && errno !=EAGAIN)){
|
if(res == 0) {
|
||||||
CLIENTTERM = 1;
|
CLIENTTERMREAD = 1;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if(errno && errno != EINTR && errno !=EAGAIN){
|
||||||
|
CLIENTTERMREAD = 1;
|
||||||
|
CLIENTTERMWRITE = 1;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -458,8 +467,13 @@ log("read from server to buf");
|
|||||||
res = param->srv->so._recvfrom(param->sostate, param->remsock, (char *)param->srvbuf + param->srvinbuf, (int)MIN((uint64_t)param->srvbufsize - param->srvinbuf, fromserver-inserverbuf), 0, (struct sockaddr *)¶m->sinsr, &sasize);
|
res = param->srv->so._recvfrom(param->sostate, param->remsock, (char *)param->srvbuf + param->srvinbuf, (int)MIN((uint64_t)param->srvbufsize - param->srvinbuf, fromserver-inserverbuf), 0, (struct sockaddr *)¶m->sinsr, &sasize);
|
||||||
if(res <= 0) {
|
if(res <= 0) {
|
||||||
FROMSERVER = 0;
|
FROMSERVER = 0;
|
||||||
if(res == 0 || (errno && errno != EINTR && errno !=EAGAIN)) {
|
if(res == 0) {
|
||||||
SERVERTERM = 1;
|
SERVERTERMREAD = 1;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if(errno && errno != EINTR && errno !=EAGAIN) {
|
||||||
|
SERVERTERMREAD = 1;
|
||||||
|
SERVERTERMWRITE = 1;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -485,42 +499,45 @@ log("done read from server to buf");
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for(after = 0; after < 2; after ++){
|
for(after = 0, cli_events=0, srv_events=0; after < 2; after ++){
|
||||||
fdsc = 0;
|
fdsc = 0;
|
||||||
|
|
||||||
if(!after){
|
if(!after){
|
||||||
memset(fds, 0, sizeof(fds));
|
memset(fds, 0, sizeof(fds));
|
||||||
}
|
}
|
||||||
if(!CLIENTTERM){
|
// if(!CLIENTTERMREAD || !CLIENTTERMWRITE){
|
||||||
if(!after){
|
if(!after){
|
||||||
fds[fdsc].fd = param->clisock;
|
if(fromclient && !CLIENTTERMREAD && !FROMCLIENT && ((
|
||||||
if(fromclient && !FROMCLIENT && ((
|
|
||||||
#ifdef WITHSPLICE
|
#ifdef WITHSPLICE
|
||||||
!usesplice &&
|
!usesplice &&
|
||||||
#endif
|
#endif
|
||||||
TOCLIENTBUF)
|
TOCLIENTBUF)
|
||||||
#ifdef WITHSPLICE
|
#ifdef WITHSPLICE
|
||||||
|| (usesplice)
|
|| (usesplice)
|
||||||
#endif
|
#endif
|
||||||
)){
|
))
|
||||||
#ifdef WITHLOG
|
cli_events |= POLLIN;
|
||||||
log("wait reading from client");
|
if(!TOCLIENT && !CLIENTTERMWRITE && (inserverbuf
|
||||||
#endif
|
|
||||||
fds[fdsc].events |= (POLLIN);
|
|
||||||
}
|
|
||||||
if(!TOCLIENT && (inserverbuf
|
|
||||||
#ifdef WITHSPLICE
|
#ifdef WITHSPLICE
|
||||||
|| inserverpipe
|
|| inserverpipe
|
||||||
#endif
|
#endif
|
||||||
)){
|
))
|
||||||
|
cli_events |= POLLOUT;
|
||||||
|
if(cli_events){
|
||||||
|
fds[fdsc].fd = param->clisock;
|
||||||
|
fds[fdsc].events = cli_events;
|
||||||
#ifdef WITHLOG
|
#ifdef WITHLOG
|
||||||
|
if(cli_events & POLLIN)
|
||||||
|
log("wait reading from client");
|
||||||
|
if(cli_events & POLLOUT)
|
||||||
log("wait writing to client");
|
log("wait writing to client");
|
||||||
#endif
|
#endif
|
||||||
fds[fdsc].events |= POLLOUT;
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else{
|
else if(cli_events){
|
||||||
if(fds[fdsc].revents & (POLLERR|POLLNVAL)) {
|
if(fds[fdsc].revents & (POLLERR|POLLNVAL)) {
|
||||||
CLIENTTERM = 1;
|
CLIENTTERMREAD = 1;
|
||||||
|
CLIENTTERMWRITE = 1;
|
||||||
HASERROR |= 1;
|
HASERROR |= 1;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -538,47 +555,49 @@ log("ready to write to client");
|
|||||||
}
|
}
|
||||||
if(fds[fdsc].revents & (POLLHUP)) {
|
if(fds[fdsc].revents & (POLLHUP)) {
|
||||||
if(fds[fdsc].events & POLLIN) FROMCLIENT = 1;
|
if(fds[fdsc].events & POLLIN) FROMCLIENT = 1;
|
||||||
if(fds[fdsc].events & POLLOUT) CLIENTTERM = 1;
|
if(fds[fdsc].events & POLLOUT) CLIENTTERMWRITE = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fdsc++;
|
fdsc++;
|
||||||
}
|
|
||||||
if(!SERVERTERM){
|
// if(!SERVERTERMREAD || !SERVERTERMWRITE){
|
||||||
if(!after){
|
if(!after){
|
||||||
fds[fdsc].fd = param->remsock;
|
if(fromserver && !SERVERTERMREAD && !FROMSERVER && ((
|
||||||
if(fromserver && !FROMSERVER && ((
|
|
||||||
#ifdef WITHSPLICE
|
#ifdef WITHSPLICE
|
||||||
!usesplice &&
|
!usesplice &&
|
||||||
#endif
|
#endif
|
||||||
TOSERVERBUF)
|
TOSERVERBUF)
|
||||||
#ifdef WITHSPLICE
|
#ifdef WITHSPLICE
|
||||||
|| (usesplice)
|
|| (usesplice)
|
||||||
#endif
|
#endif
|
||||||
)){
|
))
|
||||||
#ifdef WITHLOG
|
srv_events |= POLLIN;
|
||||||
log("wait reading from server");
|
if(!TOSERVER && !SERVERTERMWRITE && (inclientbuf
|
||||||
#endif
|
|
||||||
fds[fdsc].events |= (POLLIN);
|
|
||||||
}
|
|
||||||
if(!TOSERVER && (inclientbuf
|
|
||||||
#ifdef WITHSPLICE
|
#ifdef WITHSPLICE
|
||||||
|| inclientpipe
|
|| inclientpipe
|
||||||
#endif
|
#endif
|
||||||
)){
|
))
|
||||||
|
srv_events |= POLLOUT;
|
||||||
|
if(srv_events){
|
||||||
|
fds[fdsc].fd = param->remsock;
|
||||||
|
fds[fdsc].events = srv_events;
|
||||||
#ifdef WITHLOG
|
#ifdef WITHLOG
|
||||||
|
if(srv_events & POLLIN)
|
||||||
|
log("wait reading from server");
|
||||||
|
if(srv_events & POLLOUT)
|
||||||
log("wait writing from server");
|
log("wait writing from server");
|
||||||
#endif
|
#endif
|
||||||
fds[fdsc].events |= POLLOUT;
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else{
|
else if(srv_events){
|
||||||
if(fds[fdsc].revents & (POLLERR|POLLNVAL)) {
|
if(fds[fdsc].revents & (POLLERR|POLLNVAL)) {
|
||||||
#ifdef WITHLOG
|
#ifdef WITHLOG
|
||||||
log("poll from server failed");
|
log("poll from server failed");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
SERVERTERM = 1;
|
SERVERTERMREAD = 1;
|
||||||
|
SERVERTERMWRITE = 1;
|
||||||
HASERROR |=2;
|
HASERROR |=2;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -599,12 +618,12 @@ log("ready to write to server");
|
|||||||
log("server terminated connection");
|
log("server terminated connection");
|
||||||
#endif
|
#endif
|
||||||
if(fds[fdsc].events & POLLIN) FROMSERVER = 1;
|
if(fds[fdsc].events & POLLIN) FROMSERVER = 1;
|
||||||
if(fds[fdsc].events & POLLOUT) SERVERTERM = 1;
|
if(fds[fdsc].events & POLLOUT) SERVERTERMWRITE = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fdsc++;
|
fdsc++;
|
||||||
}
|
// }
|
||||||
#ifdef WITHSPLICE
|
#ifdef WITHSPLICE
|
||||||
if(usesplice){
|
if(usesplice){
|
||||||
if(fromclient>inclientpipe && !TOCLIENTPIPE && inclientpipe < MAXSPLICE){
|
if(fromclient>inclientpipe && !TOCLIENTPIPE && inclientpipe < MAXSPLICE){
|
||||||
@ -727,6 +746,9 @@ log("timeout");
|
|||||||
else if(inclientpipe || inserverpipe) res = 94;
|
else if(inclientpipe || inserverpipe) res = 94;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
if((param->nwrites > 0 && !SERVERTERMWRITE) || (param->nreads > 0 && !CLIENTTERMWRITE))
|
||||||
|
usleep(SLEEPTIME * 10);
|
||||||
|
|
||||||
CLEANRET:
|
CLEANRET:
|
||||||
|
|
||||||
#ifdef WITHSPLICE
|
#ifdef WITHSPLICE
|
||||||
|
|||||||
@ -98,7 +98,7 @@ void sqlerr (char *buf){
|
|||||||
fprintf(conf.stdlog, "%s\n", buf);
|
fprintf(conf.stdlog, "%s\n", buf);
|
||||||
fflush(conf.stdlog);
|
fflush(conf.stdlog);
|
||||||
}
|
}
|
||||||
pthread_mutex_unlock(&log_mutex);
|
_3proxy_mutex_unlock(&log_mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned char statbuf[8192];
|
unsigned char statbuf[8192];
|
||||||
@ -109,7 +109,7 @@ void logsql(struct clientparam * param, const unsigned char *s) {
|
|||||||
|
|
||||||
|
|
||||||
if(param->nolog) return;
|
if(param->nolog) return;
|
||||||
pthread_mutex_lock(&log_mutex);
|
_3proxy_mutex_lock(&log_mutex);
|
||||||
len = dobuf(param, statbuf, s, (unsigned char *)"\'");
|
len = dobuf(param, statbuf, s, (unsigned char *)"\'");
|
||||||
|
|
||||||
if(attempt > 5){
|
if(attempt > 5){
|
||||||
@ -146,7 +146,7 @@ void logsql(struct clientparam * param, const unsigned char *s) {
|
|||||||
}
|
}
|
||||||
attempt = 0;
|
attempt = 0;
|
||||||
}
|
}
|
||||||
pthread_mutex_unlock(&log_mutex);
|
_3proxy_mutex_unlock(&log_mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@ -37,29 +37,19 @@ extern "C" {
|
|||||||
#define SASIZETYPE socklen_t
|
#define SASIZETYPE socklen_t
|
||||||
#define SOCKET int
|
#define SOCKET int
|
||||||
#define INVALID_SOCKET (-1)
|
#define INVALID_SOCKET (-1)
|
||||||
#ifdef WITH_LINUX_FUTEX
|
#define _3proxy_mutex_t pthread_mutex_t
|
||||||
#define _GNU_SOURCE
|
#define _3proxy_mutex_init(x) pthread_mutex_init(x,NULL)
|
||||||
#include <unistd.h>
|
#define _3proxy_mutex_destroy pthread_mutex_destroy
|
||||||
#include <sys/syscall.h>
|
#define _3proxy_mutex_lock pthread_mutex_lock
|
||||||
#include <linux/kernel.h>
|
#define _3proxy_mutex_unlock pthread_mutex_unlock
|
||||||
#include <linux/futex.h>
|
|
||||||
#define pthread_mutex_t int
|
|
||||||
#define pthread_mutex_init(x, y) (*(x)=0)
|
|
||||||
#define pthread_mutex_destroy(x) (*(x)=0)
|
|
||||||
#define pthread_mutex_lock(x) mutex_lock(x)
|
|
||||||
#define pthread_mutex_unlock(x) mutex_unlock(x)
|
|
||||||
int mutex_lock(int *val);
|
|
||||||
int mutex_unlock(int *val);
|
|
||||||
#else
|
|
||||||
#endif
|
|
||||||
#else
|
#else
|
||||||
#include <winsock2.h>
|
#include <winsock2.h>
|
||||||
#include <ws2tcpip.h>
|
#include <ws2tcpip.h>
|
||||||
#define pthread_mutex_t CRITICAL_SECTION
|
#define _3proxy_mutex_t CRITICAL_SECTION
|
||||||
#define pthread_mutex_init(x, y) InitializeCriticalSection(x)
|
#define _3proxy_mutex_init(x) InitializeCriticalSection(x)
|
||||||
#define pthread_mutex_lock(x) EnterCriticalSection(x)
|
#define _3proxy_mutex_lock(x) EnterCriticalSection(x)
|
||||||
#define pthread_mutex_unlock(x) LeaveCriticalSection(x)
|
#define _3proxy_mutex_unlock(x) LeaveCriticalSection(x)
|
||||||
#define pthread_mutex_destroy(x) DeleteCriticalSection(x)
|
#define _3proxy_mutex_destroy(x) DeleteCriticalSection(x)
|
||||||
#ifdef MSVC
|
#ifdef MSVC
|
||||||
#pragma warning (disable : 4996)
|
#pragma warning (disable : 4996)
|
||||||
#endif
|
#endif
|
||||||
@ -511,7 +501,7 @@ struct hashtable {
|
|||||||
uint32_t * ihashtable;
|
uint32_t * ihashtable;
|
||||||
uint8_t * hashvalues;
|
uint8_t * hashvalues;
|
||||||
uint8_t * hashhashvalues;
|
uint8_t * hashhashvalues;
|
||||||
pthread_mutex_t hash_mutex;
|
_3proxy_mutex_t hash_mutex;
|
||||||
time_t compacted;
|
time_t compacted;
|
||||||
uint32_t ihashhashempty;
|
uint32_t ihashhashempty;
|
||||||
uint32_t ihashempty;
|
uint32_t ihashempty;
|
||||||
@ -556,7 +546,7 @@ struct srvparam {
|
|||||||
PROXYSOCKADDRTYPE extsa6;
|
PROXYSOCKADDRTYPE extsa6;
|
||||||
#endif
|
#endif
|
||||||
PROXYSOCKADDRTYPE extsa;
|
PROXYSOCKADDRTYPE extsa;
|
||||||
pthread_mutex_t counter_mutex;
|
_3proxy_mutex_t counter_mutex;
|
||||||
struct pollfd fds;
|
struct pollfd fds;
|
||||||
FILE *stdlog;
|
FILE *stdlog;
|
||||||
unsigned char * target;
|
unsigned char * target;
|
||||||
@ -673,9 +663,9 @@ struct filemon {
|
|||||||
|
|
||||||
struct extparam {
|
struct extparam {
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
HANDLE threadinit[2];
|
HANDLE threadinit;
|
||||||
#else
|
#else
|
||||||
int threadinit[2];
|
_3proxy_mutex_t threadinit;
|
||||||
#endif
|
#endif
|
||||||
int *timeouts;
|
int *timeouts;
|
||||||
struct ace * acl;
|
struct ace * acl;
|
||||||
|
|||||||
13
src/udppm.c
13
src/udppm.c
@ -17,6 +17,19 @@
|
|||||||
#define RETURN(xxx) { param->res = xxx; goto CLEANRET; }
|
#define RETURN(xxx) { param->res = xxx; goto CLEANRET; }
|
||||||
|
|
||||||
|
|
||||||
|
static void udpparam2hash(const struct hashtable *ht, void *index, uint8_t *hash){
|
||||||
|
struct clientparam *param = (struct clientparam *)index;
|
||||||
|
uint32_t m1, m2;
|
||||||
|
m1 = murmurhash3(SAADDR(¶m->srv->intsa), SAADDRLEN(¶m->srv->intsa), 0x3a3a3a3a);
|
||||||
|
m1 = murmurhash3(SAPORT(¶m->sincr), 2, m1);
|
||||||
|
m2 = murmurhash3(SAADDR(¶m->sincr), SAADDRLEN(¶m->sincr), m1);
|
||||||
|
m2 = murmurhash3(SAPORT(¶m->srv->intsa), 2, m2);
|
||||||
|
memcpy(hash, &m1, 4);
|
||||||
|
memcpy(hash+4, &m2, 4);
|
||||||
|
}
|
||||||
|
|
||||||
|
struct hashtable udp_table = {udpparam2hash, udpparam2hash, sizeof(struct clientparam *), 8};
|
||||||
|
|
||||||
void * udppmchild(struct clientparam* param) {
|
void * udppmchild(struct clientparam* param) {
|
||||||
|
|
||||||
param->clisock = param->srv->srvsock;
|
param->clisock = param->srv->srvsock;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user