mirror of
https://github.com/3proxy/3proxy.git
synced 2026-04-29 07:30:11 +08:00
Return standalone udppm; do not build standalone modules by default in cmake
Allow to set prefix in cmake, 3proxy_ by default
This commit is contained in:
parent
6c3c5f31a2
commit
05096c222a
@ -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,23 @@ 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
|
||||||
|
)
|
||||||
|
# Module man pages — installed with binary prefix
|
||||||
|
foreach(_MAN proxy socks pop3p smtpp ftppr tcppm udppm tlspr)
|
||||||
|
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()
|
||||||
|
endforeach()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Summary
|
# Summary
|
||||||
@ -677,3 +748,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,24 @@ 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 -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,13 @@ 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-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,27 @@ 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 -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
|
||||||
|
|||||||
2
debian/3proxy.manpages
vendored
2
debian/3proxy.manpages
vendored
@ -1,5 +1,5 @@
|
|||||||
man/3proxy.8
|
man/3proxy.8
|
||||||
man/3proxy.cfg.3
|
man/3proxy.cfg.5
|
||||||
man/ftppr.8
|
man/ftppr.8
|
||||||
man/pop3p.8
|
man/pop3p.8
|
||||||
man/tlspr.8
|
man/tlspr.8
|
||||||
|
|||||||
@ -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
|
||||||
|
|
||||||
|
|||||||
@ -2,7 +2,12 @@
|
|||||||
# 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
|
# PREFIX: prefix for standalone module binaries (default: 3proxy_)
|
||||||
|
# CRYPT_PREFIX: prefix for crypt binary (default: same as PREFIX)
|
||||||
|
PREFIX ?= 3proxy_
|
||||||
|
CRYPT_PREFIX ?= $(PREFIX)
|
||||||
|
|
||||||
|
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
|
||||||
@ -27,50 +32,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 +134,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 +167,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)
|
||||||
|
|
||||||
|
|||||||
135
src/hash.c
135
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;
|
||||||
@ -273,99 +272,45 @@ void hashdelete(struct hashtable *ht, void *name){
|
|||||||
pthread_mutex_unlock(&ht->hash_mutex);
|
pthread_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};
|
||||||
@ -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;
|
||||||
|
|
||||||
|
|||||||
@ -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);
|
||||||
}
|
}
|
||||||
@ -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,7 +932,7 @@ 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);
|
||||||
@ -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;
|
||||||
|
|
||||||
|
|||||||
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