mirror of
https://github.com/3proxy/3proxy.git
synced 2026-11-26 23:59:41 +08:00
Compare commits
159
Commits
0.7
..
3proxy-0.8.1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3a4f3b5cd1 | ||
|
|
a6383bbd10 | ||
|
|
359026cb5f | ||
|
|
244be50405 | ||
|
|
e3fb268b64 | ||
|
|
5e440b4482 | ||
|
|
94f3b1fe30 | ||
|
|
ee407adf42 | ||
|
|
e5dd28003c | ||
|
|
fcbccf39ef | ||
|
|
928f67aed1 | ||
|
|
e59ccd22b1 | ||
|
|
75c63d2de6 | ||
|
|
999f9e856b | ||
|
|
08be6b9f98 | ||
|
|
0be4ee932b | ||
|
|
08aa876ecd | ||
|
|
87c947987c | ||
|
|
1ef7308cbf | ||
|
|
d1f8180eab | ||
|
|
1000d80fc0 | ||
|
|
27a190cd04 | ||
|
|
e78d9f8327 | ||
|
|
ae25aac635 | ||
|
|
b6dadc1954 | ||
|
|
8b7c95ff93 | ||
|
|
5a89997d6e | ||
|
|
c2d012bf71 | ||
|
|
b3923593ed | ||
|
|
9dd2170d6f | ||
|
|
bf934201bb | ||
|
|
5287278fa5 | ||
|
|
41f21485c7 | ||
|
|
93967af747 | ||
|
|
bef5b6f473 | ||
|
|
7f90b6eae2 | ||
|
|
9dda666d8d | ||
|
|
4c3f19cd20 | ||
|
|
889c5caa1f | ||
|
|
0e9cc9e330 | ||
|
|
47e8ba2e8d | ||
|
|
d49a19cb29 | ||
|
|
e312a1aa11 | ||
|
|
22e7d9cdae | ||
|
|
347d7736c7 | ||
|
|
d9271bfec8 | ||
|
|
b56702e670 | ||
|
|
9876172e0b | ||
|
|
7df2461a26 | ||
|
|
0487084161 | ||
|
|
a4e0f1fb9a | ||
|
|
fa2679555e | ||
|
|
c263428cf6 | ||
|
|
1be800c334 | ||
|
|
658e9b3a8a | ||
|
|
f1ab0771a9 | ||
|
|
fdb1fad9f7 | ||
|
|
40f9430623 | ||
|
|
d6df311ba7 | ||
|
|
da52669995 | ||
|
|
55fb037b48 | ||
|
|
bd37ffa2f7 | ||
|
|
1220c504bd | ||
|
|
b2e415b8cb | ||
|
|
4709f7a7b9 | ||
|
|
fcbb000b0e | ||
|
|
74772de341 | ||
|
|
271d9bb91a | ||
|
|
62775da1d5 | ||
|
|
0e4a507dd8 | ||
|
|
355d31f8aa | ||
|
|
54bcff710c | ||
|
|
6c187d167b | ||
|
|
4ab2da228b | ||
|
|
a4e54079b5 | ||
|
|
f1beddc85a | ||
|
|
3c6eef6bb0 | ||
|
|
3e6b230128 | ||
|
|
c538d0c2f8 | ||
|
|
a9ec5a085c | ||
|
|
a2b5af6dab | ||
|
|
6529b9cea1 | ||
|
|
d21f6b198d | ||
|
|
f88ea518b9 | ||
|
|
4ca8988831 | ||
|
|
3198f1614f | ||
|
|
59cc68e8dd | ||
|
|
ef67ef4072 | ||
|
|
184eede38a | ||
|
|
a93ffc825b | ||
|
|
2d6b43f488 | ||
|
|
1ab94fa002 | ||
|
|
d4f4e4a807 | ||
|
|
bc725189e3 | ||
|
|
aa4125a6f0 | ||
|
|
8e6d8b3314 | ||
|
|
252d481299 | ||
|
|
f287b94236 | ||
|
|
5787633665 | ||
|
|
522e6732fe | ||
|
|
7951de875a | ||
|
|
bf8522321f | ||
|
|
5844e165b5 | ||
|
|
7fc43e3fbd | ||
|
|
e37a7f48d7 | ||
|
|
50db0015d3 | ||
|
|
8a6632f0d1 | ||
|
|
d2437975b7 | ||
|
|
e39f4638cf | ||
|
|
042fc2afde | ||
|
|
a4cb2f36b5 | ||
|
|
efdbaee29f | ||
|
|
8c95f4efcf | ||
|
|
15f9f24f04 | ||
|
|
e3645ee971 | ||
|
|
f82d1e296b | ||
|
|
b5bcb44e27 | ||
|
|
278955deef | ||
|
|
7acf3cc4ed | ||
|
|
f70e4adf47 | ||
|
|
db5c4b1255 | ||
|
|
10bc0db2a8 | ||
|
|
c7310a2060 | ||
|
|
f1e017394d | ||
|
|
a425dc40b3 | ||
|
|
085b47d64e | ||
|
|
f8cefb989c | ||
|
|
ce6c2a069c | ||
|
|
1f5198a238 | ||
|
|
6b579b8190 | ||
|
|
9416012a01 | ||
|
|
5cccf7cbdd | ||
|
|
8975b00cce | ||
|
|
7bae6c4525 | ||
|
|
7ca32fc940 | ||
|
|
4fef3a1df0 | ||
|
|
a30d5d51a5 | ||
|
|
ccf606fd9e | ||
|
|
7897b009a1 | ||
|
|
bc7ca3af09 | ||
|
|
cce3a94f04 | ||
|
|
6b99de69c4 | ||
|
|
aad2559004 | ||
|
|
e3144dc61b | ||
|
|
9ab9c2524b | ||
|
|
cb590049b3 | ||
|
|
faf5b4b124 | ||
|
|
cb7d48c9c5 | ||
|
|
2eee9d2e98 | ||
|
|
17835c4d66 | ||
|
|
1b5fb4e8d4 | ||
|
|
f4c6c9d962 | ||
|
|
5543b3052d | ||
|
|
6a0b78268f | ||
|
|
c411e03126 | ||
|
|
90ca18b3c1 | ||
|
|
97d811fbfd | ||
|
|
2890f06488 | ||
|
|
467650bbbf |
No files matched your search
@@ -25,6 +25,7 @@ doc/html/index.html
|
|||||||
verfile.sh
|
verfile.sh
|
||||||
Makefile
|
Makefile
|
||||||
Changelog
|
Changelog
|
||||||
|
res
|
||||||
copytgz.sh
|
copytgz.sh
|
||||||
*~.nib
|
*~.nib
|
||||||
local.properties
|
local.properties
|
||||||
|
|||||||
BIN
Binary file not shown.
|
Before Width: | Height: | Size: 32 KiB After Width: | Height: | Size: 32 KiB |
@@ -3,8 +3,8 @@
|
|||||||
LANGUAGE 0x09, 0x01
|
LANGUAGE 0x09, 0x01
|
||||||
|
|
||||||
VS_VERSION_INFO VERSIONINFO
|
VS_VERSION_INFO VERSIONINFO
|
||||||
FILEVERSION 0,7,0,0
|
FILEVERSION 0,8,0,0
|
||||||
PRODUCTVERSION 0,7,0,0
|
PRODUCTVERSION 0,8,0,0
|
||||||
FILETYPE 0x1L
|
FILETYPE 0x1L
|
||||||
FILESUBTYPE 0x0L
|
FILESUBTYPE 0x0L
|
||||||
BEGIN
|
BEGIN
|
||||||
|
|||||||
+4
-10
@@ -1,4 +1,3 @@
|
|||||||
#$Id: Makefile.Linux,v 1.24 2014-04-07 20:34:57 vlad Exp $
|
|
||||||
#
|
#
|
||||||
# 3 proxy Makefile for GCC/Linux/Cygwin
|
# 3 proxy Makefile for GCC/Linux/Cygwin
|
||||||
#
|
#
|
||||||
@@ -11,17 +10,15 @@
|
|||||||
BUILDDIR =
|
BUILDDIR =
|
||||||
CC = gcc
|
CC = gcc
|
||||||
|
|
||||||
CFLAGS = -Wall -g -O2 -c -pthread -DGETHOSTBYNAME_R -D_THREAD_SAFE -D_REENTRANT -DNOODBC -DWITH_STD_MALLOC -DFD_SETSIZE=4096 -DWITH_POLL
|
CFLAGS = -g -O2 -c -pthread -DGETHOSTBYNAME_R -D_THREAD_SAFE -D_REENTRANT -DNOODBC -DWITH_STD_MALLOC -DFD_SETSIZE=4096 -DWITH_POLL
|
||||||
COUT = -o
|
COUT = -o
|
||||||
LN = gcc
|
LN = gcc
|
||||||
DCFLAGS = -fpic
|
DCFLAGS = -fpic
|
||||||
LDFLAGS = -Wall -O2 -pthread
|
LDFLAGS = -O2 -pthread
|
||||||
DLFLAGS = -shared
|
DLFLAGS = -shared
|
||||||
DLSUFFICS = .ld.so
|
DLSUFFICS = .ld.so
|
||||||
# -lpthreads may be reuqired on some platforms instead of -pthreads
|
# -lpthreads may be reuqired on some platforms instead of -pthreads
|
||||||
#LIBS = -lcrypto -lssl -ldl
|
LIBS = -lcrypto -lssl -ldl
|
||||||
# libcrypto and libssl are required for SSLPlugin
|
|
||||||
LIBS = -ldl
|
|
||||||
LNOUT = -o
|
LNOUT = -o
|
||||||
EXESUFFICS =
|
EXESUFFICS =
|
||||||
OBJSUFFICS = .o
|
OBJSUFFICS = .o
|
||||||
@@ -31,9 +28,7 @@ REMOVECOMMAND = rm -f
|
|||||||
TYPECOMMAND = cat
|
TYPECOMMAND = cat
|
||||||
COMPATLIBS =
|
COMPATLIBS =
|
||||||
MAKEFILE = Makefile.Linux
|
MAKEFILE = Makefile.Linux
|
||||||
#PLUGINS = SSLPlugin StringsPlugin TrafficPlugin PCREPlugin TransparentPlugin
|
PLUGINS = SSLPlugin StringsPlugin TrafficPlugin PCREPlugin TransparentPlugin
|
||||||
# SSLPlugin is not built by default because of external dependencies
|
|
||||||
PLUGINS = StringsPlugin TrafficPlugin PCREPlugin TransparentPlugin
|
|
||||||
|
|
||||||
include Makefile.inc
|
include Makefile.inc
|
||||||
|
|
||||||
@@ -49,7 +44,6 @@ 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 = src/3proxy \
|
INSTALL_OBJS = src/3proxy \
|
||||||
src/countersutil \
|
|
||||||
src/dighosts \
|
src/dighosts \
|
||||||
src/ftppr \
|
src/ftppr \
|
||||||
src/mycrypt \
|
src/mycrypt \
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
#$Id: Makefile.Solaris,v 1.18 2008/09/30 13:58:44 vlad Exp $
|
|
||||||
#
|
#
|
||||||
# 3 proxy Makefile for Solaris/SunCC
|
# 3 proxy Makefile for Solaris/SunCC
|
||||||
#
|
#
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
#$Id: Makefile.Solaris-gcc,v 1.14 2008/09/30 13:58:44 vlad Exp $
|
|
||||||
#
|
#
|
||||||
# 3 proxy Makefile for Solaris/gcc
|
# 3 proxy Makefile for Solaris/gcc
|
||||||
#
|
#
|
||||||
|
|||||||
+2
-3
@@ -1,4 +1,3 @@
|
|||||||
#$Id: Makefile.ccc,v 1.12 2007/04/10 16:29:25 vlad Exp $
|
|
||||||
#
|
#
|
||||||
# 3 proxy Makefile for Compaq C Compiler
|
# 3 proxy Makefile for Compaq C Compiler
|
||||||
#
|
#
|
||||||
@@ -10,10 +9,10 @@
|
|||||||
|
|
||||||
BUILDDIR =
|
BUILDDIR =
|
||||||
CC = ccc
|
CC = ccc
|
||||||
CFLAGS = -Wall -O2 -c -pthread -D_THREAD_SAFE -DNOODBC -DWITH_STD_MALLOC -DFD_SETSIZE=4096 -WITH_POLL
|
CFLAGS = -O2 -c -pthread -D_THREAD_SAFE -DNOODBC -DWITH_STD_MALLOC -DFD_SETSIZE=4096 -WITH_POLL
|
||||||
COUT = -o
|
COUT = -o
|
||||||
LN = ccc
|
LN = ccc
|
||||||
LDFLAGS = -Wall -O2 -pthread
|
LDFLAGS = -O2 -pthread
|
||||||
DCFLAGS = -fpic
|
DCFLAGS = -fpic
|
||||||
DLFLAGS = -shared
|
DLFLAGS = -shared
|
||||||
DLSUFFICS = .ld.so
|
DLSUFFICS = .ld.so
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
#$Id: Makefile.debug,v 1.7 2007/04/18 05:33:19 vlad Exp $
|
|
||||||
#
|
#
|
||||||
# 3 proxy Makefile for Microsoft Visual C compiler (for both make and nmake)
|
# 3 proxy Makefile for Microsoft Visual C compiler (for both make and nmake)
|
||||||
#
|
#
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
#$Id: Makefile.inc,v 1.3 2007/01/23 16:00:26 vlad Exp $
|
|
||||||
#
|
#
|
||||||
# 3 proxy common Makefile
|
# 3 proxy common Makefile
|
||||||
#
|
#
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
#$Id: Makefile.intl,v 1.8 2007/07/21 18:47:00 vlad Exp $
|
|
||||||
#
|
#
|
||||||
# 3 proxy Makefile for Intel C compiler for Windows (for both make and nmake)
|
# 3 proxy Makefile for Intel C compiler for Windows (for both make and nmake)
|
||||||
#
|
#
|
||||||
|
|||||||
+4
-5
@@ -1,4 +1,3 @@
|
|||||||
#$Id: Makefile.msvc,v 1.17 2010-11-11 14:44:11 v.dubrovin Exp $
|
|
||||||
#
|
#
|
||||||
# 3 proxy Makefile for Microsoft Visual C compiler (for both make and nmake)
|
# 3 proxy Makefile for Microsoft Visual C compiler (for both make and nmake)
|
||||||
#
|
#
|
||||||
@@ -15,7 +14,7 @@ LN = link
|
|||||||
LDFLAGS = /nologo /subsystem:console /incremental:no /machine:I386
|
LDFLAGS = /nologo /subsystem:console /incremental:no /machine:I386
|
||||||
DLFLAGS = /DLL
|
DLFLAGS = /DLL
|
||||||
DLSUFFICS = .dll
|
DLSUFFICS = .dll
|
||||||
LIBS = ws2_32.lib advapi32.lib odbc32.lib user32.lib kernel32.lib Gdi32.lib
|
LIBS = ws2_32.lib advapi32.lib odbc32.lib user32.lib kernel32.lib Gdi32.lib libeay32MT.lib ssleay32MT.lib
|
||||||
LIBSOLD = libeay32MT.lib ssleay32MT.lib
|
LIBSOLD = libeay32MT.lib ssleay32MT.lib
|
||||||
LIBEXT = .lib
|
LIBEXT = .lib
|
||||||
LNOUT = /out:
|
LNOUT = /out:
|
||||||
@@ -27,8 +26,8 @@ REMOVECOMMAND = del 2>NUL >NUL
|
|||||||
TYPECOMMAND = type
|
TYPECOMMAND = type
|
||||||
COMPATLIBS =
|
COMPATLIBS =
|
||||||
MAKEFILE = Makefile.msvc
|
MAKEFILE = Makefile.msvc
|
||||||
PLUGINS = utf8tocp1251 WindowsAuthentication TrafficPlugin StringsPlugin PCREPlugin lastFripper FilePlugin
|
PLUGINS = utf8tocp1251 WindowsAuthentication TrafficPlugin StringsPlugin PCREPlugin FilePlugin SSLPlugin
|
||||||
VERFILE = 3proxyres.obj $(VERFILE)
|
VERFILE = $(VERFILE)
|
||||||
|
|
||||||
include Makefile.inc
|
include Makefile.inc
|
||||||
|
|
||||||
@@ -36,7 +35,7 @@ include Makefile.inc
|
|||||||
rc /fo../3proxy.res ../3proxy.rc
|
rc /fo../3proxy.res ../3proxy.rc
|
||||||
|
|
||||||
3proxyres.obj: ../3proxy.res
|
3proxyres.obj: ../3proxy.res
|
||||||
cvtres /out:3proxyres.obj /MACHINE:X86 ../3proxy.res
|
cvtres /out:3proxyres.obj /MACHINE:I386 ../3proxy.res
|
||||||
|
|
||||||
allplugins:
|
allplugins:
|
||||||
for /D %%i in ($(PLUGINS)) do (copy Makefile plugins\%%i && copy Makefile.var plugins\%%i && cd plugins\%%i && nmake && del *.obj *.idb &&cd ..\..)
|
for /D %%i in ($(PLUGINS)) do (copy Makefile plugins\%%i && copy Makefile.var plugins\%%i && cd plugins\%%i && nmake && del *.obj *.idb &&cd ..\..)
|
||||||
|
|||||||
+11
-5
@@ -1,4 +1,3 @@
|
|||||||
#$Id: Makefile.msvc64,v 1.14 2007/07/21 18:47:05 vlad Exp $
|
|
||||||
#
|
#
|
||||||
# 3 proxy Makefile for Microsoft Visual C compiler (for both make and nmake)
|
# 3 proxy Makefile for Microsoft Visual C compiler (for both make and nmake)
|
||||||
#
|
#
|
||||||
@@ -15,7 +14,7 @@ LN = link
|
|||||||
LDFLAGS = /nologo /subsystem:console /incremental:no /machine:x64
|
LDFLAGS = /nologo /subsystem:console /incremental:no /machine:x64
|
||||||
DLFLAGS = /DLL
|
DLFLAGS = /DLL
|
||||||
DLSUFFICS = .dll
|
DLSUFFICS = .dll
|
||||||
LIBS = ws2_32.lib advapi32.lib odbc32.lib user32.lib kernel32.lib Gdi32.lib
|
LIBS = ws2_32.lib advapi32.lib odbc32.lib user32.lib kernel32.lib Gdi32.lib libeay32MT.lib ssleay32MT.lib
|
||||||
LIBSOLD = libeay32MT.lib ssleay32MT.lib
|
LIBSOLD = libeay32MT.lib ssleay32MT.lib
|
||||||
LIBEXT = .lib
|
LIBEXT = .lib
|
||||||
LNOUT = /out:
|
LNOUT = /out:
|
||||||
@@ -27,8 +26,14 @@ REMOVECOMMAND = del 2>NUL >NUL
|
|||||||
TYPECOMMAND = type
|
TYPECOMMAND = type
|
||||||
COMPATLIBS =
|
COMPATLIBS =
|
||||||
MAKEFILE = Makefile.msvc64
|
MAKEFILE = Makefile.msvc64
|
||||||
PLUGINS = utf8tocp1251 WindowsAuthentication TrafficPlugin StringsPlugin PCREPlugin
|
PLUGINS = utf8tocp1251 WindowsAuthentication TrafficPlugin StringsPlugin PCREPlugin FilePlugin SSLPlugin
|
||||||
VERFILE = 3proxyres.obj $(VERFILE)
|
VERFILE = $(VERFILE)
|
||||||
|
|
||||||
|
#../3proxy.res:
|
||||||
|
# rc /fo../3proxy.res ../3proxy.rc
|
||||||
|
|
||||||
|
#3proxyres.obj: ../3proxy.res
|
||||||
|
# cvtres /out:3proxyres.obj /MACHINE:X64 ../3proxy.res
|
||||||
|
|
||||||
include Makefile.inc
|
include Makefile.inc
|
||||||
|
|
||||||
@@ -36,7 +41,8 @@ include Makefile.inc
|
|||||||
rc /fo../3proxy.res ../3proxy.rc
|
rc /fo../3proxy.res ../3proxy.rc
|
||||||
|
|
||||||
3proxyres.obj: ../3proxy.res
|
3proxyres.obj: ../3proxy.res
|
||||||
cvtres /out:3proxyres.obj /MACHINE:X64 ../3proxy.res
|
cvtres /out:3proxyres.obj /machine:x64 ../3proxy.res
|
||||||
|
|
||||||
|
|
||||||
allplugins:
|
allplugins:
|
||||||
for /D %%i in ($(PLUGINS)) do (copy Makefile plugins\%%i && copy Makefile.var plugins\%%i && cd plugins\%%i && nmake && del *.obj *.idb &&cd ..\..)
|
for /D %%i in ($(PLUGINS)) do (copy Makefile plugins\%%i && copy Makefile.var plugins\%%i && cd plugins\%%i && nmake && del *.obj *.idb &&cd ..\..)
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
#$Id: Makefile.msvc,v 1.14 2007/07/21 18:47:02 vlad Exp $
|
|
||||||
#
|
#
|
||||||
# 3 proxy Makefile for Microsoft Visual C compiler (for both make and nmake)
|
# 3 proxy Makefile for Microsoft Visual C compiler (for both make and nmake)
|
||||||
#
|
#
|
||||||
|
|||||||
+2
-3
@@ -1,4 +1,3 @@
|
|||||||
#$Id: Makefile.unix,v 1.20 2007/04/10 16:29:25 vlad Exp $
|
|
||||||
#
|
#
|
||||||
# 3 proxy Makefile for GCC/Unix
|
# 3 proxy Makefile for GCC/Unix
|
||||||
#
|
#
|
||||||
@@ -12,10 +11,10 @@ BUILDDIR =
|
|||||||
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
|
||||||
CFLAGS = -Wall -g -O2 -c -pthread -D_THREAD_SAFE -D_REENTRANT -DNOODBC -DWITH_STD_MALLOC -DFD_SETSIZE=4096 -DWITH_POLL
|
CFLAGS = -g -O2 -c -pthread -D_THREAD_SAFE -D_REENTRANT -DNOODBC -DWITH_STD_MALLOC -DFD_SETSIZE=4096 -DWITH_POLL
|
||||||
COUT = -o
|
COUT = -o
|
||||||
LN = gcc
|
LN = gcc
|
||||||
LDFLAGS = -Wall -O2 -pthread
|
LDFLAGS = -O2 -pthread
|
||||||
# -lpthreads may be reuqired on some platforms instead of -pthreads
|
# -lpthreads may be reuqired on some platforms instead of -pthreads
|
||||||
# -ldl or -lld may be required for some platforms
|
# -ldl or -lld may be required for some platforms
|
||||||
DCFLAGS = -fpic
|
DCFLAGS = -fpic
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ 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 = src/3proxy \
|
INSTALL_OBJS = src/3proxy \
|
||||||
src/countersutil \
|
|
||||||
src/dighosts \
|
src/dighosts \
|
||||||
src/ftppr \
|
src/ftppr \
|
||||||
src/mycrypt \
|
src/mycrypt \
|
||||||
|
|||||||
+1
-2
@@ -1,4 +1,3 @@
|
|||||||
#$Id: Makefile.win,v 1.9 2007/08/20 15:26:27 vlad Exp $
|
|
||||||
#
|
#
|
||||||
# 3 proxy Makefile for GCC/windows
|
# 3 proxy Makefile for GCC/windows
|
||||||
#
|
#
|
||||||
@@ -11,7 +10,7 @@
|
|||||||
|
|
||||||
BUILDDIR = ../bin/
|
BUILDDIR = ../bin/
|
||||||
CC = gcc
|
CC = gcc
|
||||||
CFLAGS = -O2 -s -c -mthreads -DWITH_STD_MALLOC
|
CFLAGS = -O2 -s -c -mthreads -DWITH_STD_MALLOC -DNOIPV6
|
||||||
COUT = -o
|
COUT = -o
|
||||||
LN = gcc
|
LN = gcc
|
||||||
LDFLAGS = -O2 -s -mthreads
|
LDFLAGS = -O2 -s -mthreads
|
||||||
|
|||||||
+2
-3
@@ -1,4 +1,3 @@
|
|||||||
#$Id: Makefile.win,v 1.9 2007/08/20 15:26:27 vlad Exp $
|
|
||||||
#
|
#
|
||||||
# 3 proxy Makefile for GCC/windows
|
# 3 proxy Makefile for GCC/windows
|
||||||
#
|
#
|
||||||
@@ -11,10 +10,10 @@
|
|||||||
|
|
||||||
BUILDDIR = ../bin/
|
BUILDDIR = ../bin/
|
||||||
CC = /opt/cegcc/arm-wince-cegcc/bin/gcc
|
CC = /opt/cegcc/arm-wince-cegcc/bin/gcc
|
||||||
CFLAGS = -Wall -O2 -s -c -mthreads -DWITH_STD_MALLOC -DNOODBC -D_WINCE -D_WIN32 -D__USE_W32_SOCKETS
|
CFLAGS = -O2 -s -c -mthreads -DWITH_STD_MALLOC -DNOODBC -D_WINCE -D_WIN32 -D__USE_W32_SOCKETS
|
||||||
COUT = -o
|
COUT = -o
|
||||||
LN = /opt/cegcc/arm-wince-cegcc/bin/gcc
|
LN = /opt/cegcc/arm-wince-cegcc/bin/gcc
|
||||||
LDFLAGS = -Wall -O2 -s -mthreads
|
LDFLAGS = -O2 -s -mthreads
|
||||||
DLFLAGS = -shared
|
DLFLAGS = -shared
|
||||||
DLSUFFICS = .dll
|
DLSUFFICS = .dll
|
||||||
LIBS = -lws2
|
LIBS = -lws2
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
3APA3A 3proxy tiny proxy server
|
3APA3A 3proxy tiny proxy server
|
||||||
(c) 2002-2014 by Vladimir '3APA3A' Dubrovin <3proxy@3proxy.ru>
|
(c) 2002-2016 by Vladimir '3APA3A' Dubrovin <3proxy@3proxy.ru>
|
||||||
|
|
||||||
please read License Agreement
|
please read License Agreement
|
||||||
*/
|
*/
|
||||||
@@ -39,7 +39,6 @@ smtpp SMTP proxy server, binds to port 25. You must specify
|
|||||||
icqpr ICQ/AIM proxy. Maps some TCP port to TCP port of ICQ
|
icqpr ICQ/AIM proxy. Maps some TCP port to TCP port of ICQ
|
||||||
server and performs packets translation. Example:
|
server and performs packets translation. Example:
|
||||||
icqpr 5190 login.icq.com 5190
|
icqpr 5190 login.icq.com 5190
|
||||||
msnpr MSN proxy (beta)
|
|
||||||
tcppm TCP port mapping. Maps some TCP port on local machine to
|
tcppm TCP port mapping. Maps some TCP port on local machine to
|
||||||
TCP port on remote host.
|
TCP port on remote host.
|
||||||
udppm UDP port mapping. Maps some UDP port on local machine to
|
udppm UDP port mapping. Maps some UDP port on local machine to
|
||||||
@@ -56,9 +55,10 @@ mycrypt Program to obtain crypted password fro cleartext. Supports
|
|||||||
mycrypt salt password
|
mycrypt salt password
|
||||||
produces MD5/crypt password with salt "salt".
|
produces MD5/crypt password with salt "salt".
|
||||||
dighosts Utility for building networks list from web page.
|
dighosts Utility for building networks list from web page.
|
||||||
countersutil Utility to manage counters file
|
|
||||||
|
|
||||||
|
|
||||||
Run utility with --help option for command line reference.
|
Run utility with --help option for command line reference.
|
||||||
|
|
||||||
Latest version is available from http://3proxy.ru/
|
Latest version is available from http://3proxy.ru/
|
||||||
|
|
||||||
|
Want to donate the project? http://3proxy.ru/donations/
|
||||||
@@ -104,4 +104,3 @@
|
|||||||
- Addon antiviral, HTTP cache filters modules, authentication
|
- Addon antiviral, HTTP cache filters modules, authentication
|
||||||
modules for different protocols (RADIUS, PAM etc).
|
modules for different protocols (RADIUS, PAM etc).
|
||||||
|
|
||||||
$Id: Release.notes,v 1.9 2014-04-07 21:24:42 vlad Exp $
|
|
||||||
@@ -15,4 +15,3 @@ on the provider's Web server.
|
|||||||
Provider has proxy server 10.1.2.5. Traffic from proxy server is not free, but
|
Provider has proxy server 10.1.2.5. Traffic from proxy server is not free, but
|
||||||
is cheaper than traffic from non-free networks.
|
is cheaper than traffic from non-free networks.
|
||||||
|
|
||||||
$Id: 0.scenario.txt,v 1.2 2004/07/23 13:33:39 vlad Exp $
|
|
||||||
@@ -199,4 +199,3 @@ admin
|
|||||||
# now we needn't any root rights. We can chroot and setgid/setuid.
|
# now we needn't any root rights. We can chroot and setgid/setuid.
|
||||||
|
|
||||||
|
|
||||||
###$Id: 3proxy.cfg.sample,v 1.7 2006/11/18 14:37:06 vlad Exp $#######
|
|
||||||
@@ -50,4 +50,3 @@ internal 127.0.0.1
|
|||||||
allow user1
|
allow user1
|
||||||
admin
|
admin
|
||||||
|
|
||||||
#$Id: counters.sample,v 1.2 2004/07/23 13:33:39 vlad Exp $
|
|
||||||
@@ -59,4 +59,3 @@ terms of compatible license, including:
|
|||||||
http://www.gnu.org/licenses/lgpl.txt
|
http://www.gnu.org/licenses/lgpl.txt
|
||||||
|
|
||||||
|
|
||||||
$Id: License,v 1.3 2007/04/05 11:59:47 vlad Exp $
|
|
||||||
@@ -153,6 +153,3 @@ A: First, I'm not programmer. Second, 3proxy was 'proof of concept' in reply for
|
|||||||
|
|
||||||
<p><i>Q: Why do you use insecure strcpy, sprintf, etc?</i></p>
|
<p><i>Q: Why do you use insecure strcpy, sprintf, etc?</i></p>
|
||||||
A: Why not? I try to use insecure function in secure manner. You're welcome to look for vulnerabilities.
|
A: Why not? I try to use insecure function in secure manner. You're welcome to look for vulnerabilities.
|
||||||
<pre>
|
|
||||||
$Id: faqe.html,v 1.10 2007/07/31 08:42:38 vlad Exp $
|
|
||||||
</pre>
|
|
||||||
+183
-186
@@ -1,283 +1,280 @@
|
|||||||
<meta http-equiv="Content-Type" content="text/html; charset=windows-1251">
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||||
3APA3A 3proxy tiny proxy server Frequently Asked Questions (FAQ)
|
3APA3A 3proxy tiny proxy server Frequently Asked Questions (FAQ)
|
||||||
<ul>
|
<ul>
|
||||||
<li><a href="#TROUBLE">Почему не работает...</a></li>
|
<li><a href="#TROUBLE">Почему не работает...</a></li>
|
||||||
<ul>
|
<ul>
|
||||||
<li><a href="#NOTHING">Q: Почему ничего не работает?</a></li>
|
<li><a href="#NOTHING">Q: Почему ничего не работает?</a></li>
|
||||||
<li><a href="#LIMITS">Q: Почему не работают ограничения доступа (перенаправления, ограничения по скорости, трафику и т.д.)?</a></li>
|
<li><a href="#LIMITS">Q: Почему не работают ограничения доступа (перенаправления, ограничения по скорости, трафику и т.д.)?</a></li>
|
||||||
<li><a href="#SERVICE">Q: Почему 3proxy не запускается как служба?</a></li>
|
<li><a href="#SERVICE">Q: Почему 3proxy не запускается как служба?</a></li>
|
||||||
<li><a href="#INTEXT">Q: Почему не получается указать internal и external?</a></li>
|
<li><a href="#INTEXT">Q: Почему не получается указать internal и external?</a></li>
|
||||||
<li><a href="#ODBC">Q: Почему не работает ведение журналов в ODBC?</a></li>
|
<li><a href="#ODBC">Q: Почему не работает ведение журналов в ODBC?</a></li>
|
||||||
<li><a href="#CHAP">Q: Почему не поддерживаются APOP и CRAM-MD5 в POP3 прокси?</a></li>
|
<li><a href="#CHAP">Q: Почему не поддерживаются APOP и CRAM-MD5 в POP3 прокси?</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
<li><a href="#SOCKSREDIR">Перенаправление socks соединений в локальный прокси</a></li>
|
<li><a href="#SOCKSREDIR">Перенаправление socks соединений в локальный прокси</a></li>
|
||||||
<ul>
|
<ul>
|
||||||
<li><a href="#REDIR">Q: Для чего это надо?</a></li>
|
<li><a href="#REDIR">Q: Для чего это надо?</a></li>
|
||||||
<li><a href="#REDIRLIMIT">Q: Какие недостатки?</a></li>
|
<li><a href="#REDIRLIMIT">Q: Какие недостатки?</a></li>
|
||||||
<li><a href="#REDIRADV">Q: Какие преимущества?</a></li>
|
<li><a href="#REDIRADV">Q: Какие преимущества?</a></li>
|
||||||
<li><a href="#REDIRHOW">Q: Как настраивается?</a></li>
|
<li><a href="#REDIRHOW">Q: Как настраивается?</a></li>
|
||||||
<li><a href="#REDIINTER">Q: Как взаимодействует с другими правилами в ACL?</a></li>
|
<li><a href="#REDIINTER">Q: Как взаимодействует с другими правилами в ACL?</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
<li><a href="#ISIT">А есть ли...</a></li>
|
<li><a href="#ISIT">А есть ли...</a></li>
|
||||||
<ul>
|
<ul>
|
||||||
<li><a href="#NAMES">Можно ли разрешать имена на родительском прокси?</a></li>
|
<li><a href="#NAMES">Можно ли разрешать имена на родительском прокси?</a></li>
|
||||||
<li><a href="#ISFTP">Существует ли сейчас поддержка FTP прокси в продукте?</a></li>
|
<li><a href="#ISFTP">Существует ли сейчас поддержка FTP прокси в продукте?</a></li>
|
||||||
<li><a href="#PORT">Каким образом можно прибиндить сервисы на свой порт, к примеру, HTTP прокси к 8080, а не 3128 как по-умолчанию?</a></li>
|
<li><a href="#PORT">Каким образом можно прибиндить сервисы на свой порт, к примеру, HTTP прокси к 8080, а не 3128 как по-умолчанию?</a></li>
|
||||||
<li><a href="#BANDLIM">Как ограничить ширину канала?</a></li>
|
<li><a href="#BANDLIM">Как ограничить ширину канала?</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
<li><a href="#BRRR">Почему так криво...</a></li>
|
<li><a href="#BRRR">Почему так криво...</a></li>
|
||||||
<ul>
|
<ul>
|
||||||
<li><a href="#TRAF">Почему так криво считается трафик? Не совпадает с ...</a></li>
|
<li><a href="#TRAF">Почему так криво считается трафик? Не совпадает с ...</a></li>
|
||||||
<li><a href="#CONFIG">Почему такая кривая конфигурация и ничерта не понятно?</a></li>
|
<li><a href="#CONFIG">Почему такая кривая конфигурация и ничерта не понятно?</a></li>
|
||||||
<li><a href="#CODE">Почему так криво написан код?</a>
|
<li><a href="#CODE">Почему так криво написан код?</a>
|
||||||
<li><a href="#UNSAFE">Почему так много strcpy, sprintf и т.д., это ж дыры!</a>
|
<li><a href="#UNSAFE">Почему так много strcpy, sprintf и т.д., это ж дыры!</a>
|
||||||
</ul>
|
</ul>
|
||||||
</ul>
|
</ul>
|
||||||
<hr>
|
<hr>
|
||||||
<li><b><a name="TROUBLE">Почему не работает...<a></b></li>
|
<li><b><a name="TROUBLE">Почему не работает...<a></b></li>
|
||||||
<ul>
|
<ul>
|
||||||
<li><a name="NOTHING"><i>Q: Почему ничего не работает?</i></a></li>
|
<li><a name="NOTHING"><i>Q: Почему ничего не работает?</i></a></li>
|
||||||
<p>
|
<p>
|
||||||
<i>A:</i> Потому что для работы нужен правильный файл конфигурации.
|
<i>A:</i> Потому что для работы нужен правильный файл конфигурации.
|
||||||
</p>
|
</p>
|
||||||
<li><a name="LIMITS"><i>Q: Почему не работают ограничения доступа (перенаправления, ограничения по скорости,
|
<li><a name="LIMITS"><i>Q: Почему не работают ограничения доступа (перенаправления, ограничения по скорости,
|
||||||
трафику и т.д.)?</i></a></li>
|
трафику и т.д.)?</i></a></li>
|
||||||
<p>
|
<p>
|
||||||
<i>A:</i> Обычные ошибки - использование auth none (для работы любых
|
<i>A:</i> Обычные ошибки - использование auth none (для работы любых
|
||||||
функций, основанных на ACL, требуется auth iponly, nbname или strong),
|
функций, основанных на ACL, требуется auth iponly, nbname или strong),
|
||||||
нарушение порядка ввода команд (команды выполняются последовательно,
|
нарушение порядка ввода команд (команды выполняются последовательно,
|
||||||
запуск сервиса proxy, socks, tcppm и т.д. должен осуществляться после
|
запуск сервиса proxy, socks, tcppm и т.д. должен осуществляться после
|
||||||
того, как указана его конфигурация), неправильный порядок записей в ACL
|
того, как указана его конфигурация), неправильный порядок записей в ACL
|
||||||
(записи просматриваются последовательно до первой, удовлетворяющей
|
(записи просматриваются последовательно до первой, удовлетворяющей
|
||||||
критериям). Если в ACL имеется хотя бы одна запись, то считается, что
|
критериям). Если в ACL имеется хотя бы одна запись, то считается, что
|
||||||
последняя запись в ACL - это неявная deny *.
|
последняя запись в ACL - это неявная deny *.
|
||||||
</p>
|
</p>
|
||||||
<li><a name="SERVICE"><i>Q: Почему 3proxy не запускается как служба?</i></a></li>
|
<li><a name="SERVICE"><i>Q: Почему 3proxy не запускается как служба?</i></a></li>
|
||||||
<p>
|
<p>
|
||||||
<i>A:</i> Наиболее вероятные причины:
|
<i>A:</i> Наиболее вероятные причины:
|
||||||
<ul>
|
<ul>
|
||||||
<li>Отсутствие команды service в файле конфигурации - команда необходима в 3proxy 0.5.2 и более ранних, чтобы 3proxy вел себя как системная служба Windows
|
<li>Отсутствие команды service в файле конфигурации - команда необходима в 3proxy 0.5.2 и более ранних, чтобы 3proxy вел себя как системная служба Windows
|
||||||
<li>Использование относительных (неполных) путей файлов в файле конфигурации
|
<li>Использование относительных (неполных) путей файлов в файле конфигурации
|
||||||
При использовании файлов журналов, файлов вставок ($filename) используйте
|
При использовании файлов журналов, файлов вставок ($filename) используйте
|
||||||
полные пути, например, $"c:\3proxy\include files\networks.local". Тоже самое
|
полные пути, например, $"c:\3proxy\include files\networks.local". Тоже самое
|
||||||
относится к файлам журналов и любым другим.
|
относится к файлам журналов и любым другим.
|
||||||
Для отладки лучше запускать 3proxy с ведением журнала на стандартный вывод.
|
Для отладки лучше запускать 3proxy с ведением журнала на стандартный вывод.
|
||||||
Не забудьте в таком случае отключить daemon и service в файле конфигурации.
|
Не забудьте в таком случае отключить daemon и service в файле конфигурации.
|
||||||
Для чистоты эксперимента запускать 3proxy из коммандной строки в таком случае
|
Для чистоты эксперимента запускать 3proxy из коммандной строки в таком случае
|
||||||
следует, находясь в другой папке.
|
следует, находясь в другой папке.
|
||||||
<li>Отсутствие у системной записи прав на доступ к исполняемому файлу, каким-либо файлам конфигурации, журнала и т.п.
|
<li>Отсутствие у системной записи прав на доступ к исполняемому файлу, каким-либо файлам конфигурации, журнала и т.п.
|
||||||
<li>Отсутствие файла конфигурации по стандартному расположению -
|
<li>Отсутствие файла конфигурации по стандартному расположению -
|
||||||
3proxy.cfg в одном каталоге с исполняемым файлом. Если файл расположен по
|
3proxy.cfg в одном каталоге с исполняемым файлом. Если файл расположен по
|
||||||
другому пути, необходимо использовать команду
|
другому пути, необходимо использовать команду
|
||||||
<pre>
|
<pre>
|
||||||
3proxy --install path_to_configuration_file</pre>
|
3proxy --install path_to_configuration_file</pre>
|
||||||
<li>Отсутствие у пользователя прав на установку или запуск службы
|
<li>Отсутствие у пользователя прав на установку или запуск службы
|
||||||
<li>Служба уже установлена или запущена
|
<li>Служба уже установлена или запущена
|
||||||
</ul>
|
</ul>
|
||||||
</p>
|
</p>
|
||||||
<li><a name="INTEXT"><i>Q: Почему не получается указать internal и external?</i></a></li></li>
|
<li><a name="INTEXT"><i>Q: Почему не получается указать internal и external?</i></a></li></li>
|
||||||
<p>
|
<p>
|
||||||
<i>A:</i> Убедитесь, что выправильно понимаете что такое internal и external адреса.
|
<i>A:</i> Убедитесь, что выправильно понимаете что такое internal и external адреса.
|
||||||
Оба адреса - это адреса, принадлежищие хосту, на котором установлен 3proxy.
|
Оба адреса - это адреса, принадлежищие хосту, на котором установлен 3proxy.
|
||||||
Эта опция конфигурации необходима в классической ситуации, когда 3proxy
|
Эта опция конфигурации необходима в классической ситуации, когда 3proxy
|
||||||
установлен на граничном компьютере с двумя (или более) подключениями:
|
установлен на граничном компьютере с двумя (или более) подключениями:
|
||||||
<pre>
|
<pre>
|
||||||
LAN connection +-------------+ Internet connection
|
LAN connection +-------------+ Internet connection
|
||||||
LAN <-------------->| 3proxy host |<-------------------> INTERNET
|
LAN <-------------->| 3proxy host |<-------------------> INTERNET
|
||||||
^+-------------+^
|
^+-------------+^
|
||||||
| |
|
| |
|
||||||
Internal IP External IP</pre>
|
Internal IP External IP</pre>
|
||||||
Если 3proxy работает на хосте с одним интерфейсом, то его адрес будет и
|
Если 3proxy работает на хосте с одним интерфейсом, то его адрес будет и
|
||||||
internal и external.
|
internal и external.
|
||||||
<br>Интерфейс с адресом internal должен существовать и быть рабочим на момент
|
<br>Интерфейс с адресом internal должен существовать и быть рабочим на момент
|
||||||
запуска 3proxy, и не должен отключаться. Если internal интерфейс
|
запуска 3proxy, и не должен отключаться. Если internal интерфейс
|
||||||
периодически отключается, то не следует его указывать, или можно указать адрес
|
периодически отключается, то не следует его указывать, или можно указать адрес
|
||||||
0.0.0.0. При этом прокси будет принимать запросы на всех интерфейсах, поэтому
|
0.0.0.0. При этом прокси будет принимать запросы на всех интерфейсах, поэтому
|
||||||
при наличии нескольких интерфейсов для ограничения доступа следует использовать
|
при наличии нескольких интерфейсов для ограничения доступа следует использовать
|
||||||
фаервол или хотя бы ACL.
|
фаервол или хотя бы ACL.
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
Интерфейс с адресом external, если он указан, должен быть рабочим на момент
|
Интерфейс с адресом external, если он указан, должен быть рабочим на момент
|
||||||
получения запроса клиента. При отсутствии external или адресе 0.0.0.0 внешний
|
получения запроса клиента. При отсутствии external или адресе 0.0.0.0 внешний
|
||||||
адрес будет выбираться системой при установке соединения. При этом, может быть
|
адрес будет выбираться системой при установке соединения. При этом, может быть
|
||||||
возможность доступа через прокси к ресурсам локальной сети, поэтому для
|
возможность доступа через прокси к ресурсам локальной сети, поэтому для
|
||||||
предотвращения несанкционированного доступа следует использовать ACL. Кроме
|
предотвращения несанкционированного доступа следует использовать ACL. Кроме
|
||||||
того, могут быть проблемы с приемом входящих соединений через SOCKSv5
|
того, могут быть проблемы с приемом входящих соединений через SOCKSv5
|
||||||
(SOCKSv5 используется в клиентах исключительно редко).
|
(SOCKSv5 используется в клиентах исключительно редко).
|
||||||
В случае, если адрес динамический, можно либо не
|
В случае, если адрес динамический, можно либо не
|
||||||
указывать external, либо использовать адрес 0.0.0.0, либо, если необходима
|
указывать external, либо использовать адрес 0.0.0.0, либо, если необходима
|
||||||
поддержка входящих соединений в SOCKSv5, использовать скрипт,
|
поддержка входящих соединений в SOCKSv5, использовать скрипт,
|
||||||
который будет получать текущий адрес и сохранять его в файл, который будет
|
который будет получать текущий адрес и сохранять его в файл, который будет
|
||||||
отслуживаться через команду monitor.
|
отслуживаться через команду monitor.
|
||||||
</p>
|
</p>
|
||||||
<li><a name="ODBC"><i>Q: Почему не работает ведение журналов в ODBC?</i></a></li>
|
<li><a name="ODBC"><i>Q: Почему не работает ведение журналов в ODBC?</i></a></li>
|
||||||
<p>
|
<p>
|
||||||
<i>A:</i> Убедитесь, что используется системный, а не
|
<i>A:</i> Убедитесь, что используется системный, а не
|
||||||
пользовательский DSN. Убедитесь, что выполняется правильный SQL запрос. Наиболее
|
пользовательский DSN. Убедитесь, что выполняется правильный SQL запрос. Наиболее
|
||||||
распространенная проблема связана с отсутствием кавычек или неправильным
|
распространенная проблема связана с отсутствием кавычек или неправильным
|
||||||
форматом данных. Самый простой способ - сделать ведение журнала в файл или
|
форматом данных. Самый простой способ - сделать ведение журнала в файл или
|
||||||
на стандартный вывод, просмотреть выдаваемые SQL запросы и попробовать
|
на стандартный вывод, просмотреть выдаваемые SQL запросы и попробовать
|
||||||
дать такой запрос вручную.
|
дать такой запрос вручную.
|
||||||
</p>
|
</p>
|
||||||
<li><a name="CHAP"><i>Q: Почему не поддерживаются APOP и CRAM-MD5 в POP3 прокси?</i></a></li>
|
<li><a name="CHAP"><i>Q: Почему не поддерживаются APOP и CRAM-MD5 в POP3 прокси?</i></a></li>
|
||||||
<p>
|
<p>
|
||||||
<i>A:</i> Любая challenge-response аутентификация, к которым относятся APOP
|
<i>A:</i> Любая challenge-response аутентификация, к которым относятся APOP
|
||||||
и CRAM-MD5, требует, чтобы со стороны сервера был передан уникальный challenge.
|
и CRAM-MD5, требует, чтобы со стороны сервера был передан уникальный challenge.
|
||||||
До начала аутентификации POP3 прокси не знает, к какому серверу следует
|
До начала аутентификации POP3 прокси не знает, к какому серверу следует
|
||||||
подключаться для получения Challenge, поэтому challenge-response в принципе
|
подключаться для получения Challenge, поэтому challenge-response в принципе
|
||||||
невозможен. Защитить соединение можно с помощью TLS (например, stunnel) или
|
невозможен. Защитить соединение можно с помощью TLS (например, stunnel) или
|
||||||
IPSec.
|
IPSec.
|
||||||
</p>
|
</p>
|
||||||
</ul>
|
</ul>
|
||||||
<hr>
|
<hr>
|
||||||
<li><b><a name="SOCKSREDIR">Перенаправление socks соединений в локальный прокси</a></b></li>
|
<li><b><a name="SOCKSREDIR">Перенаправление socks соединений в локальный прокси</a></b></li>
|
||||||
<ul>
|
<ul>
|
||||||
<li><a name="REDIR"><i>Q: Для чего это надо?</i></a></li>
|
<li><a name="REDIR"><i>Q: Для чего это надо?</i></a></li>
|
||||||
<p>
|
<p>
|
||||||
<i>A:</i> Чтобы иметь в логах URL запросов, если пользователь SOCKS пользуется
|
<i>A:</i> Чтобы иметь в логах URL запросов, если пользователь SOCKS пользуется
|
||||||
Web, FTP или POP3.
|
Web, FTP или POP3.
|
||||||
</p>
|
</p>
|
||||||
<li><a name="REDIRLIMIT"><i>Q: Какие недостатки?</i></a></li>
|
<li><a name="REDIRLIMIT"><i>Q: Какие недостатки?</i></a></li>
|
||||||
<p>
|
<p>
|
||||||
<i>A:</i> Перенапраление невозможно для web-серверов или FTP, висящих на
|
<i>A:</i> Перенапраление невозможно для web-серверов или FTP, висящих на
|
||||||
нестандартных портах, для SOCKSv4 не поддрживается авторизация с
|
нестандартных портах, для SOCKSv4 не поддрживается авторизация с
|
||||||
паролем (IE поддерживает только SOCKSv4), но при этом IE передает
|
паролем (IE поддерживает только SOCKSv4), но при этом IE передает
|
||||||
имя пользователя по SOCKSv4 (имя, с которым пользователь вошел в систему).
|
имя пользователя по SOCKSv4 (имя, с которым пользователь вошел в систему).
|
||||||
Для SOCKSv5 не поддерживается NTLM авторизация, пароли передаются в открытом
|
Для SOCKSv5 не поддерживается NTLM авторизация, пароли передаются в открытом
|
||||||
тексте.
|
тексте.
|
||||||
</p>
|
</p>
|
||||||
<li><a name="REDIRADV"><i>Q: Какие преимущества?</i></a></li>
|
<li><a name="REDIRADV"><i>Q: Какие преимущества?</i></a></li>
|
||||||
<p>
|
<p>
|
||||||
<i>A:</i> Достаточно в настройках IE только указать адрес SOCKS прокси. В
|
<i>A:</i> Достаточно в настройках IE только указать адрес SOCKS прокси. В
|
||||||
больших сетях можно для этого использовать WPAD (автоматическое
|
больших сетях можно для этого использовать WPAD (автоматическое
|
||||||
обнаружение прокси). В 3proxy достаточно запускать только одну службу
|
обнаружение прокси). В 3proxy достаточно запускать только одну службу
|
||||||
(socks). Если используется только Internet Explorer, то можно
|
(socks). Если используется только Internet Explorer, то можно
|
||||||
автоматически получать имя пользователя в логах, не запрашивая
|
автоматически получать имя пользователя в логах, не запрашивая
|
||||||
логин/пароль.
|
логин/пароль.
|
||||||
</p>
|
</p>
|
||||||
<li><a name="REDIRHOW"><i>Q: Как настраивается?</i></a></li>
|
<li><a name="REDIRHOW"><i>Q: Как настраивается?</i></a></li>
|
||||||
<p>
|
<p>
|
||||||
<i>A:</i> Указывается parent http proxy со специальным адресом 0.0.0.0 и портом
|
<i>A:</i> Указывается parent http proxy со специальным адресом 0.0.0.0 и портом
|
||||||
0. Пример:
|
0. Пример:
|
||||||
<pre>
|
<pre>
|
||||||
allow * * * 80,8080-8088
|
allow * * * 80,8080-8088
|
||||||
parent 1000 http 0.0.0.0 0
|
parent 1000 http 0.0.0.0 0
|
||||||
allow * * * 80,8080-8088
|
allow * * * 80,8080-8088
|
||||||
#перенаправить соединения по портам 80 и 8080-8088 в локальный
|
#перенаправить соединения по портам 80 и 8080-8088 в локальный
|
||||||
#http прокси. Вторая команда allow необходима, т.к. контроль доступа
|
#http прокси. Вторая команда allow необходима, т.к. контроль доступа
|
||||||
#осуществляется 2 раза - на уровне socks и на уровне HTTP прокси
|
#осуществляется 2 раза - на уровне socks и на уровне HTTP прокси
|
||||||
allow * * * 21,2121
|
allow * * * 21,2121
|
||||||
parent 1000 ftp 0.0.0.0 0
|
parent 1000 ftp 0.0.0.0 0
|
||||||
allow * * * 21,2121
|
allow * * * 21,2121
|
||||||
#перенаправить соединения по портам 21 и 2121 в локальный
|
#перенаправить соединения по портам 21 и 2121 в локальный
|
||||||
#ftp прокси
|
#ftp прокси
|
||||||
allow *
|
allow *
|
||||||
#пустить все соединения напрямую
|
#пустить все соединения напрямую
|
||||||
socks</pre>
|
socks</pre>
|
||||||
</p>
|
</p>
|
||||||
<li><a name="REDIINTER"><i>Q: Как взаимодействует с другими правилами в ACL?</i></a></li>
|
<li><a name="REDIINTER"><i>Q: Как взаимодействует с другими правилами в ACL?</i></a></li>
|
||||||
<p>
|
<p>
|
||||||
<i>A:</i> После внутреннего перенаправления правила рассматриваются еще раз за
|
<i>A:</i> После внутреннего перенаправления правила рассматриваются еще раз за
|
||||||
исключением самого правила с перенаправлением (т.е. обработка правил не
|
исключением самого правила с перенаправлением (т.е. обработка правил не
|
||||||
прекращается). Это позволяет сделать дальнейшие перенаправления на
|
прекращается). Это позволяет сделать дальнейшие перенаправления на
|
||||||
внешний прокси. По этой же причине локальное перенаправление не должно
|
внешний прокси. По этой же причине локальное перенаправление не должно
|
||||||
быть последним правилом (т.е. должно быть еще хотя бы правило allow,
|
быть последним правилом (т.е. должно быть еще хотя бы правило allow,
|
||||||
чтобы разрешить внешние соединения через HTTP прокси).
|
чтобы разрешить внешние соединения через HTTP прокси).
|
||||||
Например,
|
Например,
|
||||||
<pre>
|
<pre>
|
||||||
allow * * * 80,8080-8088
|
allow * * * 80,8080-8088
|
||||||
parent 1000 http 0.0.0.0 0
|
parent 1000 http 0.0.0.0 0
|
||||||
#перенаправить во внутренний прокси
|
#перенаправить во внутренний прокси
|
||||||
allow * * $c:\3proxy\local.nets 80,8080-8088
|
allow * * $c:\3proxy\local.nets 80,8080-8088
|
||||||
#разрешить прямой web-доступ к сетям из local.nets
|
#разрешить прямой web-доступ к сетям из local.nets
|
||||||
allow * * * 80,8080-8088
|
allow * * * 80,8080-8088
|
||||||
parent 1000 http proxy.sandy.ru 3128
|
parent 1000 http proxy.sandy.ru 3128
|
||||||
#все остальные веб-запросы перенаправить на внешний прокси-сервер
|
#все остальные веб-запросы перенаправить на внешний прокси-сервер
|
||||||
allow *
|
allow *
|
||||||
#разрешить socks-запросы по другим портам</pre>
|
#разрешить socks-запросы по другим портам</pre>
|
||||||
</p>
|
</p>
|
||||||
</ul>
|
</ul>
|
||||||
<hr>
|
<hr>
|
||||||
<li><b><a name="ISIT">А есть ли...</a></b></li>
|
<li><b><a name="ISIT">А есть ли...</a></b></li>
|
||||||
<ul>
|
<ul>
|
||||||
<li><a name="NAMES"><i>Q: Можно ли разрешать имена на родительском прокси?</i></a></li>
|
<li><a name="NAMES"><i>Q: Можно ли разрешать имена на родительском прокси?</i></a></li>
|
||||||
<p>
|
<p>
|
||||||
<i>A:</i> Можно. Для этого надо использовать тип родительского прокси http,
|
<i>A:</i> Можно. Для этого надо использовать тип родительского прокси http,
|
||||||
connect+, socks4+ и socks5+. Однако, при это надо помнить, что самому 3proxy
|
connect+, socks4+ и socks5+. Однако, при это надо помнить, что самому 3proxy
|
||||||
требуется разрешение имени для управления ACL. Поэтому, если с прокси-хоста
|
требуется разрешение имени для управления ACL. Поэтому, если с прокси-хоста
|
||||||
не работают разрешения имени, необходимо в конфигурации дать команду
|
не работают разрешения имени, необходимо в конфигурации дать команду
|
||||||
<pre>
|
<pre>
|
||||||
fakeresolve</pre>
|
fakeresolve</pre>
|
||||||
которая разрешает любое имя в адрес 127.0.0.2.
|
которая разрешает любое имя в адрес 127.0.0.2.
|
||||||
</p>
|
</p>
|
||||||
<li><a name="ISFTP"><i>Q: Существует ли сейчас поддержка FTP прокси в продукте?</i></a></li>
|
<li><a name="ISFTP"><i>Q: Существует ли сейчас поддержка FTP прокси в продукте?</i></a></li>
|
||||||
<p>
|
<p>
|
||||||
Есть поддержка как FTP через HTTP (то, что называется FTP прокси в Internet
|
Есть поддержка как FTP через HTTP (то, что называется FTP прокси в Internet
|
||||||
Explorer, Netscape, Opera) так и настоящего FTP прокси (то, что называется
|
Explorer, Netscape, Opera) так и настоящего FTP прокси (то, что называется
|
||||||
FTP proxy в FAR и FTP клиентах).
|
FTP proxy в FAR и FTP клиентах).
|
||||||
</p>
|
</p>
|
||||||
<li><a name="PORT"><i>Q: Каким образом можно прибиндить сервисы на свой порт, к примеру, HTTP прокси к 8080, а не 3128 как по-умолчанию?</i></a></li>
|
<li><a name="PORT"><i>Q: Каким образом можно прибиндить сервисы на свой порт, к примеру, HTTP прокси к 8080, а не 3128 как по-умолчанию?</i></a></li>
|
||||||
<p>
|
<p>
|
||||||
А:
|
А:
|
||||||
<pre>
|
<pre>
|
||||||
proxy -p8080</pre>
|
proxy -p8080</pre>
|
||||||
</p>
|
</p>
|
||||||
<li><a name="BANDLIM"><i>Q: Как ограничить ширину канала?</i></a></li>
|
<li><a name="BANDLIM"><i>Q: Как ограничить ширину канала?</i></a></li>
|
||||||
<p>
|
<p>
|
||||||
<i>A:</i> Читайте HowTo <a href="http://3proxy.ru/howtor.asp#BANDLIM">http://3proxy.ru/howtor.asp#BANDLIM</a>
|
<i>A:</i> Читайте HowTo <a href="http://3proxy.ru/howtor.asp#BANDLIM">http://3proxy.ru/howtor.asp#BANDLIM</a>
|
||||||
</p>
|
</p>
|
||||||
</ul>
|
</ul>
|
||||||
<hr>
|
<hr>
|
||||||
<li><b><a name="BRRR">Почему так криво...</a></b></li>
|
<li><b><a name="BRRR">Почему так криво...</a></b></li>
|
||||||
<ul>
|
<ul>
|
||||||
<li><a name="TRAF"><i>Q: Почему так криво считается трафик? Не совпадает с ...</i></a></li>
|
<li><a name="TRAF"><i>Q: Почему так криво считается трафик? Не совпадает с ...</i></a></li>
|
||||||
<p>
|
<p>
|
||||||
<i>A:</i> Следует учитывать, что 3proxy считает трафик только на прикладном уровне и
|
<i>A:</i> Следует учитывать, что 3proxy считает трафик только на прикладном уровне и
|
||||||
только проходящий через прокси-сервер. Провайдеры и другие средства учета
|
только проходящий через прокси-сервер. Провайдеры и другие средства учета
|
||||||
трафика считают трафик на сетевом уровне, что уже дает расхождение порядка 10%
|
трафика считают трафик на сетевом уровне, что уже дает расхождение порядка 10%
|
||||||
за счет информации из заголовков пакетов. Кроме того, часть трафика, как
|
за счет информации из заголовков пакетов. Кроме того, часть трафика, как
|
||||||
минимум DNS-разрешения, различный флудовый трафик и т.д. идут мимо прокси.
|
минимум DNS-разрешения, различный флудовый трафик и т.д. идут мимо прокси.
|
||||||
Уровень "шумового" трафика в Internet сейчас составляет порядка 50KB/день на
|
Уровень "шумового" трафика в Internet сейчас составляет порядка 50KB/день на
|
||||||
каждый реальный IP адрес, но может сильно варьироваться в зависимости от сети,
|
каждый реальный IP адрес, но может сильно варьироваться в зависимости от сети,
|
||||||
наличия открытых портов, реакции на ping-запросы и текущего уровня вирусной
|
наличия открытых портов, реакции на ping-запросы и текущего уровня вирусной
|
||||||
активности. По этим причинам, если 3proxy используется чтобы не "выжрать"
|
активности. По этим причинам, если 3proxy используется чтобы не "выжрать"
|
||||||
трафик, выделенный провайдером, всегда следует делать некий запас порядка
|
трафик, выделенный провайдером, всегда следует делать некий запас порядка
|
||||||
15%.
|
15%.
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
Если на одной с 3proxy машине имеются какие-либо сервисы или
|
Если на одной с 3proxy машине имеются какие-либо сервисы или
|
||||||
работает пользователь, то их трафик не проходит через proxy-сервер и так же
|
работает пользователь, то их трафик не проходит через proxy-сервер и так же
|
||||||
не будет учтен. Если где-то есть NAT, то клиенты, выходящие через NAT мимо
|
не будет учтен. Если где-то есть NAT, то клиенты, выходящие через NAT мимо
|
||||||
прокси, так же останутся неучтенными. Если расхождение с провайдером превышает
|
прокси, так же останутся неучтенными. Если расхождение с провайдером превышает
|
||||||
10% - нужно искать причину именно в этом.
|
10% - нужно искать причину именно в этом.
|
||||||
</p>
|
</p>
|
||||||
<li><a name="CONFIG"><i>Q: Почему такая кривая конфигурация и ничерта не понятно?</i></a></li>
|
<li><a name="CONFIG"><i>Q: Почему такая кривая конфигурация и ничерта не понятно?</i></a></li>
|
||||||
<p>
|
<p>
|
||||||
<i>A:</i> Есть несколько причин. Во-первых, до выхода релиза (т.е. версии 1.0) я буду изо
|
<i>A:</i> Есть несколько причин. Во-первых, до выхода релиза (т.е. версии 1.0) я буду изо
|
||||||
всех сил добиваться совместимости конфигурации между версиями. Во-вторых,
|
всех сил добиваться совместимости конфигурации между версиями. Во-вторых,
|
||||||
конфигурация сделана так, чтобы ее можно было легко разбирать программно.
|
конфигурация сделана так, чтобы ее можно было легко разбирать программно.
|
||||||
В-третьих, все там понятно. При желании. Если знать как все работает.
|
В-третьих, все там понятно. При желании. Если знать как все работает.
|
||||||
</p>
|
</p>
|
||||||
<li><a name="CODE"><i>Q: Почему так криво написан код?</i></a></li>
|
<li><a name="CODE"><i>Q: Почему так криво написан код?</i></a></li>
|
||||||
<p>
|
<p>
|
||||||
<i>A:</i> Есть несколько причин. Во-первых, я не программист. Во-вторых, 3proxy изначально
|
<i>A:</i> Есть несколько причин. Во-первых, я не программист. Во-вторых, 3proxy изначально
|
||||||
писался на коленке (в отет на "слабо" в одной из конференций). Никто
|
писался на коленке (в отет на "слабо" в одной из конференций). Никто
|
||||||
не мог предположить, что им кто-то реально будет пользоваться. В-третьих, у многих
|
не мог предположить, что им кто-то реально будет пользоваться. В-третьих, у многих
|
||||||
возникает желание разобраться в коде 3proxy чтобы внедрить его в какой-нибудь
|
возникает желание разобраться в коде 3proxy чтобы внедрить его в какой-нибудь
|
||||||
троян. Очень не хочется облегчать эту задачу. В-четвертых, мне надо добиться
|
троян. Очень не хочется облегчать эту задачу. В-четвертых, мне надо добиться
|
||||||
компиляции кода в как можно большем числе систем. Замечено, что чем кривее код в
|
компиляции кода в как можно большем числе систем. Замечено, что чем кривее код в
|
||||||
C, тем он лучше переносится.
|
C, тем он лучше переносится.
|
||||||
</p>
|
</p>
|
||||||
<li><a name="UNSAFE"><i>Q: Почему так много strcpy, sprintf и т.д., это ж дыры!</i></a><li>
|
<li><a name="UNSAFE"><i>Q: Почему так много strcpy, sprintf и т.д., это ж дыры!</i></a><li>
|
||||||
<p>
|
<p>
|
||||||
<i>A:</i> Есть несколько причин. Во-первых, несмотря на дурной тон использования этих
|
<i>A:</i> Есть несколько причин. Во-первых, несмотря на дурной тон использования этих
|
||||||
функций, они наиболее совместимы между разными системами и компиляторами.
|
функций, они наиболее совместимы между разными системами и компиляторами.
|
||||||
Во-вторых, само по себе их использование не означает присутствие дыры, если их
|
Во-вторых, само по себе их использование не означает присутствие дыры, если их
|
||||||
параметры должным образом контролируются. Найдете дыру - обязательно сообщите.
|
параметры должным образом контролируются. Найдете дыру - обязательно сообщите.
|
||||||
В третьих, может быть я уберу их перед конечным релизом, чтобы никого не
|
В третьих, может быть я уберу их перед конечным релизом, чтобы никого не
|
||||||
пугать.
|
пугать.
|
||||||
</p>
|
</p>
|
||||||
</ul>
|
</ul>
|
||||||
<pre>
|
|
||||||
$Id: faqr.html,v 1.28 2007/09/25 09:47:13 vlad Exp $
|
|
||||||
</pre>
|
|
||||||
+62
-1
@@ -33,6 +33,9 @@
|
|||||||
<li><A HREF="#BANDLIM">How to limit bandwidth</A>
|
<li><A HREF="#BANDLIM">How to limit bandwidth</A>
|
||||||
<li><A HREF="#TRAFLIM">How to limit traffic amount</A>
|
<li><A HREF="#TRAFLIM">How to limit traffic amount</A>
|
||||||
<li><A HREF="#NETLIST">How to build network lists</A>
|
<li><A HREF="#NETLIST">How to build network lists</A>
|
||||||
|
<li><a href="#NSCACHING">How to configure name resolution and DNS caching</a>
|
||||||
|
<li><a href="#IPV6">How to use IPv6</a>
|
||||||
|
<li><a href="#CONNBACK">How to use connect back</a>
|
||||||
</ul>
|
</ul>
|
||||||
<li><A HREF="#CLIENT">Client configuration</A>
|
<li><A HREF="#CLIENT">Client configuration</A>
|
||||||
<li><A HREF="#ADMIN">Administering and information analisys</A>
|
<li><A HREF="#ADMIN">Administering and information analisys</A>
|
||||||
@@ -738,6 +741,65 @@ In this example we obtain list of local networks from provider's page to
|
|||||||
local.networks file, allow direct access to these networks and redirect all
|
local.networks file, allow direct access to these networks and redirect all
|
||||||
connection to external networks to provider's proxy.
|
connection to external networks to provider's proxy.
|
||||||
</p>
|
</p>
|
||||||
|
<li><a name="NSCACHING"><i>How to configure name resolution and DNS caching</i></a>
|
||||||
|
<p>
|
||||||
|
For name resolution and caching use commands nserver, nscache / nscache6 and nsrecord.
|
||||||
|
<pre>
|
||||||
|
nserver 192.168.1.2
|
||||||
|
nserver 192.168.1.3:5353/tcp</pre>
|
||||||
|
sets DNS resolvers. 192.168.1.3 will be used via TCP/5353 (instead of default UDP/53)
|
||||||
|
only if 192.168.1.2 fails. Up to 5 nservers may be specified.
|
||||||
|
If no nserver is configured, default system name resolution functions are used.
|
||||||
|
<pre>
|
||||||
|
nscache 65535
|
||||||
|
nscache6 65535</pre>
|
||||||
|
sets name cache size for IPv4 and IPv6. Name cache must be large enouth, if presents.
|
||||||
|
name cache is only used if nserver is configured.
|
||||||
|
<pre>
|
||||||
|
nsrecord server.mycompany.example.com 192.168.1.1
|
||||||
|
nsrecord www.porno.com 127.0.0.2
|
||||||
|
...
|
||||||
|
deny * * 127.0.0.2</pre>
|
||||||
|
adds static nsrecords. Also, static nsrecords are used for dnspr, unless -s option is specified.
|
||||||
|
Since 0.8 version, parent proxy may be configured for dnspr.
|
||||||
|
</p>
|
||||||
|
<li><a name="IPV6"><i>How to use IPv6</i></a>
|
||||||
|
<p>
|
||||||
|
IPv6 is supported since 0.8. Please note, some proxy protolos, e.g. SOCKSv4,
|
||||||
|
do not support IPv6. SOCKSv5 supports IPv6 with special request type (must be
|
||||||
|
implemented by client).
|
||||||
|
<br>
|
||||||
|
3proxy supports proxying from IPv4 and IPv6 networks to IPv4,
|
||||||
|
IPv6 and mixed networks. IPv6 address may be used in
|
||||||
|
internal, external, parent commands, ACLs, -i and -e options,etc.
|
||||||
|
external command and -e options may be given twice for each service - once with IPv4
|
||||||
|
and once with IPv6 address. internal can be given only once, to bind to all IPv4 and
|
||||||
|
IPv6 addresses use [0:0:0:0:0:0:0:0] or [::].
|
||||||
|
<br>
|
||||||
|
Any service may be configured with -4, -46, -64, -6 options to specify decied
|
||||||
|
priority for name to IPv4/IPv6 address resolution (IPv4 only, IPv4 priority,
|
||||||
|
IPv6 priority, IPv6 only).
|
||||||
|
</p>
|
||||||
|
<li><a name="CONNBACK"><i>How to use connect back</i></a>
|
||||||
|
<p>
|
||||||
|
In example, users needs access from external network to proxy server located
|
||||||
|
on the host 192.168.1.2. This host can not be accessed from external network,
|
||||||
|
but it has access to external network with with external address 1.1.1.1.
|
||||||
|
Also, user has access to the host 2.2.2.2 (IP address may be dynamic) with
|
||||||
|
hostname host.dyndns.example.org via external network. User needs 2 instances
|
||||||
|
of 3proxy, first one on the host 192.168.1.2 with config
|
||||||
|
<pre>
|
||||||
|
users user:CL:password
|
||||||
|
auth strong
|
||||||
|
allow user
|
||||||
|
proxy -rhost.dyndns.example.org:1234</pre>
|
||||||
|
second one on the host.dyndns.example.org (2.2.2.2) with config
|
||||||
|
<pre>
|
||||||
|
auth iponly
|
||||||
|
allow * * 1.1.1.1
|
||||||
|
tcppm -R0.0.0.0:1234 3128 1.1.1.1 3128</pre>
|
||||||
|
For browser settings proxy is host.dyndns.example.org:3128.
|
||||||
|
</p>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<hr>
|
<hr>
|
||||||
@@ -832,4 +894,3 @@ You can control 3proxy service via "Services" administration ot via "net" comman
|
|||||||
|
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<pre>$Id: howtoe.html,v 1.41 2009/02/02 10:04:49 vlad Exp $</pre>
|
|
||||||
+716
-681
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,94 @@
|
|||||||
|
|
||||||
|
<h3>3proxy Perl Compatible Regular Expressions (PCRE) plugin</h3>
|
||||||
|
|
||||||
|
This filtering plugin can be used to create matching and replace
|
||||||
|
rules with regular expressions for client's request, client and
|
||||||
|
servers header and client and server data. It adds 3 additional
|
||||||
|
configuration commands:
|
||||||
|
|
||||||
|
<pre>
|
||||||
|
pcre TYPE FILTER_ACTION REGEXP [ACE]
|
||||||
|
pcre_rewrite TYPE FILTER_ACTION REGEXP REWRITE_EXPRESSION [ACE]
|
||||||
|
pcre_extend FILTER_ACTION [ACE]
|
||||||
|
pcre_options OPTION1 [...]
|
||||||
|
</pre>
|
||||||
|
pcre - allows to apply some rule for matching
|
||||||
|
<br>pcre_rewrite - in addition to 'pcre' allows to substitute substrings
|
||||||
|
<br>pcre_extend - extends ACL of the last pcre or pcre_rewrite comand by
|
||||||
|
adding additional ACE (like with allow/deny configuration commands).
|
||||||
|
<br>pcre_options - allows to set matching options. Awailable options are:
|
||||||
|
PCRE_CASELESS,
|
||||||
|
PCRE_MULTILINE,
|
||||||
|
PCRE_DOTALL,
|
||||||
|
PCRE_EXTENDED,
|
||||||
|
PCRE_ANCHORED,
|
||||||
|
PCRE_DOLLAR_ENDONLY,
|
||||||
|
PCRE_EXTRA,
|
||||||
|
PCRE_NOTBOL,
|
||||||
|
PCRE_NOTEOL,
|
||||||
|
PCRE_UNGREEDY,
|
||||||
|
PCRE_NOTEMPTY,
|
||||||
|
PCRE_UTF8,
|
||||||
|
PCRE_NO_AUTO_CAPTURE,
|
||||||
|
PCRE_NO_UTF8_CHECK,
|
||||||
|
PCRE_AUTO_CALLOUT,
|
||||||
|
PCRE_PARTIAL,
|
||||||
|
PCRE_DFA_SHORTEST,
|
||||||
|
PCRE_DFA_RESTART,
|
||||||
|
PCRE_FIRSTLINE,
|
||||||
|
PCRE_DUPNAMES,
|
||||||
|
PCRE_NEWLINE_CR,
|
||||||
|
PCRE_NEWLINE_LF,
|
||||||
|
PCRE_NEWLINE_CRLF,
|
||||||
|
PCRE_NEWLINE_ANY,
|
||||||
|
PCRE_NEWLINE_ANYCRLF,
|
||||||
|
PCRE_BSR_ANYCRLF,
|
||||||
|
PCRE_BSR_UNICODE
|
||||||
|
|
||||||
|
<ul>
|
||||||
|
<li>TYPE - type of filtered data. May contain one or more
|
||||||
|
(comma delimited list) values:
|
||||||
|
<ul>
|
||||||
|
<li>request - content of client's request e.g. HTTP GET request string.
|
||||||
|
(known problem: changing request string doesn't change IP of the host to connect)
|
||||||
|
<li>cliheader - content of client request headers, e.g. HTTP request header.
|
||||||
|
<li>srvheader - content of server's reply headers, e.g. HTTP status and headers.
|
||||||
|
<li>clidata - data received from client, e.g. HTTP POST request data
|
||||||
|
<li>srvdata - data received from server, e.g. HTML page
|
||||||
|
</ul>
|
||||||
|
<li>FILTER_ACTION - action on match
|
||||||
|
<ul>allow - allow this request without checking rest of the given type
|
||||||
|
of the rules
|
||||||
|
<li>deny - deny this request without checking rest of the rules
|
||||||
|
<li>dunno - continue with the rest of rules (useful with pcre_rewrite)
|
||||||
|
</ul>
|
||||||
|
<li>REGEXP - PCRE (perl) regular expression. Use * if no regexp matching
|
||||||
|
required.
|
||||||
|
<li>REWRITE_EXPRESSION - substitution string. May contain perl-style
|
||||||
|
substrings
|
||||||
|
(not tested) $1, $2. $0 - means whole matched string. \r and \n may be used
|
||||||
|
to insert new strings, string may be empty ("").
|
||||||
|
<li>ACE - access control entry (user names, source IPs, destination IPs,
|
||||||
|
ports, etc), absolutely identical to allow/deny/bandlimin commands.
|
||||||
|
Regular expression is only matched if ACL matches connection data.
|
||||||
|
Warning:
|
||||||
|
reqular expression doesn't require authentication and can not replace
|
||||||
|
authentication and/or allow/deny ACLs.
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
|
||||||
|
<h4>Example:</h4>
|
||||||
|
<pre>
|
||||||
|
plugin PCREPlugin.dll pcre_plugin
|
||||||
|
pcre request deny "porn|sex" user1,user2,user3 192.168.0.0/16
|
||||||
|
pcre srvheader deny "Content-type: application"
|
||||||
|
pcre_rewrite clidata,srvdata dunno "porn|sex|pussy" "***" baduser
|
||||||
|
pcre_extend deny * 192.168.0.1/16
|
||||||
|
</pre>
|
||||||
|
|
||||||
|
<h4>Download:</h4>
|
||||||
|
<ul>
|
||||||
|
<li>Plugin is included into 3proxy 0.6 binary and source distribution
|
||||||
|
<li>Example configuration (by Dennis Garber): <A HREF="NoPornLitest.cfg.txt">NoPornLitest.cfg</A>
|
||||||
|
</ul>
|
||||||
|
|
||||||
@@ -0,0 +1,90 @@
|
|||||||
|
<h3>Плагин регулярных выражений совместимых с Perl (PCRE) для 3proxy</h3>
|
||||||
|
|
||||||
|
Фильтрующий плагин используется для создания правил поиска и замены
|
||||||
|
регулярных выражений в запросе, заголовков запроса и ответа и данных.
|
||||||
|
Добавляет поддержку 3х новых команд в файле конфигурации:
|
||||||
|
|
||||||
|
<pre>
|
||||||
|
pcre TYPE FILTER_ACTION REGEXP [ACE]
|
||||||
|
pcre_rewrite TYPE FILTER_ACTION REGEXP REWRITE_EXPRESSION [ACE]
|
||||||
|
pcre_extend FILTER_ACTION [ACE]
|
||||||
|
pcre_options OPTION1 [...]
|
||||||
|
</pre>
|
||||||
|
pcre - позволяет искать совпадения
|
||||||
|
<br>pcre_rewrite - дополнительно позволяет производить замену подстрок
|
||||||
|
<br>pcre_extend - расширяет ACL последней команды pcre или pcre_rewrite путем
|
||||||
|
добавления еще одной ACE (аналогично списку правил allow/deny).
|
||||||
|
<br>pcre_options - позволяет устанавливать опции поиска, доступны следующие опции:
|
||||||
|
PCRE_CASELESS,
|
||||||
|
PCRE_MULTILINE,
|
||||||
|
PCRE_DOTALL,
|
||||||
|
PCRE_EXTENDED,
|
||||||
|
PCRE_ANCHORED,
|
||||||
|
PCRE_DOLLAR_ENDONLY,
|
||||||
|
PCRE_EXTRA,
|
||||||
|
PCRE_NOTBOL,
|
||||||
|
PCRE_NOTEOL,
|
||||||
|
PCRE_UNGREEDY,
|
||||||
|
PCRE_NOTEMPTY,
|
||||||
|
PCRE_UTF8,
|
||||||
|
PCRE_NO_AUTO_CAPTURE,
|
||||||
|
PCRE_NO_UTF8_CHECK,
|
||||||
|
PCRE_AUTO_CALLOUT,
|
||||||
|
PCRE_PARTIAL,
|
||||||
|
PCRE_DFA_SHORTEST,
|
||||||
|
PCRE_DFA_RESTART,
|
||||||
|
PCRE_FIRSTLINE,
|
||||||
|
PCRE_DUPNAMES,
|
||||||
|
PCRE_NEWLINE_CR,
|
||||||
|
PCRE_NEWLINE_LF,
|
||||||
|
PCRE_NEWLINE_CRLF,
|
||||||
|
PCRE_NEWLINE_ANY,
|
||||||
|
PCRE_NEWLINE_ANYCRLF,
|
||||||
|
PCRE_BSR_ANYCRLF,
|
||||||
|
PCRE_BSR_UNICODE
|
||||||
|
|
||||||
|
|
||||||
|
<ul>
|
||||||
|
<li>TYPE - тип фильтруемых данных. Может содержать одно или
|
||||||
|
несколько (список через запятую) значений:
|
||||||
|
<ul>
|
||||||
|
<li>request - содержимое запроса клиента (например строка HTTP GET-запроса).
|
||||||
|
(в настоящий момент изменение запроса не приводит к изменению адреса запрашиваемого хоста)
|
||||||
|
<li>cliheader - содержимое заголовков запроса клиента, например заголовки HTTP
|
||||||
|
<li>srvheader - содержимое заголовков ответа сервера, например заголовки HTTP
|
||||||
|
<li>clidata - данные полученные от клиента, например данные POST-запроса
|
||||||
|
<li>srvdata - данные полученные от сервера, например содержимое HTML-страницы
|
||||||
|
</ul>
|
||||||
|
<li>FILTER_ACTION - действие при совпадении. Может принимать значение
|
||||||
|
<ul>allow - разрешить данный запрос без просмотра дальнейших правил
|
||||||
|
<li>deny - запретить данный запрос без просмотра дальнейших правил
|
||||||
|
<li>dunno - продолжить анализ правил (полезно для pcre_rewrite)
|
||||||
|
</ul>
|
||||||
|
<li>REGEXP - регулярное выражение в формате PCRE (perl). Используйте * если не
|
||||||
|
требуется проерка регулярного выражения.
|
||||||
|
<li>REWRITE_EXPRESSION - строка замены. Может содержать макроподстановки
|
||||||
|
(не тестировалось) $1, $2 и т.д. аналогично perl. $0 - полная найденная
|
||||||
|
подстрока. В строке замены можно использовать сочетания \r, \n для вставки
|
||||||
|
новых строк. Строка может быть пустой ("").
|
||||||
|
<li>ACE - Список контроля доступа (имя пользователя, IP источника, IP назначения, порт и т.д.),
|
||||||
|
полностью аналогичный ACE в командах allow, deny, bandlimin и т.п. Регулярное
|
||||||
|
выражение проверяется только при совпадении ACE с запросом. ВНИМАНИЕ:
|
||||||
|
использование регулярных выражений не требует авторизации и не заменяет ее.
|
||||||
|
Авторизацию необходимо конфигурировать отдельно.
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
|
||||||
|
<h4>Пример:</h4>
|
||||||
|
<pre>
|
||||||
|
plugin PCREPlugin.dll pcre_plugin
|
||||||
|
pcre request deny "porn|sex" user1,user2,user3 192.168.0.0/16
|
||||||
|
pcre srvheader deny "Content-type: application"
|
||||||
|
pcre_rewrite clidata,srvdata dunno "porn|sex|pussy" "***" baduser
|
||||||
|
pcre_extend deny * 192.168.0.1/16
|
||||||
|
</pre>
|
||||||
|
|
||||||
|
<h4>Загрузить:</h4>
|
||||||
|
<ul>
|
||||||
|
<li>Плагин включен в дистрибутив 3proxy 0.6
|
||||||
|
<li>Пример конфигурации (by Dennis Garber): <A HREF="NoPornLitest.cfg.txt">NoPornLitest.cfg</A>
|
||||||
|
</ul>
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
<h3>3proxy SSL/TLS plugin</h3>
|
||||||
|
|
||||||
|
Plugin can be used to transparently decypher SSL/TLS data. Plugin should never be used in production environment due to
|
||||||
|
potential securiy reasons.
|
||||||
|
|
||||||
|
<pre>
|
||||||
|
ssl_certcache PATH_TO_CACHE
|
||||||
|
ssl_mitm
|
||||||
|
ssl_nomitm
|
||||||
|
</pre>
|
||||||
|
ssl_certcache - path to certificates cache. For transparent spoofing cache must contain 3 files: 3proxy.pem - public
|
||||||
|
self-signed certificates, 3proxy.key - key for public certificates, server.key - this key will be used to generates
|
||||||
|
spoofed certificates.
|
||||||
|
Generated certificates will be placed to the same path.
|
||||||
|
<br>ssl_mitm - spoof certificates for services started below
|
||||||
|
<br>ssl_nomitm - do not spoof certificates for services started below
|
||||||
|
|
||||||
|
|
||||||
|
<h4>Example:</h4>
|
||||||
|
<pre>
|
||||||
|
plugin /path/to/SslPlugin.dll ssl_plugin
|
||||||
|
ssl_certcache /path/to/cache/
|
||||||
|
ssl_mitm
|
||||||
|
proxy -p3128
|
||||||
|
ssl_nomitm
|
||||||
|
proxy -p3129
|
||||||
|
</pre>
|
||||||
|
|
||||||
|
<h4>Download:</h4>
|
||||||
|
<ul>
|
||||||
|
<li>Plugin included into 3proxy 0.8
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
© Vladimir Dubrovin, License: BSD style
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
<h3>Плагин SSL/TLS для 3proxy</h3>
|
||||||
|
|
||||||
|
Плагин используется для транспарентной дешифровки SSL-трафика с подменой сертификата.
|
||||||
|
Плагин не должен использоваться в рабочем окружении, т.к. его использование дает возможность обхода проверок SSL.
|
||||||
|
|
||||||
|
|
||||||
|
<pre>
|
||||||
|
ssl_certcache PATH_TO_CACHE
|
||||||
|
ssl_mitm
|
||||||
|
ssl_nomitm
|
||||||
|
</pre>
|
||||||
|
ssl_certcache - путь к кэшу сертификатов. Для транспорентной подмены сертификатов в кэше должно находиться 3 файла: 3proxy.pem - публичный
|
||||||
|
самоподписанный сертификат, 3proxy.key - ключ от этого сертификата, server.key - ключ с которым будут генерироваться подменные сертификаты.
|
||||||
|
Сгенерированные сертификаты будут помещаться в этот же каталог.
|
||||||
|
<br>ssl_mitm - подменять сертитфикаты для запущенных ниже сервисов
|
||||||
|
<br>ssl_nomitm - не подменять сертитфикаты для запущенных ниже сервисов
|
||||||
|
|
||||||
|
|
||||||
|
<h4>Пример:</h4>
|
||||||
|
<pre>
|
||||||
|
plugin /path/to/SslPlugin.dll ssl_plugin
|
||||||
|
ssl_certcache /path/to/cache/
|
||||||
|
ssl_mitm
|
||||||
|
proxy -p3128
|
||||||
|
ssl_nomitm
|
||||||
|
proxy -p3129
|
||||||
|
</pre>
|
||||||
|
|
||||||
|
<h4>Загрузить:</h4>
|
||||||
|
<ul>
|
||||||
|
<li>Плагин включен в дистрибутив 3proxy 0.8
|
||||||
|
</ul>
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
|
||||||
|
<h3>3proxy strings substitution plugin</h3>
|
||||||
|
May be used to make interface more pretty or to translate proxy server
|
||||||
|
messages to different language. All messages are taken from proxy.c and
|
||||||
|
moved to external text file (e.g. rus-win1251.3ps). On the moment of
|
||||||
|
writing there are 15 sections. Sections are delimited with "[end]".
|
||||||
|
<h4>Example:</h4>
|
||||||
|
<pre>plugin "StringsPlugin.dll" start c:\3proxy\bin\rus-win1251.3ps
|
||||||
|
</pre>
|
||||||
|
|
||||||
|
<h4>Download:</h4>
|
||||||
|
<ul>
|
||||||
|
<li>Plugin is included into 3proxy 0.6 binary and source distribution
|
||||||
|
</li></ul>
|
||||||
|
|
||||||
|
©Kirill Lopuchov
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
<h3>Плагин подмены строк 3proxy</h3>
|
||||||
|
|
||||||
|
Используется, в частности, для руссификации сообщений выдаваемых 3proxy.
|
||||||
|
Для корректной работы требуется 0.6 версия 3proxy.
|
||||||
|
Все сообщения были взяты из proxy.c
|
||||||
|
и вынесенны в отдельный файл. Пример файла rus-win1251.3ps.
|
||||||
|
Всего 15 секций на момент написания плагина в файле rus-win1251.3ps каждая секция отделяется строкой "[end]"
|
||||||
|
новая строка определяется строкой "\n"
|
||||||
|
|
||||||
|
<h4>Пример:</h4>
|
||||||
|
<pre>
|
||||||
|
plugin "StringsPlugin.dll" start c:\3proxy\bin\rus-win1251.3ps
|
||||||
|
</pre>
|
||||||
|
|
||||||
|
<h4>Загрузить:</h4>
|
||||||
|
<ul>
|
||||||
|
<li>Плагин включен в дистрибутив 3proxy 0.6
|
||||||
|
</ul>
|
||||||
@@ -0,0 +1,52 @@
|
|||||||
|
<h3>3proxy traffic correction plugin</h3>
|
||||||
|
3proxy logs and counts traffic on application level, while provider usually does
|
||||||
|
it on network or link level. It's significant if you use 3proxy for billing,
|
||||||
|
especially in case where network packets are small, e.g. network games.
|
||||||
|
<p>
|
||||||
|
This plugin attempts to correct 3proxy computations to approximate network or
|
||||||
|
link level traffic by using either fixed coefficients by port number or
|
||||||
|
attempting to predict number and sizes of network packets.
|
||||||
|
</p><h4>Usage:</h4>
|
||||||
|
<ol>
|
||||||
|
<li>Extract TrafficPlugin.dll to the same folder with 3proxy executable.
|
||||||
|
</li><li>Start plugin in 3proxy.cfg with
|
||||||
|
<pre>plugin TrafficPlugin.dll start
|
||||||
|
</pre>
|
||||||
|
</li><li>Add correction rules:
|
||||||
|
<br>
|
||||||
|
FOR FIXED COEFFICIENTS MODE:
|
||||||
|
<pre>trafcorrect m <service> <target port> <coefficient>
|
||||||
|
</pre>
|
||||||
|
where <service> - one of proxy, socks4, socks45, socks5, tcppm, udppm, pop3p, * matches "any".
|
||||||
|
<br> <target port> - target port, * matches any
|
||||||
|
<br> <coefficient> - coefficient to multiply traffic for this port.
|
||||||
|
<br>
|
||||||
|
FOR PACKET HEADER PREDICTION MODE
|
||||||
|
<pre>trafcorrect p <service> <tcp/udp> <target port> [empty packet size]
|
||||||
|
</pre>
|
||||||
|
tcp ot udp - transport level protocol to apply rule
|
||||||
|
<br>
|
||||||
|
empty packet size - average size of "empty" packet, that is sum of average network/transport headers.
|
||||||
|
You can use network sniffer, such is Ethereal to discover it. Usually packet size
|
||||||
|
is 42 for UDP and
|
||||||
|
<br>Modes can be mixed.
|
||||||
|
<br>Plugin creates a list of rules, first matching rule will be applied.
|
||||||
|
</li></ol>
|
||||||
|
For any mode plugin approximates traffic, logged or counted amount is not exact.
|
||||||
|
<h4>Example:</h4>
|
||||||
|
<pre>plugin "TrafficPlugin.dll" start
|
||||||
|
trafcorrect m socks5 6112 4.5
|
||||||
|
trafcorrect m socks5 * 1.1
|
||||||
|
</pre>
|
||||||
|
wrong usage:
|
||||||
|
<pre>trafcorrect m socks5 * 1.1
|
||||||
|
trafcorrect m socks5 6112 4.5
|
||||||
|
</pre>
|
||||||
|
second rule will never be applied.
|
||||||
|
<h4>Download:</h4>
|
||||||
|
<ul>
|
||||||
|
<li>Plugin is included into 3proxy 0.6 binary and source distribution
|
||||||
|
</li></ul>
|
||||||
|
|
||||||
|
©Maslov Michael aka Flexx(rus)
|
||||||
|
|
||||||
@@ -0,0 +1,69 @@
|
|||||||
|
<h3>Плагин коррекции траффика 3proxy</h3>
|
||||||
|
Как известно, 3proxy считает траффик не сетевой, а прикладной.
|
||||||
|
Обычно прикладной траффик немного меньше (примерно на 10%) чем сетевой,
|
||||||
|
однако в некоторых случаях, например когда пользователи сети играют в
|
||||||
|
игры, сетевой траффик может превысить прикладной в 4-5 раз. Это довольно неприятно,
|
||||||
|
так как получается, что они за это не платят.
|
||||||
|
<p>
|
||||||
|
Происходит это потому, что в каждом посланом пакете есть заголовок+данные. Заголовок
|
||||||
|
весит порядка 50-60 байт а количество данных может меняться от 15-20 байт (что характерно для игр)
|
||||||
|
до 800-900 байт (у IE). Также количество данных в пакете зависит от загрузки сети,
|
||||||
|
удалённости сервера и прочих причин.
|
||||||
|
<p>
|
||||||
|
Данный плагин может исправить такую ситуацию. Он может умножать счётчик траффика
|
||||||
|
при окончании соединения на некоторый коэффициент либо добавлять к данным размеры заголовков пакетов,
|
||||||
|
которые прошли по сети.
|
||||||
|
<h4>Использование</h4>
|
||||||
|
<ol>
|
||||||
|
<li>Извлечь TrafficPlugin.dll в каталог с 3proxy.exe
|
||||||
|
<li>Стартовать плагин в 3proxy.cfg
|
||||||
|
<pre>
|
||||||
|
plugin TrafficPlugin.dll start
|
||||||
|
</pre>
|
||||||
|
<li>Добавить правила:
|
||||||
|
<br>
|
||||||
|
ДЛЯ РЕЖИМА ДОМНОЖЕНИЯ ТРАФФИКА НА ЧИСЛО:
|
||||||
|
<pre>
|
||||||
|
trafcorrect m <сервис> <исходящий порт> <коэффициент>
|
||||||
|
</pre>
|
||||||
|
где: <сервис> может быть proxy, socks4, socks45, socks5, tcppm, udppm, pop3p
|
||||||
|
если сервис указан неверно то считается, что это может быть любой сервис.
|
||||||
|
можно использовать *, тогда правило будет считаться для любого сервиса.
|
||||||
|
<br> <исходящий порт> - порт, к которому подключается прокси сервер. * - любой
|
||||||
|
<коэффициент> - число на каоторое домнажается траффик. Обязательный параметр.
|
||||||
|
Должен быть от больше 0 и меньше 100
|
||||||
|
<br>
|
||||||
|
ДЛЯ РЕЖИМА С УЧЁТОМ РАЗМЕРА ЗАГОЛОВКОВ ПАКЕТОВ:
|
||||||
|
<pre>
|
||||||
|
trafcorrect p <сервис> <tcp/udp> <исходящий порт> [размер пустого пакета]
|
||||||
|
</pre>
|
||||||
|
<tcp/udp> - протокол, по которому осуществляется соединение.
|
||||||
|
[размер пакета] - средний размер пустого пакета. Можно определить захватив
|
||||||
|
данные при помощи такой утилиты как Ethereal. Параметр необязателен. Если отсутствует,
|
||||||
|
то размер пакета будет считаться равным 66 байт.
|
||||||
|
<br>Режимы можно смешивать.
|
||||||
|
Следует учитывать, что плугин создаёт список всех правил изменения траффика.
|
||||||
|
Когда происходит окончание соединения выполняется первое подходящее правило.
|
||||||
|
</ol>
|
||||||
|
Подсчет трафика в любом режиме не является точным, это некоторая аппроксимация
|
||||||
|
позволяющаяподсчитать трафик с точностью до нескольких процентов.
|
||||||
|
|
||||||
|
<h4>Пример:</h4>
|
||||||
|
<pre>
|
||||||
|
plugin "TrafficPlugin.dll" start
|
||||||
|
trafcorrect m socks5 6112 4.5
|
||||||
|
trafcorrect m socks5 * 1.1
|
||||||
|
</pre>
|
||||||
|
следующее неверно:
|
||||||
|
<pre>
|
||||||
|
plugin "TrafficPlugin.dll" start
|
||||||
|
trafcorrect m socks5 * 1.1
|
||||||
|
trafcorrect m socks5 6112 4.5
|
||||||
|
</pre>
|
||||||
|
Вторая строчка выполнена никогда не будет, т.к. правило 1 содержит *.
|
||||||
|
|
||||||
|
|
||||||
|
<h4>Загрузить:</h4>
|
||||||
|
<ul>
|
||||||
|
<li>Плагин включен в дистрибутив 3proxy 0.6
|
||||||
|
</ul>
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
|
||||||
|
<h3>3proxy Windows Authentication plugin</h3>
|
||||||
|
Support for cleartext authentication against Windows domain or local Windows account.
|
||||||
|
<h4>Usage:</h4>
|
||||||
|
<ol>
|
||||||
|
<li>Extract WindowsAuthentication.dll to the same folder with 3proxy executable.
|
||||||
|
<li>Create 3ProxyAllowedGroup - Windows system group allowed to use proxy.
|
||||||
|
You can choose different group name. Group can be either local or
|
||||||
|
Active Directory. Every account allowed to use 3proxy must be included in this
|
||||||
|
group either directly or through group nesting.
|
||||||
|
<li>Configure plugin with 'plugin' command in 3proxy.cfg, e.g.:
|
||||||
|
<pre><code>
|
||||||
|
plugin "WindowsAuthentication.dll" WindowsAuthentication "3ProxyAllowedGroup"
|
||||||
|
</code></pre>
|
||||||
|
<br>WindowsAuthentication.dll - location of DLL, if DLL is located in different folder
|
||||||
|
from 3proxy.exe you must specify complete path to DLL here. 3ProxyAllowedGroup - Windows
|
||||||
|
system group allowed to use 3proxy.
|
||||||
|
After plugin is loaded, 'windows' authentication type is supported.
|
||||||
|
|
||||||
|
<li>Configure 'auth windows' for services that require Windows authentication.
|
||||||
|
<li>It's recommended you also configure authentication caching (see 'authcache'),
|
||||||
|
to prevent excessive workload for domain controller. Example:
|
||||||
|
<pre>
|
||||||
|
authcache user,pass 900
|
||||||
|
auth cache windows
|
||||||
|
</pre>
|
||||||
|
|
||||||
|
<li>NTLM authentication is not currently supported for plugins, you should use proxy -n key to disable it.
|
||||||
|
</ol>
|
||||||
|
<h4>Download:</h4>
|
||||||
|
<ul>
|
||||||
|
<li>Plugin is included into 3proxy 0.6 binary and source distribution
|
||||||
|
</ul>
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
<h3>Плагин аутентификации Windows для 3proxy</h3>
|
||||||
|
Поддерживается только аутентификация открытым текстом в домене или на локальной машине Windows.
|
||||||
|
<h4>Использование</h4>
|
||||||
|
<ol>
|
||||||
|
<li>Извлечь WindowsAuthentication.dll в каталог с 3proxy.exe
|
||||||
|
<li>Создать 3ProxyAllowedGroup - системная группа Windows, которой разрешено использование прокси. Ее необходимо создать (можно
|
||||||
|
использовать группу с другим именем, см. ниже). Учетные записи пользователей, которым разрешен доступ к прокси
|
||||||
|
должны быть включены в группу непосредственно или посредством включения их групп. Группа может быть как локальной, так и в
|
||||||
|
ActiveDirectory.
|
||||||
|
<li>В файле конфигурации загрузить dll с помощью команды plugin:
|
||||||
|
<br>plugin "WindowsAuthentication.dll" WindowsAuthentication "3ProxyAllowedGroup"
|
||||||
|
<br>Если DLL находится в другом каталоге, то вместо "WindowsAuthentication.dll"
|
||||||
|
необходимо указать полный путь к DLL. 3ProxyAllowedGroup - название системной группы,
|
||||||
|
которой разрешен доступ к прокси.
|
||||||
|
<li>Плагин добавляет новый тип аутентификации - windows. Т.е. для использования
|
||||||
|
Windows-аутентификации надо дать команду
|
||||||
|
<pre>
|
||||||
|
auth windows
|
||||||
|
</pre>
|
||||||
|
<li>Не рекомендуется использовать данный плагин без кэширования
|
||||||
|
аутентификации (authcache), т.к. это приведет к увеличению нагрузки на
|
||||||
|
сервер/контроллер домена. Пример:
|
||||||
|
<pre>
|
||||||
|
authcache user,pass 900
|
||||||
|
auth cache windows
|
||||||
|
</pre>
|
||||||
|
|
||||||
|
<li>В настоящее время не поддерживается NTLM-аутентификация для плагинов,
|
||||||
|
поэтому необходимо запускать proxy с ключиком -n.
|
||||||
|
</ol>
|
||||||
|
<h4>Загрузить:</h4>
|
||||||
|
<ul>
|
||||||
|
<li>Плагин включен в дистрибутив 3proxy 0.6
|
||||||
|
</ul>
|
||||||
|
|
||||||
@@ -1,10 +1,10 @@
|
|||||||
<h3>3proxy security considirations</h3>
|
<h3>3proxy security considirations</h3>
|
||||||
</ul>
|
</ul>
|
||||||
<ol>
|
<ul>
|
||||||
<li>Never install 3proxy suid. If you need it to run suid write some
|
<li>Never install 3proxy suid. If you need it to run suid write some
|
||||||
wrapper with fixed configuration file.
|
wrapper with fixed configuration file.
|
||||||
<li>Make configuration file only available to account 3proxy starts with.
|
<li>Make configuration file only available to account 3proxy starts with.
|
||||||
<li>Under Windows NT/2000/XP/2003 if 3proxy is used as service create new
|
<li>Under Windows if 3proxy is used as service create new
|
||||||
unprivileged local account without "logon locally" right. Assign this account
|
unprivileged local account without "logon locally" right. Assign this account
|
||||||
to 3proxy service.
|
to 3proxy service.
|
||||||
<li>Under unix use chroot to jail 3proxy (make sure files included in
|
<li>Under unix use chroot to jail 3proxy (make sure files included in
|
||||||
@@ -20,9 +20,8 @@ authentication method is currently available.
|
|||||||
<li>Always limit connections to internal network and localhost (to 127.0.0.1 and
|
<li>Always limit connections to internal network and localhost (to 127.0.0.1 and
|
||||||
all interfaces) with ACLs. Be carefull, because BIND command in SOCKS requies
|
all interfaces) with ACLs. Be carefull, because BIND command in SOCKS requies
|
||||||
BIND method with external interface IP address to be allowed.
|
BIND method with external interface IP address to be allowed.
|
||||||
<li> Always use nserver and nscache under Unix, overwise DoS attack is possible
|
<li> Before 3proxy 0.8 always use nserver and nscache under Unix, overwise DoS attack is possible
|
||||||
with unreachable DNS server (because gethostbyname will block over threads).
|
with unreachable DNS server (because gethostbyname will block over threads).
|
||||||
<li>Remember, that 'nbname' authentication is not reliable and can be spoofed.
|
|
||||||
<li>Keep logs in secure location, because some confidential information from
|
<li>Keep logs in secure location, because some confidential information from
|
||||||
user's request can be logged.
|
user's request can be logged.
|
||||||
<li>Use -xyz+A character filtering sequences for 'logformat', especially with
|
<li>Use -xyz+A character filtering sequences for 'logformat', especially with
|
||||||
@@ -31,7 +30,6 @@ ODBC logging to prevent SQL and log record injections.
|
|||||||
<li>Participate in code audit :)
|
<li>Participate in code audit :)
|
||||||
</ol>
|
</ol>
|
||||||
|
|
||||||
</ol>
|
</ul>
|
||||||
<p>
|
<p>
|
||||||
|
|
||||||
<pre>$Id: securityen.html,v 1.4 2007/05/07 09:16:51 vlad Exp $</pre>
|
|
||||||
+1735
-1822
File diff suppressed because it is too large.
Load diff
@@ -96,4 +96,3 @@ setuid 65534
|
|||||||
После того как мы создали конфигурационный файл сервера, запускаем 3proxy командой:
|
После того как мы создали конфигурационный файл сервера, запускаем 3proxy командой:
|
||||||
/usr/local/3proxy/3proxy /usr/local/3proxy/3proxy.cfg
|
/usr/local/3proxy/3proxy /usr/local/3proxy/3proxy.cfg
|
||||||
|
|
||||||
$Id: example1.txt,v 1.7 2007/04/20 19:58:42 vlad Exp $
|
|
||||||
@@ -98,4 +98,3 @@ LIBS = -L /usr/local/lib -lodbc
|
|||||||
make clean
|
make clean
|
||||||
make -f Makefile.unix
|
make -f Makefile.unix
|
||||||
|
|
||||||
$Id: iodbc.txt,v 1.3 2006/02/08 17:59:07 vlad Exp $
|
|
||||||
+4
-6
@@ -1,4 +1,4 @@
|
|||||||
.TH 3proxy "8" "July 2009" "3proxy 0.7" "Universal proxy server"
|
.TH 3proxy "8" "January 2016" "3proxy 0.8" "Universal proxy server"
|
||||||
.SH NAME
|
.SH NAME
|
||||||
.B 3proxy
|
.B 3proxy
|
||||||
\- 3[APA3A] tiny proxy server, or trivial proxy server, or free proxy
|
\- 3[APA3A] tiny proxy server, or trivial proxy server, or free proxy
|
||||||
@@ -138,7 +138,7 @@ wget to automate this task.
|
|||||||
configuration file
|
configuration file
|
||||||
.SH BUGS
|
.SH BUGS
|
||||||
Report all bugs to
|
Report all bugs to
|
||||||
.BR 3proxy@security.nnov.ru
|
.BR 3proxy@3proxy.ru
|
||||||
.SH SEE ALSO
|
.SH SEE ALSO
|
||||||
3proxy.cfg(3), proxy(8), ftppr(8), socks(8), pop3p(8), tcppm(8), udppm(8),
|
3proxy.cfg(3), proxy(8), ftppr(8), socks(8), pop3p(8), tcppm(8), udppm(8),
|
||||||
kill(1), syslogd(8),
|
kill(1), syslogd(8),
|
||||||
@@ -147,7 +147,5 @@ http://3proxy.ru/
|
|||||||
.SH TRIVIA
|
.SH TRIVIA
|
||||||
3APA3A is pronounced as \`\`zaraza\'\'.
|
3APA3A is pronounced as \`\`zaraza\'\'.
|
||||||
.SH AUTHORS
|
.SH AUTHORS
|
||||||
3proxy is designed by 3APA3A
|
3proxy is designed by Vladimir 3APA3A Dubrovin
|
||||||
.RI ( 3APA3A@security.nnov.ru ),
|
.RI ( 3proxy@3proxy.ru )
|
||||||
Vladimir Dubrovin
|
|
||||||
.RI ( vlad@sandy.ru )
|
|
||||||
+224
-183
@@ -1,35 +1,37 @@
|
|||||||
.TH 3proxy.cfg "3" "July 2009" "3proxy 0.7" "Universal proxy server"
|
.TH 3proxy.cfg "3" "January 2016" "3proxy 0.8" "Universal proxy server"
|
||||||
.SH NAME
|
.SH NAME
|
||||||
.B 3proxy.cfg
|
.B 3proxy.cfg
|
||||||
\- 3proxy configuration file
|
\- 3proxy configuration file
|
||||||
.SH DESCRIPTION
|
.SH DESCRIPTION
|
||||||
Common structure:
|
Common structure:
|
||||||
.br
|
.br
|
||||||
Configuration file is a text file 3proxy reads configuration from. Each line
|
Configuration file is a text file 3proxy reads configuration from. Each line
|
||||||
of the file is a command executed immediately, as it was given from
|
of the file is a command executed immediately, as it was given from
|
||||||
console. Sequence of commands is important. Configuration file as actually a
|
console. Sequence of commands is important. Configuration file as actually a
|
||||||
script for 3proxy executable.
|
script for 3proxy executable.
|
||||||
Each line of the file is treated as a blank (space or tab) separated
|
Each line of the file is treated as a blank (space or tab) separated
|
||||||
command line. Additional space characters are ignored.
|
command line. Additional space characters are ignored.
|
||||||
Think about 3proxy as "application level router" with console interface.
|
Think about 3proxy as "application level router" with console interface.
|
||||||
|
|
||||||
.br
|
.br
|
||||||
Comments:
|
Comments:
|
||||||
.br
|
.br
|
||||||
Any string beginning with space character or \'#\' character is comment. It\'s
|
Any string beginning with space character or \'#\' character is comment. It\'s
|
||||||
ignored. <LF>s are ignored. <CR> is end of command.
|
ignored. <LF>s are ignored. <CR> is end of command.
|
||||||
|
|
||||||
.br
|
.br
|
||||||
Quotation:
|
Quotation:
|
||||||
.br
|
.br
|
||||||
Quotation character is " (double quote). Quotation must be used to quote
|
Quotation character is " (double quote). Quotation must be used to quote
|
||||||
spaces or another special characters. To use quotation character inside
|
spaces or another special characters. To use quotation character inside
|
||||||
quotation character must be dubbed (BASIC convention). For example to use
|
quotation character must be dubbed (BASIC convention). For example to use
|
||||||
HELLO "WORLD" as an argument you should use it as "HELLO ""WORLD"""\.
|
HELLO "WORLD" as an argument you should use it as "HELLO ""WORLD"""\.
|
||||||
Good practice is to quote any argument you use.
|
Good practice is to quote any argument you use.
|
||||||
|
|
||||||
.br
|
.br
|
||||||
File inclusion:
|
File inclusion:
|
||||||
.br
|
.br
|
||||||
You can include file by using $FILENAME macro (replace FILENAME with a path
|
You can include file by using $FILENAME macro (replace FILENAME with a path
|
||||||
to file, for example $/usr/local/etc/3proxy/conf.incl or
|
to file, for example $/usr/local/etc/3proxy/conf.incl or
|
||||||
$"c:\\Program Files\\3proxy\\include.cfg" Quotation is
|
$"c:\\Program Files\\3proxy\\include.cfg" Quotation is
|
||||||
required in last example because path contains space character.
|
required in last example because path contains space character.
|
||||||
@@ -39,9 +41,12 @@ Thus, include files are only useful to store long signle-line commands
|
|||||||
(like userlist, network lists, etc).
|
(like userlist, network lists, etc).
|
||||||
To use dollar sign somewhere in argument it must be quoted.
|
To use dollar sign somewhere in argument it must be quoted.
|
||||||
Recursion is not allowed.
|
Recursion is not allowed.
|
||||||
|
|
||||||
.br
|
.br
|
||||||
Next commands start gateway services:
|
Next commands start gateway services:
|
||||||
.br
|
.br
|
||||||
|
|
||||||
|
.br
|
||||||
.B proxy
|
.B proxy
|
||||||
[options]
|
[options]
|
||||||
.br
|
.br
|
||||||
@@ -103,15 +108,49 @@ change default server port to NUMBER
|
|||||||
.B -n
|
.B -n
|
||||||
disable NTLM authentication (required if passwords are stored in Unix crypt format.
|
disable NTLM authentication (required if passwords are stored in Unix crypt format.
|
||||||
.br
|
.br
|
||||||
|
.B -n1
|
||||||
|
enable NTLMv1 authentication.
|
||||||
|
.br
|
||||||
.B -s
|
.B -s
|
||||||
(for admin) - allow only secure operations (currently only traffic counters
|
(for admin) - secure, allow only secure operations (currently only traffic counters
|
||||||
view without ability to reset).
|
view without ability to reset).
|
||||||
.br
|
.br
|
||||||
|
(for dnspr) - simple, do not use 'resolver' and 3proxy cache, always use external DNS server.
|
||||||
|
.br
|
||||||
|
(for udppm) - singlepacket, expect only one packet from both client and server
|
||||||
|
.br
|
||||||
|
.B -u
|
||||||
|
Never ask for username/password
|
||||||
|
.br
|
||||||
|
.B -u2
|
||||||
|
(socks) require username/password in authentication methods
|
||||||
|
.br
|
||||||
.B -a
|
.B -a
|
||||||
(for proxy) - anonymous proxy (no information about client reported)
|
(for proxy) - anonymous proxy (no information about client reported)
|
||||||
.br
|
.br
|
||||||
.B -a1
|
.B -a1
|
||||||
(for proxy) - anonymous proxy (random client information reported)
|
(for proxy) - anonymous proxy (random client information reported)
|
||||||
|
.br
|
||||||
|
.B -a2
|
||||||
|
(for proxy) - generate Via: and X-Forwared-For: instead of Forwarded:
|
||||||
|
.br
|
||||||
|
.B -6
|
||||||
|
Only resolve IPv6 addresses. IPv4 addresses are packed in IPv6 in IPV6_V6ONLY compatible way.
|
||||||
|
.br
|
||||||
|
.B -4
|
||||||
|
Only resolve IPv4 addresses
|
||||||
|
.br
|
||||||
|
.B -46
|
||||||
|
Resolve IPv6 addresses if IPv4 address is not resolvable
|
||||||
|
.br
|
||||||
|
.B -64
|
||||||
|
Resolve IPv4 addresses if IPv6 address is not resolvable
|
||||||
|
.br
|
||||||
|
.B -RHOST:port
|
||||||
|
listen on given local HOST:port for incoming connections instead of making remote outgoing connection. Can be used with another 3proxy service running -r option for connect back functionality. Most commonly used with tcppm. HOST can be given as IP or hostname, useful in case of dynamic DNS.
|
||||||
|
.br
|
||||||
|
.B -rHOST:port
|
||||||
|
connect to given remote HOST:port instead of listening local connection on -p or default port. Can be used with another 3proxy service running -R option for connect back functionality. Most commonly used with proxy or socks. HOST can be given as IP or hostname, useful in case of dynamic DNS.
|
||||||
.br
|
.br
|
||||||
Also, all options mentioned for
|
Also, all options mentioned for
|
||||||
.BR proxy (8)
|
.BR proxy (8)
|
||||||
@@ -130,7 +169,9 @@ pop3username@pop3server. If POP3 proxy access must be authenticated, you can
|
|||||||
specify username as proxy_username:proxy_password:POP3_username@pop3server
|
specify username as proxy_username:proxy_password:POP3_username@pop3server
|
||||||
.br
|
.br
|
||||||
DNS proxy resolves any types of records but only hostnames are cached. It
|
DNS proxy resolves any types of records but only hostnames are cached. It
|
||||||
requires nserver/nscache to be configured.
|
requires nserver/nscache to be configured. If nserver is configured as TCP,
|
||||||
|
redirections are applied on connection, so parent proxy may be used to resolve
|
||||||
|
names to IP.
|
||||||
.br
|
.br
|
||||||
FTP proxy can be used as FTP server in any FTP client or configured as FTP
|
FTP proxy can be used as FTP server in any FTP client or configured as FTP
|
||||||
proxy on a client with FTP proxy support. Username format is one of
|
proxy on a client with FTP proxy support. Username format is one of
|
||||||
@@ -141,28 +182,24 @@ proxy on a client with FTP proxy support. Username format is one of
|
|||||||
.br
|
.br
|
||||||
proxyuser:proxypassword:FTPuser:FTPpassword@FTPserver
|
proxyuser:proxypassword:FTPuser:FTPpassword@FTPserver
|
||||||
.br
|
.br
|
||||||
Please note, if you use FTP client interface for FTP proxy
|
Please note, if you use FTP client interface for FTP proxy do not add FTPpassword and FTPServer to username, because FTP client does it for you. That is, if you use 3proxy with authentication use proxyuser:proxypassword:FTPuser as FTP username, otherwise do not change original FTP user name
|
||||||
do not add FTPpassword and FTPServer to username, because
|
|
||||||
FTP client does it for you. That is, if you use 3proxy with
|
|
||||||
authentication use
|
|
||||||
proxyuser:proxypassword:FTPuser
|
|
||||||
as FTP username, otherwise do not change original FTP user name
|
|
||||||
|
|
||||||
|
.br
|
||||||
.B include
|
.B include
|
||||||
<path>
|
<path>
|
||||||
.br
|
.br
|
||||||
Include config file
|
Include config file
|
||||||
|
|
||||||
.br
|
.br
|
||||||
.B config
|
.B config
|
||||||
<path>
|
<path>
|
||||||
.br
|
.br
|
||||||
Path to configuration file to use on 3proxy restart or to save configuration.
|
Path to configuration file to use on 3proxy restart or to save configuration.
|
||||||
|
|
||||||
.br
|
.br
|
||||||
.B writable
|
.B writable
|
||||||
.br
|
.br
|
||||||
ReOpens configuration file for write access via Web interface,
|
ReOpens configuration file for write access via Web interface,
|
||||||
and re-reads it. Usually should be first command on config file
|
and re-reads it. Usually should be first command on config file
|
||||||
but in combination with "config" it can be used anywhere to open
|
but in combination with "config" it can be used anywhere to open
|
||||||
alternate config file. Think twice before using it.
|
alternate config file. Think twice before using it.
|
||||||
@@ -170,13 +207,13 @@ alternate config file. Think twice before using it.
|
|||||||
.br
|
.br
|
||||||
.B end
|
.B end
|
||||||
.br
|
.br
|
||||||
End of configuration
|
End of configuration
|
||||||
|
|
||||||
.br
|
.br
|
||||||
.B log
|
.B log
|
||||||
[[@|&]logfile] [<LOGTYPE>]
|
[[@|&]logfile] [<LOGTYPE>]
|
||||||
.br
|
.br
|
||||||
sets logfile for all gateways
|
sets logfile for all gateways
|
||||||
.br
|
.br
|
||||||
@ - (for Unix) use syslog, filename is used as ident name
|
@ - (for Unix) use syslog, filename is used as ident name
|
||||||
.br
|
.br
|
||||||
@@ -192,10 +229,10 @@ sets logfile for all gateways
|
|||||||
.br
|
.br
|
||||||
H - Hourly
|
H - Hourly
|
||||||
.br
|
.br
|
||||||
if logfile is not specified logging goes to stdout. You can specify individual logging options for gateway by using
|
if logfile is not specified logging goes to stdout. You can specify individual logging options for gateway by using
|
||||||
-l option in gateway configuration.
|
-l option in gateway configuration.
|
||||||
.br
|
.br
|
||||||
"log" command supports same format specifications for filename template
|
"log" command supports same format specifications for filename template
|
||||||
as "logformat" (if filename contains '%' sign it's believed to be template).
|
as "logformat" (if filename contains '%' sign it's believed to be template).
|
||||||
As with "logformat" filename must begin with 'L' or 'G' to specify Local or
|
As with "logformat" filename must begin with 'L' or 'G' to specify Local or
|
||||||
Grinwitch time zone for all time-based format specificators.
|
Grinwitch time zone for all time-based format specificators.
|
||||||
@@ -203,13 +240,13 @@ Grinwitch time zone for all time-based format specificators.
|
|||||||
.br
|
.br
|
||||||
.B rotate
|
.B rotate
|
||||||
<n>
|
<n>
|
||||||
how many archived log files to keep
|
how many archived log files to keep
|
||||||
|
|
||||||
.br
|
.br
|
||||||
.B logformat
|
.B logformat
|
||||||
<format>
|
<format>
|
||||||
|
.br
|
||||||
Format for log record. First symbol in format must be L (local time)
|
Format for log record. First symbol in format must be L (local time)
|
||||||
or G (absolute Grinwitch time).
|
or G (absolute Grinwitch time).
|
||||||
It can be preceeded with -XXX+Y where XXX is list of characters to be
|
It can be preceeded with -XXX+Y where XXX is list of characters to be
|
||||||
filtered in user input (any non-printable characters are filtered too
|
filtered in user input (any non-printable characters are filtered too
|
||||||
@@ -217,72 +254,72 @@ in this case) and Y is replacement character. For example, "-,%+ L" in
|
|||||||
the beginning of logformat means comma and percent are replaced
|
the beginning of logformat means comma and percent are replaced
|
||||||
with space and all time based elemnts are in local time zone.
|
with space and all time based elemnts are in local time zone.
|
||||||
.br
|
.br
|
||||||
You can use:
|
You can use:
|
||||||
|
|
||||||
.br
|
.br
|
||||||
%y - Year in 2 digit format
|
%y - Year in 2 digit format
|
||||||
.br
|
.br
|
||||||
%Y - Year in 4 digit format
|
%Y - Year in 4 digit format
|
||||||
.br
|
.br
|
||||||
%m - Month number
|
%m - Month number
|
||||||
.br
|
.br
|
||||||
%o - Month abbriviature
|
%o - Month abbriviature
|
||||||
.br
|
.br
|
||||||
%d - Day
|
%d - Day
|
||||||
.br
|
.br
|
||||||
%H - Hour
|
%H - Hour
|
||||||
.br
|
.br
|
||||||
%M - Minute
|
%M - Minute
|
||||||
.br
|
.br
|
||||||
%S - Second
|
%S - Second
|
||||||
.br
|
.br
|
||||||
%t - Timstamp (in seconds since 01-Jan-1970)
|
%t - Timstamp (in seconds since 01-Jan-1970)
|
||||||
.br
|
.br
|
||||||
%. - milliseconds
|
%. - milliseconds
|
||||||
.br
|
.br
|
||||||
%z - timeZone (from Grinvitch)
|
%z - timeZone (from Grinvitch)
|
||||||
.br
|
.br
|
||||||
%D - request duration (in milliseconds)
|
%D - request duration (in milliseconds)
|
||||||
.br
|
.br
|
||||||
%b - average send rate per request (in Bytes per second) this speed is typically below connection speed shown by download manager.
|
%b - average send rate per request (in Bytes per second) this speed is typically below connection speed shown by download manager.
|
||||||
.br
|
.br
|
||||||
%B - average receive rate per request (in Bytes per second) this speed is typically below connection speed shown by download manager.
|
%B - average receive rate per request (in Bytes per second) this speed is typically below connection speed shown by download manager.
|
||||||
.br
|
.br
|
||||||
%U - Username
|
%U - Username
|
||||||
.br
|
.br
|
||||||
%N - service Name
|
%N - service Name
|
||||||
.br
|
.br
|
||||||
%p - service Port
|
%p - service Port
|
||||||
.br
|
.br
|
||||||
%E - Error code
|
%E - Error code
|
||||||
.br
|
.br
|
||||||
%C - Client IP
|
%C - Client IP
|
||||||
.br
|
.br
|
||||||
%c - Client port
|
%c - Client port
|
||||||
.br
|
.br
|
||||||
%R - Remote IP
|
%R - Remote IP
|
||||||
.br
|
.br
|
||||||
%r - Remote port
|
%r - Remote port
|
||||||
.br
|
.br
|
||||||
%e - External IP used to establish connection
|
%e - External IP used to establish connection
|
||||||
.br
|
.br
|
||||||
%Q - Requested IP
|
%Q - Requested IP
|
||||||
.br
|
.br
|
||||||
%q - Requested port
|
%q - Requested port
|
||||||
.br
|
.br
|
||||||
%n - requested hostname
|
%n - requested hostname
|
||||||
.br
|
.br
|
||||||
%I - bytes In
|
%I - bytes In
|
||||||
.br
|
.br
|
||||||
%O - bytes Out
|
%O - bytes Out
|
||||||
.br
|
.br
|
||||||
%h - Hops (redirections) count
|
%h - Hops (redirections) count
|
||||||
.br
|
.br
|
||||||
%T - service specific Text
|
%T - service specific Text
|
||||||
.br
|
.br
|
||||||
%N1-N2T - (N1 and N2 are positive numbers) - log only fields from N1 thorugh N2 of service specific text
|
%N1-N2T - (N1 and N2 are positive numbers) - log only fields from N1 thorugh N2 of service specific text
|
||||||
.br
|
.br
|
||||||
in case of ODBC logging logformat specifies SQL statement, for exmample:
|
in case of ODBC logging logformat specifies SQL statement, for exmample:
|
||||||
.br
|
.br
|
||||||
logformat "-'+_Linsert into log (l_date, l_user, l_service, l_in, l_out, l_descr) values ('%d-%m-%Y %H:%M:%S', '%U', '%N', %I, %O, '%T')"
|
logformat "-'+_Linsert into log (l_date, l_user, l_service, l_in, l_out, l_descr) values ('%d-%m-%Y %H:%M:%S', '%U', '%N', %I, %O, '%T')"
|
||||||
|
|
||||||
@@ -290,7 +327,7 @@ in case of ODBC logging logformat specifies SQL statement, for exmample:
|
|||||||
.B logdump
|
.B logdump
|
||||||
<in_traffic_limit> <out_traffic_limit>
|
<in_traffic_limit> <out_traffic_limit>
|
||||||
.br
|
.br
|
||||||
Immediately creates additional log records if given amount of incoming/outgoing
|
Immediately creates additional log records if given amount of incoming/outgoing
|
||||||
traffic is achieved for connection, without waiting for connection to finish.
|
traffic is achieved for connection, without waiting for connection to finish.
|
||||||
It may be useful to prevent information about long-lasting downloads on server
|
It may be useful to prevent information about long-lasting downloads on server
|
||||||
shutdown.
|
shutdown.
|
||||||
@@ -299,7 +336,7 @@ shutdown.
|
|||||||
.B archiver
|
.B archiver
|
||||||
<ext> <commandline>
|
<ext> <commandline>
|
||||||
.br
|
.br
|
||||||
Archiver to use for log files. <ext> is file extension produced by
|
Archiver to use for log files. <ext> is file extension produced by
|
||||||
archiver. Filename will be last argument to archiver, optionally you
|
archiver. Filename will be last argument to archiver, optionally you
|
||||||
can use %A as produced archive name and %F as filename.
|
can use %A as produced archive name and %F as filename.
|
||||||
|
|
||||||
@@ -307,47 +344,51 @@ can use %A as produced archive name and %F as filename.
|
|||||||
.B timeouts
|
.B timeouts
|
||||||
<BYTE_SHORT> <BYTE_LONG> <STRING_SHORT> <STRING_LONG> <CONNECTION_SHORT> <CONNECTION_LONG> <DNS> <CHAIN>
|
<BYTE_SHORT> <BYTE_LONG> <STRING_SHORT> <STRING_LONG> <CONNECTION_SHORT> <CONNECTION_LONG> <DNS> <CHAIN>
|
||||||
.br
|
.br
|
||||||
Sets timeout values
|
Sets timeout values
|
||||||
.br
|
.br
|
||||||
BYTE_SHORT - short timeout for single byte, is usually used for receiving single byte from stream.
|
BYTE_SHORT - short timeout for single byte, is usually used for receiving single byte from stream.
|
||||||
.br
|
.br
|
||||||
BYTE_LONG - long timeout for single byte, is usually used for receiving first byte in frame (for example first byte in socks request).
|
BYTE_LONG - long timeout for single byte, is usually used for receiving first byte in frame (for example first byte in socks request).
|
||||||
.br
|
.br
|
||||||
STRING_SHORT - short timeout, for character string within stream (for example to wait between 2 HTTP headers)
|
STRING_SHORT - short timeout, for character string within stream (for example to wait between 2 HTTP headers)
|
||||||
.br
|
.br
|
||||||
STRING_LONG - long timeout, for first string in stream (for example to wait for HTTP request).
|
STRING_LONG - long timeout, for first string in stream (for example to wait for HTTP request).
|
||||||
.br
|
.br
|
||||||
CONNECTION_SHORT - inactivity timeout for short connections (HTTP, POP3, etc).
|
CONNECTION_SHORT - inactivity timeout for short connections (HTTP, POP3, etc).
|
||||||
.br
|
.br
|
||||||
CONNECTION_LONG - inactivity timeout for long connection (SOCKS, portmappers, etc).
|
CONNECTION_LONG - inactivity timeout for long connection (SOCKS, portmappers, etc).
|
||||||
.br
|
.br
|
||||||
DNS - timeout for DNS request before requesting next server
|
DNS - timeout for DNS request before requesting next server
|
||||||
.br
|
.br
|
||||||
CHAIN - timeout for reading data from chained connection
|
CHAIN - timeout for reading data from chained connection
|
||||||
.br
|
.br
|
||||||
|
|
||||||
.br
|
.br
|
||||||
.B nserver
|
.B nserver
|
||||||
<ipaddr>
|
<ipaddr>[:port][/tcp]
|
||||||
.br
|
.br
|
||||||
Nameserver to use for name resolutions. If none spcified system
|
Nameserver to use for name resolutions. If none specified
|
||||||
or name server fails system routines for name resolution will be
|
or name server fails system routines for name resolution will be
|
||||||
used. It's better to specify nserver because gethostbyname() may
|
used. It's better to specify nserver because gethostbyname() may
|
||||||
be thread unsafe.
|
be thread unsafe. Optional port number may be specified.
|
||||||
|
If optional /tcp is added to IP address, name resolution will be
|
||||||
|
performed over TCP.
|
||||||
|
|
||||||
.br
|
.br
|
||||||
.B nscache
|
.B nscache
|
||||||
<cachesize>
|
<cachesize>
|
||||||
|
.B nscache6
|
||||||
|
<cachesize>
|
||||||
.br
|
.br
|
||||||
|
Cache <cachesize> records for name resolution (nscache for IPv4,
|
||||||
Cache <cachesize> records for name resolution. Cachesize usually
|
nscache6 for IPv6). Cachesize usually should be large enougth
|
||||||
should be large enougth (for example 65536).
|
(for example 65536).
|
||||||
|
|
||||||
.br
|
.br
|
||||||
.B nsrecord
|
.B nsrecord
|
||||||
<hostname> <hostaddr>
|
<hostname> <hostaddr>
|
||||||
.BR
|
.br
|
||||||
Adds static record to nscache. nscache must be enabled. If 0.0.0.0
|
Adds static record to nscache. nscache must be enabled. If 0.0.0.0
|
||||||
is used as a hostaddr host will never resolve, it can be used to
|
is used as a hostaddr host will never resolve, it can be used to
|
||||||
blacklist something or together with
|
blacklist something or together with
|
||||||
.B dialer
|
.B dialer
|
||||||
@@ -355,15 +396,15 @@ command to set up UDL for dialing.
|
|||||||
|
|
||||||
.br
|
.br
|
||||||
.B fakeresolve
|
.B fakeresolve
|
||||||
.BR
|
.br
|
||||||
All names are resolved to 127.0.0.2 address. Usefull if all requests are
|
All names are resolved to 127.0.0.2 address. Usefull if all requests are
|
||||||
redirected to parent proxy with http, socks4+, connect+ or socks5+.
|
redirected to parent proxy with http, socks4+, connect+ or socks5+.
|
||||||
|
|
||||||
.br
|
.br
|
||||||
.B dialer
|
.B dialer
|
||||||
<progname>
|
<progname>
|
||||||
.br
|
.br
|
||||||
Execute progname if external name can't be resolved.
|
Execute progname if external name can't be resolved.
|
||||||
Hint: if you use nscache, dialer may not work, because names will
|
Hint: if you use nscache, dialer may not work, because names will
|
||||||
be resolved through cache. In this case you can use something like
|
be resolved through cache. In this case you can use something like
|
||||||
http://dial.right.now/ from browser to set up connection.
|
http://dial.right.now/ from browser to set up connection.
|
||||||
@@ -373,29 +414,30 @@ http://dial.right.now/ from browser to set up connection.
|
|||||||
.B internal
|
.B internal
|
||||||
<ipaddr>
|
<ipaddr>
|
||||||
.br
|
.br
|
||||||
sets ip address of internal interface. This IP address will be used
|
sets ip address of internal interface. This IP address will be used
|
||||||
to bind gateways. Alternatively you can use -i option for individual
|
to bind gateways. Alternatively you can use -i option for individual
|
||||||
gateways
|
gateways. Since 0.8 version, IPv6 address may be used.
|
||||||
|
|
||||||
.br
|
.br
|
||||||
.B external
|
.B external
|
||||||
<ipaddr>
|
<ipaddr>
|
||||||
.br
|
.br
|
||||||
sets ip address of external interface. This IP address will be source
|
sets ip address of external interface. This IP address will be source
|
||||||
address for all connections made by proxy. Alternatively you can use
|
address for all connections made by proxy. Alternatively you can use
|
||||||
-e option to specify individual address for gateway.
|
-e option to specify individual address for gateway. Since 0.8 version
|
||||||
|
External or -e can be given twice: once with IPv4 and once with IPv6 address.
|
||||||
|
|
||||||
.br
|
.br
|
||||||
.B maxconn
|
.B maxconn
|
||||||
<number>
|
<number>
|
||||||
.br
|
.br
|
||||||
sets maximum number of simulationeous connections to each services
|
sets maximum number of simulationeous connections to each services
|
||||||
started after this command. Default is 100.
|
started after this command. Default is 100.
|
||||||
|
|
||||||
.br
|
.br
|
||||||
.B service
|
.B service
|
||||||
.br
|
.br
|
||||||
(depricated). Indicates 3proxy to behave as Windows 95/98/NT/2000/XP
|
(depricated). Indicates 3proxy to behave as Windows 95/98/NT/2000/XP
|
||||||
service, no effect for Unix. Not required for 3proxy 0.6 and above. If
|
service, no effect for Unix. Not required for 3proxy 0.6 and above. If
|
||||||
you upgraded from previous version of 3proxy use --remove and --install
|
you upgraded from previous version of 3proxy use --remove and --install
|
||||||
to reinstall service.
|
to reinstall service.
|
||||||
@@ -403,7 +445,7 @@ to reinstall service.
|
|||||||
.br
|
.br
|
||||||
.B daemon
|
.B daemon
|
||||||
.br
|
.br
|
||||||
Should be specified to close console. Do not use 'daemon' with 'service'.
|
Should be specified to close console. Do not use 'daemon' with 'service'.
|
||||||
At least under FreeBSD 'daemon' should preceed any proxy service
|
At least under FreeBSD 'daemon' should preceed any proxy service
|
||||||
and log commands to avoid sockets problem. Always place it in the beginning
|
and log commands to avoid sockets problem. Always place it in the beginning
|
||||||
of the configuration file.
|
of the configuration file.
|
||||||
@@ -412,68 +454,64 @@ of the configuration file.
|
|||||||
.B auth
|
.B auth
|
||||||
<authtype> [...]
|
<authtype> [...]
|
||||||
.br
|
.br
|
||||||
Type of user authorization. Currently supported:
|
Type of user authorization. Currently supported:
|
||||||
|
.br
|
||||||
|
none - no authentication or authorization required.
|
||||||
.br
|
.br
|
||||||
none - no authentication or authorization required.
|
|
||||||
Note: is auth is none any ip based limitation, redirection, etc will not work.
|
Note: is auth is none any ip based limitation, redirection, etc will not work.
|
||||||
This is default authentication type
|
This is default authentication type
|
||||||
.br
|
.br
|
||||||
iponly - authentication by access control list with username ignored.
|
iponly - authentication by access control list with username ignored.
|
||||||
Appropriate for most cases
|
Appropriate for most cases
|
||||||
.br
|
.br
|
||||||
useronly - authentication by username without checking for any password with
|
useronly - authentication by username without checking for any password with
|
||||||
authorization by ACLs. Useful for e.g. SOCKSv4 proxy and icqpr (icqpr set UIN /
|
authorization by ACLs. Useful for e.g. SOCKSv4 proxy and icqpr (icqpr set UIN /
|
||||||
AOL screen name as a username)
|
AOL screen name as a username)
|
||||||
.br
|
.br
|
||||||
dnsname - authentication by DNS hostnname with authorization by ACLs.
|
dnsname - authentication by DNS hostnname with authorization by ACLs.
|
||||||
DNS hostname is resolved via PTR (reverse) record and validated (resolved
|
DNS hostname is resolved via PTR (reverse) record and validated (resolved
|
||||||
name must resolve to same IP address). It's recommended to use authcache by
|
name must resolve to same IP address). It's recommended to use authcache by
|
||||||
ip for this authentication.
|
ip for this authentication.
|
||||||
NB: there is no any password check, name may be spoofed.
|
NB: there is no any password check, name may be spoofed.
|
||||||
.br
|
.br
|
||||||
nbname - authentication by NetBIOS name with authorization by ACLs.
|
strong - username/password authentication required. It will work with
|
||||||
Messanger service should be started on user's machine. Note, that
|
|
||||||
Windows 95/98 hosts do not have messanger service by default,
|
|
||||||
WinPopup program need to be started. It's recommended to use authcache by
|
|
||||||
ip for this authentication.
|
|
||||||
NB: there is no any password check, name may be spoofed.
|
|
||||||
.br
|
|
||||||
strong - username/password authentication required. It will work with
|
|
||||||
SOCKSv5, FTP, POP3 and HTTP proxy.
|
SOCKSv5, FTP, POP3 and HTTP proxy.
|
||||||
.br
|
.br
|
||||||
cache - cached authentication, may be used with 'authcache'.
|
cache - cached authentication, may be used with 'authcache'.
|
||||||
.br
|
.br
|
||||||
Plugins may add additional authentication types.
|
Plugins may add additional authentication types.
|
||||||
.br
|
.br
|
||||||
|
|
||||||
It's possible to use few authentication types in the same commands. E.g.
|
It's possible to use few authentication types in the same commands. E.g.
|
||||||
.br
|
.br
|
||||||
auth iponly strong
|
auth iponly strong
|
||||||
.br
|
.br
|
||||||
In this case 'strong' authentication will be used only in case resource
|
In this case 'strong' authentication will be used only in case resource
|
||||||
access can not be performed with 'iponly' authentication, that is username is
|
access can not be performed with 'iponly' authentication, that is username is
|
||||||
required in ACL. It's usefull to protect access to some resources with
|
required in ACL. It's usefull to protect access to some resources with
|
||||||
password allowing passwordless access to another resources, or to use
|
password allowing passwordless access to another resources, or to use
|
||||||
IP-based authentication for dedicated laptops and request username/password for
|
IP-based authentication for dedicated laptops and request username/password for
|
||||||
shared ones.
|
shared ones.
|
||||||
|
|
||||||
.br
|
.br
|
||||||
.B authcache
|
.B authcache
|
||||||
<cachtype> <cachtime>
|
<cachtype> <cachtime>
|
||||||
.br
|
.br
|
||||||
Cache authentication information to given amount of time (cachetime) in seconds.
|
Cache authentication information to given amount of time (cachetime) in seconds.
|
||||||
Cahtype is one of:
|
Cahtype is one of:
|
||||||
.br
|
.br
|
||||||
ip - after successful authentication all connections during caching time
|
ip - after successful authentication all connections during caching time
|
||||||
from same IP are assigned to the same user, username is not requested.
|
from same IP are assigned to the same user, username is not requested.
|
||||||
.br
|
.br
|
||||||
ip,user username is requested and all connections from the same IP are
|
ip,user username is requested and all connections from the same IP are
|
||||||
assigned to the same user without actual authentication.
|
assigned to the same user without actual authentication.
|
||||||
.br
|
.br
|
||||||
user - same as above, but IP is not checked.
|
user - same as above, but IP is not checked.
|
||||||
.br
|
.br
|
||||||
user,password - both username and password are checked against cached ones.
|
user,password - both username and password are checked against cached ones.
|
||||||
.br
|
.br
|
||||||
Use auth type 'cache' for cached authentication
|
Use auth type 'cache' for cached authentication
|
||||||
|
|
||||||
.br
|
.br
|
||||||
.B allow
|
.B allow
|
||||||
<userlist> <sourcelist> <targetlist> <targetportlist> <operationlist>
|
<userlist> <sourcelist> <targetlist> <targetportlist> <operationlist>
|
||||||
@@ -483,11 +521,12 @@ Use auth type 'cache' for cached authentication
|
|||||||
<userlist> <sourcelist> <targetlist> <targetportlist> <operationlist>
|
<userlist> <sourcelist> <targetlist> <targetportlist> <operationlist>
|
||||||
<weekdayslist> <timeperiodslist>
|
<weekdayslist> <timeperiodslist>
|
||||||
.br
|
.br
|
||||||
Access control entries. All lists are comma-separated, no spaces are
|
Access control entries. All lists are comma-separated, no spaces are
|
||||||
allowed. Usernames are case sensitive (if used with authtype nbname
|
allowed. Usernames are case sensitive (if used with authtype nbname
|
||||||
username must be in uppercase). Source and target lists may contain
|
username must be in uppercase). Source and target lists may contain
|
||||||
IP addresses (W.X.Y.Z) or CIDRs (W.X.Y.Z/L). Since 0.6, targetlist may also
|
IP addresses (W.X.Y.Z), ranges A.B.C.D - W.X.Y.Z (since 0.8) or CIDRs
|
||||||
contain host names, instead of addresses. It's possible to use wildmask in
|
(W.X.Y.Z/L). Since 0.6, targetlist may also contain host names,
|
||||||
|
instead of addresses. It's possible to use wildmask in
|
||||||
the begginning and in the the end of hostname, e.g. *badsite.com or
|
the begginning and in the the end of hostname, e.g. *badsite.com or
|
||||||
*badcontent*. Hostname is only checked if hostname presents in request.
|
*badcontent*. Hostname is only checked if hostname presents in request.
|
||||||
Targetportlist may contain ports (X) or port ranges lists (X-Y). For any field
|
Targetportlist may contain ports (X) or port ranges lists (X-Y). For any field
|
||||||
@@ -509,55 +548,51 @@ to appropriate interface only or to use ip filters.
|
|||||||
|
|
||||||
Operation is one of:
|
Operation is one of:
|
||||||
.br
|
.br
|
||||||
CONNECT - establish outgoing TCP connection
|
CONNECT - establish outgoing TCP connection
|
||||||
.br
|
.br
|
||||||
BIND - bind TCP port for listening
|
BIND - bind TCP port for listening
|
||||||
.br
|
.br
|
||||||
UDPASSOC - make UDP association
|
UDPASSOC - make UDP association
|
||||||
.br
|
.br
|
||||||
ICMPASSOC - make ICMP association (for future use)
|
ICMPASSOC - make ICMP association (for future use)
|
||||||
.br
|
.br
|
||||||
HTTP_GET - HTTP GET request
|
HTTP_GET - HTTP GET request
|
||||||
.br
|
.br
|
||||||
HTTP_PUT - HTTP PUT request
|
HTTP_PUT - HTTP PUT request
|
||||||
.br
|
.br
|
||||||
HTTP_POST - HTTP POST request
|
HTTP_POST - HTTP POST request
|
||||||
.br
|
.br
|
||||||
HTTP_HEAD - HTTP HEAD request
|
HTTP_HEAD - HTTP HEAD request
|
||||||
.br
|
.br
|
||||||
HTTP_CONNECT - HTTP CONNECT request
|
HTTP_CONNECT - HTTP CONNECT request
|
||||||
.br
|
.br
|
||||||
HTTP_OTHER - over HTTP request
|
HTTP_OTHER - over HTTP request
|
||||||
.br
|
.br
|
||||||
HTTP - matches any HTTP request except HTTP_CONNECT
|
HTTP - matches any HTTP request except HTTP_CONNECT
|
||||||
.br
|
.br
|
||||||
HTTPS - same as HTTP_CONNECT
|
HTTPS - same as HTTP_CONNECT
|
||||||
.br
|
.br
|
||||||
FTP_GET - FTP get request
|
FTP_GET - FTP get request
|
||||||
.br
|
.br
|
||||||
FTP_PUT - FTP put request
|
FTP_PUT - FTP put request
|
||||||
.br
|
.br
|
||||||
FTP_LIST - FTP list request
|
FTP_LIST - FTP list request
|
||||||
.br
|
.br
|
||||||
FTP_DATA - FTP data connection. Note: FTP_DATA requires access to dynamic
|
FTP_DATA - FTP data connection. Note: FTP_DATA requires access to dynamic
|
||||||
non-ptivileged (1024-65535) ports on remote side.
|
non-ptivileged (1024-65535) ports on remote side.
|
||||||
.br
|
.br
|
||||||
FTP - matches any FTP/FTP Data request
|
FTP - matches any FTP/FTP Data request
|
||||||
.br
|
.br
|
||||||
ADMIN - access to administration interface
|
ADMIN - access to administration interface
|
||||||
.br
|
.br
|
||||||
|
Weeksdays are week days numbers or periods, 0 or 7 means Sunday, 1 is Monday, 1-5 means Monday through Friday. Timeperiodlists is a list of time
|
||||||
Weeksdays are week days numbers or periods (0 or 7 means Sunday, 1 is Monday,
|
periods in HH:MM:SS-HH:MM:SS format. For example, 00:00:00-08:00:00,17:00:00-24:00:00 lists non-working hours.
|
||||||
1-5 means Monday through Friday). Timeperiodlists is a list of time
|
|
||||||
periods in HH:MM:SS-HH:MM:SS format. For example,
|
|
||||||
00:00:00-08:00:00,17:00:00-24:00:00
|
|
||||||
lists non-working hours.
|
|
||||||
|
|
||||||
.br
|
.br
|
||||||
.B parent
|
.B parent
|
||||||
<weight> <type> <ip> <port> <username> <password>
|
<weight> <type> <ip> <port> <username> <password>
|
||||||
.br
|
.br
|
||||||
this command must follow "allow" rule. It extends last allow rule to
|
this command must follow "allow" rule. It extends last allow rule to
|
||||||
build proxy chain. Proxies may be grouped. Proxy inside the
|
build proxy chain. Proxies may be grouped. Proxy inside the
|
||||||
group is selected randomly. If few groups are specified one proxy
|
group is selected randomly. If few groups are specified one proxy
|
||||||
is randomly picked from each group and chain of proxies is created
|
is randomly picked from each group and chain of proxies is created
|
||||||
@@ -592,38 +627,38 @@ with probability of 0.7) for outgoing web connections.
|
|||||||
.br
|
.br
|
||||||
type is one of:
|
type is one of:
|
||||||
.br
|
.br
|
||||||
tcp - simply redirect connection. TCP is always last in chain.
|
tcp - simply redirect connection. TCP is always last in chain.
|
||||||
.br
|
.br
|
||||||
http - redirect to HTTP proxy. HTTP is always last chain.
|
http - redirect to HTTP proxy. HTTP is always last chain.
|
||||||
.br
|
.br
|
||||||
pop3 - redirect to POP3 proxy (only local redirection is supported, can not be
|
pop3 - redirect to POP3 proxy (only local redirection is supported, can not be
|
||||||
used for chaining)
|
used for chaining)
|
||||||
.br
|
.br
|
||||||
ftp - redirect to FTP proxy (only local redirection is supported, can not be
|
ftp - redirect to FTP proxy (only local redirection is supported, can not be
|
||||||
used for chaining)
|
used for chaining)
|
||||||
.br
|
.br
|
||||||
connect - parent is HTTP CONNECT method proxy
|
connect - parent is HTTP CONNECT method proxy
|
||||||
.br
|
.br
|
||||||
connect+ - parent is HTTP CONNECT proxy with name resolution
|
connect+ - parent is HTTP CONNECT proxy with name resolution
|
||||||
.br
|
.br
|
||||||
socks4 - parent is SOCKSv4 proxy
|
socks4 - parent is SOCKSv4 proxy
|
||||||
.br
|
.br
|
||||||
socks4+ - parent is SOCKSv4 proxy with name resolution (SOCKSv4a)
|
socks4+ - parent is SOCKSv4 proxy with name resolution (SOCKSv4a)
|
||||||
.br
|
.br
|
||||||
socks5 - parent is SOCKSv5 proxy
|
socks5 - parent is SOCKSv5 proxy
|
||||||
.br
|
.br
|
||||||
socks5+ - parent is SOCKSv5 proxy with name resolution
|
socks5+ - parent is SOCKSv5 proxy with name resolution
|
||||||
.br
|
.br
|
||||||
socks4b - parent is SOCKS4b (broken SOCKSv4 implementation with shortened
|
socks4b - parent is SOCKS4b (broken SOCKSv4 implementation with shortened
|
||||||
server reply. I never saw this kind ofservers byt they say there are).
|
server reply. I never saw this kind ofservers byt they say there are).
|
||||||
Normally you should not use this option. Do not mess this option with
|
Normally you should not use this option. Do not mess this option with
|
||||||
SOCKSv4a (socks4+).
|
SOCKSv4a (socks4+).
|
||||||
.br
|
.br
|
||||||
socks5b - parent is SOCKS5b (broken SOCKSv5 implementation with shortened
|
socks5b - parent is SOCKS5b (broken SOCKSv5 implementation with shortened
|
||||||
server reply. I think you will never find it useful). Never use this option
|
server reply. I think you will never find it useful). Never use this option
|
||||||
unless you know exactly you need it.
|
unless you know exactly you need it.
|
||||||
.br
|
.br
|
||||||
admin - redirect request to local 'admin' service (with -s parameter).
|
admin - redirect request to local 'admin' service (with -s parameter).
|
||||||
.br
|
.br
|
||||||
Use "+" proxy only with "fakeresolve" option
|
Use "+" proxy only with "fakeresolve" option
|
||||||
.br
|
.br
|
||||||
@@ -664,14 +699,14 @@ example:
|
|||||||
.br
|
.br
|
||||||
socks
|
socks
|
||||||
.br
|
.br
|
||||||
redirects all SOCKS requests with target port 80 to local HTTP proxy,
|
redirects all SOCKS requests with target port 80 to local HTTP proxy,
|
||||||
local HTTP proxy parses requests and allows only GET and POST requests.
|
local HTTP proxy parses requests and allows only GET and POST requests.
|
||||||
.br
|
.br
|
||||||
parent 1000 http 1.2.3.4 0
|
parent 1000 http 1.2.3.4 0
|
||||||
.br
|
.br
|
||||||
Changes external address for given connection to 1.2.3.4
|
Changes external address for given connection to 1.2.3.4
|
||||||
(an equivalent to -e1.2.3.4)
|
(an equivalent to -e1.2.3.4)
|
||||||
|
.br
|
||||||
Optional username and password are used to authenticate on parent
|
Optional username and password are used to authenticate on parent
|
||||||
proxy. Username of '*' means username must be supplied by user.
|
proxy. Username of '*' means username must be supplied by user.
|
||||||
|
|
||||||
@@ -679,7 +714,8 @@ proxy. Username of '*' means username must be supplied by user.
|
|||||||
.br
|
.br
|
||||||
.B nolog
|
.B nolog
|
||||||
<n>
|
<n>
|
||||||
extends last allow or deny command to prevent logging, e.g.
|
.br
|
||||||
|
extends last allow or deny command to prevent logging, e.g.
|
||||||
.br
|
.br
|
||||||
allow * * 192.168.1.1
|
allow * * 192.168.1.1
|
||||||
.br
|
.br
|
||||||
@@ -689,13 +725,14 @@ nolog
|
|||||||
.br
|
.br
|
||||||
.B weight
|
.B weight
|
||||||
<n>
|
<n>
|
||||||
extends last allow or deny command to set weight for this request
|
|
||||||
.br
|
.br
|
||||||
allow * * 192.168.1.1
|
extends last allow or deny command to set weight for this request
|
||||||
.br
|
.br
|
||||||
weight 100
|
allow * * 192.168.1.1
|
||||||
.br
|
.br
|
||||||
Weight may be used for different purposes.
|
weight 100
|
||||||
|
.br
|
||||||
|
Weight may be used for different purposes.
|
||||||
|
|
||||||
.br
|
.br
|
||||||
.B bandlimin
|
.B bandlimin
|
||||||
@@ -703,6 +740,7 @@ Weight may be used for different purposes.
|
|||||||
.br
|
.br
|
||||||
.B nobandlimin
|
.B nobandlimin
|
||||||
<userlist> <sourcelist> <targetlist> <targetportlist> <operationlist>
|
<userlist> <sourcelist> <targetlist> <targetportlist> <operationlist>
|
||||||
|
.br
|
||||||
.B bandlimout
|
.B bandlimout
|
||||||
<rate> <userlist> <sourcelist> <targetlist> <targetportlist> <operationlist>
|
<rate> <userlist> <sourcelist> <targetlist> <targetportlist> <operationlist>
|
||||||
.br
|
.br
|
||||||
@@ -727,7 +765,7 @@ addresses) to 57600 bps you have to specify 4 rules like
|
|||||||
.br
|
.br
|
||||||
bandlimin 57600 * 192.168.10.19
|
bandlimin 57600 * 192.168.10.19
|
||||||
.br
|
.br
|
||||||
and every of you clients will have 56K channel. if you specify
|
and every of you clients will have 56K channel. If you specify
|
||||||
.br
|
.br
|
||||||
bandlimin 57600 * 192.168.10.16/30
|
bandlimin 57600 * 192.168.10.16/30
|
||||||
.br
|
.br
|
||||||
@@ -764,6 +802,8 @@ no traffic information on this counter is saved in file (that is
|
|||||||
if proxy restarted all information is loosed) overwise it should be
|
if proxy restarted all information is loosed) overwise it should be
|
||||||
unique sequential number.
|
unique sequential number.
|
||||||
Type specifies a type of counter. Type is one of:
|
Type specifies a type of counter. Type is one of:
|
||||||
|
.br
|
||||||
|
H - counter is resetted hourly
|
||||||
.br
|
.br
|
||||||
D - counter is resetted daily
|
D - counter is resetted daily
|
||||||
.br
|
.br
|
||||||
@@ -776,7 +816,7 @@ Reporttype is one of D,W,M,H(hourly) and repotname specifies filename
|
|||||||
template for reports. Report is text file with counter values in
|
template for reports. Report is text file with counter values in
|
||||||
format:
|
format:
|
||||||
.br
|
.br
|
||||||
<COUNTERNUMBER> <TRAF*4GB> <TRAF>
|
<COUNTERNUMBER> <TRAF>
|
||||||
.br
|
.br
|
||||||
The rest of parameters is identical to bandlim/nobandlim.
|
The rest of parameters is identical to bandlim/nobandlim.
|
||||||
|
|
||||||
@@ -784,28 +824,28 @@ format:
|
|||||||
.B users
|
.B users
|
||||||
username[:pwtype:password] ...
|
username[:pwtype:password] ...
|
||||||
.br
|
.br
|
||||||
pwtype is one of:
|
pwtype is one of:
|
||||||
.br
|
.br
|
||||||
none (empty) - use system authentication
|
none (empty) - use system authentication
|
||||||
.br
|
.br
|
||||||
CL - password is cleartext
|
CL - password is cleartext
|
||||||
.br
|
.br
|
||||||
CR - password is crypt-style password
|
CR - password is crypt-style password
|
||||||
.br
|
.br
|
||||||
NT - password is NT password (in hex)
|
NT - password is NT password (in hex)
|
||||||
.br
|
.br
|
||||||
example:
|
example:
|
||||||
.br
|
.br
|
||||||
users test1:CL:password1 "test2:CR:$1$lFDGlder$pLRb4cU2D7GAT58YQvY49."
|
users test1:CL:password1 "test2:CR:$1$lFDGlder$pLRb4cU2D7GAT58YQvY49."
|
||||||
.br
|
.br
|
||||||
users test3:NT:BD7DFBF29A93F93C63CB84790DA00E63
|
users test3:NT:BD7DFBF29A93F93C63CB84790DA00E63
|
||||||
.br
|
.br
|
||||||
(note: double quotes are requiered because password contains $ sign).
|
Note: double quotes are requiered because password contains $ sign.
|
||||||
|
|
||||||
.br
|
.br
|
||||||
.B flush
|
.B flush
|
||||||
.br
|
.br
|
||||||
empty active access list. Access list must be flushed avery time you creating
|
empty active access list. Access list must be flushed avery time you creating
|
||||||
new access list for new service. For example:
|
new access list for new service. For example:
|
||||||
.br
|
.br
|
||||||
allow *
|
allow *
|
||||||
@@ -818,35 +858,36 @@ new access list for new service. For example:
|
|||||||
.br
|
.br
|
||||||
socks
|
socks
|
||||||
.br
|
.br
|
||||||
sets different ACLs for
|
sets different ACLs for
|
||||||
.B pop3p
|
.B pop3p
|
||||||
and
|
and
|
||||||
.B socks
|
.B socks
|
||||||
|
|
||||||
.br
|
.br
|
||||||
.B system
|
.B system
|
||||||
|
<command>
|
||||||
.br
|
.br
|
||||||
execute system command
|
execute system command
|
||||||
|
|
||||||
.br
|
.br
|
||||||
.B pidfile
|
.B pidfile
|
||||||
<filename>
|
<filename>
|
||||||
.br
|
.br
|
||||||
write pid of current process to file. It can be used to manipulate
|
write pid of current process to file. It can be used to manipulate
|
||||||
3proxy with signals under Unix. Currently next signals are available:
|
3proxy with signals under Unix. Currently next signals are available:
|
||||||
|
|
||||||
.br
|
.br
|
||||||
.B monitor
|
.B monitor
|
||||||
<filename>
|
<filename>
|
||||||
.br
|
.br
|
||||||
If file monitored changes in modification time or size, 3proxy reloads
|
If file monitored changes in modification time or size, 3proxy reloads
|
||||||
configuration within one minute. Any number of files may be monitored.
|
configuration within one minute. Any number of files may be monitored.
|
||||||
|
|
||||||
.br
|
.br
|
||||||
.B setuid
|
.B setuid
|
||||||
<uid>
|
<uid>
|
||||||
.br
|
.br
|
||||||
calls setuid(uid), uid must be numeric. Unix only. Warning: under some Linux
|
calls setuid(uid), uid must be numeric. Unix only. Warning: under some Linux
|
||||||
kernels setuid() works onle for current thread. It makes it impossible to suid
|
kernels setuid() works onle for current thread. It makes it impossible to suid
|
||||||
for all threads.
|
for all threads.
|
||||||
|
|
||||||
@@ -854,35 +895,37 @@ for all threads.
|
|||||||
.B setgid
|
.B setgid
|
||||||
<gid>
|
<gid>
|
||||||
.br
|
.br
|
||||||
calls setgid(gid), gid must be numeric. Unix only.
|
calls setgid(gid), gid must be numeric. Unix only.
|
||||||
|
|
||||||
.br
|
.br
|
||||||
.B chroot
|
.B chroot
|
||||||
<path>
|
<path>
|
||||||
.br
|
.br
|
||||||
calls chroot(path). Unix only.
|
calls chroot(path). Unix only.
|
||||||
.SH PLUGINS
|
.SH PLUGINS
|
||||||
|
|
||||||
.br
|
.br
|
||||||
.B plugin
|
.B plugin
|
||||||
<path_to_shared_library> <function_to_call> [<arg1> ...]
|
<path_to_shared_library> <function_to_call> [<arg1> ...]
|
||||||
.br
|
.br
|
||||||
Loads specified library and calls given export function with given arguments,
|
Loads specified library and calls given export function with given arguments,
|
||||||
as
|
as
|
||||||
.br
|
.br
|
||||||
int functions_to_call(struct pluginlink * pl, int argc, char * argv[]);
|
int functions_to_call(struct pluginlink * pl, int argc, char * argv[]);
|
||||||
.br
|
.br
|
||||||
function_to_call must return 0 in case of success, value > 0 to indicate error.
|
function_to_call must return 0 in case of success, value > 0 to indicate error.
|
||||||
|
|
||||||
.br
|
.br
|
||||||
.B filtermaxsize
|
.B filtermaxsize
|
||||||
<max_size_of_data_to_filter>
|
<max_size_of_data_to_filter>
|
||||||
.br
|
.br
|
||||||
If Content-length (or another data length) is greater than given value, no
|
If Content-length (or another data length) is greater than given value, no
|
||||||
data filtering will be performed thorugh filtering plugins to avoid data
|
data filtering will be performed thorugh filtering plugins to avoid data
|
||||||
corruption and/or Content-Length chaging. Default is 1MB (1048576).
|
corruption and/or Content-Length chaging. Default is 1MB (1048576).
|
||||||
|
|
||||||
|
.SH BUGS
|
||||||
|
Report all bugs to
|
||||||
|
.BR 3proxy@3proxy.ru
|
||||||
.SH SEE ALSO
|
.SH SEE ALSO
|
||||||
3proxy(8), proxy(8), ftppr(8), socks(8), pop3p(8), tcppm(8), udppm(8), syslogd(8),
|
3proxy(8), proxy(8), ftppr(8), socks(8), pop3p(8), tcppm(8), udppm(8), syslogd(8),
|
||||||
.br
|
.br
|
||||||
@@ -890,7 +933,5 @@ http://3proxy.ru/
|
|||||||
.SH TRIVIA
|
.SH TRIVIA
|
||||||
3APA3A is pronounced as \`\`zaraza\'\'.
|
3APA3A is pronounced as \`\`zaraza\'\'.
|
||||||
.SH AUTHORS
|
.SH AUTHORS
|
||||||
3proxy is designed by 3APA3A
|
3proxy is designed by Vladimir 3APA3A Dubrovin
|
||||||
.RI ( 3APA3A@security.nnov.ru ),
|
.RI ( 3proxy@3proxy.ru )
|
||||||
Vladimir Dubrovin
|
|
||||||
.RI ( vlad@sandy.ru )
|
|
||||||
+4
-6
@@ -1,4 +1,4 @@
|
|||||||
.TH ftppr "8" "July 2009" "3proxy 0.7" "Universal proxy server"
|
.TH ftppr "8" "January 2016" "3proxy 0.8" "Universal proxy server"
|
||||||
.SH NAME
|
.SH NAME
|
||||||
.B ftppr
|
.B ftppr
|
||||||
\- FTP proxy gateway service
|
\- FTP proxy gateway service
|
||||||
@@ -73,13 +73,11 @@ is user\'s login on this FTP server. Login itself may contain \'@\' sign.
|
|||||||
Only cleartext authentication is currently supported.
|
Only cleartext authentication is currently supported.
|
||||||
.SH BUGS
|
.SH BUGS
|
||||||
Report all bugs to
|
Report all bugs to
|
||||||
.BR 3proxy@security.nnov.ru
|
.BR 3proxy@3proxy.ru
|
||||||
.SH SEE ALSO
|
.SH SEE ALSO
|
||||||
3proxy(8), proxy(8), pop3p(8), socks(8), tcppm(8), udppm(8), syslogd(8),
|
3proxy(8), proxy(8), pop3p(8), socks(8), tcppm(8), udppm(8), syslogd(8),
|
||||||
.br
|
.br
|
||||||
http://3proxy.ru/
|
http://3proxy.ru/
|
||||||
.SH AUTHORS
|
.SH AUTHORS
|
||||||
3proxy is designed by 3APA3A
|
3proxy is designed by Vladimir 3APA3A Dubrovin
|
||||||
.RI ( 3APA3A@security.nnov.ru ),
|
.RI ( 3proxy@3proxy.ru )
|
||||||
Vladimir Dubrovin
|
|
||||||
.RI ( vlad@sandy.ru )
|
|
||||||
+4
-6
@@ -1,4 +1,4 @@
|
|||||||
.TH icqpr "8" "July 2009" "3proxy 0.7" "Universal proxy server"
|
.TH icqpr "8" "January 2016" "3proxy 0.8" "Universal proxy server"
|
||||||
.SH NAME
|
.SH NAME
|
||||||
.B icqpr
|
.B icqpr
|
||||||
\- ICQ (AOL OSCAR) proxy
|
\- ICQ (AOL OSCAR) proxy
|
||||||
@@ -66,13 +66,11 @@ as a destination in client application. Connection is forwarded to
|
|||||||
.IR remote_host : remote_port
|
.IR remote_host : remote_port
|
||||||
.SH BUGS
|
.SH BUGS
|
||||||
Report all bugs to
|
Report all bugs to
|
||||||
.BR 3proxy@security.nnov.ru
|
.BR 3proxy@3proxy.ru
|
||||||
.SH SEE ALSO
|
.SH SEE ALSO
|
||||||
3proxy(8), proxy(8), ftppr(8), socks(8), pop3p(8), udppm(8), syslogd(8),
|
3proxy(8), proxy(8), ftppr(8), socks(8), pop3p(8), udppm(8), syslogd(8),
|
||||||
.br
|
.br
|
||||||
http://3proxy.ru/
|
http://3proxy.ru/
|
||||||
.SH AUTHORS
|
.SH AUTHORS
|
||||||
3proxy is designed by 3APA3A
|
3proxy is designed by Vladimir 3APA3A Dubrovin
|
||||||
.RI ( 3APA3A@security.nnov.ru ),
|
.RI ( 3proxy@3proxy.ru )
|
||||||
Vladimir Dubrovin
|
|
||||||
.RI ( vlad@sandy.ru )
|
|
||||||
+4
-6
@@ -1,4 +1,4 @@
|
|||||||
.TH pop3p "8" "July 2009" "3proxy 0.7" "Universal proxy server"
|
.TH pop3p "8" "January 2016" "3proxy 0.8" "Universal proxy server"
|
||||||
.SH NAME
|
.SH NAME
|
||||||
.B pop3p
|
.B pop3p
|
||||||
\- POP3 proxy gateway service
|
\- POP3 proxy gateway service
|
||||||
@@ -69,13 +69,11 @@ authentication (APOP, CRAM-MD5, etc) requires challenge from server before
|
|||||||
we know which server to connect.
|
we know which server to connect.
|
||||||
.SH BUGS
|
.SH BUGS
|
||||||
Report all bugs to
|
Report all bugs to
|
||||||
.BR 3proxy@security.nnov.ru
|
.BR 3proxy@3proxy.ru
|
||||||
.SH SEE ALSO
|
.SH SEE ALSO
|
||||||
3proxy(8), ftppr(8), proxy(8), socks(8), tcppm(8), udppm(8), syslogd(8),
|
3proxy(8), ftppr(8), proxy(8), socks(8), tcppm(8), udppm(8), syslogd(8),
|
||||||
.br
|
.br
|
||||||
http://3proxy.ru/
|
http://3proxy.ru/
|
||||||
.SH AUTHORS
|
.SH AUTHORS
|
||||||
3proxy is designed by 3APA3A
|
3proxy is designed by Vladimir 3APA3A Dubrovin
|
||||||
.RI ( 3APA3A@security.nnov.ru ),
|
.RI ( 3proxy@3proxy.ru )
|
||||||
Vladimir Dubrovin
|
|
||||||
.RI ( vlad@sandy.ru )
|
|
||||||
+4
-6
@@ -1,4 +1,4 @@
|
|||||||
.TH proxy "8" "July 2009" "3proxy 0.7" "Universal proxy server"
|
.TH proxy "8" "January 2016" "3proxy 0.8" "Universal proxy server"
|
||||||
.SH NAME
|
.SH NAME
|
||||||
.B proxy
|
.B proxy
|
||||||
\- HTTP proxy gateway service
|
\- HTTP proxy gateway service
|
||||||
@@ -64,13 +64,11 @@ limit clients, use
|
|||||||
instead.
|
instead.
|
||||||
.SH BUGS
|
.SH BUGS
|
||||||
Report all bugs to
|
Report all bugs to
|
||||||
.BR 3proxy@security.nnov.ru
|
.BR 3proxy@3proxy.ru
|
||||||
.SH SEE ALSO
|
.SH SEE ALSO
|
||||||
3proxy(8), ftppr(8), socks(8), pop3p(8), tcppm(8), udppm(8), syslogd(8),
|
3proxy(8), ftppr(8), socks(8), pop3p(8), tcppm(8), udppm(8), syslogd(8),
|
||||||
.br
|
.br
|
||||||
http://3proxy.ru/
|
http://3proxy.ru/
|
||||||
.SH AUTHORS
|
.SH AUTHORS
|
||||||
3proxy is designed by 3APA3A
|
3proxy is designed by Vladimir 3APA3A Dubrovin
|
||||||
.RI ( 3APA3A@security.nnov.ru ),
|
.RI ( 3proxy@3proxy.ru )
|
||||||
Vladimir Dubrovin
|
|
||||||
.RI ( vlad@sandy.ru )
|
|
||||||
+4
-6
@@ -1,4 +1,4 @@
|
|||||||
.TH smtpp "8" "July 2009" "3proxy 0.7" "Universal proxy server"
|
.TH smtpp "8" "January 2016" "3proxy 0.8" "Universal proxy server"
|
||||||
.SH NAME
|
.SH NAME
|
||||||
.B smtpp
|
.B smtpp
|
||||||
\- SMTP proxy gateway service
|
\- SMTP proxy gateway service
|
||||||
@@ -70,13 +70,11 @@ authentication (CRAM-MD5, SPA, etc) requires challenge from server before
|
|||||||
we know which server to connect.
|
we know which server to connect.
|
||||||
.SH BUGS
|
.SH BUGS
|
||||||
Report all bugs to
|
Report all bugs to
|
||||||
.BR 3proxy@security.nnov.ru
|
.BR 3proxy@3proxy.ru
|
||||||
.SH SEE ALSO
|
.SH SEE ALSO
|
||||||
3proxy(8), ftppr(8), proxy(8), socks(8), tcppm(8), udppm(8), syslogd(8),
|
3proxy(8), ftppr(8), proxy(8), socks(8), tcppm(8), udppm(8), syslogd(8),
|
||||||
.br
|
.br
|
||||||
http://3proxy.ru/
|
http://3proxy.ru/
|
||||||
.SH AUTHORS
|
.SH AUTHORS
|
||||||
3proxy is designed by 3APA3A
|
3proxy is designed by Vladimir 3APA3A Dubrovin
|
||||||
.RI ( 3APA3A@security.nnov.ru ),
|
.RI ( 3proxy@3proxy.ru )
|
||||||
Vladimir Dubrovin
|
|
||||||
.RI ( vlad@sandy.ru )
|
|
||||||
+4
-6
@@ -1,4 +1,4 @@
|
|||||||
.TH socks "8" "July 2009" "3proxy 0.7" "Universal proxy server"
|
.TH socks "8" "January 2016" "3proxy 0.8" "Universal proxy server"
|
||||||
.SH NAME
|
.SH NAME
|
||||||
.B socks
|
.B socks
|
||||||
\- SOCKS 4/4.5/5 gateway service
|
\- SOCKS 4/4.5/5 gateway service
|
||||||
@@ -65,13 +65,11 @@ sufficient privileges). If you need to control access use
|
|||||||
instead.
|
instead.
|
||||||
.SH BUGS
|
.SH BUGS
|
||||||
Report all bugs to
|
Report all bugs to
|
||||||
.BR 3proxy@security.nnov.ru
|
.BR 3proxy@3proxy.ru
|
||||||
.SH SEE ALSO
|
.SH SEE ALSO
|
||||||
3proxy(8), proxy(8), ftppr(8), pop3p(8), tcppm(8), udppm(8), syslogd(8),
|
3proxy(8), proxy(8), ftppr(8), pop3p(8), tcppm(8), udppm(8), syslogd(8),
|
||||||
.br
|
.br
|
||||||
http://3proxy.ru/
|
http://3proxy.ru/
|
||||||
.SH AUTHORS
|
.SH AUTHORS
|
||||||
3proxy is designed by 3APA3A
|
3proxy is designed by Vladimir 3APA3A Dubrovin
|
||||||
.RI ( 3APA3A@security.nnov.ru ),
|
.RI ( 3proxy@3proxy.ru )
|
||||||
Vladimir Dubrovin
|
|
||||||
.RI ( vlad@sandy.ru )
|
|
||||||
+4
-6
@@ -1,4 +1,4 @@
|
|||||||
.TH tcppm "8" "July 2009" "3proxy 0.7" "Universal proxy server"
|
.TH tcppm "8" "January 2016" "3proxy 0.8" "Universal proxy server"
|
||||||
.SH NAME
|
.SH NAME
|
||||||
.B tcppm
|
.B tcppm
|
||||||
\- TCP port mapper
|
\- TCP port mapper
|
||||||
@@ -59,13 +59,11 @@ as a destination in client application. Connection is forwarded to
|
|||||||
.IR remote_host : remote_port
|
.IR remote_host : remote_port
|
||||||
.SH BUGS
|
.SH BUGS
|
||||||
Report all bugs to
|
Report all bugs to
|
||||||
.BR 3proxy@security.nnov.ru
|
.BR 3proxy@3proxy.ru
|
||||||
.SH SEE ALSO
|
.SH SEE ALSO
|
||||||
3proxy(8), proxy(8), ftppr(8), socks(8), pop3p(8), udppm(8), syslogd(8),
|
3proxy(8), proxy(8), ftppr(8), socks(8), pop3p(8), udppm(8), syslogd(8),
|
||||||
.br
|
.br
|
||||||
http://3proxy.ru/
|
http://3proxy.ru/
|
||||||
.SH AUTHORS
|
.SH AUTHORS
|
||||||
3proxy is designed by 3APA3A
|
3proxy is designed by Vladimir 3APA3A Dubrovin
|
||||||
.RI ( 3APA3A@security.nnov.ru ),
|
.RI ( 3proxy@3proxy.ru )
|
||||||
Vladimir Dubrovin
|
|
||||||
.RI ( vlad@sandy.ru )
|
|
||||||
+4
-6
@@ -1,4 +1,4 @@
|
|||||||
.TH udppm "8" "July 2009" "3proxy 0.7" "Universal proxy server"
|
.TH udppm "8" "January 2016" "3proxy 0.8" "Universal proxy server"
|
||||||
.SH NAME
|
.SH NAME
|
||||||
.B udppm
|
.B udppm
|
||||||
\- UDP port mapper
|
\- UDP port mapper
|
||||||
@@ -65,13 +65,11 @@ as a destination in client application. All datagrams are forwarded to
|
|||||||
.IR remote_host : remote_port
|
.IR remote_host : remote_port
|
||||||
.SH BUGS
|
.SH BUGS
|
||||||
Report all bugs to
|
Report all bugs to
|
||||||
.BR 3proxy@security.nnov.ru
|
.BR 3proxy@3proxy.ru
|
||||||
.SH SEE ALSO
|
.SH SEE ALSO
|
||||||
3proxy(8), proxy(8), ftppr(8), socks(8), pop3p(8), udppm(8), syslogd(8),
|
3proxy(8), proxy(8), ftppr(8), socks(8), pop3p(8), udppm(8), syslogd(8),
|
||||||
.br
|
.br
|
||||||
http://3proxy.ru/
|
http://3proxy.ru/
|
||||||
.SH AUTHORS
|
.SH AUTHORS
|
||||||
3proxy is designed by 3APA3A
|
3proxy is designed by Vladimir 3APA3A Dubrovin
|
||||||
.RI ( 3APA3A@security.nnov.ru ),
|
.RI ( 3proxy@3proxy.ru )
|
||||||
Vladimir Dubrovin
|
|
||||||
.RI ( vlad@sandy.ru )
|
|
||||||
+22
-1511
File diff suppressed because it is too large.
Load diff
+6
-20
@@ -1,9 +1,8 @@
|
|||||||
#$Id: Makefile.inc,v 1.19 2008/12/10 13:12:10 vlad Exp $
|
|
||||||
#
|
#
|
||||||
# 3 proxy common Makefile
|
# 3 proxy common Makefile
|
||||||
#
|
#
|
||||||
|
|
||||||
all: pre $(VERFILE) $(BUILDDIR)3proxy$(EXESUFFICS) $(BUILDDIR)mycrypt$(EXESUFFICS) $(BUILDDIR)dighosts$(EXESUFFICS) $(BUILDDIR)pop3p$(EXESUFFICS) $(BUILDDIR)smtpp$(EXESUFFICS) $(BUILDDIR)ftppr$(EXESUFFICS) $(BUILDDIR)tcppm$(EXESUFFICS) $(BUILDDIR)icqpr$(EXESUFFICS) $(BUILDDIR)msnpr$(EXESUFFICS) $(BUILDDIR)udppm$(EXESUFFICS) $(BUILDDIR)socks$(EXESUFFICS) $(BUILDDIR)proxy$(EXESUFFICS) $(BUILDDIR)countersutil$(EXESUFFICS) allplugins
|
all: pre $(BUILDDIR)3proxy$(EXESUFFICS) $(BUILDDIR)mycrypt$(EXESUFFICS) $(BUILDDIR)dighosts$(EXESUFFICS) $(BUILDDIR)pop3p$(EXESUFFICS) $(BUILDDIR)smtpp$(EXESUFFICS) $(BUILDDIR)ftppr$(EXESUFFICS) $(BUILDDIR)tcppm$(EXESUFFICS) $(BUILDDIR)icqpr$(EXESUFFICS) $(BUILDDIR)udppm$(EXESUFFICS) $(BUILDDIR)socks$(EXESUFFICS) $(BUILDDIR)proxy$(EXESUFFICS) allplugins
|
||||||
|
|
||||||
|
|
||||||
pre:
|
pre:
|
||||||
@@ -53,9 +52,6 @@ tcppm$(OBJSUFFICS): tcppm.c proxy.h structures.h proxymain.c
|
|||||||
icqpr$(OBJSUFFICS): icqpr.c proxy.h structures.h proxymain.c
|
icqpr$(OBJSUFFICS): icqpr.c proxy.h structures.h proxymain.c
|
||||||
$(CC) $(CFLAGS) $(DEFINEOPTION)WITHMAIN $(DEFINEOPTION)PORTMAP icqpr.c
|
$(CC) $(CFLAGS) $(DEFINEOPTION)WITHMAIN $(DEFINEOPTION)PORTMAP icqpr.c
|
||||||
|
|
||||||
msnpr$(OBJSUFFICS): msnpr.c proxy.h structures.h proxymain.c
|
|
||||||
$(CC) $(CFLAGS) $(DEFINEOPTION)WITHMAIN $(DEFINEOPTION)PORTMAP msnpr.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 socks.c
|
||||||
|
|
||||||
@@ -86,9 +82,6 @@ $(BUILDDIR)tcppm$(EXESUFFICS): sockmap$(OBJSUFFICS) sockgetchar$(OBJSUFFICS) tcp
|
|||||||
$(BUILDDIR)icqpr$(EXESUFFICS): sockmap$(OBJSUFFICS) sockgetchar$(OBJSUFFICS) icqpr$(OBJSUFFICS) myalloc$(OBJSUFFICS) common$(OBJSUFFICS)
|
$(BUILDDIR)icqpr$(EXESUFFICS): sockmap$(OBJSUFFICS) sockgetchar$(OBJSUFFICS) icqpr$(OBJSUFFICS) myalloc$(OBJSUFFICS) common$(OBJSUFFICS)
|
||||||
$(LN) $(LNOUT)$(BUILDDIR)icqpr$(EXESUFFICS) $(LDFLAGS) $(VERFILE) sockmap$(OBJSUFFICS) sockgetchar$(OBJSUFFICS) icqpr$(OBJSUFFICS) myalloc$(OBJSUFFICS) common$(OBJSUFFICS) $(LIBS)
|
$(LN) $(LNOUT)$(BUILDDIR)icqpr$(EXESUFFICS) $(LDFLAGS) $(VERFILE) sockmap$(OBJSUFFICS) sockgetchar$(OBJSUFFICS) icqpr$(OBJSUFFICS) myalloc$(OBJSUFFICS) common$(OBJSUFFICS) $(LIBS)
|
||||||
|
|
||||||
$(BUILDDIR)msnpr$(EXESUFFICS): sockmap$(OBJSUFFICS) sockgetchar$(OBJSUFFICS) msnpr$(OBJSUFFICS) myalloc$(OBJSUFFICS) common$(OBJSUFFICS)
|
|
||||||
$(LN) $(LNOUT)$(BUILDDIR)msnpr$(EXESUFFICS) $(LDFLAGS) $(VERFILE) sockmap$(OBJSUFFICS) sockgetchar$(OBJSUFFICS) msnpr$(OBJSUFFICS) myalloc$(OBJSUFFICS) common$(OBJSUFFICS) $(LIBS)
|
|
||||||
|
|
||||||
$(BUILDDIR)udppm$(EXESUFFICS): sockmap$(OBJSUFFICS) sockgetchar$(OBJSUFFICS) udppm$(OBJSUFFICS) myalloc$(OBJSUFFICS) common$(OBJSUFFICS)
|
$(BUILDDIR)udppm$(EXESUFFICS): sockmap$(OBJSUFFICS) sockgetchar$(OBJSUFFICS) udppm$(OBJSUFFICS) myalloc$(OBJSUFFICS) common$(OBJSUFFICS)
|
||||||
$(LN) $(LNOUT)$(BUILDDIR)udppm$(EXESUFFICS) $(LDFLAGS) $(VERFILE) sockmap$(OBJSUFFICS) sockgetchar$(OBJSUFFICS) udppm$(OBJSUFFICS) myalloc$(OBJSUFFICS) common$(OBJSUFFICS) $(LIBS)
|
$(LN) $(LNOUT)$(BUILDDIR)udppm$(EXESUFFICS) $(LDFLAGS) $(VERFILE) sockmap$(OBJSUFFICS) sockgetchar$(OBJSUFFICS) udppm$(OBJSUFFICS) myalloc$(OBJSUFFICS) common$(OBJSUFFICS) $(LIBS)
|
||||||
|
|
||||||
@@ -115,9 +108,6 @@ srvtcppm$(OBJSUFFICS): tcppm.c proxy.h structures.h
|
|||||||
srvicqpr$(OBJSUFFICS): icqpr.c proxy.h structures.h
|
srvicqpr$(OBJSUFFICS): icqpr.c proxy.h structures.h
|
||||||
$(CC) $(COUT)srvicqpr$(OBJSUFFICS) $(CFLAGS) icqpr.c
|
$(CC) $(COUT)srvicqpr$(OBJSUFFICS) $(CFLAGS) icqpr.c
|
||||||
|
|
||||||
srvmsnpr$(OBJSUFFICS): msnpr.c proxy.h structures.h
|
|
||||||
$(CC) $(COUT)srvmsnpr$(OBJSUFFICS) $(CFLAGS) msnpr.c
|
|
||||||
|
|
||||||
srvsocks$(OBJSUFFICS): socks.c proxy.h structures.h
|
srvsocks$(OBJSUFFICS): socks.c proxy.h structures.h
|
||||||
$(CC) $(COUT)srvsocks$(OBJSUFFICS) $(CFLAGS) socks.c
|
$(CC) $(COUT)srvsocks$(OBJSUFFICS) $(CFLAGS) socks.c
|
||||||
|
|
||||||
@@ -133,6 +123,9 @@ srvdnspr$(OBJSUFFICS): dnspr.c proxy.h structures.h
|
|||||||
auth$(OBJSUFFICS): auth.c proxy.h structures.h
|
auth$(OBJSUFFICS): auth.c proxy.h structures.h
|
||||||
$(CC) $(COUT)auth$(OBJSUFFICS) $(CFLAGS) auth.c
|
$(CC) $(COUT)auth$(OBJSUFFICS) $(CFLAGS) auth.c
|
||||||
|
|
||||||
|
conf$(OBJSUFFICS): conf.c proxy.h structures.h
|
||||||
|
$(CC) $(COUT)conf$(OBJSUFFICS) $(CFLAGS) conf.c
|
||||||
|
|
||||||
datatypes$(OBJSUFFICS): datatypes.c proxy.h structures.h
|
datatypes$(OBJSUFFICS): datatypes.c proxy.h structures.h
|
||||||
$(CC) $(COUT)datatypes$(OBJSUFFICS) $(CFLAGS) datatypes.c
|
$(CC) $(COUT)datatypes$(OBJSUFFICS) $(CFLAGS) datatypes.c
|
||||||
|
|
||||||
@@ -145,13 +138,6 @@ dighosts$(OBJSUFFICS): dighosts.c
|
|||||||
$(BUILDDIR)dighosts$(EXESUFFICS): dighosts$(OBJSUFFICS) myalloc$(OBJSUFFICS) common$(OBJSUFFICS) $(COMPATLIBS)
|
$(BUILDDIR)dighosts$(EXESUFFICS): dighosts$(OBJSUFFICS) myalloc$(OBJSUFFICS) common$(OBJSUFFICS) $(COMPATLIBS)
|
||||||
$(LN) $(LNOUT)$(BUILDDIR)dighosts$(EXESUFFICS) $(LDFLAGS) $(VERFILE) dighosts$(OBJSUFFICS) myalloc$(OBJSUFFICS) common$(OBJSUFFICS) $(COMPATLIBS) $(LIBS)
|
$(LN) $(LNOUT)$(BUILDDIR)dighosts$(EXESUFFICS) $(LDFLAGS) $(VERFILE) dighosts$(OBJSUFFICS) myalloc$(OBJSUFFICS) common$(OBJSUFFICS) $(COMPATLIBS) $(LIBS)
|
||||||
|
|
||||||
countersutil$(OBJSUFFICS): countersutil.c
|
|
||||||
$(CC) $(COUT)countersutil$(OBJSUFFICS) $(CFLAGS) countersutil.c
|
|
||||||
|
|
||||||
$(BUILDDIR)countersutil$(EXESUFFICS): countersutil$(OBJSUFFICS) $(COMPATLIBS)
|
|
||||||
$(LN) $(LNOUT)$(BUILDDIR)countersutil$(EXESUFFICS) $(LDFLAGS) $(VERFILE) countersutil$(OBJSUFFICS) $(COMPATLIBS) $(LIBS)
|
|
||||||
|
|
||||||
|
|
||||||
mycryptmain$(OBJSUFFICS): mycrypt.c
|
mycryptmain$(OBJSUFFICS): mycrypt.c
|
||||||
$(CC) $(COUT)mycryptmain$(OBJSUFFICS) $(CFLAGS) $(DEFINEOPTION)WITHMAIN mycrypt.c
|
$(CC) $(COUT)mycryptmain$(OBJSUFFICS) $(CFLAGS) $(DEFINEOPTION)WITHMAIN mycrypt.c
|
||||||
|
|
||||||
@@ -174,8 +160,8 @@ ntlm$(OBJSUFFICS): ntlm.c
|
|||||||
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) srvicqpr$(OBJSUFFICS) srvmsnpr$(OBJSUFFICS) srvudppm$(OBJSUFFICS) sockmap$(OBJSUFFICS) sockgetchar$(OBJSUFFICS) myalloc$(OBJSUFFICS) common$(OBJSUFFICS) auth$(OBJSUFFICS) datatypes$(OBJSUFFICS) md4$(OBJSUFFICS) md5$(OBJSUFFICS) mycrypt$(OBJSUFFICS) base64$(OBJSUFFICS) ftp$(OBJSUFFICS) smbdes$(OBJSUFFICS) ntlm$(OBJSUFFICS) stringtable$(OBJSUFFICS) srvwebadmin$(OBJSUFFICS) srvdnspr$(OBJSUFFICS) plugins$(OBJSUFFICS) $(COMPATLIBS)
|
$(BUILDDIR)3proxy$(EXESUFFICS): 3proxy$(OBJSUFFICS) mainfunc$(OBJSUFFICS) srvproxy$(OBJSUFFICS) srvpop3p$(OBJSUFFICS) srvsmtpp$(OBJSUFFICS) srvftppr$(OBJSUFFICS) srvsocks$(OBJSUFFICS) srvtcppm$(OBJSUFFICS) srvicqpr$(OBJSUFFICS) srvudppm$(OBJSUFFICS) sockmap$(OBJSUFFICS) sockgetchar$(OBJSUFFICS) myalloc$(OBJSUFFICS) common$(OBJSUFFICS) auth$(OBJSUFFICS) conf$(OBJSUFFICS) datatypes$(OBJSUFFICS) md4$(OBJSUFFICS) md5$(OBJSUFFICS) mycrypt$(OBJSUFFICS) base64$(OBJSUFFICS) ftp$(OBJSUFFICS) smbdes$(OBJSUFFICS) ntlm$(OBJSUFFICS) stringtable$(OBJSUFFICS) srvwebadmin$(OBJSUFFICS) srvdnspr$(OBJSUFFICS) plugins$(OBJSUFFICS) $(COMPATLIBS)
|
||||||
$(LN) $(LNOUT)$(BUILDDIR)3proxy$(EXESUFFICS) $(LDFLAGS) $(VERFILE) 3proxy$(OBJSUFFICS) mainfunc$(OBJSUFFICS) auth$(OBJSUFFICS) datatypes$(OBJSUFFICS) srvproxy$(OBJSUFFICS) srvpop3p$(OBJSUFFICS) srvsmtpp$(OBJSUFFICS) srvftppr$(OBJSUFFICS) srvsocks$(OBJSUFFICS) srvtcppm$(OBJSUFFICS) srvicqpr$(OBJSUFFICS) srvmsnpr$(OBJSUFFICS) srvudppm$(OBJSUFFICS) sockmap$(OBJSUFFICS) sockgetchar$(OBJSUFFICS) myalloc$(OBJSUFFICS) common$(OBJSUFFICS) mycrypt$(OBJSUFFICS) md5$(OBJSUFFICS) md4$(OBJSUFFICS) base64$(OBJSUFFICS) ftp$(OBJSUFFICS) smbdes$(OBJSUFFICS) ntlm$(OBJSUFFICS) stringtable$(OBJSUFFICS) srvwebadmin$(OBJSUFFICS) srvdnspr$(OBJSUFFICS) plugins$(OBJSUFFICS) $(COMPATLIBS) $(LIBS)
|
$(LN) $(LNOUT)$(BUILDDIR)3proxy$(EXESUFFICS) $(LDFLAGS) $(VERFILE) 3proxy$(OBJSUFFICS) mainfunc$(OBJSUFFICS) auth$(OBJSUFFICS) conf$(OBJSUFFICS) datatypes$(OBJSUFFICS) srvproxy$(OBJSUFFICS) srvpop3p$(OBJSUFFICS) srvsmtpp$(OBJSUFFICS) srvftppr$(OBJSUFFICS) srvsocks$(OBJSUFFICS) srvtcppm$(OBJSUFFICS) srvicqpr$(OBJSUFFICS) srvudppm$(OBJSUFFICS) sockmap$(OBJSUFFICS) sockgetchar$(OBJSUFFICS) myalloc$(OBJSUFFICS) common$(OBJSUFFICS) mycrypt$(OBJSUFFICS) md5$(OBJSUFFICS) md4$(OBJSUFFICS) base64$(OBJSUFFICS) ftp$(OBJSUFFICS) smbdes$(OBJSUFFICS) ntlm$(OBJSUFFICS) stringtable$(OBJSUFFICS) srvwebadmin$(OBJSUFFICS) srvdnspr$(OBJSUFFICS) plugins$(OBJSUFFICS) $(COMPATLIBS) $(LIBS)
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
@$(REMOVECOMMAND) *$(OBJSUFFICS) $(COMPFILES)
|
@$(REMOVECOMMAND) *$(OBJSUFFICS) $(COMPFILES)
|
||||||
+304
-263
@@ -4,83 +4,28 @@
|
|||||||
|
|
||||||
please read License Agreement
|
please read License Agreement
|
||||||
|
|
||||||
$Id: auth.c,v 1.108 2012-04-11 23:01:18 vlad Exp $
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "proxy.h"
|
#include "proxy.h"
|
||||||
|
|
||||||
#define HEADERSIZE 57
|
|
||||||
#define RECORDSIZE 18
|
|
||||||
|
|
||||||
unsigned char request[] = {
|
int clientnegotiate(struct chain * redir, struct clientparam * param, struct sockaddr * addr){
|
||||||
0xa2, 0x48, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00,
|
unsigned char *buf;
|
||||||
0x00, 0x00, 0x00, 0x00, 0x20, 0x43, 0x4b, 0x41,
|
unsigned char *username;
|
||||||
0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41,
|
|
||||||
0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41,
|
|
||||||
0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41,
|
|
||||||
0x41, 0x41, 0x41, 0x41, 0x41, 0x00, 0x00, 0x21,
|
|
||||||
0x00, 0x01};
|
|
||||||
|
|
||||||
unsigned char * getNetBIOSnamebyip(unsigned long ip){
|
|
||||||
unsigned char buf[1024];
|
|
||||||
struct sockaddr_in sins;
|
|
||||||
int res;
|
|
||||||
SOCKET sock;
|
|
||||||
unsigned char * username = NULL;
|
|
||||||
int i;
|
|
||||||
int j;
|
|
||||||
int nnames;
|
|
||||||
int type;
|
|
||||||
|
|
||||||
if ( (sock=so._socket(AF_INET,SOCK_DGRAM,IPPROTO_UDP)) == INVALID_SOCKET) return NULL;
|
|
||||||
memset(&sins, 0, sizeof(sins));
|
|
||||||
sins.sin_family = AF_INET;
|
|
||||||
sins.sin_port = htons(0);
|
|
||||||
sins.sin_addr.s_addr = INADDR_ANY;
|
|
||||||
if(so._bind(sock,(struct sockaddr *)&sins,sizeof(sins))) {
|
|
||||||
so._closesocket(sock);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
sins.sin_family = AF_INET;
|
|
||||||
sins.sin_addr.s_addr = ip;
|
|
||||||
sins.sin_port = htons(137);
|
|
||||||
res=socksendto(sock, &sins, request, sizeof(request), conf.timeouts[SINGLEBYTE_L]*1000);
|
|
||||||
if(res <= 0) {
|
|
||||||
so._closesocket(sock);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
res = sockrecvfrom(sock, &sins, buf, sizeof(buf), conf.timeouts[SINGLEBYTE_L]*1000);
|
|
||||||
so._closesocket(sock);
|
|
||||||
if(res < (HEADERSIZE + RECORDSIZE)) {
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
nnames = buf[HEADERSIZE-1];
|
|
||||||
if (res < (HEADERSIZE + (nnames * RECORDSIZE))) return NULL;
|
|
||||||
for (i = 0; i < nnames; i++){
|
|
||||||
type = buf[HEADERSIZE + (i*RECORDSIZE) + 15];
|
|
||||||
if( type == 3) {
|
|
||||||
for(j = 14; j && buf[HEADERSIZE + (i*RECORDSIZE) + j] == ' '; j--)
|
|
||||||
buf[HEADERSIZE + (i*RECORDSIZE) + j] = 0;
|
|
||||||
if(username)myfree(username);
|
|
||||||
username = (unsigned char *)mystrdup((char *)buf + HEADERSIZE + i*RECORDSIZE);
|
|
||||||
}
|
|
||||||
buf[HEADERSIZE + (i*RECORDSIZE) + 15] = 0;
|
|
||||||
}
|
|
||||||
return username;
|
|
||||||
}
|
|
||||||
|
|
||||||
int clientnegotiate(struct chain * redir, struct clientparam * param, unsigned long ip, unsigned short port){
|
|
||||||
unsigned char buf[1024];
|
|
||||||
struct in_addr ina;
|
|
||||||
int res;
|
int res;
|
||||||
int len=0;
|
int len=0;
|
||||||
unsigned char * user, *pass;
|
unsigned char * user, *pass;
|
||||||
|
|
||||||
ina.s_addr = ip;
|
|
||||||
|
|
||||||
|
|
||||||
user = redir->extuser;
|
user = redir->extuser;
|
||||||
pass = redir->extpass;
|
pass = redir->extpass;
|
||||||
|
if (param->srvinbuf < 4096){
|
||||||
|
if(param->srvbuf)myfree(param->srvbuf);
|
||||||
|
param->srvbuf = myalloc(4096);
|
||||||
|
param->srvbufsize = 4096;
|
||||||
|
}
|
||||||
|
buf = param->srvbuf;
|
||||||
|
username = buf + 2048;
|
||||||
if(user) {
|
if(user) {
|
||||||
if (*user == '*') {
|
if (*user == '*') {
|
||||||
if(!param->username) return 4;
|
if(!param->username) return 4;
|
||||||
@@ -95,17 +40,22 @@ int clientnegotiate(struct chain * redir, struct clientparam * param, unsigned l
|
|||||||
case R_CONNECT:
|
case R_CONNECT:
|
||||||
case R_CONNECTP:
|
case R_CONNECTP:
|
||||||
{
|
{
|
||||||
sprintf((char *)buf, "CONNECT ");
|
len = sprintf((char *)buf, "CONNECT ");
|
||||||
if(redir->type == R_CONNECTP && param->hostname) {
|
if(redir->type == R_CONNECTP && param->hostname) {
|
||||||
len = 8 + sprintf((char *)buf + 8, "%.256s", param->hostname);
|
char * needreplace;
|
||||||
|
needreplace = strchr(param->hostname, ':');
|
||||||
|
if(needreplace) buf[len++] = '[';
|
||||||
|
len =+ sprintf((char *)buf + len, "%.256s", param->hostname);
|
||||||
|
if(needreplace) buf[len++] = ']';
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
len = 8 + myinet_ntoa(ina, (char *)buf+8);
|
if(*SAFAMILY(addr) == AF_INET6) buf[len++] = '[';
|
||||||
|
len += myinet_ntop(*SAFAMILY(addr), SAADDR(addr), (char *)buf+len, 256);
|
||||||
|
if(*SAFAMILY(addr) == AF_INET6) buf[len++] = ']';
|
||||||
}
|
}
|
||||||
len += sprintf((char *)buf + len,
|
len += sprintf((char *)buf + len,
|
||||||
":%hu HTTP/1.0\r\nProxy-Connection: keep-alive\r\n", ntohs(port));
|
":%hu HTTP/1.0\r\nProxy-Connection: keep-alive\r\n", ntohs(*SAPORT(addr)));
|
||||||
if(user){
|
if(user){
|
||||||
unsigned char username[256];
|
|
||||||
len += sprintf((char *)buf + len, "Proxy-authorization: basic ");
|
len += sprintf((char *)buf + len, "Proxy-authorization: basic ");
|
||||||
sprintf((char *)username, "%.128s:%.64s", user, pass?pass:(unsigned char *)"");
|
sprintf((char *)username, "%.128s:%.64s", user, pass?pass:(unsigned char *)"");
|
||||||
en64(username, buf+len, (int)strlen((char *)username));
|
en64(username, buf+len, (int)strlen((char *)username));
|
||||||
@@ -115,7 +65,7 @@ int clientnegotiate(struct chain * redir, struct clientparam * param, unsigned l
|
|||||||
len += sprintf((char *)buf + len, "\r\n");
|
len += sprintf((char *)buf + len, "\r\n");
|
||||||
if(socksend(param->remsock, buf, len, conf.timeouts[CHAIN_TO]) != (int)strlen((char *)buf))
|
if(socksend(param->remsock, buf, len, conf.timeouts[CHAIN_TO]) != (int)strlen((char *)buf))
|
||||||
return 31;
|
return 31;
|
||||||
param->statssrv+=len;
|
param->statssrv64+=len;
|
||||||
param->nwrites++;
|
param->nwrites++;
|
||||||
if((res = sockgetlinebuf(param, SERVER,buf,13,'\n',conf.timeouts[CHAIN_TO])) < 13)
|
if((res = sockgetlinebuf(param, SERVER,buf,13,'\n',conf.timeouts[CHAIN_TO])) < 13)
|
||||||
return 32;
|
return 32;
|
||||||
@@ -129,14 +79,15 @@ int clientnegotiate(struct chain * redir, struct clientparam * param, unsigned l
|
|||||||
case R_SOCKS4B:
|
case R_SOCKS4B:
|
||||||
{
|
{
|
||||||
|
|
||||||
|
if(*SAFAMILY(addr) != AF_INET) return 44;
|
||||||
buf[0] = 4;
|
buf[0] = 4;
|
||||||
buf[1] = 1;
|
buf[1] = 1;
|
||||||
memcpy(buf+2, &port, 2);
|
memcpy(buf+2, SAPORT(addr), 2);
|
||||||
if(redir->type == R_SOCKS4P && param->hostname) {
|
if(redir->type == R_SOCKS4P && param->hostname) {
|
||||||
buf[4] = buf[5] = buf[6] = 0;
|
buf[4] = buf[5] = buf[6] = 0;
|
||||||
buf[7] = 3;
|
buf[7] = 3;
|
||||||
}
|
}
|
||||||
else memcpy(buf+4, &ip, 4);
|
else memcpy(buf+4, SAADDR(addr), 4);
|
||||||
if(!user)user = (unsigned char *)"anonymous";
|
if(!user)user = (unsigned char *)"anonymous";
|
||||||
len = (int)strlen((char *)user) + 1;
|
len = (int)strlen((char *)user) + 1;
|
||||||
memcpy(buf+8, user, len);
|
memcpy(buf+8, user, len);
|
||||||
@@ -152,7 +103,7 @@ int clientnegotiate(struct chain * redir, struct clientparam * param, unsigned l
|
|||||||
if(socksend(param->remsock, buf, len, conf.timeouts[CHAIN_TO]) < len){
|
if(socksend(param->remsock, buf, len, conf.timeouts[CHAIN_TO]) < len){
|
||||||
return 41;
|
return 41;
|
||||||
}
|
}
|
||||||
param->statssrv+=len;
|
param->statssrv64+=len;
|
||||||
param->nwrites++;
|
param->nwrites++;
|
||||||
if((len = sockgetlinebuf(param, SERVER, buf, (redir->type == R_SOCKS4B)? 3:8, EOF, conf.timeouts[CHAIN_TO])) != ((redir->type == R_SOCKS4B)? 3:8)){
|
if((len = sockgetlinebuf(param, SERVER, buf, (redir->type == R_SOCKS4B)? 3:8, EOF, conf.timeouts[CHAIN_TO])) != ((redir->type == R_SOCKS4B)? 3:8)){
|
||||||
return 42;
|
return 42;
|
||||||
@@ -175,7 +126,7 @@ int clientnegotiate(struct chain * redir, struct clientparam * param, unsigned l
|
|||||||
if(socksend(param->remsock, buf, 3, conf.timeouts[CHAIN_TO]) != 3){
|
if(socksend(param->remsock, buf, 3, conf.timeouts[CHAIN_TO]) != 3){
|
||||||
return 51;
|
return 51;
|
||||||
}
|
}
|
||||||
param->statssrv+=len;
|
param->statssrv64+=len;
|
||||||
param->nwrites++;
|
param->nwrites++;
|
||||||
if(sockgetlinebuf(param, SERVER, buf, 2, EOF, conf.timeouts[CHAIN_TO]) != 2){
|
if(sockgetlinebuf(param, SERVER, buf, 2, EOF, conf.timeouts[CHAIN_TO]) != 2){
|
||||||
return 52;
|
return 52;
|
||||||
@@ -197,7 +148,7 @@ int clientnegotiate(struct chain * redir, struct clientparam * param, unsigned l
|
|||||||
if(socksend(param->remsock, buf, inbuf, conf.timeouts[CHAIN_TO]) != inbuf){
|
if(socksend(param->remsock, buf, inbuf, conf.timeouts[CHAIN_TO]) != inbuf){
|
||||||
return 51;
|
return 51;
|
||||||
}
|
}
|
||||||
param->statssrv+=inbuf;
|
param->statssrv64+=inbuf;
|
||||||
param->nwrites++;
|
param->nwrites++;
|
||||||
if(sockgetlinebuf(param, SERVER, buf, 2, EOF, 60) != 2){
|
if(sockgetlinebuf(param, SERVER, buf, 2, EOF, 60) != 2){
|
||||||
return 55;
|
return 55;
|
||||||
@@ -218,16 +169,17 @@ int clientnegotiate(struct chain * redir, struct clientparam * param, unsigned l
|
|||||||
len += 5;
|
len += 5;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
buf[3] = 1;
|
len = 3;
|
||||||
memcpy(buf+4, &ip, 4);
|
buf[len++] = (*SAFAMILY(addr) == AF_INET)? 1 : 4;
|
||||||
len = 8;
|
memcpy(buf+len, SAADDR(addr), SAADDRLEN(addr));
|
||||||
|
len += SAADDRLEN(addr);
|
||||||
}
|
}
|
||||||
memcpy(buf+len, &port, 2);
|
memcpy(buf+len, SAPORT(addr), 2);
|
||||||
len += 2;
|
len += 2;
|
||||||
if(socksend(param->remsock, buf, len, conf.timeouts[CHAIN_TO]) != len){
|
if(socksend(param->remsock, buf, len, conf.timeouts[CHAIN_TO]) != len){
|
||||||
return 51;
|
return 51;
|
||||||
}
|
}
|
||||||
param->statssrv+=len;
|
param->statssrv64+=len;
|
||||||
param->nwrites++;
|
param->nwrites++;
|
||||||
if(sockgetlinebuf(param, SERVER, buf, 4, EOF, conf.timeouts[CHAIN_TO]) != 4){
|
if(sockgetlinebuf(param, SERVER, buf, 4, EOF, conf.timeouts[CHAIN_TO]) != 4){
|
||||||
return 57;
|
return 57;
|
||||||
@@ -261,16 +213,14 @@ int handleredirect(struct clientparam * param, struct ace * acentry){
|
|||||||
int done = 0;
|
int done = 0;
|
||||||
struct chain * cur;
|
struct chain * cur;
|
||||||
struct chain * redir = NULL;
|
struct chain * redir = NULL;
|
||||||
unsigned long targetip;
|
|
||||||
unsigned short targetport;
|
|
||||||
int r2;
|
int r2;
|
||||||
|
|
||||||
if(param->remsock != INVALID_SOCKET) {
|
if(param->remsock != INVALID_SOCKET) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
targetip = param->req.sin_addr.s_addr;
|
if(SAISNULL(¶m->req) || !*SAPORT(¶m->req)) {
|
||||||
targetport = param->req.sin_port;
|
return 100;
|
||||||
if(!targetip || !targetport) return 100;
|
}
|
||||||
|
|
||||||
r2 = (myrand(param, sizeof(struct clientparam))%1000);
|
r2 = (myrand(param, sizeof(struct clientparam))%1000);
|
||||||
|
|
||||||
@@ -291,7 +241,7 @@ int handleredirect(struct clientparam * param, struct ace * acentry){
|
|||||||
r2 = (myrand(param, sizeof(struct clientparam))%1000);
|
r2 = (myrand(param, sizeof(struct clientparam))%1000);
|
||||||
}
|
}
|
||||||
if(!connected){
|
if(!connected){
|
||||||
if(!cur->redirip && !cur->redirport){
|
if(SAISNULL(&cur->addr) && !*SAPORT(&cur->addr)){
|
||||||
if(cur->extuser){
|
if(cur->extuser){
|
||||||
if(param->extusername)
|
if(param->extusername)
|
||||||
myfree(param->extusername);
|
myfree(param->extusername);
|
||||||
@@ -316,19 +266,25 @@ int handleredirect(struct clientparam * param, struct ace * acentry){
|
|||||||
case R_ICQ:
|
case R_ICQ:
|
||||||
param->redirectfunc = icqprchild;
|
param->redirectfunc = icqprchild;
|
||||||
break;
|
break;
|
||||||
|
/*
|
||||||
case R_MSN:
|
case R_MSN:
|
||||||
param->redirectfunc = msnprchild;
|
param->redirectfunc = msnprchild;
|
||||||
break;
|
break;
|
||||||
|
*/
|
||||||
default:
|
default:
|
||||||
param->redirectfunc = proxychild;
|
param->redirectfunc = proxychild;
|
||||||
}
|
}
|
||||||
|
if(cur->next)continue;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
else if(!cur->redirip && cur->redirport) param->extport = cur->redirport;
|
else if(!*SAPORT(&cur->addr) && !SAISNULL(&cur->addr)) {
|
||||||
else if(!cur->redirport && cur->redirip) param->extip = cur->redirip;
|
unsigned short port = *SAPORT(¶m->sinsr);
|
||||||
|
memcpy(¶m->sinsr, &cur->addr, SASIZE(&cur->addr));
|
||||||
|
*SAPORT(¶m->sinsr) = port;
|
||||||
|
}
|
||||||
|
else if(SAISNULL(&cur->addr) && *SAPORT(&cur->addr)) *SAPORT(¶m->sinsr) = *SAPORT(&cur->addr);
|
||||||
else {
|
else {
|
||||||
param->sins.sin_port = cur->redirport;
|
memcpy(¶m->sinsr, &cur->addr, SASIZE(&cur->addr));
|
||||||
param->sins.sin_addr.s_addr = cur->redirip;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if((res = alwaysauth(param))){
|
if((res = alwaysauth(param))){
|
||||||
@@ -336,7 +292,7 @@ int handleredirect(struct clientparam * param, struct ace * acentry){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
res = redir?clientnegotiate(redir, param, cur->redirip, cur->redirport):0;
|
res = (redir)?clientnegotiate(redir, param, (struct sockaddr *)&cur->addr):0;
|
||||||
if(res) return res;
|
if(res) return res;
|
||||||
}
|
}
|
||||||
redir = cur;
|
redir = cur;
|
||||||
@@ -359,9 +315,27 @@ int handleredirect(struct clientparam * param, struct ace * acentry){
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(!connected) return 9;
|
if(!connected) return 9;
|
||||||
return redir?clientnegotiate(redir, param, targetip, targetport):0;
|
return (redir)?clientnegotiate(redir, param, (struct sockaddr *)¶m->req):0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int IPInentry(struct sockaddr *sa, struct iplist *ipentry){
|
||||||
|
int addrlen;
|
||||||
|
unsigned char *ip, *ipf, *ipt;
|
||||||
|
|
||||||
|
|
||||||
|
if(!sa || ! ipentry || *SAFAMILY(sa) != ipentry->family) return 0;
|
||||||
|
|
||||||
|
ip = (unsigned char *)SAADDR(sa);
|
||||||
|
ipf = (unsigned char *)&ipentry->ip_from;
|
||||||
|
ipt = (unsigned char *)&ipentry->ip_to;
|
||||||
|
|
||||||
|
|
||||||
|
addrlen = SAADDRLEN(sa);
|
||||||
|
|
||||||
|
if(memcmp(ip,ipf,addrlen) < 0 || memcmp(ip,ipt,addrlen) > 0) return 0;
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
int ACLmatches(struct ace* acentry, struct clientparam * param){
|
int ACLmatches(struct ace* acentry, struct clientparam * param){
|
||||||
struct userlist * userentry;
|
struct userlist * userentry;
|
||||||
@@ -376,14 +350,14 @@ int ACLmatches(struct ace* acentry, struct clientparam * param){
|
|||||||
username = param->username?param->username:(unsigned char *)"-";
|
username = param->username?param->username:(unsigned char *)"-";
|
||||||
if(acentry->src) {
|
if(acentry->src) {
|
||||||
for(ipentry = acentry->src; ipentry; ipentry = ipentry->next)
|
for(ipentry = acentry->src; ipentry; ipentry = ipentry->next)
|
||||||
if(ipentry->ip == (param->sinc.sin_addr.s_addr & ipentry->mask)) {
|
if(IPInentry((struct sockaddr *)¶m->sincr, ipentry)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if(!ipentry) return 0;
|
if(!ipentry) return 0;
|
||||||
}
|
}
|
||||||
if((acentry->dst && param->req.sin_addr.s_addr) || (acentry->dstnames && param->hostname)) {
|
if((acentry->dst && !SAISNULL(¶m->req)) || (acentry->dstnames && param->hostname)) {
|
||||||
for(ipentry = acentry->dst; ipentry; ipentry = ipentry->next)
|
for(ipentry = acentry->dst; ipentry; ipentry = ipentry->next)
|
||||||
if(ipentry->ip == (param->req.sin_addr.s_addr & ipentry->mask)) {
|
if(IPInentry((struct sockaddr *)¶m->req, ipentry)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if(!ipentry) {
|
if(!ipentry) {
|
||||||
@@ -416,10 +390,10 @@ int ACLmatches(struct ace* acentry, struct clientparam * param){
|
|||||||
}
|
}
|
||||||
if(!ipentry && !hstentry) return 0;
|
if(!ipentry && !hstentry) return 0;
|
||||||
}
|
}
|
||||||
if(acentry->ports && param->req.sin_port) {
|
if(acentry->ports && *SAPORT(¶m->req)) {
|
||||||
for (portentry = acentry->ports; portentry; portentry = portentry->next)
|
for (portentry = acentry->ports; portentry; portentry = portentry->next)
|
||||||
if(ntohs(param->req.sin_port) >= portentry->startport &&
|
if(ntohs(*SAPORT(¶m->req)) >= portentry->startport &&
|
||||||
ntohs(param->req.sin_port) <= portentry->endport) {
|
ntohs(*SAPORT(¶m->req)) <= portentry->endport) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if(!portentry) return 0;
|
if(!portentry) return 0;
|
||||||
@@ -496,6 +470,7 @@ unsigned bandlimitfunc(struct clientparam *param, unsigned nbytesin, unsigned nb
|
|||||||
sec = tv.tv_sec;
|
sec = tv.tv_sec;
|
||||||
msec = tv.tv_usec;
|
msec = tv.tv_usec;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if(!nbytesin && !nbytesout) return 0;
|
if(!nbytesin && !nbytesout) return 0;
|
||||||
pthread_mutex_lock(&bandlim_mutex);
|
pthread_mutex_lock(&bandlim_mutex);
|
||||||
if(param->srv->version != conf.paused){
|
if(param->srv->version != conf.paused){
|
||||||
@@ -541,7 +516,6 @@ unsigned bandlimitfunc(struct clientparam *param, unsigned nbytesin, unsigned nb
|
|||||||
|
|
||||||
void trafcountfunc(struct clientparam *param){
|
void trafcountfunc(struct clientparam *param){
|
||||||
struct trafcount * tc;
|
struct trafcount * tc;
|
||||||
unsigned long val;
|
|
||||||
int countout = 0;
|
int countout = 0;
|
||||||
|
|
||||||
pthread_mutex_lock(&tc_mutex);
|
pthread_mutex_lock(&tc_mutex);
|
||||||
@@ -553,9 +527,7 @@ void trafcountfunc(struct clientparam *param){
|
|||||||
countout = 1;
|
countout = 1;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
val = tc->traf + param->statssrv;
|
tc->traf64 += param->statssrv64;
|
||||||
if(val < tc->traf) tc->trafgb++;
|
|
||||||
tc->traf = val;
|
|
||||||
time(&t);
|
time(&t);
|
||||||
tc->updated = t;
|
tc->updated = t;
|
||||||
}
|
}
|
||||||
@@ -567,9 +539,7 @@ void trafcountfunc(struct clientparam *param){
|
|||||||
if(tc->ace->action != COUNTOUT) {
|
if(tc->ace->action != COUNTOUT) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
val = tc->traf + param->statscli;
|
tc->traf64 += param->statscli64;
|
||||||
if(val < tc->traf) tc->trafgb++;
|
|
||||||
tc->traf = val;
|
|
||||||
time(&t);
|
time(&t);
|
||||||
tc->updated = t;
|
tc->updated = t;
|
||||||
}
|
}
|
||||||
@@ -596,15 +566,9 @@ int alwaysauth(struct clientparam * param){
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if((tc->traflimgb < tc->trafgb) ||
|
if(tc->traflim64 <= tc->traf64) return 10;
|
||||||
((tc->traflimgb == tc->trafgb) && (tc->traflim < tc->traf))
|
|
||||||
) return 10;
|
|
||||||
param->trafcountfunc = conf.trafcountfunc;
|
param->trafcountfunc = conf.trafcountfunc;
|
||||||
if(tc->traflimgb - tc->trafgb < 1 || ((tc->traflimgb - tc->trafgb) == 1 && tc->traf > tc->traflim)){
|
param->maxtrafin64 = tc->traflim64 - tc->traf64;
|
||||||
unsigned maxtraf = tc->traflim - tc->traf;
|
|
||||||
if(!param->maxtrafin || param->maxtrafin > maxtraf) param->maxtrafin = maxtraf;
|
|
||||||
}
|
|
||||||
if((tc->trafgb > tc->traflimgb) || (tc->trafgb == tc->traflimgb && tc->traf >= tc->traflim)) param->maxtrafin = 1;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(countout)for(tc = conf.trafcounter; tc; tc = tc->next) {
|
if(countout)for(tc = conf.trafcounter; tc; tc = tc->next) {
|
||||||
@@ -615,15 +579,9 @@ int alwaysauth(struct clientparam * param){
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if((tc->traflimgb < tc->trafgb) ||
|
if(tc->traflim64 <= tc->traf64) return 10;
|
||||||
((tc->traflimgb == tc->trafgb) && (tc->traflim < tc->traf))
|
|
||||||
) return 10;
|
|
||||||
param->trafcountfunc = conf.trafcountfunc;
|
param->trafcountfunc = conf.trafcountfunc;
|
||||||
if(tc->traflimgb - tc->trafgb < 1 || ((tc->traflimgb - tc->trafgb) == 1 && tc->traf > tc->traflim)){
|
param->maxtrafout64 = tc->traflim64 - tc->traf64;
|
||||||
unsigned maxtraf = tc->traflim - tc->traf;
|
|
||||||
if(!param->maxtrafout || param->maxtrafout > maxtraf) param->maxtrafout = maxtraf;
|
|
||||||
}
|
|
||||||
if((tc->trafgb > tc->traflimgb) || (tc->trafgb == tc->traflimgb && tc->traf >= tc->traflim)) param->maxtrafout = 1;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -647,7 +605,7 @@ int checkACL(struct clientparam * param){
|
|||||||
if(param->operation < 256 && !(param->operation & CONNECT)){
|
if(param->operation < 256 && !(param->operation & CONNECT)){
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if(param->redirected && acentry->chains && !acentry->chains->redirip && !acentry->chains->redirport) {
|
if(param->redirected && acentry->chains && SAISNULL(&acentry->chains->addr) && !*SAPORT(&acentry->chains->addr)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
memcpy(&dup, acentry, sizeof(struct ace));
|
memcpy(&dup, acentry, sizeof(struct ace));
|
||||||
@@ -663,7 +621,11 @@ struct authcache {
|
|||||||
char * username;
|
char * username;
|
||||||
char * password;
|
char * password;
|
||||||
time_t expires;
|
time_t expires;
|
||||||
unsigned long ip;
|
#ifndef NOIPV6
|
||||||
|
struct sockaddr_in6 sa;
|
||||||
|
#else
|
||||||
|
struct sockaddr_in sa;
|
||||||
|
#endif
|
||||||
struct authcache *next;
|
struct authcache *next;
|
||||||
} *authc = NULL;
|
} *authc = NULL;
|
||||||
|
|
||||||
@@ -690,7 +652,7 @@ int cacheauth(struct clientparam * param){
|
|||||||
|
|
||||||
}
|
}
|
||||||
if(((!(conf.authcachetype&2)) || (param->username && ac->username && !strcmp(ac->username, param->username))) &&
|
if(((!(conf.authcachetype&2)) || (param->username && ac->username && !strcmp(ac->username, param->username))) &&
|
||||||
((!(conf.authcachetype&1)) || ac->ip == param->sinc.sin_addr.s_addr) &&
|
((!(conf.authcachetype&1)) || (*SAFAMILY(&ac->sa) == *SAFAMILY(¶m->sincr) && !memcmp(SAADDR(&ac->sa), ¶m->sincr, SAADDRLEN(&ac->sa)))) &&
|
||||||
(!(conf.authcachetype&4) || (ac->password && param->password && !strcmp(ac->password, param->password)))) {
|
(!(conf.authcachetype&4) || (ac->password && param->password && !strcmp(ac->password, param->password)))) {
|
||||||
if(param->username){
|
if(param->username){
|
||||||
myfree(param->username);
|
myfree(param->username);
|
||||||
@@ -724,7 +686,7 @@ int doauth(struct clientparam * param){
|
|||||||
pthread_mutex_lock(&hash_mutex);
|
pthread_mutex_lock(&hash_mutex);
|
||||||
for(ac = authc; ac; ac = ac->next){
|
for(ac = authc; ac; ac = ac->next){
|
||||||
if((!(conf.authcachetype&2) || !strcmp(ac->username, param->username)) &&
|
if((!(conf.authcachetype&2) || !strcmp(ac->username, param->username)) &&
|
||||||
(!(conf.authcachetype&1) || ac->ip == param->sinc.sin_addr.s_addr) &&
|
(!(conf.authcachetype&1) || (*SAFAMILY(&ac->sa) == *SAFAMILY(¶m->sincr) && !memcmp(SAADDR(&ac->sa), ¶m->sincr, SAADDRLEN(&ac->sa)))) &&
|
||||||
(!(conf.authcachetype&4) || (ac->password && !strcmp(ac->password, param->password)))) {
|
(!(conf.authcachetype&4) || (ac->password && !strcmp(ac->password, param->password)))) {
|
||||||
ac->expires = conf.time + conf.authcachetime;
|
ac->expires = conf.time + conf.authcachetime;
|
||||||
if(strcmp(ac->username, param->username)){
|
if(strcmp(ac->username, param->username)){
|
||||||
@@ -737,7 +699,7 @@ int doauth(struct clientparam * param){
|
|||||||
ac->password = mystrdup(param->password);
|
ac->password = mystrdup(param->password);
|
||||||
myfree(tmp);
|
myfree(tmp);
|
||||||
}
|
}
|
||||||
ac->ip = param->sinc.sin_addr.s_addr;
|
memcpy(&ac->sa, ¶m->sincr, SASIZE(¶m->sincr));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -746,7 +708,7 @@ int doauth(struct clientparam * param){
|
|||||||
if(ac){
|
if(ac){
|
||||||
ac->expires = conf.time + conf.authcachetime;
|
ac->expires = conf.time + conf.authcachetime;
|
||||||
ac->username = mystrdup(param->username);
|
ac->username = mystrdup(param->username);
|
||||||
ac->ip = param->sinc.sin_addr.s_addr;
|
memcpy(&ac->sa, ¶m->sincr, SASIZE(¶m->sincr));
|
||||||
ac->password = NULL;
|
ac->password = NULL;
|
||||||
if((conf.authcachetype&4) && param->password) ac->password = mystrdup(param->password);
|
if((conf.authcachetype&4) && param->password) ac->password = mystrdup(param->password);
|
||||||
}
|
}
|
||||||
@@ -781,28 +743,37 @@ int userauth(struct clientparam * param){
|
|||||||
return (param->username)? 0:4;
|
return (param->username)? 0:4;
|
||||||
}
|
}
|
||||||
|
|
||||||
int nbnameauth(struct clientparam * param){
|
|
||||||
unsigned char * name = getNetBIOSnamebyip(param->sinc.sin_addr.s_addr);
|
|
||||||
|
|
||||||
if (param->username) myfree (param->username);
|
|
||||||
param->username = name;
|
|
||||||
return name? 0:4;
|
|
||||||
}
|
|
||||||
|
|
||||||
int dnsauth(struct clientparam * param){
|
int dnsauth(struct clientparam * param){
|
||||||
char buf[32];
|
char buf[128];
|
||||||
unsigned u = ntohl(param->sinc.sin_addr.s_addr);
|
char addr[16];
|
||||||
|
char dig[]="0123456789abcdef";
|
||||||
|
|
||||||
sprintf(buf, "%u.%u.%u.%u.in-addr.arpa",
|
unsigned u;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
if(*SAFAMILY(¶m->sincr)!=AF_INET){
|
||||||
|
char *s = buf;
|
||||||
|
for(i=15; i>=0; i--){
|
||||||
|
unsigned char c=((unsigned char *)SAADDR(¶m->sincr))[i];
|
||||||
|
*s++ = dig[(c&0xf)];
|
||||||
|
*s++ = '.';
|
||||||
|
*s++ = dig[(c>>4)];
|
||||||
|
*s++ = '.';
|
||||||
|
}
|
||||||
|
sprintf(s, "ip6.arpa");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
u = ntohl(*(unsigned long *)SAADDR(¶m->sincr));
|
||||||
|
|
||||||
((u&0x000000FF)),
|
sprintf(buf, "%u.%u.%u.%u.in-addr.arpa",
|
||||||
((u&0x0000FF00)>>8),
|
((u&0x000000FF)),
|
||||||
((u&0x00FF0000)>>16),
|
((u&0x0000FF00)>>8),
|
||||||
((u&0xFF000000)>>24));
|
((u&0x00FF0000)>>16),
|
||||||
|
((u&0xFF000000)>>24));
|
||||||
|
|
||||||
|
}
|
||||||
if(param->sinc.sin_addr.s_addr != udpresolve(buf, NULL, param, 1)) return 6;
|
if(!udpresolve(*SAFAMILY(¶m->sincr), buf, addr, NULL, param, 1)) return 6;
|
||||||
|
if(!memcmp(SAADDR(¶m->sincr), addr, SAADDRLEN(¶m->sincr))) return 6;
|
||||||
|
|
||||||
return param->username? 0:4;
|
return param->username? 0:4;
|
||||||
}
|
}
|
||||||
@@ -872,25 +843,29 @@ struct auth authfuncs[] = {
|
|||||||
{authfuncs+1, NULL, NULL, ""},
|
{authfuncs+1, NULL, NULL, ""},
|
||||||
{authfuncs+2, ipauth, NULL, "iponly"},
|
{authfuncs+2, ipauth, NULL, "iponly"},
|
||||||
{authfuncs+3, userauth, checkACL, "useronly"},
|
{authfuncs+3, userauth, checkACL, "useronly"},
|
||||||
{authfuncs+4, nbnameauth, checkACL, "nbname"},
|
{authfuncs+4, dnsauth, checkACL, "dnsname"},
|
||||||
{authfuncs+5, dnsauth, checkACL, "dnsname"},
|
{authfuncs+5, strongauth, checkACL, "strong"},
|
||||||
{authfuncs+6, strongauth, checkACL, "strong"},
|
{authfuncs+6, cacheauth, checkACL, "cache"},
|
||||||
{authfuncs+7, cacheauth, checkACL, "cache"},
|
{authfuncs+7, NULL, NULL, "none"},
|
||||||
{authfuncs+8, NULL, NULL, "none"},
|
|
||||||
|
|
||||||
{NULL, NULL, NULL, ""}
|
{NULL, NULL, NULL, ""}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
struct hashtable dns_table = {0, NULL, NULL, NULL};
|
|
||||||
|
struct hashtable dns_table = {0, 4, {0,0,0,0}, NULL, NULL, NULL};
|
||||||
|
struct hashtable dns6_table = {0, 16, {0,0,0,0}, NULL, NULL, NULL};
|
||||||
|
|
||||||
|
|
||||||
void nametohash(const unsigned char * name, unsigned char *hash){
|
void nametohash(const unsigned char * name, unsigned char *hash, unsigned char *rnd){
|
||||||
unsigned i, j;
|
unsigned i, j, k;
|
||||||
memset(hash, 0, sizeof(unsigned)*4);
|
memcpy(hash, rnd, sizeof(unsigned)*4);
|
||||||
for(i=0, j=0; name[j]; j++){
|
for(i=0, j=0, k=0; name[j]; j++){
|
||||||
hash[i] += toupper(name[j]) - 32;
|
hash[i] += (toupper(name[j]) - 32)+rnd[((toupper(name[j]))*29277+rnd[(k+j+i)%16]+k+j+i)%16];
|
||||||
if(++i == sizeof(unsigned)*4) i = 0;
|
if(++i == sizeof(unsigned)*4) {
|
||||||
|
i = 0;
|
||||||
|
k++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -918,8 +893,23 @@ void destroyhashtable(struct hashtable *ht){
|
|||||||
pthread_mutex_unlock(&hash_mutex);
|
pthread_mutex_unlock(&hash_mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define hvalue(I) ((struct hashentry *)((char *)ht->hashvalues + (I)*(sizeof(struct hashentry) + ht->recsize - 4)))
|
||||||
int inithashtable(struct hashtable *ht, unsigned nhashsize){
|
int inithashtable(struct hashtable *ht, unsigned nhashsize){
|
||||||
unsigned i;
|
unsigned i;
|
||||||
|
clock_t c;
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
struct timeb tb;
|
||||||
|
|
||||||
|
ftime(&tb);
|
||||||
|
|
||||||
|
#else
|
||||||
|
struct timeval tb;
|
||||||
|
struct timezone tz;
|
||||||
|
gettimeofday(&tb, &tz);
|
||||||
|
#endif
|
||||||
|
c = clock();
|
||||||
|
|
||||||
if(nhashsize<4) return 1;
|
if(nhashsize<4) return 1;
|
||||||
pthread_mutex_lock(&hash_mutex);
|
pthread_mutex_lock(&hash_mutex);
|
||||||
@@ -932,82 +922,90 @@ int inithashtable(struct hashtable *ht, unsigned nhashsize){
|
|||||||
ht->hashvalues = NULL;
|
ht->hashvalues = NULL;
|
||||||
}
|
}
|
||||||
ht->hashsize = 0;
|
ht->hashsize = 0;
|
||||||
if(!(ht->hashtable = myalloc((nhashsize>>2) * sizeof(struct hashentry *)))){
|
if(!(ht->hashtable = myalloc((nhashsize>>2) * sizeof(struct hashentry *)))){
|
||||||
pthread_mutex_unlock(&hash_mutex);
|
pthread_mutex_unlock(&hash_mutex);
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
if(!(ht->hashvalues = myalloc(nhashsize * sizeof(struct hashentry)))){
|
if(!(ht->hashvalues = myalloc(nhashsize * (sizeof(struct hashentry) + (ht->recsize-4))))){
|
||||||
myfree(ht->hashtable);
|
myfree(ht->hashtable);
|
||||||
ht->hashtable = NULL;
|
ht->hashtable = NULL;
|
||||||
pthread_mutex_unlock(&hash_mutex);
|
pthread_mutex_unlock(&hash_mutex);
|
||||||
return 3;
|
return 3;
|
||||||
}
|
}
|
||||||
ht->hashsize = nhashsize;
|
ht->hashsize = nhashsize;
|
||||||
|
ht->rnd[0] = myrand(&tb, sizeof(tb));
|
||||||
|
ht->rnd[1] = myrand(ht->hashtable, sizeof(ht->hashtable));
|
||||||
|
ht->rnd[2] = myrand(&c, sizeof(c));
|
||||||
|
ht->rnd[3] = myrand(ht->hashvalues,sizeof(ht->hashvalues));
|
||||||
memset(ht->hashtable, 0, (ht->hashsize>>2) * sizeof(struct hashentry *));
|
memset(ht->hashtable, 0, (ht->hashsize>>2) * sizeof(struct hashentry *));
|
||||||
memset(ht->hashvalues, 0, ht->hashsize * sizeof(struct hashentry));
|
memset(ht->hashvalues, 0, ht->hashsize * (sizeof(struct hashentry) + ht->recsize -4));
|
||||||
|
|
||||||
for(i = 0; i< (ht->hashsize - 1); i++) {
|
for(i = 0; i< (ht->hashsize - 1); i++) {
|
||||||
(ht->hashvalues + i)->next = ht->hashvalues + i + 1;
|
hvalue(i)->next = hvalue(i+1);
|
||||||
}
|
}
|
||||||
ht->hashempty = ht->hashvalues;
|
ht->hashempty = ht->hashvalues;
|
||||||
pthread_mutex_unlock(&hash_mutex);
|
pthread_mutex_unlock(&hash_mutex);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int initdnshashtable(unsigned nhashsize){
|
void hashadd(struct hashtable *ht, const unsigned char* name, unsigned char* value, time_t expires){
|
||||||
return inithashtable(&dns_table, nhashsize);
|
struct hashentry * hen, *he;
|
||||||
}
|
struct hashentry ** hep;
|
||||||
|
|
||||||
void hashadd(struct hashtable *ht, const unsigned char* name, unsigned long value, time_t expires){
|
|
||||||
struct hashentry * he;
|
|
||||||
unsigned index;
|
unsigned index;
|
||||||
|
|
||||||
pthread_mutex_lock(&hash_mutex);
|
pthread_mutex_lock(&hash_mutex);
|
||||||
if(!value||!name||!ht->hashtable||!ht->hashempty){
|
if(!ht||!value||!name||!ht->hashtable||!ht->hashempty) {
|
||||||
pthread_mutex_unlock(&hash_mutex);
|
pthread_mutex_unlock(&hash_mutex);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
he = ht->hashempty;
|
hen = ht->hashempty;
|
||||||
ht->hashempty = ht->hashempty->next;
|
ht->hashempty = ht->hashempty->next;
|
||||||
nametohash(name, he->hash);
|
nametohash(name, hen->hash, (unsigned char *)ht->rnd);
|
||||||
he->value = value;
|
memcpy(hen->value, value, ht->recsize);
|
||||||
he->expires = expires;
|
hen->expires = expires;
|
||||||
he->next = NULL;
|
hen->next = NULL;
|
||||||
index = hashindex(ht, he->hash);
|
index = hashindex(ht, hen->hash);
|
||||||
if(!ht->hashtable[index] || !memcmp(he->hash, ht->hashtable[index]->hash, sizeof(he->hash))){
|
|
||||||
he->next = ht->hashtable[index];
|
for(hep = ht->hashtable + index; (he = *hep)!=NULL; ){
|
||||||
ht->hashtable[index] = he;
|
if(he->expires < conf.time || !memcmp(hen->hash, he->hash, sizeof(he->hash))) {
|
||||||
}
|
(*hep) = he->next;
|
||||||
else {
|
he->expires = 0;
|
||||||
memset(he, 0, sizeof(struct hashentry));
|
he->next = ht->hashempty;
|
||||||
he->next = ht->hashempty;
|
ht->hashempty = he;
|
||||||
ht->hashempty = he;
|
}
|
||||||
|
else hep=&(he->next);
|
||||||
}
|
}
|
||||||
|
hen->next = ht->hashtable[index];
|
||||||
|
ht->hashtable[index] = hen;
|
||||||
pthread_mutex_unlock(&hash_mutex);
|
pthread_mutex_unlock(&hash_mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned long hashresolv(struct hashtable *ht, const unsigned char* name, unsigned *ttl){
|
unsigned long hashresolv(struct hashtable *ht, const unsigned char* name, unsigned char* value, unsigned *ttl){
|
||||||
unsigned char hash[sizeof(unsigned)*4];
|
unsigned char hash[sizeof(unsigned)*4];
|
||||||
struct hashentry ** hep;
|
struct hashentry ** hep;
|
||||||
struct hashentry *he;
|
struct hashentry *he;
|
||||||
unsigned index;
|
unsigned index;
|
||||||
time_t t;
|
|
||||||
|
|
||||||
if(!ht->hashtable || !name) return 0;
|
|
||||||
time(&t);
|
|
||||||
nametohash(name, hash);
|
|
||||||
index = hashindex(ht, hash);
|
|
||||||
pthread_mutex_lock(&hash_mutex);
|
pthread_mutex_lock(&hash_mutex);
|
||||||
|
if(!ht || !ht->hashtable || !name) {
|
||||||
|
pthread_mutex_unlock(&hash_mutex);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
nametohash(name, hash, (unsigned char *)ht->rnd);
|
||||||
|
index = hashindex(ht, hash);
|
||||||
for(hep = ht->hashtable + index; (he = *hep)!=NULL; ){
|
for(hep = ht->hashtable + index; (he = *hep)!=NULL; ){
|
||||||
if((unsigned long)he->expires < (unsigned long)t) {
|
if(he->expires < conf.time) {
|
||||||
(*hep) = he->next;
|
(*hep) = he->next;
|
||||||
he->expires = 0;
|
he->expires = 0;
|
||||||
he->next = ht->hashempty;
|
he->next = ht->hashempty;
|
||||||
ht->hashempty = he;
|
ht->hashempty = he;
|
||||||
}
|
}
|
||||||
else if(!memcmp(hash, he->hash, sizeof(unsigned)*4)){
|
else if(!memcmp(hash, he->hash, sizeof(unsigned)*4)){
|
||||||
|
if(ttl) *ttl = (unsigned)(he->expires - conf.time);
|
||||||
|
memcpy(value, he->value, ht->recsize);
|
||||||
pthread_mutex_unlock(&hash_mutex);
|
pthread_mutex_unlock(&hash_mutex);
|
||||||
if(ttl) *ttl = (unsigned)(he->expires - t);
|
return 1;
|
||||||
return he->value;
|
|
||||||
}
|
}
|
||||||
else hep=&(he->next);
|
else hep=&(he->next);
|
||||||
}
|
}
|
||||||
@@ -1015,48 +1013,76 @@ unsigned long hashresolv(struct hashtable *ht, const unsigned char* name, unsign
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned long nservers[MAXNSERVERS] = {0, 0, 0, 0, 0};
|
struct nserver nservers[MAXNSERVERS] = {{{0},0}, {{0},0}, {{0},0}, {{0},0}, {{0},0}};
|
||||||
|
struct nserver authnserver;
|
||||||
unsigned long authnserver;
|
|
||||||
|
|
||||||
|
|
||||||
unsigned long udpresolve(unsigned char * name, unsigned *retttl, struct clientparam* param, int makeauth){
|
unsigned long udpresolve(int af, unsigned char * name, unsigned char * value, unsigned *retttl, struct clientparam* param, int makeauth){
|
||||||
|
|
||||||
int i;
|
int i,n;
|
||||||
unsigned long retval;
|
unsigned long retval;
|
||||||
|
|
||||||
if((retval = hashresolv(&dns_table, name, retttl))) {
|
if((af == AF_INET) && (retval = hashresolv(&dns_table, name, value, retttl))) {
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
if((af == AF_INET6) && (retval = hashresolv(&dns6_table, name, value, retttl))) {
|
||||||
for(i=0; (i<(makeauth && authnserver)? 1 : MAXNSERVERS) && ((makeauth && authnserver) || nservers[i]); i++){
|
return retval;
|
||||||
unsigned short nquery, nq, na;
|
}
|
||||||
unsigned char buf[4096], *s1, *s2;
|
n = (makeauth && !SAISNULL(&authnserver.addr))? 1 : numservers;
|
||||||
|
for(i=0; i<n; i++){
|
||||||
|
unsigned short nq, na;
|
||||||
|
unsigned char b[4098], *buf, *s1, *s2;
|
||||||
int j, k, len, flen;
|
int j, k, len, flen;
|
||||||
SOCKET sock;
|
SOCKET sock;
|
||||||
unsigned ttl;
|
unsigned ttl;
|
||||||
time_t t;
|
#ifndef NOIPV6
|
||||||
struct sockaddr_in sin, *sinsp;
|
struct sockaddr_in6 addr;
|
||||||
|
#else
|
||||||
|
struct sockaddr_in addr;
|
||||||
|
#endif
|
||||||
|
struct sockaddr *sinsr, *sinsl;
|
||||||
|
int usetcp = 0;
|
||||||
|
unsigned short serial = 1;
|
||||||
|
|
||||||
memset(&sin, 0, sizeof(sin));
|
buf = b+2;
|
||||||
sinsp = (param && !makeauth)? ¶m->sins : &sin;
|
|
||||||
|
sinsl = (param && !makeauth)? (struct sockaddr *)¶m->sinsl : (struct sockaddr *)&addr;
|
||||||
|
sinsr = (param && !makeauth)? (struct sockaddr *)¶m->sinsr : (struct sockaddr *)&addr;
|
||||||
|
memset(sinsl, 0, sizeof(addr));
|
||||||
|
memset(sinsr, 0, sizeof(addr));
|
||||||
|
|
||||||
|
|
||||||
if((sock=so._socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) == INVALID_SOCKET) break;
|
if(makeauth && !SAISNULL(&authnserver.addr)){
|
||||||
sinsp->sin_family = AF_INET;
|
usetcp = authnserver.usetcp;
|
||||||
sinsp->sin_port = htons(0);
|
*SAFAMILY(sinsl) = *SAFAMILY(&authnserver.addr);
|
||||||
sinsp->sin_addr.s_addr = htonl(0);
|
}
|
||||||
if(so._bind(sock,(struct sockaddr *)sinsp,sizeof(struct sockaddr_in))) {
|
else {
|
||||||
|
usetcp = nservers[i].usetcp;
|
||||||
|
*SAFAMILY(sinsl) = *SAFAMILY(&nservers[i].addr);
|
||||||
|
}
|
||||||
|
if((sock=so._socket(SASOCK(sinsl), usetcp?SOCK_STREAM:SOCK_DGRAM, usetcp?IPPROTO_TCP:IPPROTO_UDP)) == INVALID_SOCKET) break;
|
||||||
|
if(so._bind(sock,sinsl,sizeof(addr))){
|
||||||
so._shutdown(sock, SHUT_RDWR);
|
so._shutdown(sock, SHUT_RDWR);
|
||||||
so._closesocket(sock);
|
so._closesocket(sock);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
sinsp->sin_addr.s_addr = (makeauth && authnserver)?authnserver : nservers[i];
|
if(makeauth && !SAISNULL(&authnserver.addr)){
|
||||||
sinsp->sin_port = htons(53);
|
memcpy(sinsr, &authnserver.addr, sizeof(addr));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
memcpy(sinsr, &nservers[i].addr, sizeof(addr));
|
||||||
|
}
|
||||||
|
if(usetcp){
|
||||||
|
if(so._connect(sock,sinsr,sizeof(addr))) {
|
||||||
|
so._shutdown(sock, SHUT_RDWR);
|
||||||
|
so._closesocket(sock);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
len = (int)strlen((char *)name);
|
len = (int)strlen((char *)name);
|
||||||
nquery = myrand(name, len);
|
|
||||||
*(unsigned short*)buf = nquery; /* query id */
|
serial = myrand(name,len);
|
||||||
|
*(unsigned short*)buf = serial; /* query id */
|
||||||
buf[2] = 1; /* recursive */
|
buf[2] = 1; /* recursive */
|
||||||
buf[3] = 0;
|
buf[3] = 0;
|
||||||
buf[4] = 0;
|
buf[4] = 0;
|
||||||
@@ -1074,21 +1100,38 @@ unsigned long udpresolve(unsigned char * name, unsigned *retttl, struct clientpa
|
|||||||
*s2 = (len - (int)(s2 - buf)) - 1;
|
*s2 = (len - (int)(s2 - buf)) - 1;
|
||||||
len++;
|
len++;
|
||||||
buf[len++] = 0;
|
buf[len++] = 0;
|
||||||
buf[len++] = (makeauth == 1)? 0x0c : 0x01; /* PTR:host address */
|
buf[len++] = (makeauth == 1)? 0x0c : (af==AF_INET6? 0x1c:0x01); /* PTR:host address */
|
||||||
buf[len++] = 0;
|
buf[len++] = 0;
|
||||||
buf[len++] = 1; /* INET */
|
buf[len++] = 1; /* INET */
|
||||||
if(socksendto(sock, sinsp, buf, len, conf.timeouts[SINGLEBYTE_L]*1000) != len){
|
if(usetcp){
|
||||||
|
buf-=2;
|
||||||
|
*(unsigned short*)buf = htons(len);
|
||||||
|
len+=2;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(socksendto(sock, sinsr, buf, len, conf.timeouts[SINGLEBYTE_L]*1000) != len){
|
||||||
so._shutdown(sock, SHUT_RDWR);
|
so._shutdown(sock, SHUT_RDWR);
|
||||||
so._closesocket(sock);
|
so._closesocket(sock);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if(param) param->statscli += len;
|
if(param) param->statscli64 += len;
|
||||||
len = sockrecvfrom(sock, sinsp, buf, 4096, 15000);
|
len = sockrecvfrom(sock, sinsr, buf, 4096, conf.timeouts[DNS_TO]*1000);
|
||||||
so._shutdown(sock, SHUT_RDWR);
|
so._shutdown(sock, SHUT_RDWR);
|
||||||
so._closesocket(sock);
|
so._closesocket(sock);
|
||||||
if(len <= 13) continue;
|
if(len <= 13) {
|
||||||
if(param) param->statssrv += len;
|
continue;
|
||||||
if(*(unsigned short *)buf != nquery)continue;
|
}
|
||||||
|
if(param) param->statssrv64 += len;
|
||||||
|
if(usetcp){
|
||||||
|
unsigned short us;
|
||||||
|
us = ntohs(*(unsigned short*)buf);
|
||||||
|
len-=2;
|
||||||
|
buf+=2;
|
||||||
|
if(us > 4096 || us < len || (us > len && sockrecvfrom(sock, sinsr, buf+len, us-len, conf.timeouts[DNS_TO]*1000) != us-len)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(*(unsigned short *)buf != serial)continue;
|
||||||
if((na = buf[7] + (((unsigned short)buf[6])<<8)) < 1) {
|
if((na = buf[7] + (((unsigned short)buf[6])<<8)) < 1) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -1105,25 +1148,27 @@ unsigned long udpresolve(unsigned char * name, unsigned *retttl, struct clientpa
|
|||||||
k += 4;
|
k += 4;
|
||||||
if(na > 255) na = 255; /* somebody is very evil */
|
if(na > 255) na = 255; /* somebody is very evil */
|
||||||
for (j = 0; j < na; j++) { /* now there should be answers */
|
for (j = 0; j < na; j++) { /* now there should be answers */
|
||||||
if((k+16) > len) {
|
if((k+(af == AF_INET6?28:16)) > len) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
flen = buf[k+11] + (((unsigned short)buf[k+10])<<8);
|
flen = buf[k+11] + (((unsigned short)buf[k+10])<<8);
|
||||||
if((k+12+flen) > len) break;
|
if((k+12+flen) > len) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
if(makeauth != 1){
|
if(makeauth != 1){
|
||||||
if(buf[k+2] != 0 || buf[k+3] != 0x01 || flen != 4) {
|
if(buf[k+2] != 0 || buf[k+3] != (af == AF_INET6?0x1c:0x1) || flen != (af == AF_INET6?16:4)) {
|
||||||
k+= (12 + flen);
|
k+= (12 + flen);
|
||||||
continue; /* we need A IPv4 */
|
continue; /* we need A IPv4 */
|
||||||
}
|
}
|
||||||
retval = *(unsigned long *)(buf + k + 12);
|
|
||||||
ttl = ntohl(*(unsigned long *)(buf + k + 6));
|
ttl = ntohl(*(unsigned long *)(buf + k + 6));
|
||||||
t = time(0);
|
memcpy(value, buf + k + 12, af == AF_INET6? 16:4);
|
||||||
if(ttl < 60 || ((unsigned)t)+ttl < ttl) ttl = 300;
|
if(ttl < 60 || ttl > (3600*12)) ttl = 300;
|
||||||
if(ttl){
|
if(ttl){
|
||||||
hashadd(&dns_table, name, retval, ((unsigned)t)+ttl);
|
hashadd(af == AF_INET6?&dns6_table:&dns_table, name, value, conf.time+ttl);
|
||||||
|
|
||||||
}
|
}
|
||||||
if(retttl) *retttl = ttl;
|
if(retttl) *retttl = ttl;
|
||||||
return retval;
|
return 1;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
@@ -1140,19 +1185,30 @@ unsigned long udpresolve(unsigned char * name, unsigned *retttl, struct clientpa
|
|||||||
if(param->username)myfree(param->username);
|
if(param->username)myfree(param->username);
|
||||||
param->username = mystrdup (buf + k + 13);
|
param->username = mystrdup (buf + k + 13);
|
||||||
|
|
||||||
return udpresolve(param->username, NULL, NULL, 2);
|
return udpresolve(af,param->username, value, NULL, NULL, 2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned long myresolver(unsigned char * name){
|
unsigned long myresolver(int af, unsigned char * name, unsigned char * value){
|
||||||
return udpresolve(name, NULL, NULL, 0);
|
return udpresolve(af, name, value, NULL, NULL, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned long fakeresolver (unsigned char *name){
|
unsigned long fakeresolver (int af, unsigned char *name, unsigned char * value){
|
||||||
return htonl(0x7F000002);
|
memset(value, 0, af == AF_INET6? 16 : 4);
|
||||||
|
if(af == AF_INET6){
|
||||||
|
memset(value, 0, 16);
|
||||||
|
value[15] = 2;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
value[0] = 127;
|
||||||
|
value[1] = 0;
|
||||||
|
value[2] = 0;
|
||||||
|
value[3] = 2;
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef NOODBC
|
#ifndef NOODBC
|
||||||
@@ -1254,46 +1310,45 @@ 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(&odbc_mutex);
|
pthread_mutex_unlock(&log_mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
void logsql(struct clientparam * param, const unsigned char *s) {
|
void logsql(struct clientparam * param, const unsigned char *s) {
|
||||||
unsigned char buf[4096];
|
|
||||||
SQLRETURN ret;
|
SQLRETURN ret;
|
||||||
int len;
|
int len;
|
||||||
|
|
||||||
len = dobuf(param, buf, s, "\'");
|
|
||||||
|
|
||||||
if(param->nolog) return;
|
if(param->nolog) return;
|
||||||
pthread_mutex_lock(&odbc_mutex);
|
pthread_mutex_lock(&log_mutex);
|
||||||
|
len = dobuf(param, tmpbuf, s, "\'");
|
||||||
|
|
||||||
if(attempt > 5){
|
if(attempt > 5){
|
||||||
time_t t;
|
time_t t;
|
||||||
|
|
||||||
t = time(0);
|
t = time(0);
|
||||||
if (t - attempt_time < 180){
|
if (t - attempt_time < 180){
|
||||||
sqlerr(buf);
|
sqlerr(tmpbuf);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(!hstmt){
|
if(!hstmt){
|
||||||
if(!init_sql(sqlstring)) {
|
if(!init_sql(sqlstring)) {
|
||||||
sqlerr(buf);
|
sqlerr(tmpbuf);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(hstmt){
|
if(hstmt){
|
||||||
ret = SQLExecDirect(hstmt, (SQLCHAR *)buf, (SQLINTEGER)len);
|
ret = SQLExecDirect(hstmt, (SQLCHAR *)tmpbuf, (SQLINTEGER)len);
|
||||||
if(ret != SQL_SUCCESS && ret != SQL_SUCCESS_WITH_INFO){
|
if(ret != SQL_SUCCESS && ret != SQL_SUCCESS_WITH_INFO){
|
||||||
close_sql();
|
close_sql();
|
||||||
if(!init_sql(sqlstring)){
|
if(!init_sql(sqlstring)){
|
||||||
sqlerr(buf);
|
sqlerr(tmpbuf);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(hstmt) {
|
if(hstmt) {
|
||||||
ret = SQLExecDirect(hstmt, (SQLCHAR *)buf, (SQLINTEGER)len);
|
ret = SQLExecDirect(hstmt, (SQLCHAR *)tmpbuf, (SQLINTEGER)len);
|
||||||
if(ret != SQL_SUCCESS && ret != SQL_SUCCESS_WITH_INFO){
|
if(ret != SQL_SUCCESS && ret != SQL_SUCCESS_WITH_INFO){
|
||||||
sqlerr(buf);
|
sqlerr(tmpbuf);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
attempt = 0;
|
attempt = 0;
|
||||||
@@ -1301,22 +1356,8 @@ void logsql(struct clientparam * param, const unsigned char *s) {
|
|||||||
}
|
}
|
||||||
attempt = 0;
|
attempt = 0;
|
||||||
}
|
}
|
||||||
pthread_mutex_unlock(&odbc_mutex);
|
pthread_mutex_unlock(&log_mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef WITHMAIN
|
|
||||||
int main(int argc, unsigned char * argv[]) {
|
|
||||||
unsigned ip = 0;
|
|
||||||
WSADATA wd;
|
|
||||||
WSAStartup(MAKEWORD( 1, 1 ), &wd);
|
|
||||||
if(argc == 2)ip=getip(argv[1]);
|
|
||||||
if(!hp) {
|
|
||||||
printf("Not found");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
printf("Name: '%s'\n", getnamebyip(ip);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
@@ -3,7 +3,6 @@
|
|||||||
*
|
*
|
||||||
* please read License Agreement
|
* please read License Agreement
|
||||||
*
|
*
|
||||||
* $Id: base64.c,v 1.6 2008/01/08 21:46:36 vlad Exp $
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|||||||
+215
-79
@@ -4,7 +4,6 @@
|
|||||||
|
|
||||||
please read License Agreement
|
please read License Agreement
|
||||||
|
|
||||||
$Id: common.c,v 1.94 2014-04-07 21:24:45 vlad Exp $
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
@@ -22,13 +21,22 @@ int randomizer = 1;
|
|||||||
|
|
||||||
unsigned char **stringtable = NULL;
|
unsigned char **stringtable = NULL;
|
||||||
|
|
||||||
int myinet_ntoa(struct in_addr in, char * buf){
|
int myinet_ntop(int af, void *src, char *dst, socklen_t size){
|
||||||
unsigned u = ntohl(in.s_addr);
|
#ifndef NOIPV6
|
||||||
return sprintf(buf, "%u.%u.%u.%u",
|
if(af != AF_INET6){
|
||||||
((u&0xFF000000)>>24),
|
#endif
|
||||||
((u&0x00FF0000)>>16),
|
unsigned u = ntohl(((struct in_addr *)src)->s_addr);
|
||||||
((u&0x0000FF00)>>8),
|
return sprintf(dst, "%u.%u.%u.%u",
|
||||||
((u&0x000000FF)));
|
((u&0xFF000000)>>24),
|
||||||
|
((u&0x00FF0000)>>16),
|
||||||
|
((u&0x0000FF00)>>8),
|
||||||
|
((u&0x000000FF)));
|
||||||
|
#ifndef NOIPV6
|
||||||
|
}
|
||||||
|
*dst = 0;
|
||||||
|
inet_ntop(af, src, dst, size);
|
||||||
|
return (int)strlen(dst);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
char *rotations[] = {
|
char *rotations[] = {
|
||||||
@@ -56,8 +64,11 @@ struct extparam conf = {
|
|||||||
NULL, NULL,
|
NULL, NULL,
|
||||||
NONE, NONE,
|
NONE, NONE,
|
||||||
NULL,
|
NULL,
|
||||||
INADDR_ANY, INADDR_ANY,
|
#ifndef NOIPV6
|
||||||
0, 0,
|
{AF_INET},{AF_INET6},{AF_INET},
|
||||||
|
#else
|
||||||
|
{AF_INET},{AF_INET},
|
||||||
|
#endif
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
doconnect,
|
doconnect,
|
||||||
@@ -76,6 +87,10 @@ struct extparam conf = {
|
|||||||
'@'
|
'@'
|
||||||
};
|
};
|
||||||
|
|
||||||
|
int numservers=0;
|
||||||
|
|
||||||
|
char* NULLADDR="\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0";
|
||||||
|
|
||||||
int myrand(void * entropy, int len){
|
int myrand(void * entropy, int len){
|
||||||
int i;
|
int i;
|
||||||
unsigned short init;
|
unsigned short init;
|
||||||
@@ -201,23 +216,45 @@ int ceparseargs(const char *str){
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int parsehostname(char *hostname, struct clientparam *param, unsigned short port){
|
void parsehost(int family, char *host, struct sockaddr *sa){
|
||||||
char *sp;
|
char *sp=NULL,*se=NULL;
|
||||||
|
unsigned short port;
|
||||||
|
|
||||||
if(!hostname || !*hostname)return 1;
|
if(*host == '[') se=strchr(host, ']');
|
||||||
if ( (sp = strchr(hostname, ':')) ) *sp = 0;
|
if ( (sp = strchr(se?se:host, ':')) ) *sp = 0;
|
||||||
if(hostname != param->hostname){
|
if(se){
|
||||||
if(param->hostname) myfree(param->hostname);
|
*se = 0;
|
||||||
param->hostname = (unsigned char *)mystrdup(hostname);
|
|
||||||
}
|
}
|
||||||
if(sp){
|
if(sp){
|
||||||
port = atoi(sp+1);
|
port = atoi(sp+1);
|
||||||
*sp = ':';
|
|
||||||
}
|
}
|
||||||
param->req.sin_port=htons(port);
|
getip46(family, host + (se!=0), (struct sockaddr *)sa);
|
||||||
param->req.sin_addr.s_addr = getip(param->hostname);
|
if(se) *se = ']';
|
||||||
param->sins.sin_addr.s_addr = 0;
|
if(sp) *sp = ':';
|
||||||
param->sins.sin_port = 0;
|
*SAPORT(sa) = htons(port);
|
||||||
|
}
|
||||||
|
|
||||||
|
int parsehostname(char *hostname, struct clientparam *param, unsigned short port){
|
||||||
|
char *sp=NULL,*se=NULL;
|
||||||
|
|
||||||
|
if(!hostname || !*hostname)return 1;
|
||||||
|
if(*hostname == '[') se=strchr(hostname, ']');
|
||||||
|
if ( (sp = strchr(se?se:hostname, ':')) ) *sp = 0;
|
||||||
|
if(se){
|
||||||
|
*se = 0;
|
||||||
|
}
|
||||||
|
if(hostname != (char *)param->hostname){
|
||||||
|
if(param->hostname) myfree(param->hostname);
|
||||||
|
param->hostname = (unsigned char *)mystrdup(hostname + (se!=0));
|
||||||
|
}
|
||||||
|
if(sp){
|
||||||
|
port = atoi(sp+1);
|
||||||
|
}
|
||||||
|
getip46(param->srv->family, param->hostname, (struct sockaddr *)¶m->req);
|
||||||
|
if(se) *se = ']';
|
||||||
|
if(sp) *sp = ':';
|
||||||
|
*SAPORT(¶m->req) = htons(port);
|
||||||
|
memset(¶m->sinsr, 0, sizeof(param->sinsr));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -225,7 +262,7 @@ int parseusername(char *username, struct clientparam *param, int extpasswd){
|
|||||||
char *sb = NULL, *se = NULL, *sp = NULL;
|
char *sb = NULL, *se = NULL, *sp = NULL;
|
||||||
|
|
||||||
if(!username || !*username) return 1;
|
if(!username || !*username) return 1;
|
||||||
if(!param->srv->nouser && (sb = strchr(username, ':')) && (se = strchr(sb + 1, ':')) && (!extpasswd || (sp = strchr(se + 1, ':')))){
|
if(param->srv->needuser && (sb = strchr(username, ':')) && (se = strchr(sb + 1, ':')) && (!extpasswd || (sp = strchr(se + 1, ':')))){
|
||||||
*sb = 0;
|
*sb = 0;
|
||||||
*se = 0;
|
*se = 0;
|
||||||
if(sp) *sp = 0;
|
if(sp) *sp = 0;
|
||||||
@@ -260,6 +297,7 @@ int parseconnusername(char *username, struct clientparam *param, int extpasswd,
|
|||||||
if(!username || !*username) return 1;
|
if(!username || !*username) return 1;
|
||||||
if ((sb=strchr(username, conf.delimchar)) == NULL){
|
if ((sb=strchr(username, conf.delimchar)) == NULL){
|
||||||
if(!param->hostname && param->remsock == INVALID_SOCKET) return 2;
|
if(!param->hostname && param->remsock == INVALID_SOCKET) return 2;
|
||||||
|
if(param->hostname)parsehostname(param->hostname, param, port);
|
||||||
return parseusername(username, param, extpasswd);
|
return parseusername(username, param, extpasswd);
|
||||||
}
|
}
|
||||||
while ((se=strchr(sb+1, conf.delimchar)))sb=se;
|
while ((se=strchr(sb+1, conf.delimchar)))sb=se;
|
||||||
@@ -287,7 +325,7 @@ void clearstat(struct clientparam * param) {
|
|||||||
param->time_start = (time_t)tv.tv_sec;
|
param->time_start = (time_t)tv.tv_sec;
|
||||||
param->msec_start = (tv.tv_usec / 1000);
|
param->msec_start = (tv.tv_usec / 1000);
|
||||||
#endif
|
#endif
|
||||||
param->statscli = param->statssrv = param->nreads = param->nwrites =
|
param->statscli64 = param->statssrv64 = param->nreads = param->nwrites =
|
||||||
param->nconnects = 0;
|
param->nconnects = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -306,7 +344,6 @@ int dobuf2(struct clientparam * param, unsigned char * buf, const unsigned char
|
|||||||
|
|
||||||
long timezone;
|
long timezone;
|
||||||
unsigned delay;
|
unsigned delay;
|
||||||
struct in_addr tmpia;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -378,10 +415,10 @@ int dobuf2(struct clientparam * param, unsigned char * buf, const unsigned char
|
|||||||
i+=10;
|
i+=10;
|
||||||
break;
|
break;
|
||||||
case 'b':
|
case 'b':
|
||||||
i+=sprintf((char *)buf+i, "%u", delay?(unsigned)(param->statscli * 1000./delay):0);
|
i+=sprintf((char *)buf+i, "%u", delay?(unsigned)(param->statscli64 * 1000./delay):0);
|
||||||
break;
|
break;
|
||||||
case 'B':
|
case 'B':
|
||||||
i+=sprintf((char *)buf+i, "%u", delay?(unsigned)(param->statssrv * 1000./delay):0);
|
i+=sprintf((char *)buf+i, "%u", delay?(unsigned)(param->statssrv64 * 1000./delay):0);
|
||||||
break;
|
break;
|
||||||
case 'D':
|
case 'D':
|
||||||
i+=sprintf((char *)buf+i, "%u", delay);
|
i+=sprintf((char *)buf+i, "%u", delay);
|
||||||
@@ -412,7 +449,7 @@ int dobuf2(struct clientparam * param, unsigned char * buf, const unsigned char
|
|||||||
break;
|
break;
|
||||||
case 'n':
|
case 'n':
|
||||||
len = param->hostname? (int)strlen((char *)param->hostname) : 0;
|
len = param->hostname? (int)strlen((char *)param->hostname) : 0;
|
||||||
if (len > 0) for(len = 0; param->hostname[len] && i < 4000; len++, i++){
|
if (len > 0 && !strchr((char *)param->hostname, ':')) for(len = 0; param->hostname[len] && i < 4000; len++, i++){
|
||||||
buf[i] = param->hostname[len];
|
buf[i] = param->hostname[len];
|
||||||
if(param->srv->nonprintable && (buf[i] < 0x20 || strchr((char *)param->srv->nonprintable, buf[i]))) buf[i] = param->srv->replace;
|
if(param->srv->nonprintable && (buf[i] < 0x20 || strchr((char *)param->srv->nonprintable, buf[i]))) buf[i] = param->srv->replace;
|
||||||
if(doublec && strchr((char *)doublec, buf[i])) {
|
if(doublec && strchr((char *)doublec, buf[i])) {
|
||||||
@@ -420,7 +457,12 @@ int dobuf2(struct clientparam * param, unsigned char * buf, const unsigned char
|
|||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else i += myinet_ntoa(param->sins.sin_addr, (char *)buf + i);
|
else {
|
||||||
|
buf[i++] = '[';
|
||||||
|
i += myinet_ntop(*SAFAMILY(¶m->req), SAADDR(¶m->req), (char *)buf + i, 64);
|
||||||
|
buf[i++] = ']';
|
||||||
|
buf[i++] = 0;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'N':
|
case 'N':
|
||||||
@@ -449,40 +491,39 @@ int dobuf2(struct clientparam * param, unsigned char * buf, const unsigned char
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'e':
|
case 'e':
|
||||||
tmpia.s_addr = param->extip;
|
i += myinet_ntop(*SAFAMILY(¶m->sinsl), SAADDR(¶m->sinsl), (char *)buf + i, 64);
|
||||||
i += myinet_ntoa(tmpia, (char *)buf + i);
|
|
||||||
break;
|
break;
|
||||||
case 'C':
|
case 'C':
|
||||||
i += myinet_ntoa(param->sinc.sin_addr, (char *)buf + i);
|
i += myinet_ntop(*SAFAMILY(¶m->sincr), SAADDR(¶m->sincr), (char *)buf + i, 64);
|
||||||
break;
|
break;
|
||||||
case 'R':
|
case 'R':
|
||||||
i += myinet_ntoa(param->sins.sin_addr, (char *)buf + i);
|
i += myinet_ntop(*SAFAMILY(¶m->sinsr), SAADDR(¶m->sinsr), (char *)buf + i, 64);
|
||||||
break;
|
break;
|
||||||
case 'Q':
|
case 'Q':
|
||||||
i += myinet_ntoa(param->req.sin_addr, (char *)buf + i);
|
i += myinet_ntop(*SAFAMILY(¶m->req), SAADDR(¶m->req), (char *)buf + i, 64);
|
||||||
break;
|
break;
|
||||||
case 'p':
|
case 'p':
|
||||||
sprintf((char *)buf+i, "%hu", ntohs(param->srv->intport));
|
sprintf((char *)buf+i, "%hu", ntohs(*SAPORT(¶m->srv->intsa)));
|
||||||
i += (int)strlen((char *)buf+i);
|
i += (int)strlen((char *)buf+i);
|
||||||
break;
|
break;
|
||||||
case 'c':
|
case 'c':
|
||||||
sprintf((char *)buf+i, "%hu", ntohs(param->sinc.sin_port));
|
sprintf((char *)buf+i, "%hu", ntohs(*SAPORT(¶m->sincr)));
|
||||||
i += (int)strlen((char *)buf+i);
|
i += (int)strlen((char *)buf+i);
|
||||||
break;
|
break;
|
||||||
case 'r':
|
case 'r':
|
||||||
sprintf((char *)buf+i, "%hu", ntohs(param->sins.sin_port));
|
sprintf((char *)buf+i, "%hu", ntohs(*SAPORT(¶m->sinsr)));
|
||||||
i += (int)strlen((char *)buf+i);
|
i += (int)strlen((char *)buf+i);
|
||||||
break;
|
break;
|
||||||
case 'q':
|
case 'q':
|
||||||
sprintf((char *)buf+i, "%hu", ntohs(param->req.sin_port));
|
sprintf((char *)buf+i, "%hu", ntohs(*SAPORT(¶m->req)));
|
||||||
i += (int)strlen((char *)buf+i);
|
i += (int)strlen((char *)buf+i);
|
||||||
break;
|
break;
|
||||||
case 'I':
|
case 'I':
|
||||||
sprintf((char *)buf+i, "%lu", param->statssrv);
|
sprintf((char *)buf+i, "%"PRINTF_INT64_MODIFIER"u", param->statssrv64);
|
||||||
i += (int)strlen((char *)buf+i);
|
i += (int)strlen((char *)buf+i);
|
||||||
break;
|
break;
|
||||||
case 'O':
|
case 'O':
|
||||||
sprintf((char *)buf+i, "%lu", param->statscli);
|
sprintf((char *)buf+i, "%"PRINTF_INT64_MODIFIER"u", param->statscli64);
|
||||||
i += (int)strlen((char *)buf+i);
|
i += (int)strlen((char *)buf+i);
|
||||||
break;
|
break;
|
||||||
case 'h':
|
case 'h':
|
||||||
@@ -560,77 +601,94 @@ void lognone(struct clientparam * param, const unsigned char *s) {
|
|||||||
if(param->trafcountfunc)(*param->trafcountfunc)(param);
|
if(param->trafcountfunc)(*param->trafcountfunc)(param);
|
||||||
clearstat(param);
|
clearstat(param);
|
||||||
}
|
}
|
||||||
|
pthread_mutex_t log_mutex;
|
||||||
|
int logmutexinit = 0;
|
||||||
|
unsigned char tmpbuf[8192];
|
||||||
|
|
||||||
void logstdout(struct clientparam * param, const unsigned char *s) {
|
void logstdout(struct clientparam * param, const unsigned char *s) {
|
||||||
unsigned char buf[4096];
|
|
||||||
FILE *log;
|
FILE *log;
|
||||||
|
|
||||||
|
if(!logmutexinit){
|
||||||
|
pthread_mutex_init(&log_mutex, NULL);
|
||||||
|
logmutexinit = 1;
|
||||||
|
}
|
||||||
|
pthread_mutex_lock(&log_mutex);
|
||||||
log = param->srv->stdlog?param->srv->stdlog:conf.stdlog?conf.stdlog:stdout;
|
log = param->srv->stdlog?param->srv->stdlog:conf.stdlog?conf.stdlog:stdout;
|
||||||
dobuf(param, buf, s, NULL);
|
dobuf(param, tmpbuf, s, NULL);
|
||||||
if(!param->nolog)if(fprintf(log, "%s\n", buf) < 0) {
|
if(!param->nolog)if(fprintf(log, "%s\n", tmpbuf) < 0) {
|
||||||
perror("printf()");
|
perror("printf()");
|
||||||
};
|
};
|
||||||
if(log != conf.stdlog)fflush(log);
|
if(log != conf.stdlog)fflush(log);
|
||||||
|
pthread_mutex_unlock(&log_mutex);
|
||||||
}
|
}
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
void logsyslog(struct clientparam * param, const unsigned char *s) {
|
void logsyslog(struct clientparam * param, const unsigned char *s) {
|
||||||
unsigned char buf[4096];
|
|
||||||
|
|
||||||
dobuf(param, buf, s, NULL);
|
if(!logmutexinit){
|
||||||
if(!param->nolog)syslog(LOG_INFO, "%s", buf);
|
pthread_mutex_init(&log_mutex, NULL);
|
||||||
|
logmutexinit = 1;
|
||||||
|
}
|
||||||
|
pthread_mutex_lock(&log_mutex);
|
||||||
|
dobuf(param, tmpbuf, s, NULL);
|
||||||
|
if(!param->nolog)syslog(LOG_INFO, "%s", tmpbuf);
|
||||||
|
pthread_mutex_unlock(&log_mutex);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int doconnect(struct clientparam * param){
|
int doconnect(struct clientparam * param){
|
||||||
SASIZETYPE size = sizeof(param->sins);
|
SASIZETYPE size = sizeof(param->sinsr);
|
||||||
struct sockaddr_in bindsa;
|
|
||||||
|
if (*SAFAMILY(¶m->sincr) == *SAFAMILY(¶m->req) && !memcmp(SAADDR(¶m->sincr), SAADDR(¶m->req), SAADDRLEN(¶m->req)) &&
|
||||||
|
*SAPORT(¶m->sincr) == *SAPORT(¶m->req)) return 519;
|
||||||
|
|
||||||
if (param->operation == ADMIN || param->operation == DNSRESOLVE || param->operation == BIND || param->operation == UDPASSOC)
|
if (param->operation == ADMIN || param->operation == DNSRESOLVE || param->operation == BIND || param->operation == UDPASSOC)
|
||||||
return 0;
|
return 0;
|
||||||
if (param->remsock != INVALID_SOCKET){
|
if (param->remsock != INVALID_SOCKET){
|
||||||
if(so._getpeername(param->remsock, (struct sockaddr *)¶m->sins, &size)==-1) {return (15);}
|
if(so._getpeername(param->remsock, (struct sockaddr *)¶m->sinsr, &size)==-1) {return (15);}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
struct linger lg;
|
struct linger lg = {1,conf.timeouts[SINGLEBYTE_S]};
|
||||||
|
int opt = 1;
|
||||||
|
|
||||||
if(!param->sins.sin_addr.s_addr)
|
if(SAISNULL(¶m->sinsr)){
|
||||||
if(!(param->sins.sin_addr.s_addr = param->req.sin_addr.s_addr)) return 100;
|
if(SAISNULL(¶m->req)) {
|
||||||
if(!param->sins.sin_port)param->sins.sin_port = param->req.sin_port;
|
return 100;
|
||||||
if ((param->remsock=so._socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) == INVALID_SOCKET) {return (11);}
|
}
|
||||||
|
*SAFAMILY(¶m->sinsr) = *SAFAMILY(¶m->req);
|
||||||
|
memcpy(SAADDR(¶m->sinsr), SAADDR(¶m->req), SAADDRLEN(¶m->req));
|
||||||
|
}
|
||||||
|
if(!*SAPORT(¶m->sinsr))*SAPORT(¶m->sinsr) = *SAPORT(¶m->req);
|
||||||
|
if ((param->remsock=so._socket(SASOCK(¶m->sinsr), SOCK_STREAM, IPPROTO_TCP)) == INVALID_SOCKET) {return (11);}
|
||||||
so._setsockopt(param->remsock, SOL_SOCKET, SO_LINGER, (unsigned char *)&lg, sizeof(lg));
|
so._setsockopt(param->remsock, SOL_SOCKET, SO_LINGER, (unsigned char *)&lg, sizeof(lg));
|
||||||
memset(&bindsa, 0, sizeof(bindsa));
|
so._setsockopt(param->remsock, SOL_SOCKET, SO_REUSEADDR, (unsigned char *)&opt, sizeof(int));
|
||||||
bindsa.sin_family = AF_INET;
|
|
||||||
bindsa.sin_port = param->extport;
|
#ifndef NOIPV6
|
||||||
bindsa.sin_addr.s_addr = param->extip;
|
if(*SAFAMILY(¶m->sinsr) == AF_INET6) memcpy(¶m->sinsl, ¶m->srv->extsa6, sizeof(param->srv->extsa6));
|
||||||
if (param->srv->targetport && !bindsa.sin_port && ntohs(param->sinc.sin_port) > 1023) bindsa.sin_port = param->sinc.sin_port;
|
else
|
||||||
if(so._bind(param->remsock, (struct sockaddr*)&bindsa, sizeof(bindsa))==-1) {
|
#endif
|
||||||
memset(&bindsa, 0, sizeof(bindsa));
|
memcpy(¶m->sinsl, ¶m->srv->extsa, sizeof(param->srv->extsa));
|
||||||
bindsa.sin_family = AF_INET;
|
if (param->srv->targetport && !*SAPORT(¶m->sinsl) && ntohs(*SAPORT(¶m->sincr)) > 1023) *SAPORT(¶m->sinsl) = *SAPORT(¶m->sincr);
|
||||||
bindsa.sin_addr.s_addr = param->extip;
|
if(so._bind(param->remsock, (struct sockaddr*)¶m->sinsl, sizeof(param->sinsl))==-1) {
|
||||||
bindsa.sin_port = 0;
|
*SAPORT(¶m->sinsl) = 0;
|
||||||
if(so._bind(param->remsock, (struct sockaddr*)&bindsa, sizeof(bindsa))==-1) {
|
if(so._bind(param->remsock, (struct sockaddr*)¶m->sinsl, sizeof(param->sinsl))==-1) {
|
||||||
return 12;
|
return 12;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
param->sins.sin_family = AF_INET;
|
|
||||||
if(param->operation >= 256 || (param->operation & CONNECT)){
|
if(param->operation >= 256 || (param->operation & CONNECT)){
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
unsigned long ul = 1;
|
unsigned long ul = 1;
|
||||||
#endif
|
#endif
|
||||||
if(so._connect(param->remsock,(struct sockaddr *)¶m->sins,sizeof(param->sins))) {return (13);}
|
if(so._connect(param->remsock,(struct sockaddr *)¶m->sinsr,sizeof(param->sinsr))) {return (13);}
|
||||||
param->nconnects++;
|
param->nconnects++;
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
ioctlsocket(param->remsock, FIONBIO, &ul);
|
ioctlsocket(param->remsock, FIONBIO, &ul);
|
||||||
#else
|
#else
|
||||||
fcntl(param->remsock,F_SETFL,O_NONBLOCK);
|
fcntl(param->remsock,F_SETFL,O_NONBLOCK);
|
||||||
#endif
|
#endif
|
||||||
if(so._getsockname(param->remsock, (struct sockaddr *)&bindsa, &size)==-1) {return (15);}
|
size = sizeof(param->sinsl);
|
||||||
param->extip = bindsa.sin_addr.s_addr;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
if(so._getsockname(param->remsock, (struct sockaddr *)¶m->sins, &size)==-1) {return (15);}
|
|
||||||
}
|
}
|
||||||
|
if(so._getsockname(param->remsock, (struct sockaddr *)¶m->sinsl, &size)==-1) {return (15);}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -667,11 +725,13 @@ struct hostent * my_gethostbyname(char *name, char *buf, struct hostent *hp){
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef NOIPV6
|
||||||
unsigned long getip(unsigned char *name){
|
unsigned long getip(unsigned char *name){
|
||||||
unsigned long retval;
|
unsigned long retval;
|
||||||
int i;
|
int i;
|
||||||
int ndots = 0;
|
int ndots = 0;
|
||||||
struct hostent *hp=NULL;
|
struct hostent *hp=NULL;
|
||||||
|
RESOLVFUNC tmpresolv;
|
||||||
|
|
||||||
#ifdef GETHOSTBYNAME_R
|
#ifdef GETHOSTBYNAME_R
|
||||||
struct hostent he;
|
struct hostent he;
|
||||||
@@ -688,15 +748,14 @@ unsigned long getip(unsigned char *name){
|
|||||||
if(name[i] <'0' || name[i] >'9') break;
|
if(name[i] <'0' || name[i] >'9') break;
|
||||||
}
|
}
|
||||||
if(!name[i] && ndots == 3){
|
if(!name[i] && ndots == 3){
|
||||||
unsigned long ip;
|
if(scanaddr(name, &retval, NULL) == 4){
|
||||||
if(scanaddr(name, &ip, NULL) == 4){
|
return retval;
|
||||||
return ip;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(resolvfunc){
|
if((tmpresolv=resolvfunc)){
|
||||||
if((retval = (*resolvfunc)(name))) return retval;
|
if((*tmpresolv)(AF_INET, name, (unsigned char *)&retval)) return retval;
|
||||||
if(conf.demanddialprog) system(conf.demanddialprog);
|
if(conf.demanddialprog) system(conf.demanddialprog);
|
||||||
return (*resolvfunc)(name);
|
return (*tmpresolv)(AF_INET, name, (unsigned char *)&retval)?retval:0;
|
||||||
}
|
}
|
||||||
#if !defined(_WIN32) && !defined(GETHOSTBYNAME_R)
|
#if !defined(_WIN32) && !defined(GETHOSTBYNAME_R)
|
||||||
if(!ghbn_init){
|
if(!ghbn_init){
|
||||||
@@ -719,3 +778,80 @@ unsigned long getip(unsigned char *name){
|
|||||||
#endif
|
#endif
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
unsigned long getip46(int family, unsigned char *name, struct sockaddr *sa){
|
||||||
|
#ifndef NOIPV6
|
||||||
|
int ndots=0, ncols=0, nhex=0;
|
||||||
|
struct addrinfo *ai, hint;
|
||||||
|
int i;
|
||||||
|
RESOLVFUNC tmpresolv;
|
||||||
|
|
||||||
|
if(!sa) return 0;
|
||||||
|
if(!family) {
|
||||||
|
family = 4;
|
||||||
|
#else
|
||||||
|
((struct sockaddr_in *)sa)->sin_family = AF_INET;
|
||||||
|
return (((struct sockaddr_in *)sa)->sin_addr.s_addr = getip(name))? AF_INET:0;
|
||||||
|
#endif
|
||||||
|
#ifndef NOIPV6
|
||||||
|
}
|
||||||
|
for(i=0; name[i]; i++){
|
||||||
|
if(name[i] == '.'){
|
||||||
|
if(++ndots > 3) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(name[i] == ':'){
|
||||||
|
if(++ncols > 7) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(name[i] == '%' || (name[i] >= 'a' && name[i] <= 'f') || (name[i] >= 'A' && name[i] <= 'F')){
|
||||||
|
nhex++;
|
||||||
|
}
|
||||||
|
else if(name[i] <'0' || name[i] >'9') {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(!name[i]){
|
||||||
|
if(ndots == 3 && ncols == 0 && nhex == 0){
|
||||||
|
*SAFAMILY(sa)=(family == 6)?AF_INET6 : AF_INET;
|
||||||
|
return inet_pton(*SAFAMILY(sa), name, SAADDR(sa))? *SAFAMILY(sa) : 0;
|
||||||
|
}
|
||||||
|
if(ncols >= 2) {
|
||||||
|
*SAFAMILY(sa)=AF_INET6;
|
||||||
|
return inet_pton(AF_INET6, name, SAADDR(sa))?(family==4? 0:AF_INET6) : 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if((tmpresolv = resolvfunc)){
|
||||||
|
int f = (family == 6 || family == 64)?AF_INET6:AF_INET;
|
||||||
|
*SAFAMILY(sa) = f;
|
||||||
|
if(tmpresolv(f, name, SAADDR(sa))) return f;
|
||||||
|
if(family == 4 || family == 6) return 0;
|
||||||
|
f = (family == 46)? AF_INET6 : AF_INET;
|
||||||
|
*SAFAMILY(sa) = f;
|
||||||
|
if(tmpresolv(f, name, SAADDR(sa))) return f;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
memset(&hint, 0, sizeof(hint));
|
||||||
|
hint.ai_family = (family == 6 || family == 64)?AF_INET6:AF_INET;
|
||||||
|
if (getaddrinfo(name, NULL, &hint, &ai)) {
|
||||||
|
if(family == 64 || family == 46){
|
||||||
|
hint.ai_family = (family == 64)?AF_INET:AF_INET6;
|
||||||
|
if (getaddrinfo(name, NULL, &hint, &ai)) return 0;
|
||||||
|
}
|
||||||
|
else return 0;
|
||||||
|
}
|
||||||
|
if(ai){
|
||||||
|
if(ai->ai_addr->sa_family == AF_INET || ai->ai_addr->sa_family == AF_INET6){
|
||||||
|
*SAFAMILY(sa)=ai->ai_addr->sa_family;
|
||||||
|
memcpy(SAADDR(sa), SAADDR(ai->ai_addr), SAADDRLEN(ai->ai_addr));
|
||||||
|
freeaddrinfo(ai);
|
||||||
|
return *SAFAMILY(sa);
|
||||||
|
}
|
||||||
|
freeaddrinfo(ai);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
+1685
File diff suppressed because it is too large.
Load diff
@@ -1,145 +0,0 @@
|
|||||||
/*
|
|
||||||
3APA3A simpliest proxy server
|
|
||||||
(c) 2002-2008 by ZARAZA <3APA3A@security.nnov.ru>
|
|
||||||
|
|
||||||
please read License Agreement
|
|
||||||
|
|
||||||
$Id: common.c,v 1.81 2007/12/18 09:26:44 vlad Exp $
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "proxy.h"
|
|
||||||
|
|
||||||
struct counter_header {
|
|
||||||
unsigned char sig[4];
|
|
||||||
time_t updated;
|
|
||||||
} cheader = {"3CF", (time_t)0};
|
|
||||||
|
|
||||||
|
|
||||||
struct counter_record {
|
|
||||||
unsigned long traf;
|
|
||||||
unsigned long trafgb;
|
|
||||||
time_t cleared;
|
|
||||||
time_t updated;
|
|
||||||
} crecord;
|
|
||||||
|
|
||||||
#ifdef _WIN32
|
|
||||||
struct counter_header_old {
|
|
||||||
unsigned char sig[4];
|
|
||||||
DWORD updated;
|
|
||||||
} cheader_old = {"3CF", (time_t)0};
|
|
||||||
|
|
||||||
|
|
||||||
struct counter_record_old {
|
|
||||||
unsigned long traf;
|
|
||||||
unsigned long trafgb;
|
|
||||||
DWORD cleared;
|
|
||||||
DWORD updated;
|
|
||||||
} crecord_old;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
int main(int argc, char *argv[]){
|
|
||||||
FILE *txt;
|
|
||||||
int bin;
|
|
||||||
int i;
|
|
||||||
long unsigned lu1, lu2;
|
|
||||||
char buf[256];
|
|
||||||
if(argc!=4){
|
|
||||||
fprintf(stderr, "Usage: %s command binary_file text_file\n"
|
|
||||||
" commands are:\n"
|
|
||||||
"\texport - dump counterfile to text\n"
|
|
||||||
#ifdef _WIN32
|
|
||||||
"\toldexport - export counterfile from older 3proxy version\n"
|
|
||||||
#endif
|
|
||||||
"\timport- import counterfile from text\n"
|
|
||||||
"Examples:\n"
|
|
||||||
#ifdef _WIN32
|
|
||||||
" %s oldexport counterfile.3cf tmpfile\n"
|
|
||||||
#else
|
|
||||||
" %s export counterfilenew.3cf tmpfile\n"
|
|
||||||
#endif
|
|
||||||
" %s import counterfilenew.3cf tmpfile\n"
|
|
||||||
"text file record format:\n"
|
|
||||||
"%%d %%10lu %%10lu %%lu %%lu\n"
|
|
||||||
" 1 - counter number\n"
|
|
||||||
" 2 - traffic (Bytes)\n"
|
|
||||||
" 3 - traffic (GB)\n"
|
|
||||||
" 4 - time counter reset (time_t)\n"
|
|
||||||
" 5 - time counter updated (time_t)\n"
|
|
||||||
,argv[0] , argv[0], argv[0]);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
if(!strcmp(argv[1], "export")){
|
|
||||||
bin = open((char *)argv[2], O_BINARY|O_RDONLY, 0660);
|
|
||||||
if(bin < 0){
|
|
||||||
fprintf(stderr, "Failed to open %s\n", argv[2]);
|
|
||||||
return 2;
|
|
||||||
}
|
|
||||||
if(read(bin, &cheader, sizeof(cheader)) != sizeof(cheader) ||
|
|
||||||
memcmp(&cheader, "3CF", 4)){
|
|
||||||
fprintf(stderr, "Invalid counter file\n");
|
|
||||||
return 3;
|
|
||||||
}
|
|
||||||
txt = fopen(argv[3], "w");
|
|
||||||
if(!txt) txt = stdout;
|
|
||||||
for(i=1; read(bin, &crecord, sizeof(crecord))==sizeof(crecord); i++)
|
|
||||||
fprintf(txt,"%d %10lu %10lu %lu %lu\n", i,
|
|
||||||
crecord.trafgb,
|
|
||||||
crecord.traf,
|
|
||||||
(unsigned long) crecord.cleared,
|
|
||||||
(unsigned long) crecord.updated);
|
|
||||||
}
|
|
||||||
#ifdef _WIN32
|
|
||||||
else if(!strcmp(argv[1], "oldexport")){
|
|
||||||
bin = open((char *)argv[2], O_BINARY|O_RDONLY, 0660);
|
|
||||||
if(bin < 0){
|
|
||||||
fprintf(stderr, "Failed to open %s\n", argv[2]);
|
|
||||||
return 2;
|
|
||||||
}
|
|
||||||
if(read(bin, &cheader_old, sizeof(cheader_old)) != sizeof(cheader_old) ||
|
|
||||||
memcmp(&cheader, "3CF", 4)){
|
|
||||||
fprintf(stderr, "Invalid counter file\n");
|
|
||||||
return 3;
|
|
||||||
}
|
|
||||||
txt = fopen(argv[3], "w");
|
|
||||||
if(!txt) txt = stdout;
|
|
||||||
for(i=1; read(bin, &crecord_old, sizeof(crecord_old))==sizeof(crecord_old); i++)
|
|
||||||
fprintf(txt, "%d %10lu %10lu %lu %lu\n", i,
|
|
||||||
crecord_old.trafgb,
|
|
||||||
crecord_old.traf,
|
|
||||||
(unsigned long) crecord_old.cleared,
|
|
||||||
(unsigned long) crecord_old.updated);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
else if(!strcmp(argv[1], "import")){
|
|
||||||
bin = open((char *)argv[2], O_BINARY|O_WRONLY|O_CREAT|O_EXCL, 0660);
|
|
||||||
if(bin < 0){
|
|
||||||
fprintf(stderr, "Failed to open %s\n", argv[2]);
|
|
||||||
return 2;
|
|
||||||
}
|
|
||||||
txt = fopen(argv[3], "r");
|
|
||||||
if(!txt) {
|
|
||||||
fprintf(stderr, "Failed to open %s\n", argv[3]);
|
|
||||||
return 3;
|
|
||||||
}
|
|
||||||
cheader.updated = time(0);
|
|
||||||
write(bin, &cheader, sizeof(cheader));
|
|
||||||
while(fgets(buf, 256, txt) &&
|
|
||||||
sscanf(buf, "%d %10lu %10lu %lu %lu\n",
|
|
||||||
&i, &crecord.trafgb, &crecord.traf,
|
|
||||||
&lu1, &lu2) == 5){
|
|
||||||
|
|
||||||
crecord.cleared = (time_t) lu1;
|
|
||||||
crecord.updated = (time_t) lu1;
|
|
||||||
lseek(bin,
|
|
||||||
sizeof(struct counter_header) + (i-1) * sizeof(crecord),
|
|
||||||
SEEK_SET);
|
|
||||||
write(bin, &crecord, sizeof(crecord));
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
fprintf(stderr, "Unknown command: %s\n", argv[1]);
|
|
||||||
return 5;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
+110
-127
@@ -3,11 +3,15 @@
|
|||||||
*
|
*
|
||||||
* please read License Agreement
|
* please read License Agreement
|
||||||
*
|
*
|
||||||
* $Id: datatypes.c,v 1.28 2009/08/14 09:56:21 v.dubrovin Exp $
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "proxy.h"
|
#include "proxy.h"
|
||||||
|
|
||||||
|
static void pr_unsigned64(struct node *node, CBFUNC cbf, void*cb){
|
||||||
|
char buf[32];
|
||||||
|
if(node->value)(*cbf)(cb, buf, sprintf(buf, "%"PRINTF_INT64_MODIFIER"u", *(uint64_t *)node->value));
|
||||||
|
}
|
||||||
|
|
||||||
static void pr_integer(struct node *node, CBFUNC cbf, void*cb){
|
static void pr_integer(struct node *node, CBFUNC cbf, void*cb){
|
||||||
char buf[16];
|
char buf[16];
|
||||||
if(node->value)(*cbf)(cb, buf, sprintf(buf, "%d", *(int *)node->value));
|
if(node->value)(*cbf)(cb, buf, sprintf(buf, "%d", *(int *)node->value));
|
||||||
@@ -52,19 +56,27 @@ static void pr_datetime(struct node *node, CBFUNC cbf, void*cb){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int ipprint(char *buf, unsigned uu){
|
|
||||||
unsigned u = ntohl(uu);
|
|
||||||
|
|
||||||
return sprintf(buf, "%u.%u.%u.%u",
|
|
||||||
((u&0xFF000000)>>24),
|
|
||||||
((u&0x00FF0000)>>16),
|
|
||||||
((u&0x0000FF00)>>8),
|
|
||||||
((u&0x000000FF)));
|
|
||||||
}
|
|
||||||
|
|
||||||
static void pr_ip(struct node *node, CBFUNC cbf, void*cb){
|
static void pr_ip(struct node *node, CBFUNC cbf, void*cb){
|
||||||
char buf[16];
|
char buf[16];
|
||||||
if(node->value)(*cbf)(cb, buf, ipprint(buf, *(unsigned *)node -> value));
|
if(node->value)(*cbf)(cb, buf, myinet_ntop(AF_INET, node -> value, buf, 4));
|
||||||
|
}
|
||||||
|
|
||||||
|
static void pr_ip6(struct node *node, CBFUNC cbf, void*cb){
|
||||||
|
char buf[64];
|
||||||
|
if(node->value)(*cbf)(cb, buf, myinet_ntop(AF_INET6, node -> value, buf, 16));
|
||||||
|
}
|
||||||
|
|
||||||
|
static void pr_sa(struct node *node, CBFUNC cbf, void*cb){
|
||||||
|
#ifdef NOIPV6
|
||||||
|
if(node->value)return pr_ip(node, cbf, cb);
|
||||||
|
#else
|
||||||
|
char buf[64];
|
||||||
|
buf[0] = '[';
|
||||||
|
buf[1] = 0;
|
||||||
|
inet_ntop(*SAFAMILY(node->value), node->value, buf+1, sizeof(buf)-10);
|
||||||
|
sprintf(buf + strlen(buf), "]:hu", (unsigned short)*SAPORT(node->value));
|
||||||
|
if(node->value)(*cbf)(cb, buf, strlen(buf));
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static void pr_wdays(struct node *node, CBFUNC cbf, void*cb){
|
static void pr_wdays(struct node *node, CBFUNC cbf, void*cb){
|
||||||
@@ -225,9 +237,22 @@ static void pr_userlist(struct node *node, CBFUNC cbf, void*cb){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int printiple(char *buf, struct iplist* ipl){
|
||||||
|
int addrlen = (ipl->family == AF_INET6)?16:4, i;
|
||||||
|
i = myinet_ntop(ipl->family, &ipl->ip_from, buf, addrlen);
|
||||||
|
if(memcmp(&ipl->ip_from, &ipl->ip_to, addrlen)){
|
||||||
|
buf[i++] = '-';
|
||||||
|
i += myinet_ntop(ipl->family, &ipl->ip_from, buf+i, addrlen);
|
||||||
|
}
|
||||||
|
if(ipl->next){
|
||||||
|
buf[i++] = ',';
|
||||||
|
buf[i++] = ' ';
|
||||||
|
}
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
||||||
static void pr_iplist(struct node *node, CBFUNC cbf, void*cb){
|
static void pr_iplist(struct node *node, CBFUNC cbf, void*cb){
|
||||||
char buf[20];
|
char buf[128];
|
||||||
int i;
|
|
||||||
struct iplist *il = (struct iplist *)node->value;
|
struct iplist *il = (struct iplist *)node->value;
|
||||||
|
|
||||||
if(!il) {
|
if(!il) {
|
||||||
@@ -235,10 +260,7 @@ static void pr_iplist(struct node *node, CBFUNC cbf, void*cb){
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for(; il; il = il->next){
|
for(; il; il = il->next){
|
||||||
i = ipprint(buf, il->ip);
|
(*cbf)(cb, buf, printiple(buf, il));
|
||||||
i += cidrprint(buf+i, il->mask);
|
|
||||||
if(il->next)buf[i++] = ',';
|
|
||||||
(*cbf)(cb, buf, i);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -259,18 +281,6 @@ static void * ef_iplist_next(struct node *node){
|
|||||||
return (((struct iplist *)node->value) -> next);
|
return (((struct iplist *)node->value) -> next);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void * ef_iplist_ip(struct node *node){
|
|
||||||
return &(((struct iplist *)node->value) -> ip);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void * ef_iplist_cidr(struct node *node){
|
|
||||||
return &(((struct iplist *)node->value) -> mask);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void * ef_iplist_mask(struct node *node){
|
|
||||||
return &(((struct iplist *)node->value) -> mask);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void * ef_userlist_next(struct node * node){
|
static void * ef_userlist_next(struct node * node){
|
||||||
return (((struct userlist *)node->value) -> next);
|
return (((struct userlist *)node->value) -> next);
|
||||||
}
|
}
|
||||||
@@ -333,12 +343,8 @@ static void * ef_chain_type(struct node * node){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void * ef_chain_ip(struct node * node){
|
static void * ef_chain_addr(struct node * node){
|
||||||
return &((struct chain *)node->value) -> redirip;
|
return &((struct chain *)node->value) -> addr;
|
||||||
}
|
|
||||||
|
|
||||||
static void * ef_chain_port(struct node * node){
|
|
||||||
return &((struct chain *)node->value) -> redirport;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void * ef_chain_weight(struct node * node){
|
static void * ef_chain_weight(struct node * node){
|
||||||
@@ -446,12 +452,26 @@ static void * ef_trafcounter_type(struct node * node){
|
|||||||
return &((struct trafcount *)node->value) -> type;
|
return &((struct trafcount *)node->value) -> type;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void * ef_trafcounter_traffic(struct node * node){
|
static void * ef_trafcounter_traffic64(struct node * node){
|
||||||
return &((struct trafcount *)node->value) -> traf;
|
return &((struct trafcount *)node->value) -> traf64;
|
||||||
|
}
|
||||||
|
static void * ef_trafcounter_limit64(struct node * node){
|
||||||
|
return &((struct trafcount *)node->value) -> traflim64;
|
||||||
|
}
|
||||||
|
static void * ef_client_maxtrafin64(struct node * node){
|
||||||
|
return &((struct clientparam *)node->value) -> maxtrafin64;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void * ef_trafcounter_limit(struct node * node){
|
static void * ef_client_maxtrafout64(struct node * node){
|
||||||
return &((struct trafcount *)node->value) -> traflim;
|
return &((struct clientparam *)node->value) -> maxtrafout64;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void * ef_client_bytesin64(struct node * node){
|
||||||
|
return &((struct clientparam *)node->value) -> statssrv64;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void * ef_client_bytesout64(struct node * node){
|
||||||
|
return &((struct clientparam *)node->value) -> statscli64;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void * ef_trafcounter_cleared(struct node * node){
|
static void * ef_trafcounter_cleared(struct node * node){
|
||||||
@@ -487,7 +507,6 @@ static void * ef_server_auth(struct node * node){
|
|||||||
AUTHFUNC af = ((struct srvparam *)node->value) -> authfunc;
|
AUTHFUNC af = ((struct srvparam *)node->value) -> authfunc;
|
||||||
|
|
||||||
if(af == alwaysauth) return "none";
|
if(af == alwaysauth) return "none";
|
||||||
if(af == nbnameauth) return "nbname";
|
|
||||||
if(af == ipauth) return "iponly";
|
if(af == ipauth) return "iponly";
|
||||||
if(af == strongauth) return "strong";
|
if(af == strongauth) return "strong";
|
||||||
return "uknown";
|
return "uknown";
|
||||||
@@ -536,21 +555,19 @@ static void * ef_server_targetport(struct node * node){
|
|||||||
return &((struct srvparam *)node->value) -> targetport;
|
return &((struct srvparam *)node->value) -> targetport;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void * ef_server_intip(struct node * node){
|
static void * ef_server_intsa(struct node * node){
|
||||||
return &((struct srvparam *)node->value) -> intip;
|
return &((struct srvparam *)node->value) -> intsa;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void * ef_server_extip(struct node * node){
|
static void * ef_server_extsa(struct node * node){
|
||||||
return &((struct srvparam *)node->value) -> extip;
|
return &((struct srvparam *)node->value) -> extsa;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void * ef_server_intport(struct node * node){
|
#ifndef NOIPV6
|
||||||
return &((struct srvparam *)node->value) -> intport;
|
static void * ef_server_extsa6(struct node * node){
|
||||||
}
|
return &((struct srvparam *)node->value) -> extsa6;
|
||||||
|
|
||||||
static void * ef_server_extport(struct node * node){
|
|
||||||
return &((struct srvparam *)node->value) -> extport;
|
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static void * ef_server_acl(struct node * node){
|
static void * ef_server_acl(struct node * node){
|
||||||
return ((struct srvparam *)node->value) -> acl;
|
return ((struct srvparam *)node->value) -> acl;
|
||||||
@@ -573,14 +590,6 @@ static void * ef_client_next(struct node * node){
|
|||||||
return ((struct clientparam *)node->value) -> next;
|
return ((struct clientparam *)node->value) -> next;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void * ef_client_maxtrafin(struct node * node){
|
|
||||||
return &((struct clientparam *)node->value) -> maxtrafin;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void * ef_client_maxtrafout(struct node * node){
|
|
||||||
return &((struct clientparam *)node->value) -> maxtrafout;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void * ef_client_type(struct node * node){
|
static void * ef_client_type(struct node * node){
|
||||||
int service = ((struct clientparam *)node->value) -> service;
|
int service = ((struct clientparam *)node->value) -> service;
|
||||||
return (service>=0 && service < 15)? (void *)conf.stringtable[SERVICES + service] : (void *)"unknown";
|
return (service>=0 && service < 15)? (void *)conf.stringtable[SERVICES + service] : (void *)"unknown";
|
||||||
@@ -617,36 +626,16 @@ static void * ef_client_extpassword(struct node * node){
|
|||||||
return ((struct clientparam *)node->value) -> extpassword;
|
return ((struct clientparam *)node->value) -> extpassword;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void * ef_client_cliip(struct node * node){
|
static void * ef_client_clisa(struct node * node){
|
||||||
return &((struct clientparam *)node->value) -> sinc.sin_addr.s_addr;
|
return &((struct clientparam *)node->value) -> sincr;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void * ef_client_srvip(struct node * node){
|
static void * ef_client_srvsa(struct node * node){
|
||||||
return &((struct clientparam *)node->value) -> sins.sin_addr.s_addr;
|
return &((struct clientparam *)node->value) -> sinsr;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void * ef_client_reqip(struct node * node){
|
static void * ef_client_reqsa(struct node * node){
|
||||||
return &((struct clientparam *)node->value) -> req.sin_addr.s_addr;
|
return &((struct clientparam *)node->value) -> req;
|
||||||
}
|
|
||||||
|
|
||||||
static void * ef_client_reqport(struct node * node){
|
|
||||||
return &((struct clientparam *)node->value) -> req.sin_port;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void * ef_client_srvport(struct node * node){
|
|
||||||
return &((struct clientparam *)node->value) -> sins.sin_port;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void * ef_client_cliport(struct node * node){
|
|
||||||
return &((struct clientparam *)node->value) -> sinc.sin_port;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void * ef_client_bytesin(struct node * node){
|
|
||||||
return &((struct clientparam *)node->value) -> statssrv;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void * ef_client_bytesout(struct node * node){
|
|
||||||
return &((struct clientparam *)node->value) -> statscli;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void * ef_client_pwtype(struct node * node){
|
static void * ef_client_pwtype(struct node * node){
|
||||||
@@ -695,20 +684,12 @@ static struct property prop_pwlist[] = {
|
|||||||
{NULL, "next", ef_pwlist_next, TYPE_PWLIST, "next"}
|
{NULL, "next", ef_pwlist_next, TYPE_PWLIST, "next"}
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct property prop_iplist[] = {
|
|
||||||
{prop_iplist + 1, "ip", ef_iplist_ip, TYPE_IP, "ip address"},
|
|
||||||
{prop_iplist + 2, "cidr", ef_iplist_cidr, TYPE_CIDR, "ip mask length"},
|
|
||||||
{prop_iplist + 3, "mask", ef_iplist_mask, TYPE_IP, "ip mask"},
|
|
||||||
{NULL, "next", ef_iplist_next, TYPE_IPLIST, "next"}
|
|
||||||
};
|
|
||||||
|
|
||||||
static struct property prop_chain[] = {
|
static struct property prop_chain[] = {
|
||||||
{prop_chain + 1, "ip", ef_chain_ip, TYPE_IP, "parent ip address"},
|
{prop_chain + 1, "addr", ef_chain_addr, TYPE_SA, "parent address"},
|
||||||
{prop_chain + 2, "port", ef_chain_port, TYPE_PORT, "parent port"},
|
{prop_chain + 2, "type", ef_chain_type, TYPE_STRING, "parent type"},
|
||||||
{prop_chain + 3, "type", ef_chain_type, TYPE_STRING, "parent type"},
|
{prop_chain + 3, "weight", ef_chain_weight, TYPE_SHORT, "parent weight 0-1000"},
|
||||||
{prop_chain + 4, "weight", ef_chain_weight, TYPE_SHORT, "parent weight 0-1000"},
|
{prop_chain + 4, "user", ef_chain_user, TYPE_STRING, "parent login"},
|
||||||
{prop_chain + 5, "user", ef_chain_user, TYPE_STRING, "parent login"},
|
{prop_chain + 5, "password", ef_chain_password, TYPE_STRING, "parent password"},
|
||||||
{prop_chain + 6, "password", ef_chain_password, TYPE_STRING, "parent password"},
|
|
||||||
{NULL, "next", ef_chain_next, TYPE_CHAIN, "next"}
|
{NULL, "next", ef_chain_next, TYPE_CHAIN, "next"}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -742,8 +723,10 @@ static struct property prop_trafcounter[] = {
|
|||||||
{prop_trafcounter + 2, "ace", ef_trafcounter_ace, TYPE_ACE, "traffic to count"},
|
{prop_trafcounter + 2, "ace", ef_trafcounter_ace, TYPE_ACE, "traffic to count"},
|
||||||
{prop_trafcounter + 3, "number", ef_trafcounter_number, TYPE_UNSIGNED, "counter number"},
|
{prop_trafcounter + 3, "number", ef_trafcounter_number, TYPE_UNSIGNED, "counter number"},
|
||||||
{prop_trafcounter + 4, "type", ef_trafcounter_type, TYPE_ROTATION, "rotation type"},
|
{prop_trafcounter + 4, "type", ef_trafcounter_type, TYPE_ROTATION, "rotation type"},
|
||||||
{prop_trafcounter + 5, "traffic", ef_trafcounter_traffic, TYPE_TRAFFIC, "counter value"},
|
|
||||||
{prop_trafcounter + 6, "limit", ef_trafcounter_limit, TYPE_TRAFFIC, "counter limit"},
|
|
||||||
|
{prop_trafcounter + 5, "traffic", ef_trafcounter_traffic64, TYPE_UNSIGNED64, "counter value"},
|
||||||
|
{prop_trafcounter + 6, "limit", ef_trafcounter_limit64, TYPE_UNSIGNED64, "counter limit"},
|
||||||
{prop_trafcounter + 7, "cleared", ef_trafcounter_cleared, TYPE_DATETIME, "last rotated"},
|
{prop_trafcounter + 7, "cleared", ef_trafcounter_cleared, TYPE_DATETIME, "last rotated"},
|
||||||
{prop_trafcounter + 8, "updated", ef_trafcounter_updated, TYPE_DATETIME, "last updated"},
|
{prop_trafcounter + 8, "updated", ef_trafcounter_updated, TYPE_DATETIME, "last updated"},
|
||||||
{prop_trafcounter + 9, "comment", ef_trafcounter_comment, TYPE_STRING, "counter comment"},
|
{prop_trafcounter + 9, "comment", ef_trafcounter_comment, TYPE_STRING, "counter comment"},
|
||||||
@@ -758,21 +741,22 @@ static struct property prop_server[] = {
|
|||||||
{prop_server + 2, "target", ef_server_target, TYPE_STRING, "portmapper target ip"},
|
{prop_server + 2, "target", ef_server_target, TYPE_STRING, "portmapper target ip"},
|
||||||
{prop_server + 3, "targetport", ef_server_targetport, TYPE_PORT, "portmapper target port"},
|
{prop_server + 3, "targetport", ef_server_targetport, TYPE_PORT, "portmapper target port"},
|
||||||
{prop_server + 4, "starttime", ef_server_starttime, TYPE_DATETIME, "service started seconds"},
|
{prop_server + 4, "starttime", ef_server_starttime, TYPE_DATETIME, "service started seconds"},
|
||||||
{prop_server + 5, "intip", ef_server_intip, TYPE_IP, "ip address of internal interface"},
|
{prop_server + 5, "intsa", ef_server_intsa, TYPE_SA, "ip address of internal interface"},
|
||||||
{prop_server + 6, "extip", ef_server_extip, TYPE_IP, "ip address of external interface"},
|
{prop_server + 6, "extsa", ef_server_extsa, TYPE_SA, "ip address of external interface"},
|
||||||
{prop_server + 7, "intport", ef_server_intport, TYPE_PORT, "port to listen"},
|
{prop_server + 7, "auth", ef_server_auth, TYPE_STRING, "service authentication type"},
|
||||||
{prop_server + 8, "extport", ef_server_extport, TYPE_PORT, "port to use for outgoing connection"},
|
{prop_server + 8, "acl", ef_server_acl, TYPE_ACE, "access control list"},
|
||||||
{prop_server + 9, "auth", ef_server_auth, TYPE_STRING, "service authentication type"},
|
{prop_server + 9, "singlepacket", ef_server_singlepacket, TYPE_INTEGER, "is single packet redirection"},
|
||||||
{prop_server + 10, "acl", ef_server_acl, TYPE_ACE, "access control list"},
|
{prop_server + 10, "usentlm", ef_server_usentlm, TYPE_INTEGER, "allow NTLM authentication"},
|
||||||
{prop_server + 11, "singlepacket", ef_server_singlepacket, TYPE_INTEGER, "is single packet redirection"},
|
{prop_server + 11, "log", ef_server_log, TYPE_STRING, "type of logging"},
|
||||||
{prop_server + 12, "usentlm", ef_server_usentlm, TYPE_INTEGER, "allow NTLM authentication"},
|
{prop_server + 12, "logtarget", ef_server_logtarget, TYPE_STRING, "log target options"},
|
||||||
{prop_server + 13, "log", ef_server_log, TYPE_STRING, "type of logging"},
|
{prop_server + 13, "logformat", ef_server_logformat, TYPE_STRING, "logging format string"},
|
||||||
{prop_server + 14, "logtarget", ef_server_logtarget, TYPE_STRING, "log target options"},
|
{prop_server + 14, "nonprintable", ef_server_nonprintable, TYPE_STRING, "non printable characters"},
|
||||||
{prop_server + 15, "logformat", ef_server_logformat, TYPE_STRING, "logging format string"},
|
{prop_server + 15, "replacement", ef_server_replacement, TYPE_CHAR, "replacement character"},
|
||||||
{prop_server + 16, "nonprintable", ef_server_nonprintable, TYPE_STRING, "non printable characters"},
|
{prop_server + 16, "childcount", ef_server_childcount, TYPE_INTEGER, "number of servers connected"},
|
||||||
{prop_server + 17, "replacement", ef_server_replacement, TYPE_CHAR, "replacement character"},
|
{prop_server + 17, "child", ef_server_child, TYPE_CLIENT, "connected clients"},
|
||||||
{prop_server + 18, "childcount", ef_server_childcount, TYPE_INTEGER, "number of servers connected"},
|
#ifndef NOIPV6
|
||||||
{prop_server + 19, "child", ef_server_child, TYPE_CLIENT, "connected clients"},
|
{prop_server + 18, "extsa6", ef_server_extsa6, TYPE_SA, "ipv6 address of external interface"},
|
||||||
|
#endif
|
||||||
{NULL, "next", ef_server_next, TYPE_SERVER, "next"}
|
{NULL, "next", ef_server_next, TYPE_SERVER, "next"}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -789,17 +773,14 @@ static struct property prop_client[] = {
|
|||||||
{prop_client + 9, "extpassword", ef_client_extpassword, TYPE_STRING, "password for requested host"},
|
{prop_client + 9, "extpassword", ef_client_extpassword, TYPE_STRING, "password for requested host"},
|
||||||
{prop_client + 10, "username", ef_client_username, TYPE_STRING, "client username"},
|
{prop_client + 10, "username", ef_client_username, TYPE_STRING, "client username"},
|
||||||
{prop_client + 11, "password", ef_client_password, TYPE_STRING, "client password"},
|
{prop_client + 11, "password", ef_client_password, TYPE_STRING, "client password"},
|
||||||
{prop_client + 12, "cliip", ef_client_cliip, TYPE_IP, "client ip"},
|
{prop_client + 12, "clisa", ef_client_clisa, TYPE_SA, "client sa"},
|
||||||
{prop_client + 13, "cliport", ef_client_cliport, TYPE_PORT, "client port"},
|
{prop_client + 13, "srvsa", ef_client_srvsa, TYPE_IP, "target server sa"},
|
||||||
{prop_client + 14, "srvip", ef_client_srvip, TYPE_IP, "target server ip"},
|
{prop_client + 14, "reqsa", ef_client_reqsa, TYPE_IP, "requested server sa"},
|
||||||
{prop_client + 15, "srvport", ef_client_srvport, TYPE_PORT, "target server port"},
|
{prop_client + 15, "bytesin", ef_client_bytesin64, TYPE_UNSIGNED64, "bytes from server to client"},
|
||||||
{prop_client + 16, "reqip", ef_client_reqip, TYPE_IP, "requested server ip"},
|
{prop_client + 16, "bytesout", ef_client_bytesout64, TYPE_UNSIGNED64, "bytes from client to server"},
|
||||||
{prop_client + 17, "reqport", ef_client_reqport, TYPE_PORT, "requested server port"},
|
{prop_client + 17, "maxtrafin", ef_client_maxtrafin64, TYPE_UNSIGNED64, "maximum traffic allowed for download"},
|
||||||
{prop_client + 18, "bytesin", ef_client_bytesin, TYPE_UNSIGNED, "bytes from server to client"},
|
{prop_client + 18, "maxtrafout", ef_client_maxtrafout64, TYPE_UNSIGNED64, "maximum traffic allowed for upload"},
|
||||||
{prop_client + 19, "bytesout", ef_client_bytesout, TYPE_UNSIGNED, "bytes from client to server"},
|
{prop_client + 19, "pwtype", ef_client_pwtype, TYPE_INTEGER, "type of client password"},
|
||||||
{prop_client + 20, "pwtype", ef_client_pwtype, TYPE_INTEGER, "type of client password"},
|
|
||||||
{prop_client + 21, "maxtrafin", ef_client_maxtrafin, TYPE_UNSIGNED, "maximum traffic allowed for download"},
|
|
||||||
{prop_client + 22, "maxtrafout", ef_client_maxtrafout, TYPE_UNSIGNED, "maximum traffic allowed for upload"},
|
|
||||||
{NULL, "next", ef_client_next, TYPE_CLIENT, "next"}
|
{NULL, "next", ef_client_next, TYPE_CLIENT, "next"}
|
||||||
|
|
||||||
|
|
||||||
@@ -810,16 +791,18 @@ struct datatype datatypes[64] = {
|
|||||||
{"short", NULL, pr_short, NULL},
|
{"short", NULL, pr_short, NULL},
|
||||||
{"char", NULL, pr_char, NULL},
|
{"char", NULL, pr_char, NULL},
|
||||||
{"unsigned", NULL, pr_unsigned, NULL},
|
{"unsigned", NULL, pr_unsigned, NULL},
|
||||||
|
{"unsigned64", NULL, pr_unsigned64, NULL},
|
||||||
{"traffic", NULL, pr_traffic, NULL},
|
{"traffic", NULL, pr_traffic, NULL},
|
||||||
{"port", NULL, pr_port, NULL},
|
{"port", NULL, pr_port, NULL},
|
||||||
{"ip", NULL, pr_ip, NULL},
|
{"ip", NULL, pr_ip, NULL},
|
||||||
|
{"sa", NULL, pr_sa, NULL},
|
||||||
{"cidr", NULL, pr_cidr, NULL},
|
{"cidr", NULL, pr_cidr, NULL},
|
||||||
{"string", NULL, pr_string, NULL},
|
{"string", NULL, pr_string, NULL},
|
||||||
{"datetime", NULL, pr_datetime, NULL},
|
{"datetime", NULL, pr_datetime, NULL},
|
||||||
{"operations", NULL, pr_operations, NULL},
|
{"operations", NULL, pr_operations, NULL},
|
||||||
{"rotation", NULL, pr_rotation, NULL},
|
{"rotation", NULL, pr_rotation, NULL},
|
||||||
{"portlist", ef_portlist_next, pr_portlist, prop_portlist},
|
{"portlist", ef_portlist_next, pr_portlist, prop_portlist},
|
||||||
{"iplist", ef_iplist_next, pr_iplist, prop_iplist},
|
{"iplist", ef_iplist_next, pr_iplist, NULL},
|
||||||
{"userlist", ef_userlist_next, pr_userlist, prop_userlist},
|
{"userlist", ef_userlist_next, pr_userlist, prop_userlist},
|
||||||
{"pwlist", ef_pwlist_next, NULL, prop_pwlist},
|
{"pwlist", ef_pwlist_next, NULL, prop_pwlist},
|
||||||
{"chain", ef_chain_next, NULL, prop_chain},
|
{"chain", ef_chain_next, NULL, prop_chain},
|
||||||
|
|||||||
+1
-3
@@ -3,7 +3,6 @@
|
|||||||
*
|
*
|
||||||
* please read License Agreement
|
* please read License Agreement
|
||||||
*
|
*
|
||||||
* $Id: dighosts.c,v 1.10 2009/10/06 08:38:00 v.dubrovin Exp $
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "proxy.h"
|
#include "proxy.h"
|
||||||
@@ -84,12 +83,11 @@ int main(int argc, char *argv[]){
|
|||||||
return 4;
|
return 4;
|
||||||
}
|
}
|
||||||
*hostend = '/';
|
*hostend = '/';
|
||||||
if(!(sa.sin_addr.s_addr = getip(host))) {
|
if(!getip46(4, host, (struct sockaddr *)&sa)) {
|
||||||
fprintf(stderr, "Unable to resolve %s\n", host);
|
fprintf(stderr, "Unable to resolve %s\n", host);
|
||||||
return 5;
|
return 5;
|
||||||
}
|
}
|
||||||
sa.sin_port = htons(80);
|
sa.sin_port = htons(80);
|
||||||
sa.sin_family = AF_INET;
|
|
||||||
if((sock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) == INVALID_SOCKET) return 6;
|
if((sock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) == INVALID_SOCKET) return 6;
|
||||||
sprintf((char *)buf, (char *)request, hostend, host);
|
sprintf((char *)buf, (char *)request, hostend, host);
|
||||||
if(connect(sock,(struct sockaddr *)&sa,sizeof(sa))) {
|
if(connect(sock,(struct sockaddr *)&sa,sizeof(sa))) {
|
||||||
|
|||||||
+59
-44
@@ -4,7 +4,6 @@
|
|||||||
|
|
||||||
please read License Agreement
|
please read License Agreement
|
||||||
|
|
||||||
$Id: dnspr.c,v 1.22 2009/09/17 12:21:05 v.dubrovin Exp $
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "proxy.h"
|
#include "proxy.h"
|
||||||
@@ -14,11 +13,12 @@
|
|||||||
#endif
|
#endif
|
||||||
#define RETURN(xxx) { param->res = xxx; goto CLEANRET; }
|
#define RETURN(xxx) { param->res = xxx; goto CLEANRET; }
|
||||||
|
|
||||||
#define BUFSIZE 4096
|
#define BUFSIZE 16384
|
||||||
|
|
||||||
|
|
||||||
void * dnsprchild(struct clientparam* param) {
|
void * dnsprchild(struct clientparam* param) {
|
||||||
unsigned long ip = 0;
|
unsigned long ip = 0;
|
||||||
|
unsigned char *bbuf;
|
||||||
unsigned char *buf, *s1, *s2;
|
unsigned char *buf, *s1, *s2;
|
||||||
char * host = NULL;
|
char * host = NULL;
|
||||||
unsigned char c;
|
unsigned char c;
|
||||||
@@ -27,26 +27,28 @@ void * dnsprchild(struct clientparam* param) {
|
|||||||
int len;
|
int len;
|
||||||
unsigned type=0;
|
unsigned type=0;
|
||||||
unsigned ttl;
|
unsigned ttl;
|
||||||
|
unsigned char addr[16];
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
unsigned long ul = 1;
|
unsigned long ul = 1;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
if(!(buf = myalloc(BUFSIZE))){
|
if(!(bbuf = myalloc(BUFSIZE+2))){
|
||||||
param->srv->fds.events = POLLIN;
|
param->srv->fds.events = POLLIN;
|
||||||
RETURN (21);
|
RETURN (21);
|
||||||
}
|
}
|
||||||
size = sizeof(struct sockaddr_in);
|
buf = bbuf+2;
|
||||||
i = so._recvfrom(param->srv->srvsock, buf, BUFSIZE, 0, (struct sockaddr *)¶m->sinc, &size);
|
size = sizeof(param->sincr);
|
||||||
|
i = so._recvfrom(param->srv->srvsock, buf, BUFSIZE, 0, (struct sockaddr *)¶m->sincr, &size);
|
||||||
|
size = sizeof(param->sinsl);
|
||||||
|
getsockname(param->srv->srvsock, (struct sockaddr *)¶m->sincl, &size);
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
if((param->clisock=so._socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) == INVALID_SOCKET) {
|
if((param->clisock=so._socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) == INVALID_SOCKET) {
|
||||||
RETURN(818);
|
RETURN(818);
|
||||||
}
|
}
|
||||||
ioctlsocket(param->clisock, FIONBIO, &ul);
|
ioctlsocket(param->clisock, FIONBIO, &ul);
|
||||||
size = sizeof(struct sockaddr_in);
|
|
||||||
if(so._getsockname(param->srv->srvsock, (struct sockaddr *)¶m->sins, &size)) {RETURN(21);};
|
|
||||||
if(so._setsockopt(param->clisock, SOL_SOCKET, SO_REUSEADDR, (unsigned char *)&ul, sizeof(int))) {RETURN(820);};
|
if(so._setsockopt(param->clisock, SOL_SOCKET, SO_REUSEADDR, (unsigned char *)&ul, sizeof(int))) {RETURN(820);};
|
||||||
if(so._bind(param->clisock,(struct sockaddr *)¶m->sins,sizeof(struct sockaddr_in))) {
|
if(so._bind(param->clisock,(struct sockaddr *)¶m->sincl,sizeof(param->sincl))) {
|
||||||
RETURN(822);
|
RETURN(822);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -80,8 +82,8 @@ void * dnsprchild(struct clientparam* param) {
|
|||||||
*s2 = (len - (int)(s2 - buf)) - 1;
|
*s2 = (len - (int)(s2 - buf)) - 1;
|
||||||
|
|
||||||
type = ((unsigned)buf[len+1])*256 + (unsigned)buf[len+2];
|
type = ((unsigned)buf[len+1])*256 + (unsigned)buf[len+2];
|
||||||
if(type==1){
|
if((type==0x01 || type==0x1c) && !param->srv->singlepacket){
|
||||||
ip = udpresolve((unsigned char *)host, &ttl, param, 0);
|
ip = udpresolve((type==0x1c)?AF_INET6:AF_INET, (unsigned char *)host, addr, &ttl, param, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
len+=5;
|
len+=5;
|
||||||
@@ -95,19 +97,19 @@ void * dnsprchild(struct clientparam* param) {
|
|||||||
memset(buf+len, 0, 16);
|
memset(buf+len, 0, 16);
|
||||||
buf[len] = 0xc0;
|
buf[len] = 0xc0;
|
||||||
buf[len+1] = 0x0c;
|
buf[len+1] = 0x0c;
|
||||||
buf[len+3] = 1;
|
buf[len+3] = type;
|
||||||
buf[len+5] = 1;
|
buf[len+5] = 1;
|
||||||
ttl = htonl(ttl);
|
ttl = htonl(ttl);
|
||||||
memcpy(buf + len + 6, &ttl, 4);
|
memcpy(buf + len + 6, &ttl, 4);
|
||||||
buf[len+11] = 4;
|
buf[len+11] = type==1? 4:16;
|
||||||
memcpy(buf+len+12,(void *)&ip,4);
|
memcpy(buf+len+12,(void *)&addr,type==1? 4:16);
|
||||||
len+=16;
|
len+=(type==1?16:28);
|
||||||
}
|
}
|
||||||
if(type == 0x0c) {
|
else if(type == 0x0c) {
|
||||||
unsigned a, b, c, d;
|
unsigned a, b, c, d;
|
||||||
sscanf(host, "%u.%u.%u.%u", &a, &b, &c, &d);
|
sscanf(host, "%u.%u.%u.%u", &a, &b, &c, &d);
|
||||||
ip = htonl((d<<24) ^ (c<<16) ^ (b<<8) ^ a);
|
ip = htonl((d<<24) ^ (c<<16) ^ (b<<8) ^ a);
|
||||||
if(ip == param->srv->intip){
|
if(*SAFAMILY(¶m->sincl) == AF_INET && ip == *(unsigned long*)SAADDR(¶m->sincl)){
|
||||||
buf[2] = 0x85;
|
buf[2] = 0x85;
|
||||||
buf[3] = 0x80;
|
buf[3] = 0x80;
|
||||||
buf[6] = 0;
|
buf[6] = 0;
|
||||||
@@ -127,36 +129,52 @@ void * dnsprchild(struct clientparam* param) {
|
|||||||
}
|
}
|
||||||
else ip = 0;
|
else ip = 0;
|
||||||
}
|
}
|
||||||
if(!ip && nservers[0] && type!=1){
|
if(!ip && numservers){
|
||||||
if((param->remsock=so._socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) == INVALID_SOCKET) {
|
if((param->remsock=so._socket(SASOCK(&nservers[0].addr), nservers[0].usetcp? SOCK_STREAM:SOCK_DGRAM, nservers[0].usetcp?IPPROTO_TCP:IPPROTO_UDP)) == INVALID_SOCKET) {
|
||||||
RETURN(818);
|
RETURN(818);
|
||||||
}
|
}
|
||||||
#ifdef _WIN32
|
memset(¶m->sinsl, 0, sizeof(param->sinsl));
|
||||||
ioctlsocket(param->remsock, FIONBIO, &ul);
|
*SAFAMILY(¶m->sinsl) = *SAFAMILY(&nservers[0].addr);
|
||||||
#else
|
if(so._bind(param->remsock,(struct sockaddr *)¶m->sinsl,sizeof(param->sinsl))) {
|
||||||
fcntl(param->remsock,F_SETFL,O_NONBLOCK);
|
|
||||||
#endif
|
|
||||||
param->sins.sin_family = AF_INET;
|
|
||||||
param->sins.sin_port = htons(0);
|
|
||||||
param->sins.sin_addr.s_addr = htonl(0);
|
|
||||||
if(so._bind(param->remsock,(struct sockaddr *)¶m->sins,sizeof(struct sockaddr_in))) {
|
|
||||||
RETURN(819);
|
RETURN(819);
|
||||||
}
|
}
|
||||||
param->sins.sin_addr.s_addr = nservers[0];
|
memcpy(¶m->sinsr, &nservers[0].addr, sizeof(param->sinsr));
|
||||||
param->sins.sin_port = htons(53);
|
if(nservers[0].usetcp) {
|
||||||
if(socksendto(param->remsock, ¶m->sins, buf, i, conf.timeouts[SINGLEBYTE_L]*1000) != i){
|
if(so._connect(param->remsock,(struct sockaddr *)¶m->sinsr,sizeof(param->sinsr))) RETURN(830);
|
||||||
|
buf-=2;
|
||||||
|
*(unsigned short*)buf = htons(i);
|
||||||
|
i+=2;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
#ifdef _WIN32
|
||||||
|
/* ioctlsocket(param->remsock, FIONBIO, &ul); */
|
||||||
|
#else
|
||||||
|
/* fcntl(param->remsock,F_SETFL,O_NONBLOCK); */
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
if(socksendto(param->remsock, (struct sockaddr *)¶m->sinsr, buf, i, conf.timeouts[SINGLEBYTE_L]*1000) != i){
|
||||||
RETURN(820);
|
RETURN(820);
|
||||||
}
|
}
|
||||||
param->statscli += i;
|
param->statscli64 += i;
|
||||||
param->nwrites++;
|
param->nwrites++;
|
||||||
len = sockrecvfrom(param->remsock, ¶m->sins, buf, BUFSIZE, 15000);
|
len = sockrecvfrom(param->remsock, (struct sockaddr *)¶m->sinsr, buf, BUFSIZE, conf.timeouts[DNS_TO]*1000);
|
||||||
if(len <= 13) {
|
if(len <= 13) {
|
||||||
RETURN(821);
|
RETURN(821);
|
||||||
}
|
}
|
||||||
param->statssrv += len;
|
param->statssrv64 += len;
|
||||||
param->nreads++;
|
param->nreads++;
|
||||||
|
if(nservers[0].usetcp) {
|
||||||
|
unsigned short us;
|
||||||
|
us = ntohs(*(unsigned short *)buf);
|
||||||
|
if(us > 4096) RETURN(833);
|
||||||
|
buf += 2;
|
||||||
|
len -= 2;
|
||||||
|
if(len < us) len += sockgetlinebuf(param, SERVER, buf+len, us - len, 0, conf.timeouts[SINGLEBYTE_L]);
|
||||||
|
if(len != us) RETURN(832);
|
||||||
|
}
|
||||||
if(buf[6] || buf[7]){
|
if(buf[6] || buf[7]){
|
||||||
if(socksendto(param->clisock, ¶m->sinc, buf, len, conf.timeouts[SINGLEBYTE_L]*1000) != len){
|
if(socksendto(param->clisock, (struct sockaddr *)¶m->sincr, buf, len, conf.timeouts[SINGLEBYTE_L]*1000) != len){
|
||||||
RETURN(822);
|
RETURN(822);
|
||||||
}
|
}
|
||||||
RETURN(0);
|
RETURN(0);
|
||||||
@@ -167,25 +185,22 @@ void * dnsprchild(struct clientparam* param) {
|
|||||||
buf[2] = 0x85;
|
buf[2] = 0x85;
|
||||||
buf[3] = 0x83;
|
buf[3] = 0x83;
|
||||||
}
|
}
|
||||||
usleep(SLEEPTIME);
|
res = socksendto(param->clisock, (struct sockaddr *)¶m->sincr, buf, len, conf.timeouts[SINGLEBYTE_L]*1000);
|
||||||
res = socksendto(param->clisock, ¶m->sinc, buf, len, conf.timeouts[SINGLEBYTE_L]*1000);
|
|
||||||
if(res != len){RETURN(819);}
|
if(res != len){RETURN(819);}
|
||||||
if(!ip) {RETURN(888);}
|
if(!ip) {RETURN(888);}
|
||||||
|
|
||||||
CLEANRET:
|
CLEANRET:
|
||||||
|
|
||||||
if(param->res!=813){
|
if(param->res!=813){
|
||||||
sprintf((char *)buf, "%04x/%s(%u.%u.%u.%u)",
|
sprintf((char *)buf, "%04x/%s/",
|
||||||
(unsigned)type,
|
(unsigned)type,
|
||||||
host?host:"",
|
host?host:"");
|
||||||
(unsigned)(ntohl(ip)&0xff000000)>>24,
|
if(ip && type == 0x01 || type == 0x1c){
|
||||||
(unsigned)(ntohl(ip)&0x00ff0000)>>16,
|
myinet_ntop(type == 0x01? AF_INET:AF_INET6, addr, buf+strlen(buf), 64);
|
||||||
(unsigned)(ntohl(ip)&0x0000ff00)>>8,
|
}
|
||||||
(unsigned)(ntohl(ip)&0x000000ff)
|
|
||||||
);
|
|
||||||
(*param->srv->logfunc)(param, buf);
|
(*param->srv->logfunc)(param, buf);
|
||||||
}
|
}
|
||||||
if(buf)myfree(buf);
|
if(bbuf)myfree(bbuf);
|
||||||
if(host)myfree(host);
|
if(host)myfree(host);
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
param->clisock = INVALID_SOCKET;
|
param->clisock = INVALID_SOCKET;
|
||||||
|
|||||||
@@ -3,7 +3,6 @@
|
|||||||
*
|
*
|
||||||
* please read License Agreement
|
* please read License Agreement
|
||||||
*
|
*
|
||||||
* $Id: ftp.c,v 1.34 2009/09/17 12:21:06 v.dubrovin Exp $
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "proxy.h"
|
#include "proxy.h"
|
||||||
@@ -33,7 +32,7 @@ int ftplogin(struct clientparam *param, char *nbuf, int *innbuf) {
|
|||||||
if((int)socksend(param->remsock, (unsigned char *)buf, (int)strlen(buf), conf.timeouts[STRING_S]) != (int)strlen(buf)){
|
if((int)socksend(param->remsock, (unsigned char *)buf, (int)strlen(buf), conf.timeouts[STRING_S]) != (int)strlen(buf)){
|
||||||
return 703;
|
return 703;
|
||||||
}
|
}
|
||||||
param->statscli += (int)strlen(buf);
|
param->statscli64 += (int)strlen(buf);
|
||||||
param->nwrites++;
|
param->nwrites++;
|
||||||
while((i = sockgetlinebuf(param, SERVER, (unsigned char *)buf, len - 1, '\n', conf.timeouts[STRING_L])) > 0 && (i < 3 || !isnumber(*buf) || buf[3] == '-')){
|
while((i = sockgetlinebuf(param, SERVER, (unsigned char *)buf, len - 1, '\n', conf.timeouts[STRING_L])) > 0 && (i < 3 || !isnumber(*buf) || buf[3] == '-')){
|
||||||
}
|
}
|
||||||
@@ -50,7 +49,7 @@ int ftplogin(struct clientparam *param, char *nbuf, int *innbuf) {
|
|||||||
if((int)socksend(param->remsock, (unsigned char *)buf, res, conf.timeouts[STRING_S]) != (int)strlen(buf)){
|
if((int)socksend(param->remsock, (unsigned char *)buf, res, conf.timeouts[STRING_S]) != (int)strlen(buf)){
|
||||||
return 705;
|
return 705;
|
||||||
}
|
}
|
||||||
param->statscli += res;
|
param->statscli64 += res;
|
||||||
param->nwrites++;
|
param->nwrites++;
|
||||||
while((i = sockgetlinebuf(param, SERVER, (unsigned char *)buf, len - 1, '\n', conf.timeouts[STRING_L])) > 0){
|
while((i = sockgetlinebuf(param, SERVER, (unsigned char *)buf, len - 1, '\n', conf.timeouts[STRING_L])) > 0){
|
||||||
buf[i] = 0;
|
buf[i] = 0;
|
||||||
@@ -81,7 +80,7 @@ int ftpcd(struct clientparam *param, unsigned char* path, char *nbuf, int *innbu
|
|||||||
if((int)socksend(param->remsock, (unsigned char *)buf, (int)strlen(buf), conf.timeouts[STRING_S]) != (int)strlen(buf)){
|
if((int)socksend(param->remsock, (unsigned char *)buf, (int)strlen(buf), conf.timeouts[STRING_S]) != (int)strlen(buf)){
|
||||||
return 711;
|
return 711;
|
||||||
}
|
}
|
||||||
param->statscli += (int)strlen(buf);
|
param->statscli64 += (int)strlen(buf);
|
||||||
param->nwrites++;
|
param->nwrites++;
|
||||||
while((i = sockgetlinebuf(param, SERVER, (unsigned char *)buf, sizeof(buf) - 1, '\n', conf.timeouts[STRING_L])) > 0 && (i < 3 || !isnumber(*buf) || buf[3] == '-')){
|
while((i = sockgetlinebuf(param, SERVER, (unsigned char *)buf, sizeof(buf) - 1, '\n', conf.timeouts[STRING_L])) > 0 && (i < 3 || !isnumber(*buf) || buf[3] == '-')){
|
||||||
if(nbuf && innbuf && inbuf + i < *innbuf && i > 6) {
|
if(nbuf && innbuf && inbuf + i < *innbuf && i > 6) {
|
||||||
@@ -114,7 +113,7 @@ int ftpsyst(struct clientparam *param, unsigned char *buf, unsigned len){
|
|||||||
if(socksend(param->remsock, (unsigned char *)"SYST\r\n", 6, conf.timeouts[STRING_S]) != 6){
|
if(socksend(param->remsock, (unsigned char *)"SYST\r\n", 6, conf.timeouts[STRING_S]) != 6){
|
||||||
return 721;
|
return 721;
|
||||||
}
|
}
|
||||||
param->statscli+=6;
|
param->statscli64 += 6;
|
||||||
param->nwrites++;
|
param->nwrites++;
|
||||||
while((i = sockgetlinebuf(param, SERVER, buf, len - 1, '\n', conf.timeouts[STRING_L])) > 0 && (i < 3 || !isnumber(*buf) || buf[3] == '-')){
|
while((i = sockgetlinebuf(param, SERVER, buf, len - 1, '\n', conf.timeouts[STRING_L])) > 0 && (i < 3 || !isnumber(*buf) || buf[3] == '-')){
|
||||||
}
|
}
|
||||||
@@ -133,7 +132,7 @@ int ftppwd(struct clientparam *param, unsigned char *buf, unsigned len){
|
|||||||
if(socksend(param->remsock, (unsigned char *)"PWD\r\n", 5, conf.timeouts[STRING_S]) != 5){
|
if(socksend(param->remsock, (unsigned char *)"PWD\r\n", 5, conf.timeouts[STRING_S]) != 5){
|
||||||
return 731;
|
return 731;
|
||||||
}
|
}
|
||||||
param->statscli += 5;
|
param->statscli64 += 5;
|
||||||
param->nwrites++;
|
param->nwrites++;
|
||||||
while((i = sockgetlinebuf(param, SERVER, buf, len - 1, '\n', conf.timeouts[STRING_L])) > 0 && (i < 3 || !isnumber(*buf) || buf[3] == '-')){
|
while((i = sockgetlinebuf(param, SERVER, buf, len - 1, '\n', conf.timeouts[STRING_L])) > 0 && (i < 3 || !isnumber(*buf) || buf[3] == '-')){
|
||||||
}
|
}
|
||||||
@@ -158,7 +157,7 @@ int ftptype(struct clientparam *param, unsigned char* f_type){
|
|||||||
if((int)socksend(param->remsock, (unsigned char *)buf, (int)strlen(buf), conf.timeouts[STRING_S]) != (int)strlen(buf)){
|
if((int)socksend(param->remsock, (unsigned char *)buf, (int)strlen(buf), conf.timeouts[STRING_S]) != (int)strlen(buf)){
|
||||||
return 741;
|
return 741;
|
||||||
}
|
}
|
||||||
param->statscli += (int)strlen(buf);
|
param->statscli64 += (int)strlen(buf);
|
||||||
param->nwrites++;
|
param->nwrites++;
|
||||||
while((i = sockgetlinebuf(param, SERVER, (unsigned char *)buf, sizeof(buf) - 1, '\n', conf.timeouts[STRING_L])) > 0 && (i < 3 || !isnumber(*buf) || buf[3] == '-')){
|
while((i = sockgetlinebuf(param, SERVER, (unsigned char *)buf, sizeof(buf) - 1, '\n', conf.timeouts[STRING_L])) > 0 && (i < 3 || !isnumber(*buf) || buf[3] == '-')){
|
||||||
}
|
}
|
||||||
@@ -179,7 +178,7 @@ SOCKET ftpdata(struct clientparam *param){
|
|||||||
if(socksend(param->remsock, (unsigned char *)"PASV\r\n", 6, conf.timeouts[STRING_S]) != 6){
|
if(socksend(param->remsock, (unsigned char *)"PASV\r\n", 6, conf.timeouts[STRING_S]) != 6){
|
||||||
return INVALID_SOCKET;
|
return INVALID_SOCKET;
|
||||||
}
|
}
|
||||||
param->statscli+=6;
|
param->statscli64 += 6;
|
||||||
param->nwrites++;
|
param->nwrites++;
|
||||||
while((i = sockgetlinebuf(param, SERVER, (unsigned char *)buf, sizeof(buf) - 1, '\n', conf.timeouts[STRING_L])) > 0 && (i < 3 || !isnumber(*buf) || buf[3] == '-')){
|
while((i = sockgetlinebuf(param, SERVER, (unsigned char *)buf, sizeof(buf) - 1, '\n', conf.timeouts[STRING_L])) > 0 && (i < 3 || !isnumber(*buf) || buf[3] == '-')){
|
||||||
}
|
}
|
||||||
@@ -190,12 +189,14 @@ SOCKET ftpdata(struct clientparam *param){
|
|||||||
if(sscanf(sb+1, "%lu,%lu,%lu,%lu,%hu,%hu", &b1, &b2, &b3, &b4, &b5, &b6)!=6) return INVALID_SOCKET;
|
if(sscanf(sb+1, "%lu,%lu,%lu,%lu,%hu,%hu", &b1, &b2, &b3, &b4, &b5, &b6)!=6) return INVALID_SOCKET;
|
||||||
rem = param->remsock;
|
rem = param->remsock;
|
||||||
param->remsock = INVALID_SOCKET;
|
param->remsock = INVALID_SOCKET;
|
||||||
param->req.sin_family = AF_INET;
|
memcpy(¶m->req,¶m->sinsr,sizeof(param->req));
|
||||||
param->req.sin_port = param->sins.sin_port = htons((unsigned short)((b5<<8)^b6));
|
*SAPORT(¶m->req) = *SAPORT(¶m->sinsr) = htons((unsigned short)((b5<<8)^b6));
|
||||||
param->req.sin_addr.s_addr = param->sins.sin_addr.s_addr = htonl((b1<<24)^(b2<<16)^(b3<<8)^b4);
|
|
||||||
i = param->operation;
|
i = param->operation;
|
||||||
param->operation = FTP_DATA;
|
param->operation = FTP_DATA;
|
||||||
if((param->res = (*param->srv->authfunc)(param))) return INVALID_SOCKET;
|
if((param->res = (*param->srv->authfunc)(param))) {
|
||||||
|
param->remsock = rem;
|
||||||
|
return INVALID_SOCKET;
|
||||||
|
}
|
||||||
param->operation = i;
|
param->operation = i;
|
||||||
s = param->remsock;
|
s = param->remsock;
|
||||||
param->remsock = rem;
|
param->remsock = rem;
|
||||||
@@ -217,7 +218,7 @@ SOCKET ftpcommand(struct clientparam *param, unsigned char * command, unsigned c
|
|||||||
so._closesocket(s);
|
so._closesocket(s);
|
||||||
return INVALID_SOCKET;
|
return INVALID_SOCKET;
|
||||||
}
|
}
|
||||||
param->statscli += (int)strlen(buf);
|
param->statscli64 += (int)strlen(buf);
|
||||||
param->nwrites++;
|
param->nwrites++;
|
||||||
while((i = sockgetlinebuf(param, SERVER, (unsigned char *)buf, sizeof(buf) - 1, '\n', conf.timeouts[STRING_L])) > 0 && (i < 3 || !isnumber(*buf) || buf[3] == '-')){
|
while((i = sockgetlinebuf(param, SERVER, (unsigned char *)buf, sizeof(buf) - 1, '\n', conf.timeouts[STRING_L])) > 0 && (i < 3 || !isnumber(*buf) || buf[3] == '-')){
|
||||||
}
|
}
|
||||||
|
|||||||
+31
-29
@@ -4,7 +4,6 @@
|
|||||||
|
|
||||||
please read License Agreement
|
please read License Agreement
|
||||||
|
|
||||||
$Id: ftppr.c,v 1.45 2011-08-15 19:52:27 vlad Exp $
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "proxy.h"
|
#include "proxy.h"
|
||||||
@@ -71,7 +70,7 @@ void * ftpprchild(struct clientparam* param) {
|
|||||||
param->res = res;
|
param->res = res;
|
||||||
if(inbuf && inbuf != BUFSIZE && socksend(param->ctrlsock, buf, inbuf, conf.timeouts[STRING_S])!=inbuf) {RETURN (807);}
|
if(inbuf && inbuf != BUFSIZE && socksend(param->ctrlsock, buf, inbuf, conf.timeouts[STRING_S])!=inbuf) {RETURN (807);}
|
||||||
if(!res) status = 3;
|
if(!res) status = 3;
|
||||||
sprintf((char *)buf, "%.64s@%.128s%c%hu", param->extusername, param->hostname, (ntohs(param->sins.sin_port)==21)?0:':', ntohs(param->sins.sin_port));
|
sprintf((char *)buf, "%.64s@%.128s%c%hu", param->extusername, param->hostname, (ntohs(*SAPORT(¶m->sinsr))==21)?0:':', ntohs(*SAPORT(¶m->sinsr)));
|
||||||
req = mystrdup((char *)buf);
|
req = mystrdup((char *)buf);
|
||||||
#ifndef WITHMAIN
|
#ifndef WITHMAIN
|
||||||
{
|
{
|
||||||
@@ -119,32 +118,35 @@ void * ftpprchild(struct clientparam* param) {
|
|||||||
so._closesocket(clidatasock);
|
so._closesocket(clidatasock);
|
||||||
clidatasock = INVALID_SOCKET;
|
clidatasock = INVALID_SOCKET;
|
||||||
}
|
}
|
||||||
if ((clidatasock=socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) == INVALID_SOCKET) {RETURN(821);}
|
if ((clidatasock=socket(SASOCK(¶m->sincl), SOCK_STREAM, IPPROTO_TCP)) == INVALID_SOCKET) {RETURN(821);}
|
||||||
sasize = sizeof(struct sockaddr_in);
|
sasize = sizeof(param->sincl);
|
||||||
if(so._getsockname(param->ctrlsock, (struct sockaddr *)¶m->sinc, &sasize)){RETURN(824);}
|
*SAPORT(¶m->sincl) = 0;
|
||||||
param->sinc.sin_port = 0;
|
if(so._bind(clidatasock, (struct sockaddr *)¶m->sincl, sasize)){RETURN(822);}
|
||||||
if(so._bind(clidatasock, (struct sockaddr *)¶m->sinc, sasize)){RETURN(822);}
|
|
||||||
if (pasv) {
|
if (pasv) {
|
||||||
if(so._listen(clidatasock, 1)) {RETURN(823);}
|
if(so._listen(clidatasock, 1)) {RETURN(823);}
|
||||||
if(so._getsockname(clidatasock, (struct sockaddr *)¶m->sinc, &sasize)){RETURN(824);}
|
if(so._getsockname(clidatasock, (struct sockaddr *)¶m->sincl, &sasize)){RETURN(824);}
|
||||||
sprintf((char *)buf, "227 OK (%u,%u,%u,%u,%u,%u)\r\n",
|
if(*SAFAMILY(¶m->sincl) == AF_INET)
|
||||||
(unsigned)(((unsigned char *)(¶m->sinc.sin_addr.s_addr))[0]),
|
sprintf((char *)buf, "227 OK (%u,%u,%u,%u,%u,%u)\r\n",
|
||||||
(unsigned)(((unsigned char *)(¶m->sinc.sin_addr.s_addr))[1]),
|
(unsigned)(((unsigned char *)(SAADDR(¶m->sincl)))[0]),
|
||||||
(unsigned)(((unsigned char *)(¶m->sinc.sin_addr.s_addr))[2]),
|
(unsigned)(((unsigned char *)(SAADDR(¶m->sincl)))[1]),
|
||||||
(unsigned)(((unsigned char *)(¶m->sinc.sin_addr.s_addr))[3]),
|
(unsigned)(((unsigned char *)(SAADDR(¶m->sincl)))[2]),
|
||||||
(unsigned)(((unsigned char *)(¶m->sinc.sin_port))[0]),
|
(unsigned)(((unsigned char *)(SAADDR(¶m->sincl)))[3]),
|
||||||
(unsigned)(((unsigned char *)(¶m->sinc.sin_port))[1])
|
(unsigned)(((unsigned char *)(SAPORT(¶m->sincl)))[0]),
|
||||||
);
|
(unsigned)(((unsigned char *)(SAPORT(¶m->sincl)))[1])
|
||||||
|
);
|
||||||
|
else sprintf((char *)buf, "227 OK (127,0,0,1,%u,%u)\r\n",
|
||||||
|
(unsigned)(((unsigned char *)(SAPORT(¶m->sincl)))[0]),
|
||||||
|
(unsigned)(((unsigned char *)(SAPORT(¶m->sincl)))[1])
|
||||||
|
);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
unsigned long b1, b2, b3, b4;
|
unsigned long b1, b2, b3, b4;
|
||||||
unsigned short b5, b6;
|
unsigned short b5, b6;
|
||||||
|
|
||||||
if(sscanf((char *)buf+5, "%lu,%lu,%lu,%lu,%hu,%hu", &b1, &b2, &b3, &b4, &b5, &b6)!=6) {RETURN(828);}
|
if(sscanf((char *)buf+5, "%lu,%lu,%lu,%lu,%hu,%hu", &b1, &b2, &b3, &b4, &b5, &b6)!=6) {RETURN(828);}
|
||||||
param->sinc.sin_family = AF_INET;
|
*SAPORT(¶m->sincr) = htons((unsigned short)((b5<<8)^b6));
|
||||||
param->sinc.sin_port = htons((unsigned short)((b5<<8)^b6));
|
sasize = sizeof(param->sincr);
|
||||||
param->sinc.sin_addr.s_addr = htonl((b1<<24)^(b2<<16)^(b3<<8)^b4);
|
if(so._connect(clidatasock, (struct sockaddr *)¶m->sincr, sasize)) {
|
||||||
if(so._connect(clidatasock, (struct sockaddr *)¶m->sinc, sasize)) {
|
|
||||||
so._closesocket(clidatasock);
|
so._closesocket(clidatasock);
|
||||||
clidatasock = INVALID_SOCKET;
|
clidatasock = INVALID_SOCKET;
|
||||||
RETURN(826);
|
RETURN(826);
|
||||||
@@ -203,8 +205,8 @@ void * ftpprchild(struct clientparam* param) {
|
|||||||
if(res != 1) {
|
if(res != 1) {
|
||||||
RETURN(857);
|
RETURN(857);
|
||||||
}
|
}
|
||||||
sasize = sizeof(struct sockaddr_in);
|
sasize = sizeof(param->sincr);
|
||||||
ss = so._accept(clidatasock, (struct sockaddr *)¶m->sinc, &sasize);
|
ss = so._accept(clidatasock, (struct sockaddr *)¶m->sincr, &sasize);
|
||||||
if (ss == INVALID_SOCKET) { RETURN (858);}
|
if (ss == INVALID_SOCKET) { RETURN (858);}
|
||||||
so._shutdown(clidatasock, SHUT_RDWR);
|
so._shutdown(clidatasock, SHUT_RDWR);
|
||||||
so._closesocket(clidatasock);
|
so._closesocket(clidatasock);
|
||||||
@@ -274,7 +276,7 @@ void * ftpprchild(struct clientparam* param) {
|
|||||||
buf[i++] = '\r';
|
buf[i++] = '\r';
|
||||||
buf[i++] = '\n';
|
buf[i++] = '\n';
|
||||||
if(socksend(param->remsock, buf, i, conf.timeouts[STRING_S])!=i) {RETURN (811);}
|
if(socksend(param->remsock, buf, i, conf.timeouts[STRING_S])!=i) {RETURN (811);}
|
||||||
param->statscli += i;
|
param->statscli64+=(i);
|
||||||
param->nwrites++;
|
param->nwrites++;
|
||||||
while((i = sockgetlinebuf(param, SERVER, buf, BUFSIZE, '\n', conf.timeouts[STRING_L])) > 0){
|
while((i = sockgetlinebuf(param, SERVER, buf, BUFSIZE, '\n', conf.timeouts[STRING_L])) > 0){
|
||||||
if(socksend(param->ctrlsock, buf, i, conf.timeouts[STRING_S])!=i) {RETURN (812);}
|
if(socksend(param->ctrlsock, buf, i, conf.timeouts[STRING_S])!=i) {RETURN (812);}
|
||||||
@@ -283,9 +285,9 @@ void * ftpprchild(struct clientparam* param) {
|
|||||||
if(status == 5) {RETURN (0);}
|
if(status == 5) {RETURN (0);}
|
||||||
if(i < 3) {RETURN (813);}
|
if(i < 3) {RETURN (813);}
|
||||||
}
|
}
|
||||||
sasize = sizeof(struct sockaddr_in);
|
sasize = sizeof(param->sincr);
|
||||||
if(so._getpeername(param->ctrlsock, (struct sockaddr *)¶m->sinc, &sasize)){RETURN(819);}
|
if(so._getpeername(param->ctrlsock, (struct sockaddr *)¶m->sincr, &sasize)){RETURN(819);}
|
||||||
if(req && (param->statscli || param->statssrv)){
|
if(req && (param->statscli64 || param->statssrv64)){
|
||||||
(*param->srv->logfunc)(param, (unsigned char *)req);
|
(*param->srv->logfunc)(param, (unsigned char *)req);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -304,9 +306,9 @@ CLEANRET:
|
|||||||
so._shutdown(clidatasock, SHUT_RDWR);
|
so._shutdown(clidatasock, SHUT_RDWR);
|
||||||
so._closesocket(clidatasock);
|
so._closesocket(clidatasock);
|
||||||
}
|
}
|
||||||
sasize = sizeof(struct sockaddr_in);
|
sasize = sizeof(param->sincr);
|
||||||
so._getpeername(param->ctrlsock, (struct sockaddr *)¶m->sinc, &sasize);
|
so._getpeername(param->ctrlsock, (struct sockaddr *)¶m->sincr, &sasize);
|
||||||
if(param->res != 0 || param->statscli || param->statssrv ){
|
if(param->res != 0 || param->statscli64 || param->statssrv64 ){
|
||||||
(*param->srv->logfunc)(param, (unsigned char *)((req && (param->res > 802))? req:NULL));
|
(*param->srv->logfunc)(param, (unsigned char *)((req && (param->res > 802))? req:NULL));
|
||||||
}
|
}
|
||||||
if(req) myfree(req);
|
if(req) myfree(req);
|
||||||
|
|||||||
+8
-12
@@ -4,7 +4,6 @@
|
|||||||
|
|
||||||
please read License Agreement
|
please read License Agreement
|
||||||
|
|
||||||
$Id: icqpr.c,v 1.30 2012-04-11 23:01:19 vlad Exp $
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "proxy.h"
|
#include "proxy.h"
|
||||||
@@ -105,11 +104,11 @@ static void addbuffer(int increment, struct clientparam * param, unsigned char *
|
|||||||
*buf_p = newbuf;
|
*buf_p = newbuf;
|
||||||
*bufsize_p = bufsize;
|
*bufsize_p = bufsize;
|
||||||
}
|
}
|
||||||
if(increment) len = sockrecvfrom(param->remsock, ¶m->sins, *buf_p + *length_p, increment, conf.timeouts[STRING_S]*1000);
|
if(increment) len = sockrecvfrom(param->remsock, (struct sockaddr *)¶m->sinsr, *buf_p + *length_p, increment, conf.timeouts[STRING_S]*1000);
|
||||||
if(len > 0) {
|
if(len > 0) {
|
||||||
*length_p += len;
|
*length_p += len;
|
||||||
param->nreads++;
|
param->nreads++;
|
||||||
param->statssrv += len;
|
param->statssrv64 += len;
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -118,7 +117,7 @@ static void addbuffer(int increment, struct clientparam * param, unsigned char *
|
|||||||
|
|
||||||
static int searchcookie(struct clientparam *param, struct flap_header * flap, int len, int * dif, struct tlv_header *tlv, int extra){
|
static int searchcookie(struct clientparam *param, struct flap_header * flap, int len, int * dif, struct tlv_header *tlv, int extra){
|
||||||
struct icq_cookie *ic;
|
struct icq_cookie *ic;
|
||||||
char smallbuf[32];
|
char smallbuf[64];
|
||||||
struct tlv_header *bostlv = NULL;
|
struct tlv_header *bostlv = NULL;
|
||||||
struct sockaddr_in sa;
|
struct sockaddr_in sa;
|
||||||
SASIZETYPE size = sizeof(sa);
|
SASIZETYPE size = sizeof(sa);
|
||||||
@@ -165,7 +164,7 @@ static int searchcookie(struct clientparam *param, struct flap_header * flap, in
|
|||||||
pthread_mutex_unlock(&icq_cookie_mutex);
|
pthread_mutex_unlock(&icq_cookie_mutex);
|
||||||
if(bostlv){
|
if(bostlv){
|
||||||
if(so._getsockname(param->clisock, (struct sockaddr *)&sa, &size)==-1) return 1;
|
if(so._getsockname(param->clisock, (struct sockaddr *)&sa, &size)==-1) return 1;
|
||||||
len = myinet_ntoa(sa.sin_addr, smallbuf);
|
len = myinet_ntop(*SAFAMILY(&sa),SAADDR(&sa), smallbuf, 64);
|
||||||
if(strchr(ic->connectstring, ':'))sprintf(smallbuf+len, ":%hu", ntohs(sa.sin_port));
|
if(strchr(ic->connectstring, ':'))sprintf(smallbuf+len, ":%hu", ntohs(sa.sin_port));
|
||||||
len = (int)strlen(smallbuf);
|
len = (int)strlen(smallbuf);
|
||||||
*dif = len - (int)ntohs(bostlv->size);
|
*dif = len - (int)ntohs(bostlv->size);
|
||||||
@@ -437,20 +436,17 @@ void * icqprchild(struct clientparam* param) {
|
|||||||
|
|
||||||
if(greet){
|
if(greet){
|
||||||
if(socksend(param->remsock, tmpsend, 10, conf.timeouts[STRING_S])!=10) {RETURN (1105);}
|
if(socksend(param->remsock, tmpsend, 10, conf.timeouts[STRING_S])!=10) {RETURN (1105);}
|
||||||
param->statscli += 10;
|
param->statscli64 += 10;
|
||||||
}
|
}
|
||||||
if(readflap(param, SERVER, tmpsend, 1024)) {RETURN (1111);}
|
if(readflap(param, SERVER, tmpsend, 1024)) {RETURN (1111);}
|
||||||
param->statssrv += (ntohs(((struct flap_header *)tmpsend)->size) + 6);
|
param->statssrv64 += (ntohs(((struct flap_header *)tmpsend)->size) + 6);
|
||||||
mystate.srvseq = ntohs(((struct flap_header *)tmpsend)->seq) + 1;
|
mystate.srvseq = ntohs(((struct flap_header *)tmpsend)->seq) + 1;
|
||||||
mystate.seq = 1;
|
mystate.seq = 1;
|
||||||
len = ntohs(flap->size) + 6;
|
len = ntohs(flap->size) + 6;
|
||||||
if((res=handledatfltcli(param, &buf, &buflen, offset, &len))!=PASS) RETURN(res);
|
if((res=handledatfltcli(param, &buf, &buflen, offset, &len))!=PASS) RETURN(res);
|
||||||
if(socksend(param->remsock, buf+offset, len, conf.timeouts[STRING_S])!=(ntohs(flap->size)+6)) {RETURN (1106);}
|
if(socksend(param->remsock, buf+offset, len, conf.timeouts[STRING_S])!=(ntohs(flap->size)+6)) {RETURN (1106);}
|
||||||
offset = 0;
|
offset = 0;
|
||||||
param->statscli += len;
|
param->statscli64 += len;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if(logintype == ICQMD5) {
|
if(logintype == ICQMD5) {
|
||||||
if(readflap(param, SERVER, buf, 65550)) {RETURN (1112);}
|
if(readflap(param, SERVER, buf, 65550)) {RETURN (1112);}
|
||||||
@@ -466,7 +462,7 @@ void * icqprchild(struct clientparam* param) {
|
|||||||
len = ntohs(flap->size) + 6;
|
len = ntohs(flap->size) + 6;
|
||||||
if((res=handledatfltcli(param, &buf, &buflen, offset, &len))!=PASS) RETURN(res);
|
if((res=handledatfltcli(param, &buf, &buflen, offset, &len))!=PASS) RETURN(res);
|
||||||
if(socksend(param->remsock, buf+offset, len, conf.timeouts[STRING_S])!=len) {RETURN (1115);}
|
if(socksend(param->remsock, buf+offset, len, conf.timeouts[STRING_S])!=len) {RETURN (1115);}
|
||||||
param->statscli += len;
|
param->statscli64 += len;
|
||||||
offset = 0;
|
offset = 0;
|
||||||
}
|
}
|
||||||
if(logintype != ICQCOOKIE) {
|
if(logintype != ICQCOOKIE) {
|
||||||
|
|||||||
@@ -1,8 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* md4c.c MD4 message-digest algorithm
|
* md4c.c MD4 message-digest algorithm
|
||||||
*
|
*
|
||||||
* Version: $Id: md4.c,v 1.1 2010-11-11 11:32:32 v.dubrovin Exp $
|
|
||||||
*
|
|
||||||
* License to copy and use this software is granted provided that it
|
* License to copy and use this software is granted provided that it
|
||||||
* is identified as the "RSA Data Security, Inc. MD4 Message-Digest
|
* is identified as the "RSA Data Security, Inc. MD4 Message-Digest
|
||||||
* Algorithm" in all material mentioning or referencing this software
|
* Algorithm" in all material mentioning or referencing this software
|
||||||
|
|||||||
-234
@@ -1,234 +0,0 @@
|
|||||||
/*
|
|
||||||
3APA3A simpliest proxy server
|
|
||||||
(c) 2002-2008 by ZARAZA <3APA3A@security.nnov.ru>
|
|
||||||
|
|
||||||
please read License Agreement
|
|
||||||
|
|
||||||
$Id: msnpr.c,v 1.3 2012-04-11 23:01:19 vlad Exp $
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "proxy.h"
|
|
||||||
|
|
||||||
#ifndef PORTMAP
|
|
||||||
#define PORTMAP
|
|
||||||
#endif
|
|
||||||
#define RETURN(xxx) { param->res = xxx; goto CLEANRET; }
|
|
||||||
|
|
||||||
struct msn_cookie {
|
|
||||||
struct msn_cookie *next;
|
|
||||||
unsigned char *userid;
|
|
||||||
char * connectstring;
|
|
||||||
};
|
|
||||||
|
|
||||||
static struct msn_cookie *msn_cookies = NULL;
|
|
||||||
pthread_mutex_t msn_cookie_mutex;
|
|
||||||
int msn_cookie_mutex_init = 0;
|
|
||||||
|
|
||||||
static void msn_clear(void *fo){
|
|
||||||
};
|
|
||||||
|
|
||||||
static FILTER_ACTION msn_srv(void *fc, struct clientparam * param, unsigned char ** buf_p, int * bufsize_p, int offset, int * length_p){
|
|
||||||
unsigned char *data = *buf_p + offset;
|
|
||||||
int len = (int)(*length_p - offset);
|
|
||||||
struct sockaddr_in sa;
|
|
||||||
SASIZETYPE size = sizeof(sa);
|
|
||||||
struct msn_cookie *cookie;
|
|
||||||
char tmpbuf[256];
|
|
||||||
char *sp1, *sp2, *sp3;
|
|
||||||
|
|
||||||
|
|
||||||
if(*bufsize_p - *length_p < 32) return CONTINUE;
|
|
||||||
if(len < 10 || len > 220) return CONTINUE;
|
|
||||||
|
|
||||||
data[len] = 0;
|
|
||||||
|
|
||||||
|
|
||||||
sp1 = data + 3;
|
|
||||||
if(data[0] == 'X' && data[1] == 'F' && data[2] == 'R' && data[3] == ' '){
|
|
||||||
if(!(sp2 = strchr(sp1 + 1, ' ')) || !(sp2 = strchr(sp2 + 1, ' '))|| !(sp3 = strchr(sp2 + 1, ' '))) return CONTINUE;
|
|
||||||
}
|
|
||||||
else if(data[0] == 'R' && data[1] == 'N' && data[2] == 'G' && data[3] == ' '){
|
|
||||||
if(!(sp2 = strchr(sp1 + 1, ' ')) || !(sp3 = strchr(sp2 + 1, ' '))) return CONTINUE;
|
|
||||||
}
|
|
||||||
else return CONTINUE;
|
|
||||||
|
|
||||||
*sp2 = 0;
|
|
||||||
*sp3 = 0;
|
|
||||||
if(getsockname(param->clisock, (struct sockaddr *)&sa, &size)==-1) {
|
|
||||||
return CONTINUE;
|
|
||||||
};
|
|
||||||
cookie = myalloc(sizeof(struct msn_cookie));
|
|
||||||
cookie->connectstring = mystrdup(sp2 + 1);
|
|
||||||
cookie->userid = mystrdup(param->username);
|
|
||||||
|
|
||||||
pthread_mutex_lock(&msn_cookie_mutex);
|
|
||||||
cookie->next = msn_cookies;
|
|
||||||
msn_cookies = cookie;
|
|
||||||
pthread_mutex_unlock(&msn_cookie_mutex);
|
|
||||||
|
|
||||||
strcpy(tmpbuf, data);
|
|
||||||
len = (int)strlen(tmpbuf);
|
|
||||||
tmpbuf[len++] = ' ';
|
|
||||||
|
|
||||||
len+=myinet_ntoa(sa.sin_addr, tmpbuf+len);
|
|
||||||
sprintf(tmpbuf+len, ":%hu %s", ntohs(sa.sin_port), sp3 + 1);
|
|
||||||
len = (int)strlen(tmpbuf);
|
|
||||||
memcpy(*buf_p + offset, tmpbuf, len);
|
|
||||||
*length_p = offset + len;
|
|
||||||
|
|
||||||
return CONTINUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static struct filter msnfilter = {
|
|
||||||
NULL,
|
|
||||||
"msnfilter",
|
|
||||||
NULL,
|
|
||||||
NULL,
|
|
||||||
NULL,
|
|
||||||
NULL,
|
|
||||||
NULL,
|
|
||||||
NULL,
|
|
||||||
NULL,
|
|
||||||
NULL,
|
|
||||||
*msn_srv,
|
|
||||||
*msn_clear,
|
|
||||||
NULL
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
void * msnprchild(struct clientparam* param) {
|
|
||||||
int res, len;
|
|
||||||
unsigned char *buf;
|
|
||||||
int buflen = 256;
|
|
||||||
char *sp1, *sp2, *sp3;
|
|
||||||
char *verstr = NULL;
|
|
||||||
int id;
|
|
||||||
struct msn_cookie *cookie, *prevcookie=NULL;
|
|
||||||
int sec = 0;
|
|
||||||
struct filterp **newfilters;
|
|
||||||
int skip = 0;
|
|
||||||
struct filterp msnfilterp = {
|
|
||||||
&msnfilter,
|
|
||||||
(void *)&skip
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
if(!msn_cookie_mutex_init){
|
|
||||||
msn_cookie_mutex_init = 1;
|
|
||||||
pthread_mutex_init(&msn_cookie_mutex, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
buf = myalloc(buflen);
|
|
||||||
res = sockgetlinebuf(param, CLIENT, buf, 240, '\n', conf.timeouts[STRING_S]);
|
|
||||||
if(res < 10) RETURN(1201);
|
|
||||||
buf[res] = 0;
|
|
||||||
if(!(sp1 = strchr(buf, ' ')) || !(sp2 = strchr(sp1 + 1, ' ')) || !(sp3 = strchr(sp2 + 1, ' ')) || ((int)(sp3-sp2)) < 6) RETURN(1202);
|
|
||||||
if((buf[0] == 'U' && buf[1] == 'S' && buf[2] == 'R') ||
|
|
||||||
(buf[0] == 'A' && buf[1] == 'N' && buf[2] == 'S')){
|
|
||||||
len = 1 + (int)(sp3 - sp2);
|
|
||||||
param->username = myalloc(len - 1);
|
|
||||||
memcpy(param->username, sp2 + 1, len - 2);
|
|
||||||
sec = 1;
|
|
||||||
|
|
||||||
}
|
|
||||||
else if(buf[0] != 'V' || buf[1] != 'E' || buf[2] != 'R') {RETURN(1203);}
|
|
||||||
else {
|
|
||||||
id = atoi(sp1 + 1);
|
|
||||||
verstr = mystrdup(buf);
|
|
||||||
|
|
||||||
if(socksend(param->clisock, buf, res, conf.timeouts[STRING_S])!=res) {RETURN (1204);}
|
|
||||||
|
|
||||||
res = sockgetlinebuf(param, CLIENT, buf, 240, '\n', conf.timeouts[STRING_S]);
|
|
||||||
if(res < 10) RETURN(1205);
|
|
||||||
buf[res] = 0;
|
|
||||||
if(buf[0] != 'C' || buf[1] != 'V' || buf[2] != 'R' || !(sp1=strrchr(buf,' ')) || (len = (int)strlen(sp1+1)) < 3) RETURN(1206);
|
|
||||||
param->username = myalloc(len - 1);
|
|
||||||
memcpy(param->username, sp1 + 1, len - 2);
|
|
||||||
}
|
|
||||||
param->username[len - 2] = 0;
|
|
||||||
param->operation = CONNECT;
|
|
||||||
|
|
||||||
pthread_mutex_lock(&msn_cookie_mutex);
|
|
||||||
for(cookie = msn_cookies; cookie; cookie = cookie->next){
|
|
||||||
if(!strcmp(param->username, cookie->userid)){
|
|
||||||
parsehostname(cookie->connectstring, param, ntohs(param->srv->targetport));
|
|
||||||
if(prevcookie)prevcookie->next = cookie->next;
|
|
||||||
else msn_cookies = cookie->next;
|
|
||||||
myfree(cookie->connectstring);
|
|
||||||
myfree(cookie->userid);
|
|
||||||
myfree(cookie);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
prevcookie = cookie;
|
|
||||||
}
|
|
||||||
pthread_mutex_unlock(&msn_cookie_mutex);
|
|
||||||
if(!cookie) {
|
|
||||||
if(sec) RETURN(1233);
|
|
||||||
parsehostname((char *)param->srv->target, param, ntohs(param->srv->targetport));
|
|
||||||
}
|
|
||||||
res = (*param->srv->authfunc)(param);
|
|
||||||
if(res) {RETURN(res);}
|
|
||||||
|
|
||||||
if(!sec){
|
|
||||||
len = (int)strlen(verstr);
|
|
||||||
if(socksend(param->remsock, verstr, len, conf.timeouts[STRING_S])!= len) {RETURN (1207);}
|
|
||||||
param->statscli += len;
|
|
||||||
|
|
||||||
|
|
||||||
myfree(verstr);
|
|
||||||
verstr = mystrdup(buf);
|
|
||||||
|
|
||||||
len = sockgetlinebuf(param, SERVER, buf, 240, '\n', conf.timeouts[STRING_S]);
|
|
||||||
if(len < 10) RETURN(1208);
|
|
||||||
param->statssrv += len;
|
|
||||||
|
|
||||||
strcpy(buf, verstr);
|
|
||||||
}
|
|
||||||
|
|
||||||
len = (int)strlen(buf);
|
|
||||||
if((res=handledatfltcli(param, &buf, &buflen, 0, &len))!=PASS) RETURN(res);
|
|
||||||
if(socksend(param->remsock, buf, len, conf.timeouts[STRING_S])!= len) {RETURN (1207);}
|
|
||||||
|
|
||||||
|
|
||||||
param->statscli += len;
|
|
||||||
|
|
||||||
if(sec){
|
|
||||||
RETURN(sockmap(param, conf.timeouts[CONNECTION_L]));
|
|
||||||
}
|
|
||||||
|
|
||||||
param->ndatfilterssrv++;
|
|
||||||
newfilters = myalloc(param->ndatfilterssrv * sizeof(struct filterp *));
|
|
||||||
if(param->ndatfilterssrv > 1){
|
|
||||||
memcpy(newfilters, param->datfilterssrv, (param->ndatfilterssrv - 1) * sizeof(struct filterp *));
|
|
||||||
myfree(param->datfilterssrv);
|
|
||||||
}
|
|
||||||
param->datfilterssrv = newfilters;
|
|
||||||
newfilters[param->ndatfilterssrv - 1] = &msnfilterp;
|
|
||||||
|
|
||||||
param->res = sockmap(param, conf.timeouts[CONNECTION_L]);
|
|
||||||
|
|
||||||
param->ndatfilterssrv--;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
CLEANRET:
|
|
||||||
|
|
||||||
|
|
||||||
if(verstr)myfree(verstr);
|
|
||||||
if(buf)myfree(buf);
|
|
||||||
(*param->srv->logfunc)(param, NULL);
|
|
||||||
freeparam(param);
|
|
||||||
return (NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef WITHMAIN
|
|
||||||
struct proxydef childdef = {
|
|
||||||
msnprchild,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
S_MSNPR,
|
|
||||||
""
|
|
||||||
};
|
|
||||||
#include "proxymain.c"
|
|
||||||
#endif
|
|
||||||
+1
-2
@@ -4,7 +4,6 @@
|
|||||||
|
|
||||||
please read License Agreement
|
please read License Agreement
|
||||||
|
|
||||||
$Id: myalloc.c,v 1.5 2008/01/08 21:46:38 vlad Exp $
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "proxy.h"
|
#include "proxy.h"
|
||||||
@@ -333,7 +332,7 @@ void *myrealloc(void *ptr, size_t size){
|
|||||||
if(size <= memsizes[l]) return ptr;
|
if(size <= memsizes[l]) return ptr;
|
||||||
p = myalloc(size);
|
p = myalloc(size);
|
||||||
if(p){
|
if(p){
|
||||||
memcpy(p,ptr,size);
|
memmove(p,ptr,size);
|
||||||
myfree(ptr);
|
myfree(ptr);
|
||||||
}
|
}
|
||||||
return p;
|
return p;
|
||||||
|
|||||||
@@ -4,7 +4,6 @@
|
|||||||
|
|
||||||
please read License Agreement
|
please read License Agreement
|
||||||
|
|
||||||
$Id: mycrypt.c,v 1.8 2008/01/08 21:46:38 vlad Exp $
|
|
||||||
*/
|
*/
|
||||||
#include "libs/md5.h"
|
#include "libs/md5.h"
|
||||||
#include "libs/md4.h"
|
#include "libs/md4.h"
|
||||||
|
|||||||
+2
-3
@@ -4,7 +4,6 @@
|
|||||||
|
|
||||||
please read License Agreement
|
please read License Agreement
|
||||||
|
|
||||||
$Id: ntlm.c,v 1.9 2008/01/08 21:46:38 vlad Exp $
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "proxy.h"
|
#include "proxy.h"
|
||||||
@@ -81,8 +80,8 @@ void genchallenge(struct clientparam *param, char * challenge, char *buf){
|
|||||||
chal->flags[3] = 0xA0;
|
chal->flags[3] = 0xA0;
|
||||||
text2unicode(hostname, (char *)chal->data, 64);
|
text2unicode(hostname, (char *)chal->data, 64);
|
||||||
time((time_t *)challenge);
|
time((time_t *)challenge);
|
||||||
memcpy(challenge+4, ¶m->sinc.sin_addr.s_addr, 4);
|
memcpy(challenge+4, SAADDR(¶m->sincr), 4);
|
||||||
challenge[1]^=param->sinc.sin_port;
|
challenge[1]^=*SAPORT(¶m->sincr);
|
||||||
for(i = 0; i < 8; i++) challenge[i] ^= myrand(challenge, 8);
|
for(i = 0; i < 8; i++) challenge[i] ^= myrand(challenge, 8);
|
||||||
memcpy(chal->challenge, challenge, 8);
|
memcpy(chal->challenge, challenge, 8);
|
||||||
en64((unsigned char *)tmpbuf, (unsigned char *)buf, (int)((unsigned char *)chal->data - (unsigned char *)chal) + len);
|
en64((unsigned char *)tmpbuf, (unsigned char *)buf, (int)((unsigned char *)chal->data - (unsigned char *)chal) + len);
|
||||||
|
|||||||
+39
-39
@@ -4,7 +4,6 @@
|
|||||||
|
|
||||||
please read License Agreement
|
please read License Agreement
|
||||||
|
|
||||||
$Id: ntlm.c,v 1.8 2007/12/27 13:20:04 vlad Exp $
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "proxy.h"
|
#include "proxy.h"
|
||||||
@@ -33,10 +32,10 @@ struct symbol symbols[] = {
|
|||||||
{symbols+5, "sockgetcharcli", (void *) sockgetcharcli},
|
{symbols+5, "sockgetcharcli", (void *) sockgetcharcli},
|
||||||
{symbols+6, "sockgetcharsrv", (void *) sockgetcharsrv},
|
{symbols+6, "sockgetcharsrv", (void *) sockgetcharsrv},
|
||||||
{symbols+7, "sockgetlinebuf", (void *) sockgetlinebuf},
|
{symbols+7, "sockgetlinebuf", (void *) sockgetlinebuf},
|
||||||
{symbols+8, "myinet_ntoa", (void *) myinet_ntoa},
|
{symbols+8, "myinet_ntop", (void *) myinet_ntop},
|
||||||
{symbols+9, "dobuf", (void *) dobuf},
|
{symbols+9, "dobuf", (void *) dobuf},
|
||||||
{symbols+10, "scanaddr", (void *) scanaddr},
|
{symbols+10, "scanaddr", (void *) scanaddr},
|
||||||
{symbols+11, "getip", (void *) getip},
|
{symbols+11, "getip46", (void *) getip46},
|
||||||
{symbols+12, "sockmap", (void *) sockmap},
|
{symbols+12, "sockmap", (void *) sockmap},
|
||||||
{symbols+13, "sockfuncs", (void *) &so},
|
{symbols+13, "sockfuncs", (void *) &so},
|
||||||
{symbols+14, "ACLmatches", (void *) ACLmatches},
|
{symbols+14, "ACLmatches", (void *) ACLmatches},
|
||||||
@@ -44,40 +43,41 @@ struct symbol symbols[] = {
|
|||||||
{symbols+16, "trafcountfunc", (void *) trafcountfunc},
|
{symbols+16, "trafcountfunc", (void *) trafcountfunc},
|
||||||
{symbols+17, "alwaysauth", (void *) alwaysauth},
|
{symbols+17, "alwaysauth", (void *) alwaysauth},
|
||||||
{symbols+18, "ipauth", (void *) ipauth},
|
{symbols+18, "ipauth", (void *) ipauth},
|
||||||
{symbols+19, "nbnameauth", (void *) nbnameauth},
|
{symbols+19, "strongauth", (void *) strongauth},
|
||||||
{symbols+20, "strongauth", (void *) strongauth},
|
{symbols+20, "checkACL", (void *) checkACL},
|
||||||
{symbols+21, "checkACL", (void *) checkACL},
|
{symbols+21, "nametohash", (void *) nametohash},
|
||||||
{symbols+22, "nametohash", (void *) nametohash},
|
{symbols+22, "hashindex", (void *) hashindex},
|
||||||
{symbols+23, "hashindex", (void *) hashindex},
|
{symbols+23, "nservers", (void *) nservers},
|
||||||
{symbols+24, "nservers", (void *) nservers},
|
{symbols+24, "udpresolve", (void *) udpresolve},
|
||||||
{symbols+25, "udpresolve", (void *) udpresolve},
|
{symbols+25, "bandlim_mutex", (void *) &bandlim_mutex},
|
||||||
{symbols+26, "bandlim_mutex", (void *) &bandlim_mutex},
|
{symbols+26, "tc_mutex", (void *) &tc_mutex},
|
||||||
{symbols+27, "tc_mutex", (void *) &tc_mutex},
|
{symbols+27, "hash_mutex", (void *) &hash_mutex},
|
||||||
{symbols+28, "hash_mutex", (void *) &hash_mutex},
|
{symbols+28, "pwl_mutex", (void *) &pwl_mutex},
|
||||||
{symbols+29, "pwl_mutex", (void *) &pwl_mutex},
|
{symbols+29, "linenum", (void *) &linenum},
|
||||||
{symbols+30, "linenum", (void *) &linenum},
|
{symbols+30, "proxy_stringtable", (void *) proxy_stringtable},
|
||||||
{symbols+31, "proxy_stringtable", (void *) proxy_stringtable},
|
{symbols+31, "en64", (void *) en64},
|
||||||
{symbols+32, "en64", (void *) en64},
|
{symbols+32, "de64", (void *) de64},
|
||||||
{symbols+33, "de64", (void *) de64},
|
{symbols+33, "tohex", (void *) tohex},
|
||||||
{symbols+34, "tohex", (void *) tohex},
|
{symbols+34, "fromhex", (void *) fromhex},
|
||||||
{symbols+35, "fromhex", (void *) fromhex},
|
{symbols+35, "dnspr", (void *) dnsprchild},
|
||||||
{symbols+36, "dnspr", (void *) dnsprchild},
|
{symbols+36, "pop3p", (void *) pop3pchild},
|
||||||
{symbols+37, "pop3p", (void *) pop3pchild},
|
{symbols+37, "proxy", (void *) proxychild},
|
||||||
{symbols+38, "proxy", (void *) proxychild},
|
{symbols+38, "socks", (void *) sockschild},
|
||||||
{symbols+39, "socks", (void *) sockschild},
|
{symbols+39, "tcppm", (void *) tcppmchild},
|
||||||
{symbols+40, "tcppm", (void *) tcppmchild},
|
{symbols+40, "udppm", (void *) udppmchild},
|
||||||
{symbols+41, "udppm", (void *) udppmchild},
|
{symbols+41, "admin", (void *) adminchild},
|
||||||
{symbols+42, "admin", (void *) adminchild},
|
{symbols+42, "ftppr", (void *) ftpprchild},
|
||||||
{symbols+43, "ftppr", (void *) ftpprchild},
|
{symbols+43, "smtpp", (void *) smtppchild},
|
||||||
{symbols+44, "smtpp", (void *) smtppchild},
|
{symbols+44, "icqpr", (void *) icqprchild},
|
||||||
{symbols+45, "icqpr", (void *) icqprchild},
|
/*
|
||||||
{symbols+46, "msnpr", (void *) msnprchild},
|
{symbols+45, "msnpr", (void *) msnprchild},
|
||||||
{symbols+47, "authfuncs", (void *) &authfuncs},
|
*/
|
||||||
{symbols+48, "commandhandlers", (void *) &commandhandlers},
|
{symbols+45, "authfuncs", (void *) &authfuncs},
|
||||||
{symbols+49, "decodeurl", (void *) decodeurl},
|
{symbols+46, "commandhandlers", (void *) &commandhandlers},
|
||||||
{symbols+50, "parsestr", (void *) parsestr},
|
{symbols+47, "decodeurl", (void *) decodeurl},
|
||||||
{symbols+51, "make_ace", (void *) make_ace},
|
{symbols+48, "parsestr", (void *) parsestr},
|
||||||
{symbols+52, "freeacl", (void *) freeacl},
|
{symbols+49, "make_ace", (void *) make_ace},
|
||||||
|
{symbols+50, "freeacl", (void *) freeacl},
|
||||||
{NULL, "", NULL}
|
{NULL, "", NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -103,11 +103,11 @@ struct pluginlink pluginlink = {
|
|||||||
sockgetcharcli,
|
sockgetcharcli,
|
||||||
sockgetcharsrv,
|
sockgetcharsrv,
|
||||||
sockgetlinebuf,
|
sockgetlinebuf,
|
||||||
myinet_ntoa,
|
myinet_ntop,
|
||||||
dobuf,
|
dobuf,
|
||||||
dobuf2,
|
dobuf2,
|
||||||
scanaddr,
|
scanaddr,
|
||||||
getip,
|
getip46,
|
||||||
sockmap,
|
sockmap,
|
||||||
ACLmatches,
|
ACLmatches,
|
||||||
alwaysauth,
|
alwaysauth,
|
||||||
|
|||||||
@@ -4,7 +4,6 @@
|
|||||||
|
|
||||||
please read License Agreement
|
please read License Agreement
|
||||||
|
|
||||||
$Id: FilePlugin.c,v 1.8 2012-04-11 23:01:22 vlad Exp $
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "../../structures.h"
|
#include "../../structures.h"
|
||||||
@@ -847,6 +846,36 @@ static struct symbol fp_symbols[] = {
|
|||||||
{NULL, "fp_stringtable", (void*) fp_stringtable}
|
{NULL, "fp_stringtable", (void*) fp_stringtable}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static int h_cachedir(int argc, unsigned char **argv){
|
||||||
|
char * dirp;
|
||||||
|
size_t len;
|
||||||
|
|
||||||
|
dirp = (argc > 1)? argv[1] : getenv("TEMP");
|
||||||
|
len = strlen(dirp);
|
||||||
|
if(!dirp || !len || len > 200 || strchr(dirp, '%')) {
|
||||||
|
fprintf(stderr, "FilePlugin: invalid directory path: %s\n", dirp);
|
||||||
|
return (1);
|
||||||
|
}
|
||||||
|
#ifdef _WIN32
|
||||||
|
if(dirp[len-1] == '\\') dirp[len-1] = 0;
|
||||||
|
sprintf(path, "%.256s\\%%07d.tmp", dirp);
|
||||||
|
#else
|
||||||
|
if(dirp[len-1] == '/') dirp[len-1] = 0;
|
||||||
|
sprintf(path, "%.256s/%%07d.tmp", dirp);
|
||||||
|
#endif
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int h_preview(int argc, unsigned char **argv){
|
||||||
|
preview = atoi(argv[1]);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static struct commands file_commandhandlers[] = {
|
||||||
|
{file_commandhandlers + 1, "file_cachedir", h_cachedir, 2, 2},
|
||||||
|
{NULL, "file_preview", h_preview, 2, 2},
|
||||||
|
};
|
||||||
|
|
||||||
static int file_loaded=0;
|
static int file_loaded=0;
|
||||||
|
|
||||||
|
|
||||||
@@ -858,7 +887,6 @@ __declspec(dllexport)
|
|||||||
int file_plugin (struct pluginlink * pluginlink,
|
int file_plugin (struct pluginlink * pluginlink,
|
||||||
int argc, char** argv){
|
int argc, char** argv){
|
||||||
|
|
||||||
char * dirp;
|
|
||||||
if(!file_loaded){
|
if(!file_loaded){
|
||||||
pthread_mutex_init(&file_mutex, NULL);
|
pthread_mutex_init(&file_mutex, NULL);
|
||||||
file_loaded = 1;
|
file_loaded = 1;
|
||||||
@@ -875,19 +903,11 @@ __declspec(dllexport)
|
|||||||
pl->conf->filters = &fp_filter;
|
pl->conf->filters = &fp_filter;
|
||||||
fp_symbols[1].next = pl->symbols.next;
|
fp_symbols[1].next = pl->symbols.next;
|
||||||
pl->symbols.next = fp_symbols;
|
pl->symbols.next = fp_symbols;
|
||||||
|
file_commandhandlers[1].next = pl->commandhandlers->next;
|
||||||
|
pl->commandhandlers->next = file_commandhandlers;
|
||||||
}
|
}
|
||||||
dirp = (argc > 1)? argv[1] : getenv("TEMP");
|
h_cachedir(0, NULL);
|
||||||
if(strlen(dirp) > 200 || strchr(dirp, '%')) {
|
preview = 32768;
|
||||||
fprintf(stderr, "FilePlugin: invalid directory path: %s\n", dirp);
|
|
||||||
return (13001);
|
|
||||||
}
|
|
||||||
#ifdef _WIN32
|
|
||||||
sprintf(path, "%.256s\\%%07d.tmp", dirp);
|
|
||||||
#else
|
|
||||||
sprintf(path, "%.256s/%%07d.tmp", dirp);
|
|
||||||
#endif
|
|
||||||
if(argc > 2) preview = atoi(argv[2]);
|
|
||||||
if(!preview) preview = 32768;
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,6 @@
|
|||||||
|
|
||||||
please read License Agreement
|
please read License Agreement
|
||||||
|
|
||||||
$Id: pcre_plugin.c,v 1.11 2012-04-25 18:17:22 vlad Exp $
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "../../structures.h"
|
#include "../../structures.h"
|
||||||
@@ -230,12 +229,12 @@ static int h_pcre(int argc, unsigned char **argv){
|
|||||||
struct filter *newf;
|
struct filter *newf;
|
||||||
char *replace = NULL;
|
char *replace = NULL;
|
||||||
|
|
||||||
if(!strcmp(argv[2], "allow")) action = PASS;
|
if(!strncmp(argv[2], "allow",5)) action = PASS;
|
||||||
else if(!strcmp(argv[2], "deny")) action = REJECT;
|
else if(!strncmp(argv[2], "deny",4)) action = REJECT;
|
||||||
else if(!strcmp(argv[2], "remove")) action = REMOVE;
|
else if(!strncmp(argv[2], "remove",6)) action = REMOVE;
|
||||||
else if(!strcmp(argv[2], "dunno")) action = CONTINUE;
|
else if(!strncmp(argv[2], "dunno",5)) action = CONTINUE;
|
||||||
else return 1;
|
else return 1;
|
||||||
if(!strcmp(argv[0], "pcre_rewrite")) {
|
if(!strncmp(argv[0], "pcre_rewrite", 12)) {
|
||||||
int i,j;
|
int i,j;
|
||||||
offset = 5;
|
offset = 5;
|
||||||
replace = pl->mystrdup(argv[4]);
|
replace = pl->mystrdup(argv[4]);
|
||||||
@@ -267,6 +266,7 @@ static int h_pcre(int argc, unsigned char **argv){
|
|||||||
replace[j] = 0;
|
replace[j] = 0;
|
||||||
}
|
}
|
||||||
if(!(acl = pl->make_ace(argc - offset, argv + offset))) return 2;
|
if(!(acl = pl->make_ace(argc - offset, argv + offset))) return 2;
|
||||||
|
acl->nolog = (strstr(argv[2],"log") == 0);
|
||||||
if(*argv[3] && !(*argv[3] == '*' && !argv[3][1]) ){
|
if(*argv[3] && !(*argv[3] == '*' && !argv[3][1]) ){
|
||||||
re = pcre_compile((char *)argv[3], pcre_options, &errptr, &offset, NULL);
|
re = pcre_compile((char *)argv[3], pcre_options, &errptr, &offset, NULL);
|
||||||
if(!re) {
|
if(!re) {
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ static int already_loaded = 0;
|
|||||||
static struct auth pamauth;
|
static struct auth pamauth;
|
||||||
#ifdef USERCASE
|
#ifdef USERCASE
|
||||||
static int usercaselow = 0;
|
static int usercaselow = 0;
|
||||||
#edif
|
#endif
|
||||||
static unsigned char *service=NULL;
|
static unsigned char *service=NULL;
|
||||||
static struct pluginlink * pl;
|
static struct pluginlink * pl;
|
||||||
|
|
||||||
|
|||||||
@@ -2,12 +2,11 @@
|
|||||||
#define _CRT_SECURE_NO_WARNINGS
|
#define _CRT_SECURE_NO_WARNINGS
|
||||||
|
|
||||||
#include "../../structures.h"
|
#include "../../structures.h"
|
||||||
#include "../../proxy.h"
|
|
||||||
#include "my_ssl.h"
|
|
||||||
|
|
||||||
#include <memory.h>
|
#include <memory.h>
|
||||||
#include <errno.h>
|
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
#ifndef _WIN32
|
||||||
|
#include <sys/file.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <openssl/crypto.h>
|
#include <openssl/crypto.h>
|
||||||
#include <openssl/x509.h>
|
#include <openssl/x509.h>
|
||||||
@@ -16,6 +15,12 @@
|
|||||||
#include <openssl/ssl.h>
|
#include <openssl/ssl.h>
|
||||||
#include <openssl/err.h>
|
#include <openssl/err.h>
|
||||||
|
|
||||||
|
#include "../../proxy.h"
|
||||||
|
#include "my_ssl.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
typedef struct _ssl_conn {
|
typedef struct _ssl_conn {
|
||||||
SSL_CTX *ctx;
|
SSL_CTX *ctx;
|
||||||
SSL *ssl;
|
SSL *ssl;
|
||||||
@@ -110,20 +115,23 @@ SSL_CERT ssl_copy_cert(SSL_CERT cert)
|
|||||||
static char hash_name[sizeof(src_cert->sha1_hash)*2 + 1];
|
static char hash_name[sizeof(src_cert->sha1_hash)*2 + 1];
|
||||||
static char cache_name[200];
|
static char cache_name[200];
|
||||||
|
|
||||||
pthread_mutex_lock(&ssl_file_mutex);
|
|
||||||
bin2hex(src_cert->sha1_hash, sizeof(src_cert->sha1_hash), hash_name, sizeof(hash_name));
|
bin2hex(src_cert->sha1_hash, sizeof(src_cert->sha1_hash), hash_name, sizeof(hash_name));
|
||||||
sprintf(cache_name, "%s%s.pem", cert_path, hash_name);
|
sprintf(cache_name, "%s%s.pem", cert_path, hash_name);
|
||||||
/* check if certificate is already cached */
|
/* check if certificate is already cached */
|
||||||
fcache = fopen(cache_name, "rb");
|
fcache = fopen(cache_name, "rb");
|
||||||
if ( fcache != NULL ) {
|
if ( fcache != NULL ) {
|
||||||
|
#ifndef _WIN32
|
||||||
|
flock(fileno(fcache), LOCK_SH);
|
||||||
|
#endif
|
||||||
dst_cert = PEM_read_X509(fcache, &dst_cert, NULL, NULL);
|
dst_cert = PEM_read_X509(fcache, &dst_cert, NULL, NULL);
|
||||||
|
#ifndef _WIN32
|
||||||
|
flock(fileno(fcache), LOCK_UN);
|
||||||
|
#endif
|
||||||
fclose(fcache);
|
fclose(fcache);
|
||||||
if ( dst_cert != NULL ){
|
if ( dst_cert != NULL ){
|
||||||
pthread_mutex_unlock(&ssl_file_mutex);
|
|
||||||
return dst_cert;
|
return dst_cert;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pthread_mutex_unlock(&ssl_file_mutex);
|
|
||||||
|
|
||||||
/* proceed if certificate is not cached */
|
/* proceed if certificate is not cached */
|
||||||
dst_cert = X509_dup(src_cert);
|
dst_cert = X509_dup(src_cert);
|
||||||
@@ -163,18 +171,22 @@ SSL_CERT ssl_copy_cert(SSL_CERT cert)
|
|||||||
|
|
||||||
/* write to cache */
|
/* write to cache */
|
||||||
|
|
||||||
pthread_mutex_lock(&ssl_file_mutex);
|
|
||||||
fcache = fopen(cache_name, "wb");
|
fcache = fopen(cache_name, "wb");
|
||||||
if ( fcache != NULL ) {
|
if ( fcache != NULL ) {
|
||||||
|
#ifndef _WIN32
|
||||||
|
flock(fileno(fcache), LOCK_EX);
|
||||||
|
#endif
|
||||||
PEM_write_X509(fcache, dst_cert);
|
PEM_write_X509(fcache, dst_cert);
|
||||||
|
#ifndef _WIN32
|
||||||
|
flock(fileno(fcache), LOCK_UN);
|
||||||
|
#endif
|
||||||
fclose(fcache);
|
fclose(fcache);
|
||||||
}
|
}
|
||||||
pthread_mutex_unlock(&ssl_file_mutex);
|
|
||||||
return dst_cert;
|
return dst_cert;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
SSL_CONN ssl_handshake_to_server(SOCKET s, SSL_CERT *server_cert, char **errSSL)
|
SSL_CONN ssl_handshake_to_server(SOCKET s, char * hostname, SSL_CERT *server_cert, char **errSSL)
|
||||||
{
|
{
|
||||||
int err = 0;
|
int err = 0;
|
||||||
X509 *cert;
|
X509 *cert;
|
||||||
@@ -204,6 +216,7 @@ SSL_CONN ssl_handshake_to_server(SOCKET s, SSL_CERT *server_cert, char **errSSL)
|
|||||||
ssl_conn_free(conn);
|
ssl_conn_free(conn);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
if(hostname && *hostname)SSL_set_tlsext_host_name(conn->ssl, hostname);
|
||||||
err = SSL_connect(conn->ssl);
|
err = SSL_connect(conn->ssl);
|
||||||
if ( err == -1 ) {
|
if ( err == -1 ) {
|
||||||
*errSSL = ERR_error_string(ERR_get_error(), errbuf);
|
*errSSL = ERR_error_string(ERR_get_error(), errbuf);
|
||||||
@@ -212,6 +225,10 @@ SSL_CONN ssl_handshake_to_server(SOCKET s, SSL_CERT *server_cert, char **errSSL)
|
|||||||
}
|
}
|
||||||
|
|
||||||
cert = SSL_get_peer_certificate(conn->ssl);
|
cert = SSL_get_peer_certificate(conn->ssl);
|
||||||
|
if(!cert) {
|
||||||
|
ssl_conn_free(conn);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
/* TODO: Verify certificate */
|
/* TODO: Verify certificate */
|
||||||
|
|
||||||
@@ -312,10 +329,14 @@ void ssl_conn_free(SSL_CONN connection)
|
|||||||
{
|
{
|
||||||
ssl_conn *conn = (ssl_conn *) connection;
|
ssl_conn *conn = (ssl_conn *) connection;
|
||||||
|
|
||||||
SSL_shutdown(conn->ssl);
|
if(conn){
|
||||||
SSL_free(conn->ssl);
|
if(conn->ssl){
|
||||||
SSL_CTX_free(conn->ctx);
|
SSL_shutdown(conn->ssl);
|
||||||
free(conn);
|
SSL_free(conn->ssl);
|
||||||
|
}
|
||||||
|
if(conn->ctx) SSL_CTX_free(conn->ctx);
|
||||||
|
free(conn);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void _ssl_cert_free(SSL_CERT cert)
|
void _ssl_cert_free(SSL_CERT cert)
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ SSL_CERT ssl_copy_cert(SSL_CERT cert);
|
|||||||
//
|
//
|
||||||
// SSL/TLS handshakes
|
// SSL/TLS handshakes
|
||||||
//
|
//
|
||||||
SSL_CONN ssl_handshake_to_server(SOCKET s, SSL_CERT *server_cert, char **errSSL);
|
SSL_CONN ssl_handshake_to_server(SOCKET s, char * hostname, SSL_CERT *server_cert, char **errSSL);
|
||||||
SSL_CONN ssl_handshake_to_client(SOCKET s, SSL_CERT server_cert, char **errSSL);
|
SSL_CONN ssl_handshake_to_client(SOCKET s, SSL_CERT server_cert, char **errSSL);
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|||||||
@@ -4,17 +4,15 @@
|
|||||||
|
|
||||||
please read License Agreement
|
please read License Agreement
|
||||||
|
|
||||||
$Id: ssl_plugin.c,v 1.9 2010-11-11 11:32:33 v.dubrovin Exp $
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "../../structures.h"
|
#include "../../structures.h"
|
||||||
#include "../../proxy.h"
|
|
||||||
#include <openssl/rsa.h> /* SSLeay stuff */
|
#include <openssl/rsa.h> /* SSLeay stuff */
|
||||||
#include <openssl/crypto.h>
|
#include <openssl/crypto.h>
|
||||||
#include <openssl/x509.h>
|
#include <openssl/x509.h>
|
||||||
#include <openssl/pem.h>
|
#include <openssl/pem.h>
|
||||||
#include <openssl/ssl.h>
|
#include <openssl/ssl.h>
|
||||||
#include <openssl/err.h>
|
#include "../../proxy.h"
|
||||||
#include "my_ssl.h"
|
#include "my_ssl.h"
|
||||||
|
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
@@ -54,13 +52,15 @@ struct SSLqueue {
|
|||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Todo: use hashtable
|
TO DO: use hashtable
|
||||||
*/
|
*/
|
||||||
static struct SSLqueue *searchSSL(SOCKET s){
|
static struct SSLqueue *searchSSL(SOCKET s){
|
||||||
struct SSLqueue *sslq;
|
struct SSLqueue *sslq = NULL;
|
||||||
|
pthread_mutex_lock(&ssl_mutex);
|
||||||
for(sslq = SSLq; sslq; sslq = sslq->next)
|
for(sslq = SSLq; sslq; sslq = sslq->next)
|
||||||
if(sslq->s == s) return sslq;
|
if(sslq->s == s) break;
|
||||||
return NULL;
|
pthread_mutex_unlock(&ssl_mutex);
|
||||||
|
return sslq;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void addSSL(SOCKET s, SSL_CERT cert, SSL_CONN conn, struct clientparam* param){
|
static void addSSL(SOCKET s, SSL_CERT cert, SSL_CONN conn, struct clientparam* param){
|
||||||
@@ -235,7 +235,7 @@ int dossl(struct clientparam* param, SSL_CONN* ServerConnp, SSL_CONN* ClientConn
|
|||||||
ul = ((unsigned long)ssl_connect_timeout)*1000;
|
ul = ((unsigned long)ssl_connect_timeout)*1000;
|
||||||
setsockopt(param->remsock, SOL_SOCKET, SO_SNDTIMEO, (char *)&ul, 4);
|
setsockopt(param->remsock, SOL_SOCKET, SO_SNDTIMEO, (char *)&ul, 4);
|
||||||
}
|
}
|
||||||
ServerConn = ssl_handshake_to_server(param->remsock, &ServerCert, &errSSL);
|
ServerConn = ssl_handshake_to_server(param->remsock, (char *)param->hostname, &ServerCert, &errSSL);
|
||||||
if ( ServerConn == NULL || ServerCert == NULL ) {
|
if ( ServerConn == NULL || ServerCert == NULL ) {
|
||||||
param->res = 8011;
|
param->res = 8011;
|
||||||
param->srv->logfunc(param, (unsigned char *)"SSL handshake to server failed");
|
param->srv->logfunc(param, (unsigned char *)"SSL handshake to server failed");
|
||||||
@@ -325,6 +325,47 @@ static struct filter ssl_filter = {
|
|||||||
ssl_filter_close
|
ssl_filter_close
|
||||||
};
|
};
|
||||||
|
|
||||||
|
int mitm = 0;
|
||||||
|
|
||||||
|
static int h_mitm(int argc, unsigned char **argv){
|
||||||
|
if((mitm&1)) return 1;
|
||||||
|
if(mitm) usleep(100*SLEEPTIME);
|
||||||
|
ssl_filter.next = pl->conf->filters;
|
||||||
|
pl->conf->filters = &ssl_filter;
|
||||||
|
mitm++;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int h_nomitm(int argc, unsigned char **argv){
|
||||||
|
struct filter * sf;
|
||||||
|
if(!(mitm&1)) return 1;
|
||||||
|
if(mitm) usleep(100*SLEEPTIME);
|
||||||
|
if(pl->conf->filters == &ssl_filter) pl->conf->filters = ssl_filter.next;
|
||||||
|
else for(sf = pl->conf->filters; sf && sf->next; sf=sf->next){
|
||||||
|
if(sf->next == &ssl_filter) {
|
||||||
|
sf->next = ssl_filter.next;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
mitm++;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int h_certpath(int argc, unsigned char **argv){
|
||||||
|
size_t len;
|
||||||
|
len = strlen(argv[1]);
|
||||||
|
if(!len || (argv[1][len - 1] != '/' && argv[1][len - 1] != '\\')) return 1;
|
||||||
|
if(cert_path && *cert_path) free(cert_path);
|
||||||
|
cert_path = strdup(argv[1]);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static struct commands ssl_commandhandlers[] = {
|
||||||
|
{ssl_commandhandlers+1, "ssl_mitm", h_mitm, 1, 1},
|
||||||
|
{ssl_commandhandlers+2, "ssl_nomitm", h_nomitm, 1, 1},
|
||||||
|
{NULL, "ssl_certcache", h_certpath, 2, 2},
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
__declspec(dllexport)
|
__declspec(dllexport)
|
||||||
@@ -333,15 +374,9 @@ __declspec(dllexport)
|
|||||||
int ssl_plugin (struct pluginlink * pluginlink,
|
int ssl_plugin (struct pluginlink * pluginlink,
|
||||||
int argc, char** argv){
|
int argc, char** argv){
|
||||||
pl = pluginlink;
|
pl = pluginlink;
|
||||||
if(argc > 1) {
|
|
||||||
if(cert_path && *cert_path) free(cert_path);
|
|
||||||
cert_path = strdup(argv[1]);
|
|
||||||
}
|
|
||||||
if(!ssl_loaded){
|
if(!ssl_loaded){
|
||||||
ssl_loaded = 1;
|
ssl_loaded = 1;
|
||||||
pthread_mutex_init(&ssl_mutex, NULL);
|
pthread_mutex_init(&ssl_mutex, NULL);
|
||||||
ssl_filter.next = pl->conf->filters;
|
|
||||||
pl->conf->filters = &ssl_filter;
|
|
||||||
memcpy(&sso, pl->so, sizeof(struct sockfuncs));
|
memcpy(&sso, pl->so, sizeof(struct sockfuncs));
|
||||||
pl->so->_send = ssl_send;
|
pl->so->_send = ssl_send;
|
||||||
pl->so->_recv = ssl_recv;
|
pl->so->_recv = ssl_recv;
|
||||||
@@ -349,10 +384,13 @@ __declspec(dllexport)
|
|||||||
pl->so->_recvfrom = ssl_recvfrom;
|
pl->so->_recvfrom = ssl_recvfrom;
|
||||||
pl->so->_closesocket = ssl_closesocket;
|
pl->so->_closesocket = ssl_closesocket;
|
||||||
pl->so->_poll = ssl_poll;
|
pl->so->_poll = ssl_poll;
|
||||||
|
ssl_commandhandlers[2].next = pl->commandhandlers->next;
|
||||||
|
pl->commandhandlers->next = ssl_commandhandlers;
|
||||||
}
|
}
|
||||||
else{
|
else {
|
||||||
ssl_release();
|
ssl_release();
|
||||||
}
|
}
|
||||||
|
|
||||||
ssl_init();
|
ssl_init();
|
||||||
tcppmfunc = (PROXYFUNC)pl->findbyname("tcppm");
|
tcppmfunc = (PROXYFUNC)pl->findbyname("tcppm");
|
||||||
if(!tcppmfunc){return 13;}
|
if(!tcppmfunc){return 13;}
|
||||||
|
|||||||
@@ -179,18 +179,27 @@ void mylogfunc(struct clientparam * param, const unsigned char * pz) {
|
|||||||
int port;
|
int port;
|
||||||
int rule = 0;
|
int rule = 0;
|
||||||
struct trafcorrect * starttrafcorrect = firsttrafcorrect;
|
struct trafcorrect * starttrafcorrect = firsttrafcorrect;
|
||||||
int statssrv_before, statscli_before;
|
#ifndef NOPSTDINT
|
||||||
|
uint64_t statssrv_before, statscli_before;
|
||||||
|
#else
|
||||||
|
unsigned long statssrv_before, statscli_before;
|
||||||
|
#endif
|
||||||
int ok = 0;
|
int ok = 0;
|
||||||
for (;starttrafcorrect != NULL; starttrafcorrect = starttrafcorrect->next) {
|
for (;starttrafcorrect != NULL; starttrafcorrect = starttrafcorrect->next) {
|
||||||
port = starttrafcorrect->port;
|
port = starttrafcorrect->port;
|
||||||
g_s = starttrafcorrect->p_service;
|
g_s = starttrafcorrect->p_service;
|
||||||
if (starttrafcorrect->p_service == S_NOSERVICE) g_s = param->service;
|
if (starttrafcorrect->p_service == S_NOSERVICE) g_s = param->service;
|
||||||
if (starttrafcorrect->port <= 0) port = myhtons(param->sins.sin_port);
|
if (starttrafcorrect->port <= 0) port = myhtons(*SAPORT(¶m->sinsr));
|
||||||
|
|
||||||
|
#ifndef NOPSTDINT
|
||||||
|
statssrv_before = param->statssrv64;
|
||||||
|
statscli_before = param->statscli64;
|
||||||
|
#else
|
||||||
statssrv_before = param->statssrv;
|
statssrv_before = param->statssrv;
|
||||||
statscli_before = param->statscli;
|
statscli_before = param->statscli;
|
||||||
|
#endif
|
||||||
rule++;
|
rule++;
|
||||||
if (((g_s == param->service) && (port == myhtons(param->sins.sin_port))) ||
|
if (((g_s == param->service) && (port == myhtons(*SAPORT(¶m->sinsr)))) ||
|
||||||
( ((starttrafcorrect->type == UDP) &&
|
( ((starttrafcorrect->type == UDP) &&
|
||||||
((param->operation == UDPASSOC)||
|
((param->operation == UDPASSOC)||
|
||||||
(param->operation == DNSRESOLVE)||
|
(param->operation == DNSRESOLVE)||
|
||||||
@@ -201,28 +210,47 @@ void mylogfunc(struct clientparam * param, const unsigned char * pz) {
|
|||||||
/* ôèëüòð ïîäîø¸ë. ìîæíî èçìåíÿòü çíà÷åíèå òðàôôèêà
|
/* ôèëüòð ïîäîø¸ë. ìîæíî èçìåíÿòü çíà÷åíèå òðàôôèêà
|
||||||
äîìíîæàåì íà ÷èñëî */
|
äîìíîæàåì íà ÷èñëî */
|
||||||
if (starttrafcorrect->type == MULTIPLAY) {
|
if (starttrafcorrect->type == MULTIPLAY) {
|
||||||
|
#ifndef NOPSTDINT
|
||||||
|
param->statssrv64 = (unsigned)((double)param->statssrv64 *starttrafcorrect->coeff);
|
||||||
|
param->statscli64 = (unsigned)((double)param->statscli64 * starttrafcorrect->coeff);
|
||||||
|
#else
|
||||||
param->statssrv = (unsigned)((double)param->statssrv *starttrafcorrect->coeff);
|
param->statssrv = (unsigned)((double)param->statssrv *starttrafcorrect->coeff);
|
||||||
param->statscli = (unsigned)((double)param->statscli * starttrafcorrect->coeff);
|
param->statscli = (unsigned)((double)param->statscli * starttrafcorrect->coeff);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
/* ñ ó÷¸òîì ïàêåòîâ */
|
/* ñ ó÷¸òîì ïàêåòîâ */
|
||||||
if (starttrafcorrect->type == IPCORRECT) {
|
if (starttrafcorrect->type == IPCORRECT) {
|
||||||
if (starttrafcorrect->con_type == TCP) {
|
if (starttrafcorrect->con_type == TCP) {
|
||||||
|
#ifndef NOPSTDINT
|
||||||
|
param->statssrv64+=(param->nreads + 3*param->nconnects)*starttrafcorrect->psize;
|
||||||
|
param->statscli64+=(param->nwrites + 3*param->nconnects)*starttrafcorrect->psize;
|
||||||
|
#else
|
||||||
param->statssrv+=(param->nreads + 3*param->nconnects)*starttrafcorrect->psize;
|
param->statssrv+=(param->nreads + 3*param->nconnects)*starttrafcorrect->psize;
|
||||||
param->statscli+=(param->nwrites + 3*param->nconnects)*starttrafcorrect->psize;
|
param->statscli+=(param->nwrites + 3*param->nconnects)*starttrafcorrect->psize;
|
||||||
|
#endif
|
||||||
} else {
|
} else {
|
||||||
|
#ifndef NOPSTDINT
|
||||||
|
param->statssrv64+=param->nreads*starttrafcorrect->psize;
|
||||||
|
param->statscli64+=param->nwrites*starttrafcorrect->psize;
|
||||||
|
#else
|
||||||
param->statssrv+=param->nreads*starttrafcorrect->psize;
|
param->statssrv+=param->nreads*starttrafcorrect->psize;
|
||||||
param->statscli+=param->nwrites*starttrafcorrect->psize;
|
param->statscli+=param->nwrites*starttrafcorrect->psize;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (DBGLEVEL == 1) {
|
if (DBGLEVEL == 1) {
|
||||||
fprintf(stdout, "Port=%hd; Before: srv=%d, cli=%d; After: srv=%ld, cli=%ld; nreads=%ld; nwrites=%ld; Rule=%d\n",myhtons(param->sins.sin_port), statssrv_before, statscli_before, param->statssrv, param->statscli,param->nreads,param->nwrites,rule);
|
#ifndef NOPSTDINT
|
||||||
|
fprintf(stdout, "Port=%hd; Before: srv=%"PRINTF_INT64_MODIFIER"d, cli=%"PRINTF_INT64_MODIFIER"d; After: srv=%"PRINTF_INT64_MODIFIER"d, cli=%"PRINTF_INT64_MODIFIER"d; nreads=%ld; nwrites=%ld; Rule=%d\n",myhtons(*SAPORT(¶m->sinsr)), statssrv_before, statscli_before, param->statssrv64, param->statscli64,param->nreads,param->nwrites,rule);
|
||||||
|
#else
|
||||||
|
fprintf(stdout, "Port=%hd; Before: srv=%lu, cli=%lu; After: srv=%lu, cli=%lu; nreads=%ld; nwrites=%ld; Rule=%d\n",myhtons(param->sins.sin_port), statssrv_before, statscli_before, param->statssrv, param->statscli,param->nreads,param->nwrites,rule);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
ok = 1;
|
ok = 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((!ok) && (DBGLEVEL == 1)) {
|
if ((!ok) && (DBGLEVEL == 1)) {
|
||||||
fprintf(stdout, "No rules specifed: service=%d, port=%d, operation=%d", param->service, param->sins.sin_port,param->operation);
|
fprintf(stdout, "No rules specifed: service=%d, port=%d, operation=%d", param->service, *SAPORT(¶m->sinsr),param->operation);
|
||||||
}
|
}
|
||||||
origlogfunc(param, pz);
|
origlogfunc(param, pz);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,6 @@
|
|||||||
|
|
||||||
please read License Agreement
|
please read License Agreement
|
||||||
|
|
||||||
$Id: transparent_plugin.c,v 1.9 2010-11-11 11:32:33 v.dubrovin Exp $
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/utsname.h>
|
#include <sys/utsname.h>
|
||||||
|
|||||||
@@ -4,7 +4,6 @@
|
|||||||
|
|
||||||
please read License Agreement
|
please read License Agreement
|
||||||
|
|
||||||
$Id: WindowsAuthentication.c,v 1.12 2011-04-12 13:05:58 v.dubrovin Exp $
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "../../structures.h"
|
#include "../../structures.h"
|
||||||
|
|||||||
@@ -4,7 +4,6 @@
|
|||||||
|
|
||||||
please read License Agreement
|
please read License Agreement
|
||||||
|
|
||||||
$Id: utf8tocp1251.c,v 1.9 2009/09/03 05:32:56 v.dubrovin Exp $
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "../../structures.h"
|
#include "../../structures.h"
|
||||||
|
|||||||
+2
-3
@@ -4,7 +4,6 @@
|
|||||||
|
|
||||||
please read License Agreement
|
please read License Agreement
|
||||||
|
|
||||||
$Id: pop3p.c,v 1.17 2008/01/08 21:46:38 vlad Exp $
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "proxy.h"
|
#include "proxy.h"
|
||||||
@@ -43,13 +42,13 @@ void * pop3pchild(struct clientparam* param) {
|
|||||||
socksend(param->remsock, param->extusername, (int)strlen((char *)param->extusername), conf.timeouts[STRING_S]) <= 0 ||
|
socksend(param->remsock, param->extusername, (int)strlen((char *)param->extusername), conf.timeouts[STRING_S]) <= 0 ||
|
||||||
socksend(param->remsock, (unsigned char *)"\r\n", 2, conf.timeouts[STRING_S])!=2)
|
socksend(param->remsock, (unsigned char *)"\r\n", 2, conf.timeouts[STRING_S])!=2)
|
||||||
{RETURN(623);}
|
{RETURN(623);}
|
||||||
param->statscli += (int)(strlen((char *)param->extusername) + 7);
|
param->statscli64 += (uint64_t)(strlen((char *)param->extusername) + 7);
|
||||||
param->nwrites++;
|
param->nwrites++;
|
||||||
RETURN (sockmap(param, 180));
|
RETURN (sockmap(param, 180));
|
||||||
CLEANRET:
|
CLEANRET:
|
||||||
|
|
||||||
if(param->hostname&¶m->extusername) {
|
if(param->hostname&¶m->extusername) {
|
||||||
sprintf((char *)buf, "%.64s@%.128s%c%hu", param->extusername, param->hostname, (ntohs(param->sins.sin_port)==110)?0:':', ntohs(param->sins.sin_port));
|
sprintf((char *)buf, "%.64s@%.128s%c%hu", param->extusername, param->hostname, (*SAPORT(¶m->sinsr)==110)?0:':', ntohs(*SAPORT(¶m->sinsr)));
|
||||||
(*param->srv->logfunc)(param, buf);
|
(*param->srv->logfunc)(param, buf);
|
||||||
}
|
}
|
||||||
else (*param->srv->logfunc)(param, NULL);
|
else (*param->srv->logfunc)(param, NULL);
|
||||||
|
|||||||
+68
-74
@@ -4,7 +4,6 @@
|
|||||||
|
|
||||||
please read License Agreement
|
please read License Agreement
|
||||||
|
|
||||||
$Id: proxy.c,v 1.107 2014-04-07 20:35:07 vlad Exp $
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
@@ -132,8 +131,9 @@ char * proxy_stringtable[] = {
|
|||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#define BUFSIZE 8192
|
||||||
#define LINESIZE 4096
|
#define LINESIZE 4096
|
||||||
#define BUFSIZE (LINESIZE*2)
|
#define FTPBUFSIZE 1536
|
||||||
|
|
||||||
static void logurl(struct clientparam * param, char * buf, char * req, int ftp){
|
static void logurl(struct clientparam * param, char * buf, char * req, int ftp){
|
||||||
char *sb;
|
char *sb;
|
||||||
@@ -217,7 +217,7 @@ void * proxychild(struct clientparam* param) {
|
|||||||
unsigned char *ftpbase=NULL;
|
unsigned char *ftpbase=NULL;
|
||||||
unsigned char username[1024];
|
unsigned char username[1024];
|
||||||
int keepalive = 0;
|
int keepalive = 0;
|
||||||
unsigned long contentlength = 0;
|
uint64_t contentlength64 = 0;
|
||||||
int hascontent =0;
|
int hascontent =0;
|
||||||
int isconnect = 0;
|
int isconnect = 0;
|
||||||
int redirect = 0;
|
int redirect = 0;
|
||||||
@@ -229,7 +229,8 @@ void * proxychild(struct clientparam* param) {
|
|||||||
int authenticate;
|
int authenticate;
|
||||||
struct pollfd fds[2];
|
struct pollfd fds[2];
|
||||||
SOCKET ftps;
|
SOCKET ftps;
|
||||||
SASIZETYPE sasize;
|
char ftpbuf[FTPBUFSIZE];
|
||||||
|
int inftpbuf = 0;
|
||||||
#ifndef WITHMAIN
|
#ifndef WITHMAIN
|
||||||
FILTER_ACTION action;
|
FILTER_ACTION action;
|
||||||
#endif
|
#endif
|
||||||
@@ -241,7 +242,7 @@ void * proxychild(struct clientparam* param) {
|
|||||||
bufsize = BUFSIZE;
|
bufsize = BUFSIZE;
|
||||||
anonymous = param->srv->singlepacket;
|
anonymous = param->srv->singlepacket;
|
||||||
for(;;){
|
for(;;){
|
||||||
memset(buf, 0, BUFSIZE);
|
memset(buf, 0, bufsize);
|
||||||
inbuf = 0;
|
inbuf = 0;
|
||||||
|
|
||||||
|
|
||||||
@@ -260,8 +261,6 @@ for(;;){
|
|||||||
ckeepalive = 0;
|
ckeepalive = 0;
|
||||||
so._shutdown(param->remsock, SHUT_RDWR);
|
so._shutdown(param->remsock, SHUT_RDWR);
|
||||||
so._closesocket(param->remsock);
|
so._closesocket(param->remsock);
|
||||||
param->sins.sin_addr.s_addr = 0;
|
|
||||||
param->sins.sin_port = 0;
|
|
||||||
param->remsock = INVALID_SOCKET;
|
param->remsock = INVALID_SOCKET;
|
||||||
param->redirected = 0;
|
param->redirected = 0;
|
||||||
param->redirtype = 0;
|
param->redirtype = 0;
|
||||||
@@ -282,8 +281,6 @@ for(;;){
|
|||||||
so._shutdown(param->remsock, SHUT_RDWR);
|
so._shutdown(param->remsock, SHUT_RDWR);
|
||||||
so._closesocket(param->remsock);
|
so._closesocket(param->remsock);
|
||||||
}
|
}
|
||||||
param->sins.sin_addr.s_addr = 0;
|
|
||||||
param->sins.sin_port = 0;
|
|
||||||
param->remsock = INVALID_SOCKET;
|
param->remsock = INVALID_SOCKET;
|
||||||
param->redirected = 0;
|
param->redirected = 0;
|
||||||
param->redirtype = 0;
|
param->redirtype = 0;
|
||||||
@@ -300,7 +297,6 @@ for(;;){
|
|||||||
|
|
||||||
if ((sb=(unsigned char *)(unsigned char *)strchr((char *)buf, ' ')) == NULL) {RETURN(512);}
|
if ((sb=(unsigned char *)(unsigned char *)strchr((char *)buf, ' ')) == NULL) {RETURN(512);}
|
||||||
ss = ++sb;
|
ss = ++sb;
|
||||||
param->transparent = 0;
|
|
||||||
if(!isconnect) {
|
if(!isconnect) {
|
||||||
if (!strncasecmp((char *)sb, "http://", 7)) {
|
if (!strncasecmp((char *)sb, "http://", 7)) {
|
||||||
sb += 7;
|
sb += 7;
|
||||||
@@ -389,14 +385,14 @@ for(;;){
|
|||||||
while( (i = sockgetlinebuf(param, CLIENT, buf, BUFSIZE - 1, '\n', conf.timeouts[STRING_S])) > 2){
|
while( (i = sockgetlinebuf(param, CLIENT, buf, BUFSIZE - 1, '\n', conf.timeouts[STRING_S])) > 2){
|
||||||
if(i> 15 && (!strncasecmp((char *)(buf), "content-length", 14))){
|
if(i> 15 && (!strncasecmp((char *)(buf), "content-length", 14))){
|
||||||
buf[i]=0;
|
buf[i]=0;
|
||||||
sscanf((char *)buf + 15, "%lu", &contentlength);
|
sscanf((char *)buf + 15, "%"PRINTF_INT64_MODIFIER"u", &contentlength64);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
while( contentlength > 0 && (i = sockgetlinebuf(param, CLIENT, buf, (BUFSIZE < contentlength)? BUFSIZE - 1:contentlength, '\n', conf.timeouts[STRING_S])) > 0){
|
while( contentlength64 > 0 && (i = sockgetlinebuf(param, CLIENT, buf, (BUFSIZE < contentlength64)? BUFSIZE - 1:(int)contentlength64, '\n', conf.timeouts[STRING_S])) > 0){
|
||||||
if ((unsigned long)i > contentlength) break;
|
if ((uint64_t)i > contentlength64) break;
|
||||||
contentlength-=i;
|
contentlength64-=i;
|
||||||
}
|
}
|
||||||
contentlength = 0;
|
contentlength64 = 0;
|
||||||
if(param->password)myfree(param->password);
|
if(param->password)myfree(param->password);
|
||||||
param->password = myalloc(32);
|
param->password = myalloc(32);
|
||||||
param->pwtype = 2;
|
param->pwtype = 2;
|
||||||
@@ -493,15 +489,15 @@ for(;;){
|
|||||||
if(!sb)continue;
|
if(!sb)continue;
|
||||||
++sb;
|
++sb;
|
||||||
while(isspace(*sb))sb++;
|
while(isspace(*sb))sb++;
|
||||||
sscanf(sb, "%lu",&contentlength);
|
sscanf(sb, "%"PRINTF_INT64_MODIFIER"u",&contentlength64);
|
||||||
if(param->maxtrafout && (param->maxtrafout < param->statscli || (unsigned)contentlength > param->maxtrafout - param->statscli)){
|
if(param->maxtrafout64 && (param->maxtrafout64 < param->statscli64 || contentlength64 > param->maxtrafout64 - param->statscli64)){
|
||||||
RETURN(10);
|
RETURN(10);
|
||||||
}
|
}
|
||||||
if(param->ndatfilterscli > 0 && contentlength > 0) continue;
|
if(param->ndatfilterscli > 0 && contentlength64 > 0) continue;
|
||||||
}
|
}
|
||||||
inbuf += i;
|
inbuf += i;
|
||||||
if((bufsize - inbuf) < LINESIZE){
|
if((bufsize - inbuf) < LINESIZE){
|
||||||
if (bufsize > 20000){
|
if (bufsize > (LINESIZE * 16)){
|
||||||
RETURN (516);
|
RETURN (516);
|
||||||
}
|
}
|
||||||
if(!(newbuf = myrealloc(buf, bufsize + BUFSIZE))){RETURN (21);}
|
if(!(newbuf = myrealloc(buf, bufsize + BUFSIZE))){RETURN (21);}
|
||||||
@@ -528,48 +524,35 @@ for(;;){
|
|||||||
RETURN(0);
|
RETURN(0);
|
||||||
}
|
}
|
||||||
if(action != PASS) RETURN(517);
|
if(action != PASS) RETURN(517);
|
||||||
if(param->ndatfilterscli > 0 && contentlength > 0){
|
if(param->ndatfilterscli > 0 && contentlength64 > 0){
|
||||||
unsigned long newlen;
|
uint64_t newlen64;
|
||||||
newlen = sockfillbuffcli(param, contentlength, CONNECTION_S);
|
newlen64 = sockfillbuffcli(param, (unsigned long)contentlength64, CONNECTION_S);
|
||||||
if(newlen == contentlength) {
|
if(newlen64 == contentlength64) {
|
||||||
action = handledatfltcli(param, ¶m->clibuf, ¶m->clibufsize, 0, ¶m->cliinbuf);
|
action = handledatfltcli(param, ¶m->clibuf, ¶m->clibufsize, 0, ¶m->cliinbuf);
|
||||||
if(action == HANDLED){
|
if(action == HANDLED){
|
||||||
RETURN(0);
|
RETURN(0);
|
||||||
}
|
}
|
||||||
if(action != PASS) RETURN(517);
|
if(action != PASS) RETURN(517);
|
||||||
contentlength = param->cliinbuf;
|
contentlength64 = param->cliinbuf;
|
||||||
param->ndatfilterscli = 0;
|
param->ndatfilterscli = 0;
|
||||||
}
|
}
|
||||||
sprintf((char*)buf+strlen((char *)buf), "Content-Length: %lu\r\n", contentlength);
|
sprintf((char*)buf+strlen((char *)buf), "Content-Length: %"PRINTF_INT64_MODIFIER"u\r\n", contentlength64);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if((res = (*param->srv->authfunc)(param))) {RETURN(res);}
|
if((res = (*param->srv->authfunc)(param))) {RETURN(res);}
|
||||||
if (param->sins.sin_addr.s_addr == param->srv->intip && param->sins.sin_port == param->srv->intport) {
|
|
||||||
RETURN(519);
|
|
||||||
}
|
|
||||||
sasize = sizeof(struct sockaddr_in);
|
|
||||||
if(so._getpeername(param->remsock, (struct sockaddr *)¶m->sins, &sasize)){
|
|
||||||
RETURN(520);
|
|
||||||
}
|
|
||||||
#define FTPBUFSIZE 1536
|
|
||||||
|
|
||||||
if(ftp && param->redirtype != R_HTTP){
|
if(ftp && param->redirtype != R_HTTP){
|
||||||
SOCKET s;
|
SOCKET s;
|
||||||
int mode = 0;
|
int mode = 0;
|
||||||
int i=0;
|
int i=0;
|
||||||
char ftpbuf[FTPBUFSIZE];
|
|
||||||
int inftpbuf = 0;
|
|
||||||
|
|
||||||
|
inftpbuf = 0;
|
||||||
if(!ckeepalive){
|
if(!ckeepalive){
|
||||||
inftpbuf = FTPBUFSIZE - 20;
|
inftpbuf = FTPBUFSIZE - 20;
|
||||||
res = ftplogin(param, ftpbuf, &inftpbuf);
|
res = ftplogin(param, ftpbuf, &inftpbuf);
|
||||||
if(res){
|
if(res){
|
||||||
if (res == 700 || res == 701){
|
|
||||||
socksend(param->clisock, (unsigned char *)proxy_stringtable[16], (int)strlen(proxy_stringtable[16]), conf.timeouts[STRING_S]);
|
|
||||||
socksend(param->clisock, (unsigned char *)ftpbuf, inftpbuf, conf.timeouts[STRING_S]);
|
|
||||||
}
|
|
||||||
RETURN(res);
|
RETURN(res);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -620,7 +603,7 @@ for(;;){
|
|||||||
socksend(param->clisock, (unsigned char *)proxy_stringtable[8], (int)strlen(proxy_stringtable[8]), conf.timeouts[STRING_S]);
|
socksend(param->clisock, (unsigned char *)proxy_stringtable[8], (int)strlen(proxy_stringtable[8]), conf.timeouts[STRING_S]);
|
||||||
s = param->remsock;
|
s = param->remsock;
|
||||||
param->remsock = ftps;
|
param->remsock = ftps;
|
||||||
if((param->operation == FTP_PUT) && (contentlength > 0)) param->waitclient = contentlength;
|
if((param->operation == FTP_PUT) && (contentlength64 > 0)) param->waitclient64 = contentlength64;
|
||||||
res = sockmap(param, conf.timeouts[CONNECTION_L]);
|
res = sockmap(param, conf.timeouts[CONNECTION_L]);
|
||||||
if (res == 99) res = 0;
|
if (res == 99) res = 0;
|
||||||
so._closesocket(ftps);
|
so._closesocket(ftps);
|
||||||
@@ -822,23 +805,31 @@ for(;;){
|
|||||||
if(socksend(param->remsock, req , (res = (int)strlen((char *)req)), conf.timeouts[STRING_L]) != res) {
|
if(socksend(param->remsock, req , (res = (int)strlen((char *)req)), conf.timeouts[STRING_L]) != res) {
|
||||||
RETURN(518);
|
RETURN(518);
|
||||||
}
|
}
|
||||||
param->statscli += res;
|
param->statscli64 += res;
|
||||||
param->nwrites++;
|
param->nwrites++;
|
||||||
}
|
}
|
||||||
inbuf = 0;
|
inbuf = 0;
|
||||||
#ifndef ANONYMOUS
|
#ifndef ANONYMOUS
|
||||||
if(anonymous!=1){
|
if(!anonymous){
|
||||||
|
int len = strlen((char *)buf);
|
||||||
|
len += sprintf((char*)buf + len, "Forwarded: for=");
|
||||||
|
if(*SAFAMILY(¶m->sincr) == AF_INET6) len += sprintf((char*)buf + len, "\"[");
|
||||||
|
len += myinet_ntop(*SAFAMILY(¶m->sincr), SAADDR(¶m->sincr), (char *)buf + len, 128);
|
||||||
|
if(*SAFAMILY(¶m->sincr) == AF_INET6) len += sprintf((char*)buf + len, "]:%d\";by=", (int)ntohs(*SAPORT(¶m->sincr)));
|
||||||
|
else len += sprintf((char*)buf + len, ":%d;by=", (int)ntohs(*SAPORT(¶m->sincr)));
|
||||||
|
gethostname((char *)(buf + len), 256);
|
||||||
|
sprintf((char*)buf+strlen((char *)buf), ":%d\r\n", (int)ntohs(*SAPORT(¶m->sincl)));
|
||||||
|
}
|
||||||
|
else if(anonymous>1){
|
||||||
sprintf((char*)buf+strlen((char *)buf), "Via: 1.1 ");
|
sprintf((char*)buf+strlen((char *)buf), "Via: 1.1 ");
|
||||||
gethostname((char *)(buf+strlen((char *)buf)), 256);
|
gethostname((char *)(buf+strlen((char *)buf)), 256);
|
||||||
sprintf((char*)buf+strlen((char *)buf), ":%d (%s %s)\r\nX-Forwarded-For: ", (int)ntohs(param->srv->intport), conf.stringtable?conf.stringtable[2]:(unsigned char *)"", conf.stringtable?conf.stringtable[3]:(unsigned char *)"");
|
sprintf((char*)buf+strlen((char *)buf), ":%d (%s %s)\r\nX-Forwarded-For: ", (int)ntohs(*SAPORT(¶m->srv->intsa)), conf.stringtable?conf.stringtable[2]:(unsigned char *)"", conf.stringtable?conf.stringtable[3]:(unsigned char *)"");
|
||||||
if(!anonymous)myinet_ntoa(param->sinc.sin_addr, (char *)buf + strlen((char *)buf));
|
if(anonymous != 2)myinet_ntop(*SAFAMILY(¶m->sincr), SAADDR(¶m->sincr), (char *)buf + strlen((char *)buf), 128);
|
||||||
else {
|
else {
|
||||||
unsigned long tmp;
|
unsigned long tmp;
|
||||||
|
|
||||||
tmp = param->sinc.sin_addr.s_addr;
|
tmp = ((unsigned long)myrand(param, sizeof(struct clientparam))<<16)^(unsigned long)rand();
|
||||||
param->sinc.sin_addr.s_addr = ((unsigned long)myrand(param, sizeof(struct clientparam))<<16)^(unsigned long)rand();
|
myinet_ntop(AF_INET, &tmp, (char *)buf + strlen((char *)buf), 64);
|
||||||
myinet_ntoa(param->sinc.sin_addr, (char *)buf + strlen((char *)buf));
|
|
||||||
param->sinc.sin_addr.s_addr = tmp;
|
|
||||||
}
|
}
|
||||||
sprintf((char*)buf+strlen((char *)buf), "\r\n");
|
sprintf((char*)buf+strlen((char *)buf), "\r\n");
|
||||||
}
|
}
|
||||||
@@ -846,7 +837,7 @@ for(;;){
|
|||||||
if(keepalive <= 1) sprintf((char*)buf+strlen((char *)buf), "%s: %s\r\n", (param->redirtype == R_HTTP)?"Proxy-Connection":"Connection", keepalive? "keep-alive":"close");
|
if(keepalive <= 1) sprintf((char*)buf+strlen((char *)buf), "%s: %s\r\n", (param->redirtype == R_HTTP)?"Proxy-Connection":"Connection", keepalive? "keep-alive":"close");
|
||||||
if(param->extusername){
|
if(param->extusername){
|
||||||
sprintf((char*)buf + strlen((char *)buf), "%s: basic ", (redirect)?"Proxy-Authorization":"Authorization");
|
sprintf((char*)buf + strlen((char *)buf), "%s: basic ", (redirect)?"Proxy-Authorization":"Authorization");
|
||||||
sprintf((char*)username, "%.32s:%.64s", param->extusername, param->extpassword?param->extpassword:(unsigned char*)"");
|
sprintf((char*)username, "%.128s:%.64s", param->extusername, param->extpassword?param->extpassword:(unsigned char*)"");
|
||||||
en64(username, buf+strlen((char *)buf), (int)strlen((char *)username));
|
en64(username, buf+strlen((char *)buf), (int)strlen((char *)username));
|
||||||
sprintf((char*)buf + strlen((char *)buf), "\r\n");
|
sprintf((char*)buf + strlen((char *)buf), "\r\n");
|
||||||
}
|
}
|
||||||
@@ -854,21 +845,21 @@ for(;;){
|
|||||||
if ((res = socksend(param->remsock, buf+reqlen, (int)strlen((char *)buf+reqlen), conf.timeouts[STRING_S])) != (int)strlen((char *)buf+reqlen)) {
|
if ((res = socksend(param->remsock, buf+reqlen, (int)strlen((char *)buf+reqlen), conf.timeouts[STRING_S])) != (int)strlen((char *)buf+reqlen)) {
|
||||||
RETURN(518);
|
RETURN(518);
|
||||||
}
|
}
|
||||||
param->statscli += res;
|
param->statscli64 += res;
|
||||||
param->nwrites++;
|
param->nwrites++;
|
||||||
if(param->bandlimfunc) {
|
if(param->bandlimfunc) {
|
||||||
sleeptime = param->bandlimfunc(param, 0, (int)strlen((char *)buf));
|
sleeptime = param->bandlimfunc(param, 0, (int)strlen((char *)buf));
|
||||||
}
|
}
|
||||||
if(contentlength > 0){
|
if(contentlength64 > 0){
|
||||||
param->nolongdatfilter = 0;
|
param->nolongdatfilter = 0;
|
||||||
param->waitclient = contentlength;
|
param->waitclient64 = contentlength64;
|
||||||
res = sockmap(param, conf.timeouts[CONNECTION_S]);
|
res = sockmap(param, conf.timeouts[CONNECTION_S]);
|
||||||
param->waitclient = 0;
|
param->waitclient64 = 0;
|
||||||
if(res != 99) {
|
if(res != 99) {
|
||||||
RETURN(res);
|
RETURN(res);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
contentlength = 0;
|
contentlength64 = 0;
|
||||||
inbuf = 0;
|
inbuf = 0;
|
||||||
ckeepalive = keepalive;
|
ckeepalive = keepalive;
|
||||||
res = 0;
|
res = 0;
|
||||||
@@ -901,13 +892,13 @@ for(;;){
|
|||||||
if(!sb)continue;
|
if(!sb)continue;
|
||||||
++sb;
|
++sb;
|
||||||
while(isspace(*sb))sb++;
|
while(isspace(*sb))sb++;
|
||||||
sscanf(sb, "%lu", &contentlength);
|
sscanf(sb, "%"PRINTF_INT64_MODIFIER"u", &contentlength64);
|
||||||
hascontent = 1;
|
hascontent = 1;
|
||||||
if(param->unsafefilter && param->ndatfilterssrv > 0) {
|
if(param->unsafefilter && param->ndatfilterssrv > 0) {
|
||||||
hascontent = 2;
|
hascontent = 2;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if(param->maxtrafin && (param->maxtrafin < param->statssrv || (unsigned)contentlength > param->maxtrafin - param->statssrv)){
|
if(param->maxtrafin64 && (param->maxtrafin64 < param->statssrv64 || contentlength64 + param->statssrv64 > param->maxtrafin64)){
|
||||||
RETURN(10);
|
RETURN(10);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -936,7 +927,7 @@ for(;;){
|
|||||||
}
|
}
|
||||||
if((res == 304 || res == 204) && !hascontent){
|
if((res == 304 || res == 204) && !hascontent){
|
||||||
hascontent = 1;
|
hascontent = 1;
|
||||||
contentlength = 0;
|
contentlength64 = 0;
|
||||||
}
|
}
|
||||||
if(param->bandlimfunc) {
|
if(param->bandlimfunc) {
|
||||||
int st1;
|
int st1;
|
||||||
@@ -960,25 +951,25 @@ for(;;){
|
|||||||
param->nolongdatfilter = 0;
|
param->nolongdatfilter = 0;
|
||||||
|
|
||||||
|
|
||||||
if (conf.filtermaxsize && contentlength > (unsigned long)conf.filtermaxsize) {
|
if (conf.filtermaxsize && contentlength64 > (uint64_t)conf.filtermaxsize) {
|
||||||
param->nolongdatfilter = 1;
|
param->nolongdatfilter = 1;
|
||||||
}
|
}
|
||||||
else if(param->unsafefilter && param->ndatfilterssrv > 0 && contentlength > 0 && param->operation != HTTP_HEAD && res != 204 && res != 304){
|
else if(param->unsafefilter && param->ndatfilterssrv > 0 && contentlength64 > 0 && param->operation != HTTP_HEAD && res != 204 && res != 304){
|
||||||
unsigned long newlen;
|
uint64_t newlen;
|
||||||
newlen = sockfillbuffsrv(param, (unsigned long) contentlength, CONNECTION_S);
|
newlen = (uint64_t)sockfillbuffsrv(param, (unsigned long) contentlength64, CONNECTION_S);
|
||||||
if(newlen == contentlength) {
|
if(newlen == contentlength64) {
|
||||||
action = handledatfltsrv(param, ¶m->srvbuf, ¶m->srvbufsize, 0, ¶m->srvinbuf);
|
action = handledatfltsrv(param, ¶m->srvbuf, ¶m->srvbufsize, 0, ¶m->srvinbuf);
|
||||||
param->nolongdatfilter = 1;
|
param->nolongdatfilter = 1;
|
||||||
if(action == HANDLED){
|
if(action == HANDLED){
|
||||||
RETURN(0);
|
RETURN(0);
|
||||||
}
|
}
|
||||||
if(action != PASS) RETURN(517);
|
if(action != PASS) RETURN(517);
|
||||||
contentlength = param->srvinbuf;
|
contentlength64 = param->srvinbuf;
|
||||||
sprintf((char*)buf+strlen((char *)buf), "Content-Length: %lu\r\n", contentlength);
|
sprintf((char*)buf+strlen((char *)buf), "Content-Length: %"PRINTF_INT64_MODIFIER"u\r\n", contentlength64);
|
||||||
hascontent = 1;
|
hascontent = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (contentlength > 0 && hascontent != 1) ckeepalive = 0;
|
if (contentlength64 > 0 && hascontent != 1) ckeepalive = 0;
|
||||||
#else
|
#else
|
||||||
#endif
|
#endif
|
||||||
if(!isconnect || param->operation){
|
if(!isconnect || param->operation){
|
||||||
@@ -997,7 +988,7 @@ for(;;){
|
|||||||
RETURN(521);
|
RETURN(521);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if((param->chunked || contentlength > 0) && param->operation != HTTP_HEAD && res != 204 && res != 304) {
|
if((param->chunked || contentlength64 > 0) && param->operation != HTTP_HEAD && res != 204 && res != 304) {
|
||||||
do {
|
do {
|
||||||
if(param->chunked){
|
if(param->chunked){
|
||||||
char smallbuf[32];
|
char smallbuf[32];
|
||||||
@@ -1022,18 +1013,18 @@ for(;;){
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
smallbuf[i] = 0;
|
smallbuf[i] = 0;
|
||||||
contentlength = 0;
|
contentlength64 = 0;
|
||||||
sscanf(smallbuf, "%lx", &contentlength);
|
sscanf(smallbuf, "%"PRINTF_INT64_MODIFIER"x", &contentlength64);
|
||||||
if(contentlength == 0) {
|
if(contentlength64 == 0) {
|
||||||
param->chunked = 2;
|
param->chunked = 2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(param->chunked != 2){
|
if(param->chunked != 2){
|
||||||
param->waitserver = contentlength;
|
param->waitserver64 = contentlength64;
|
||||||
if((res = sockmap(param, conf.timeouts[CONNECTION_S])) != 98){
|
if((res = sockmap(param, conf.timeouts[CONNECTION_S])) != 98){
|
||||||
RETURN(res);
|
RETURN(res);
|
||||||
}
|
}
|
||||||
param->waitserver = 0;
|
param->waitserver64 = 0;
|
||||||
}
|
}
|
||||||
} while(param->chunked);
|
} while(param->chunked);
|
||||||
}
|
}
|
||||||
@@ -1046,8 +1037,7 @@ for(;;){
|
|||||||
else if(!hascontent && !param->chunked) {
|
else if(!hascontent && !param->chunked) {
|
||||||
RETURN(sockmap(param, conf.timeouts[CONNECTION_S]));
|
RETURN(sockmap(param, conf.timeouts[CONNECTION_S]));
|
||||||
}
|
}
|
||||||
contentlength = 0;
|
contentlength64 = 0;
|
||||||
|
|
||||||
REQUESTEND:
|
REQUESTEND:
|
||||||
|
|
||||||
if((!ckeepalive || !keepalive) && param->remsock != INVALID_SOCKET){
|
if((!ckeepalive || !keepalive) && param->remsock != INVALID_SOCKET){
|
||||||
@@ -1069,6 +1059,10 @@ CLEANRET:
|
|||||||
if(param->res == 10) {
|
if(param->res == 10) {
|
||||||
socksend(param->clisock, (unsigned char *)proxy_stringtable[2], (int)strlen(proxy_stringtable[2]), conf.timeouts[STRING_S]);
|
socksend(param->clisock, (unsigned char *)proxy_stringtable[2], (int)strlen(proxy_stringtable[2]), conf.timeouts[STRING_S]);
|
||||||
}
|
}
|
||||||
|
else if (res == 700 || res == 701){
|
||||||
|
socksend(param->clisock, (unsigned char *)proxy_stringtable[16], (int)strlen(proxy_stringtable[16]), conf.timeouts[STRING_S]);
|
||||||
|
socksend(param->clisock, (unsigned char *)ftpbuf, inftpbuf, conf.timeouts[STRING_S]);
|
||||||
|
}
|
||||||
else if(param->res == 100 || (param->res >10 && param->res < 20) || (param->res >701 && param->res <= 705)) {
|
else if(param->res == 100 || (param->res >10 && param->res < 20) || (param->res >701 && param->res <= 705)) {
|
||||||
socksend(param->clisock, (unsigned char *)proxy_stringtable[1], (int)strlen(proxy_stringtable[1]), conf.timeouts[STRING_S]);
|
socksend(param->clisock, (unsigned char *)proxy_stringtable[1], (int)strlen(proxy_stringtable[1]), conf.timeouts[STRING_S]);
|
||||||
}
|
}
|
||||||
@@ -1078,7 +1072,7 @@ CLEANRET:
|
|||||||
else if(param->res >=30 && param->res < 80) {
|
else if(param->res >=30 && param->res < 80) {
|
||||||
socksend(param->clisock, (unsigned char *)proxy_stringtable[5], (int)strlen(proxy_stringtable[5]), conf.timeouts[STRING_S]);
|
socksend(param->clisock, (unsigned char *)proxy_stringtable[5], (int)strlen(proxy_stringtable[5]), conf.timeouts[STRING_S]);
|
||||||
}
|
}
|
||||||
else if(param->res == 1 || (param->srv->nouser && param->res < 10)) {
|
else if(param->res == 1 || (!param->srv->needuser && param->res < 10)) {
|
||||||
socksend(param->clisock, (unsigned char *)proxy_stringtable[11], (int)strlen(proxy_stringtable[11]), conf.timeouts[STRING_S]);
|
socksend(param->clisock, (unsigned char *)proxy_stringtable[11], (int)strlen(proxy_stringtable[11]), conf.timeouts[STRING_S]);
|
||||||
}
|
}
|
||||||
else if(param->res < 10) {
|
else if(param->res < 10) {
|
||||||
|
|||||||
+27
-20
@@ -4,7 +4,6 @@
|
|||||||
|
|
||||||
please read License Agreement
|
please read License Agreement
|
||||||
|
|
||||||
$Id: proxy.h,v 1.92 2012-04-11 23:01:20 vlad Exp $
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define COPYRIGHT "(c)2000-2009 3APA3A, Vladimir Dubrovin & 3proxy.ru\n"\
|
#define COPYRIGHT "(c)2000-2009 3APA3A, Vladimir Dubrovin & 3proxy.ru\n"\
|
||||||
@@ -42,7 +41,7 @@
|
|||||||
#define NOCOUNTOUT 8
|
#define NOCOUNTOUT 8
|
||||||
|
|
||||||
#define UDPBUFSIZE 16384
|
#define UDPBUFSIZE 16384
|
||||||
#define TCPBUFSIZE 4096
|
#define TCPBUFSIZE 8192
|
||||||
|
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
@@ -59,13 +58,13 @@
|
|||||||
#ifndef FD_SETSIZE
|
#ifndef FD_SETSIZE
|
||||||
#define FD_SETSIZE 4096
|
#define FD_SETSIZE 4096
|
||||||
#endif
|
#endif
|
||||||
#include <errno.h>
|
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <sys/uio.h>
|
#include <sys/uio.h>
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#include <syslog.h>
|
#include <syslog.h>
|
||||||
|
#include <errno.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __CYGWIN__
|
#ifdef __CYGWIN__
|
||||||
@@ -78,7 +77,13 @@
|
|||||||
#undef errno
|
#undef errno
|
||||||
#endif
|
#endif
|
||||||
#define errno WSAGetLastError()
|
#define errno WSAGetLastError()
|
||||||
|
#ifdef EAGAIN
|
||||||
|
#undef EAGAIN
|
||||||
|
#endif
|
||||||
#define EAGAIN WSAEWOULDBLOCK
|
#define EAGAIN WSAEWOULDBLOCK
|
||||||
|
#ifdef EINTR
|
||||||
|
#undef EINTR
|
||||||
|
#endif
|
||||||
#define EINTR WSAEWOULDBLOCK
|
#define EINTR WSAEWOULDBLOCK
|
||||||
#define SLEEPTIME 1
|
#define SLEEPTIME 1
|
||||||
#define usleep Sleep
|
#define usleep Sleep
|
||||||
@@ -148,8 +153,8 @@ extern struct extparam conf;
|
|||||||
|
|
||||||
int sockmap(struct clientparam * param, int timeo);
|
int sockmap(struct clientparam * param, int timeo);
|
||||||
int socksend(SOCKET sock, unsigned char * buf, int bufsize, int to);
|
int socksend(SOCKET sock, unsigned char * buf, int bufsize, int to);
|
||||||
int socksendto(SOCKET sock, struct sockaddr_in * sin, unsigned char * buf, int bufsize, int to);
|
int socksendto(SOCKET sock, struct sockaddr * sin, unsigned char * buf, int bufsize, int to);
|
||||||
int sockrecvfrom(SOCKET sock, struct sockaddr_in * sin, unsigned char * buf, int bufsize, int to);
|
int sockrecvfrom(SOCKET sock, struct sockaddr * sin, unsigned char * buf, int bufsize, int to);
|
||||||
|
|
||||||
|
|
||||||
int sockgetcharcli(struct clientparam * param, int timeosec, int timeousec);
|
int sockgetcharcli(struct clientparam * param, int timeosec, int timeousec);
|
||||||
@@ -174,7 +179,6 @@ int init_sql(char * s);
|
|||||||
void close_sql();
|
void close_sql();
|
||||||
#endif
|
#endif
|
||||||
int doconnect(struct clientparam * param);
|
int doconnect(struct clientparam * param);
|
||||||
int nbnameauth(struct clientparam * param);
|
|
||||||
int alwaysauth(struct clientparam * param);
|
int alwaysauth(struct clientparam * param);
|
||||||
int ipauth(struct clientparam * param);
|
int ipauth(struct clientparam * param);
|
||||||
int doauth(struct clientparam * param);
|
int doauth(struct clientparam * param);
|
||||||
@@ -184,13 +188,14 @@ unsigned bandlimitfunc(struct clientparam *param, unsigned nbytesin, unsigned nb
|
|||||||
|
|
||||||
|
|
||||||
int scanaddr(const unsigned char *s, unsigned long * ip, unsigned long * mask);
|
int scanaddr(const unsigned char *s, unsigned long * ip, unsigned long * mask);
|
||||||
int myinet_ntoa(struct in_addr in, char * buf);
|
int myinet_ntop(int af, void *src, char *dst, socklen_t size);
|
||||||
extern unsigned long nservers[MAXNSERVERS];
|
extern struct nserver nservers[MAXNSERVERS];
|
||||||
extern unsigned long authnserver;
|
struct nserver authnserver;
|
||||||
unsigned long getip(unsigned char *name);
|
unsigned long getip(unsigned char *name);
|
||||||
unsigned long myresolver(unsigned char *);
|
unsigned long getip46(int family, unsigned char *name, struct sockaddr *sa);
|
||||||
unsigned long fakeresolver (unsigned char *name);
|
unsigned long myresolver(int, unsigned char *, unsigned char *);
|
||||||
int initdnshashtable(unsigned nhashsize);
|
unsigned long fakeresolver (int, unsigned char *, unsigned char*);
|
||||||
|
int inithashtable(struct hashtable *hashtable, unsigned nhashsize);
|
||||||
void freeparam(struct clientparam * param);
|
void freeparam(struct clientparam * param);
|
||||||
void clearstat(struct clientparam * param);
|
void clearstat(struct clientparam * param);
|
||||||
void dumpcounters(struct trafcount *tl, int counterd);
|
void dumpcounters(struct trafcount *tl, int counterd);
|
||||||
@@ -228,17 +233,20 @@ void mschap(const unsigned char *win_password,
|
|||||||
const unsigned char *challenge, unsigned char *response);
|
const unsigned char *challenge, unsigned char *response);
|
||||||
|
|
||||||
struct hashtable;
|
struct hashtable;
|
||||||
void hashadd(struct hashtable *ht, const unsigned char* name, unsigned long value, time_t expires);
|
void hashadd(struct hashtable *ht, const unsigned char* name, unsigned char* value, time_t expires);
|
||||||
|
|
||||||
|
void parsehost(int family, char *host, struct sockaddr *sa);
|
||||||
int parsehostname(char *hostname, struct clientparam *param, unsigned short port);
|
int parsehostname(char *hostname, struct clientparam *param, unsigned short port);
|
||||||
int parseusername(char *username, struct clientparam *param, int extpasswd);
|
int parseusername(char *username, struct clientparam *param, int extpasswd);
|
||||||
int parseconnusername(char *username, struct clientparam *param, int extpasswd, unsigned short port);
|
int parseconnusername(char *username, struct clientparam *param, int extpasswd, unsigned short port);
|
||||||
int ACLmatches(struct ace* acentry, struct clientparam * param);
|
int ACLmatches(struct ace* acentry, struct clientparam * param);
|
||||||
|
int checkACL(struct clientparam * param);
|
||||||
|
|
||||||
unsigned long udpresolve(unsigned char * name, unsigned *retttl, struct clientparam* param, int makeauth);
|
unsigned long udpresolve(int af, unsigned char * name, unsigned char * value, unsigned *retttl, struct clientparam* param, int makeauth);
|
||||||
|
|
||||||
struct ace * copyacl (struct ace *ac);
|
struct ace * copyacl (struct ace *ac);
|
||||||
struct auth * copyauth (struct auth *);
|
struct auth * copyauth (struct auth *);
|
||||||
|
void * itfree(void *data, void * retval);
|
||||||
void freeacl(struct ace *ac);
|
void freeacl(struct ace *ac);
|
||||||
void freeauth(struct auth *);
|
void freeauth(struct auth *);
|
||||||
void freefilter(struct filter *filter);
|
void freefilter(struct filter *filter);
|
||||||
@@ -258,6 +266,7 @@ void srvinit(struct srvparam * srv, struct clientparam *param);
|
|||||||
void srvinit2(struct srvparam * srv, struct clientparam *param);
|
void srvinit2(struct srvparam * srv, struct clientparam *param);
|
||||||
void srvfree(struct srvparam * srv);
|
void srvfree(struct srvparam * srv);
|
||||||
unsigned char * dologname (unsigned char *buf, unsigned char *name, const unsigned char *ext, ROTATION lt, time_t t);
|
unsigned char * dologname (unsigned char *buf, unsigned char *name, const unsigned char *ext, ROTATION lt, time_t t);
|
||||||
|
int readconfig(FILE * fp);
|
||||||
|
|
||||||
|
|
||||||
int myrand(void * entropy, int len);
|
int myrand(void * entropy, int len);
|
||||||
@@ -300,16 +309,14 @@ struct datatype;
|
|||||||
struct dictionary;
|
struct dictionary;
|
||||||
struct node;
|
struct node;
|
||||||
struct property;
|
struct property;
|
||||||
|
extern unsigned char tmpbuf[8192];
|
||||||
|
extern pthread_mutex_t config_mutex;
|
||||||
extern pthread_mutex_t bandlim_mutex;
|
extern pthread_mutex_t bandlim_mutex;
|
||||||
extern pthread_mutex_t hash_mutex;
|
extern pthread_mutex_t hash_mutex;
|
||||||
extern pthread_mutex_t tc_mutex;
|
extern pthread_mutex_t tc_mutex;
|
||||||
extern pthread_mutex_t pwl_mutex;
|
extern pthread_mutex_t pwl_mutex;
|
||||||
#ifndef NOODBC
|
extern pthread_mutex_t log_mutex;
|
||||||
extern pthread_mutex_t odbc_mutex;
|
extern int logmutexinit;
|
||||||
#endif
|
|
||||||
|
|
||||||
extern struct hashtable dns_table;
|
|
||||||
|
|
||||||
extern struct datatype datatypes[64];
|
extern struct datatype datatypes[64];
|
||||||
|
|
||||||
|
|||||||
+263
-195
@@ -4,14 +4,60 @@
|
|||||||
|
|
||||||
please read License Agreement
|
please read License Agreement
|
||||||
|
|
||||||
$Id: proxymain.c,v 1.85 2012-04-15 22:46:09 vlad Exp $
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "proxy.h"
|
#include "proxy.h"
|
||||||
|
|
||||||
|
|
||||||
|
#define param ((struct clientparam *) p)
|
||||||
|
#ifdef _WIN32
|
||||||
|
DWORD WINAPI threadfunc(LPVOID p) {
|
||||||
|
#else
|
||||||
|
void * threadfunc (void *p) {
|
||||||
|
#endif
|
||||||
|
int i = 0;
|
||||||
|
if(param->srv->cbsock != INVALID_SOCKET){
|
||||||
|
SASIZETYPE size = sizeof(param->sinsr);
|
||||||
|
for(i=0; i<3; i++){
|
||||||
|
param->remsock = so._accept(param->srv->cbsock, (struct sockaddr*)¶m->sinsr, &size);
|
||||||
|
if(param->remsock == INVALID_SOCKET) {
|
||||||
|
param->res = 13;
|
||||||
|
param->srv->logfunc(param, "Connect back accept() failed");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
#ifndef WITHMAIN
|
||||||
|
memcpy(¶m->req, ¶m->sinsr, size);
|
||||||
|
if(param->srv->acl) param->res = checkACL(param);
|
||||||
|
if(param->res){
|
||||||
|
param->srv->logfunc(param, "Connect back ACL failed");
|
||||||
|
so._closesocket(param->remsock);
|
||||||
|
param->remsock = INVALID_SOCKET;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
if(so._sendto(param->remsock, "C", 1, 0, (struct sockaddr*)¶m->sinsr, size) != 1){
|
||||||
|
param->srv->logfunc(param, "Connect back sending command failed");
|
||||||
|
so._closesocket(param->remsock);
|
||||||
|
param->remsock = INVALID_SOCKET;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(i == 3){
|
||||||
|
freeparam(param);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
((struct clientparam *) p)->srv->pf((struct clientparam *)p);
|
||||||
|
}
|
||||||
|
#ifdef _WIN32
|
||||||
|
return 0;
|
||||||
|
#else
|
||||||
|
return NULL;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
#undef param
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -43,7 +89,7 @@ int MODULEMAINFUNC (int argc, char** argv){
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
SOCKET sock = INVALID_SOCKET;
|
SOCKET sock = INVALID_SOCKET, new_sock = INVALID_SOCKET;
|
||||||
int i=0;
|
int i=0;
|
||||||
SASIZETYPE size;
|
SASIZETYPE size;
|
||||||
pthread_t thread;
|
pthread_t thread;
|
||||||
@@ -54,8 +100,15 @@ int MODULEMAINFUNC (int argc, char** argv){
|
|||||||
unsigned sleeptime;
|
unsigned sleeptime;
|
||||||
unsigned char buf[256];
|
unsigned char buf[256];
|
||||||
char *hostname=NULL;
|
char *hostname=NULL;
|
||||||
int opt = 1, isudp;
|
int opt = 1, isudp = 0, iscbl = 0, iscbc = 0;
|
||||||
|
unsigned char *cbc_string = NULL, *cbl_string = NULL;
|
||||||
|
#ifndef NOIPV6
|
||||||
|
struct sockaddr_in6 cbsa;
|
||||||
|
#else
|
||||||
|
struct sockaddr_in cbsa;
|
||||||
|
#endif
|
||||||
FILE *fp = NULL;
|
FILE *fp = NULL;
|
||||||
|
struct linger lg;
|
||||||
int nlog = 5000;
|
int nlog = 5000;
|
||||||
char loghelp[] =
|
char loghelp[] =
|
||||||
#ifdef STDMAIN
|
#ifdef STDMAIN
|
||||||
@@ -66,6 +119,7 @@ int MODULEMAINFUNC (int argc, char** argv){
|
|||||||
" -d go to background (daemon)\n"
|
" -d go to background (daemon)\n"
|
||||||
#else
|
#else
|
||||||
" -u never ask for username\n"
|
" -u never ask for username\n"
|
||||||
|
" -u2 always ask for username\n"
|
||||||
#endif
|
#endif
|
||||||
" -fFORMAT logging format (see documentation)\n"
|
" -fFORMAT logging format (see documentation)\n"
|
||||||
" -l log to stderr\n"
|
" -l log to stderr\n"
|
||||||
@@ -73,7 +127,13 @@ int MODULEMAINFUNC (int argc, char** argv){
|
|||||||
" -bBUFSIZE size of network buffer (default 4096 for TCP, 16384 for UDP)\n"
|
" -bBUFSIZE size of network buffer (default 4096 for TCP, 16384 for UDP)\n"
|
||||||
" -t be silent (do not log service start/stop)\n"
|
" -t be silent (do not log service start/stop)\n"
|
||||||
" -iIP ip address or internal interface (clients are expected to connect)\n"
|
" -iIP ip address or internal interface (clients are expected to connect)\n"
|
||||||
" -eIP ip address or external interface (outgoing connection will have this)\n";
|
" -eIP ip address or external interface (outgoing connection will have this)\n"
|
||||||
|
" -rHOST:PORT Use IP:port for connect back proxy instead of listen port\n"
|
||||||
|
" -RHOST:PORT Use PORT to listen connect back proxy connection to pass data to\n"
|
||||||
|
" -4 Use IPv4 for outgoing connections\n"
|
||||||
|
" -6 Use IPv6 for outgoing connections\n"
|
||||||
|
" -46 Prefer IPv4 for outgoing connections, use both IPv4 and IPv6\n"
|
||||||
|
" -64 Prefer IPv6 for outgoing connections, use both IPv4 and IPv6\n";
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
unsigned long ul = 1;
|
unsigned long ul = 1;
|
||||||
@@ -82,8 +142,6 @@ int MODULEMAINFUNC (int argc, char** argv){
|
|||||||
int inetd = 0;
|
int inetd = 0;
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
SOCKET new_sock = INVALID_SOCKET;
|
|
||||||
struct linger lg;
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
HANDLE h;
|
HANDLE h;
|
||||||
#endif
|
#endif
|
||||||
@@ -116,7 +174,7 @@ int MODULEMAINFUNC (int argc, char** argv){
|
|||||||
signal(SIGPIPE, SIG_IGN);
|
signal(SIGPIPE, SIG_IGN);
|
||||||
|
|
||||||
pthread_attr_init(&pa);
|
pthread_attr_init(&pa);
|
||||||
pthread_attr_setstacksize(&pa,PTHREAD_STACK_MIN + 16384);
|
pthread_attr_setstacksize(&pa,PTHREAD_STACK_MIN + 8192);
|
||||||
pthread_attr_setdetachstate(&pa,PTHREAD_CREATE_DETACHED);
|
pthread_attr_setdetachstate(&pa,PTHREAD_CREATE_DETACHED);
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
@@ -138,7 +196,7 @@ int MODULEMAINFUNC (int argc, char** argv){
|
|||||||
conf.services = conf.services->prev = &srv;
|
conf.services = conf.services->prev = &srv;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
srv.nouser = 1;
|
srv.needuser = 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
for (i=1; i<argc; i++) {
|
for (i=1; i<argc; i++) {
|
||||||
@@ -150,7 +208,8 @@ int MODULEMAINFUNC (int argc, char** argv){
|
|||||||
break;
|
break;
|
||||||
case 'l':
|
case 'l':
|
||||||
srv.logfunc = logstdout;
|
srv.logfunc = logstdout;
|
||||||
srv.logtarget = (unsigned char*)argv[i] + 2;
|
if(srv.logtarget) myfree(srv.logtarget);
|
||||||
|
srv.logtarget = mystrdup((unsigned char*)argv[i] + 2);
|
||||||
if(argv[i][2]) {
|
if(argv[i][2]) {
|
||||||
if(argv[i][2]=='@'){
|
if(argv[i][2]=='@'){
|
||||||
|
|
||||||
@@ -173,13 +232,25 @@ int MODULEMAINFUNC (int argc, char** argv){
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'i':
|
case 'i':
|
||||||
srv.intip = getip((unsigned char *)argv[i]+2);
|
getip46(46, argv[i]+2, (struct sockaddr *)&srv.intsa);
|
||||||
break;
|
break;
|
||||||
case 'e':
|
case 'e':
|
||||||
srv.extip = getip((unsigned char *)argv[i]+2);
|
{
|
||||||
|
#ifndef NOIPV6
|
||||||
|
struct sockaddr_in6 sa6;
|
||||||
|
error = !getip46(46, argv[i]+2, (struct sockaddr *)&sa6);
|
||||||
|
if(!error) memcpy((*SAFAMILY(&sa6)==AF_INET)?(void *)&srv.extsa:(void *)&srv.extsa6, &sa6, SASIZE(&sa6));
|
||||||
|
#else
|
||||||
|
error = !getip46(46, argv[i]+2, (struct sockaddr *)&srv.extsa);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 'p':
|
case 'p':
|
||||||
srv.intport = htons(atoi(argv[i]+2));
|
*SAPORT(&srv.intsa) = htons(atoi(argv[i]+2));
|
||||||
|
break;
|
||||||
|
case '4':
|
||||||
|
case '6':
|
||||||
|
srv.family = atoi(argv[i]+1);
|
||||||
break;
|
break;
|
||||||
case 'b':
|
case 'b':
|
||||||
srv.bufsize = atoi(argv[i]+2);
|
srv.bufsize = atoi(argv[i]+2);
|
||||||
@@ -190,16 +261,17 @@ int MODULEMAINFUNC (int argc, char** argv){
|
|||||||
#ifdef STDMAIN
|
#ifdef STDMAIN
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
case 'I':
|
case 'I':
|
||||||
size = sizeof(defparam.sinc);
|
size = sizeof(defparam.sincl);
|
||||||
if(so._getsockname(0, (struct sockaddr*)&defparam.sinc, &size) ||
|
if(so._getsockname(0, (struct sockaddr*)&defparam.sincl, &size) ||
|
||||||
defparam.sinc.sin_family != AF_INET) error = 1;
|
SAFAMILY(&defparam.sincl) != AF_INET) error = 1;
|
||||||
|
|
||||||
else inetd = 1;
|
else inetd = 1;
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
case 'f':
|
case 'f':
|
||||||
srv.logformat = (unsigned char *)argv[i] + 2;
|
if(srv.logformat)myfree(srv.logformat);
|
||||||
|
srv.logformat = mystrdup((unsigned char *)argv[i] + 2);
|
||||||
break;
|
break;
|
||||||
case 't':
|
case 't':
|
||||||
srv.silent = 1;
|
srv.silent = 1;
|
||||||
@@ -207,8 +279,17 @@ int MODULEMAINFUNC (int argc, char** argv){
|
|||||||
case 'h':
|
case 'h':
|
||||||
hostname = argv[i] + 2;
|
hostname = argv[i] + 2;
|
||||||
break;
|
break;
|
||||||
|
case 'r':
|
||||||
|
cbc_string = mystrdup(argv[i] + 2);
|
||||||
|
iscbc = 1;
|
||||||
|
break;
|
||||||
|
case 'R':
|
||||||
|
cbl_string = mystrdup(argv[i] + 2);
|
||||||
|
iscbl = 1;
|
||||||
|
break;
|
||||||
case 'u':
|
case 'u':
|
||||||
srv.nouser = 1;
|
srv.needuser = 0;
|
||||||
|
if(*(argv[i] + 2)) srv.needuser = atoi(argv[i] + 2);
|
||||||
break;
|
break;
|
||||||
case 'T':
|
case 'T':
|
||||||
srv.transparent = 1;
|
srv.transparent = 1;
|
||||||
@@ -240,6 +321,8 @@ int MODULEMAINFUNC (int argc, char** argv){
|
|||||||
"Available options are:\n"
|
"Available options are:\n"
|
||||||
"%s"
|
"%s"
|
||||||
" -pPORT - service port to accept connections\n"
|
" -pPORT - service port to accept connections\n"
|
||||||
|
" -RIP:PORT - connect back IP:PORT to listen and accept connections\n"
|
||||||
|
" -rIP:PORT - connect back IP:PORT to establish connect back connection\n"
|
||||||
"%s"
|
"%s"
|
||||||
"\tExample: %s -i127.0.0.1\n\n"
|
"\tExample: %s -i127.0.0.1\n\n"
|
||||||
"%s",
|
"%s",
|
||||||
@@ -259,7 +342,7 @@ int MODULEMAINFUNC (int argc, char** argv){
|
|||||||
else {
|
else {
|
||||||
#endif
|
#endif
|
||||||
#ifndef NOPORTMAP
|
#ifndef NOPORTMAP
|
||||||
if (error || argc != i+3 || *argv[i]=='-'|| (srv.intport = htons((unsigned short)atoi(argv[i])))==0 || (srv.targetport = htons((unsigned short)atoi(argv[i+2])))==0) {
|
if (error || argc != i+3 || *argv[i]=='-'|| (*SAPORT(&srv.intsa) = htons((unsigned short)atoi(argv[i])))==0 || (srv.targetport = htons((unsigned short)atoi(argv[i+2])))==0) {
|
||||||
#ifndef STDMAIN
|
#ifndef STDMAIN
|
||||||
haveerror = 1;
|
haveerror = 1;
|
||||||
conf.threadinit = 0;
|
conf.threadinit = 0;
|
||||||
@@ -269,6 +352,8 @@ int MODULEMAINFUNC (int argc, char** argv){
|
|||||||
" [-e<external_ip>] <port_to_bind>"
|
" [-e<external_ip>] <port_to_bind>"
|
||||||
" <target_hostname> <target_port>\n"
|
" <target_hostname> <target_port>\n"
|
||||||
"Available options are:\n"
|
"Available options are:\n"
|
||||||
|
" -RIP:PORT - connect back IP:PORT to listen and accept connections\n"
|
||||||
|
" -rIP:PORT - connect back IP:PORT to establish connect back connection\n"
|
||||||
"%s"
|
"%s"
|
||||||
"%s"
|
"%s"
|
||||||
"\tExample: %s -d -i127.0.0.1 6666 serv.somehost.ru 6666\n\n"
|
"\tExample: %s -d -i127.0.0.1 6666 serv.somehost.ru 6666\n\n"
|
||||||
@@ -311,8 +396,12 @@ int MODULEMAINFUNC (int argc, char** argv){
|
|||||||
|
|
||||||
|
|
||||||
srvinit2(&srv, &defparam);
|
srvinit2(&srv, &defparam);
|
||||||
if(!srv.intport) srv.intport = htons(childdef.port);
|
if(!*SAFAMILY(&srv.intsa)) *SAFAMILY(&srv.intsa) = AF_INET;
|
||||||
if(!defparam.sinc.sin_port) defparam.sinc.sin_port = htons(childdef.port);
|
if(!*SAPORT(&srv.intsa)) *SAPORT(&srv.intsa) = htons(childdef.port);
|
||||||
|
*SAFAMILY(&srv.extsa) = AF_INET;
|
||||||
|
#ifndef NOIPV6
|
||||||
|
*SAFAMILY(&srv.extsa6) = AF_INET6;
|
||||||
|
#endif
|
||||||
if(hostname)parsehostname(hostname, &defparam, childdef.port);
|
if(hostname)parsehostname(hostname, &defparam, childdef.port);
|
||||||
|
|
||||||
|
|
||||||
@@ -324,58 +413,83 @@ int MODULEMAINFUNC (int argc, char** argv){
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if(srv.srvsock == INVALID_SOCKET){
|
|
||||||
|
|
||||||
if(!isudp){
|
|
||||||
lg.l_onoff = 1;
|
if (!iscbc) {
|
||||||
lg.l_linger = conf.timeouts[STRING_L];
|
if(srv.srvsock == INVALID_SOCKET){
|
||||||
sock=so._socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
|
|
||||||
}
|
if(!isudp){
|
||||||
else {
|
lg.l_onoff = 1;
|
||||||
sock=so._socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP);
|
lg.l_linger = conf.timeouts[STRING_L];
|
||||||
}
|
sock=so._socket(SASOCK(&srv.intsa), SOCK_STREAM, IPPROTO_TCP);
|
||||||
if( sock == INVALID_SOCKET) {
|
}
|
||||||
perror("socket()");
|
else {
|
||||||
return -2;
|
sock=so._socket(SASOCK(&srv.intsa), SOCK_DGRAM, IPPROTO_UDP);
|
||||||
}
|
}
|
||||||
|
if( sock == INVALID_SOCKET) {
|
||||||
|
perror("socket()");
|
||||||
|
return -2;
|
||||||
|
}
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
ioctlsocket(sock, FIONBIO, &ul);
|
ioctlsocket(sock, FIONBIO, &ul);
|
||||||
#else
|
#else
|
||||||
fcntl(sock,F_SETFL,O_NONBLOCK);
|
fcntl(sock,F_SETFL,O_NONBLOCK);
|
||||||
#endif
|
#endif
|
||||||
srv.srvsock = sock;
|
srv.srvsock = sock;
|
||||||
if(so._setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (unsigned char *)&opt, sizeof(int)))perror("setsockopt()");
|
opt = 1;
|
||||||
|
if(so._setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (unsigned char *)&opt, sizeof(int)))perror("setsockopt()");
|
||||||
#ifdef SO_REUSEPORT
|
#ifdef SO_REUSEPORT
|
||||||
so._setsockopt(sock, SOL_SOCKET, SO_REUSEPORT, (unsigned char *)&opt, sizeof(int));
|
opt = 1;
|
||||||
|
so._setsockopt(sock, SOL_SOCKET, SO_REUSEPORT, (unsigned char *)&opt, sizeof(int));
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
size = sizeof(srv.intsa);
|
||||||
|
for(sleeptime = SLEEPTIME * 100; so._bind(sock, (struct sockaddr*)&srv.intsa, size)==-1; usleep(sleeptime)) {
|
||||||
|
sprintf((char *)buf, "bind(): %s", strerror(errno));
|
||||||
|
if(!srv.silent)(*srv.logfunc)(&defparam, buf);
|
||||||
|
sleeptime = (sleeptime<<1);
|
||||||
|
if(!sleeptime) {
|
||||||
|
so._closesocket(sock);
|
||||||
|
return -3;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(!isudp){
|
||||||
|
if(so._listen (sock, 1 + (srv.maxchild>>4))==-1) {
|
||||||
|
sprintf((char *)buf, "listen(): %s", strerror(errno));
|
||||||
|
if(!srv.silent)(*srv.logfunc)(&defparam, buf);
|
||||||
|
return -4;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
defparam.clisock = sock;
|
||||||
|
|
||||||
size = sizeof(defparam.sinc);
|
if(!srv.silent && !iscbc){
|
||||||
for(sleeptime = SLEEPTIME * 100; so._bind(sock, (struct sockaddr*)&defparam.sinc, size)==-1; usleep(sleeptime)) {
|
sprintf((char *)buf, "Accepting connections [%u/%u]", (unsigned)getpid(), (unsigned)pthread_self());
|
||||||
sprintf((char *)buf, "bind(): %s", strerror(errno));
|
(*srv.logfunc)(&defparam, buf);
|
||||||
if(!srv.silent)(*srv.logfunc)(&defparam, buf);
|
|
||||||
sleeptime = (sleeptime<<1);
|
|
||||||
if(!sleeptime) {
|
|
||||||
so._closesocket(sock);
|
|
||||||
return -3;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(!isudp){
|
if(iscbl){
|
||||||
if(so._listen (sock, 1 + (srv.maxchild>>4))==-1) {
|
parsehost(srv.family, cbl_string, (struct sockaddr *)&cbsa);
|
||||||
sprintf((char *)buf, "listen(): %s", strerror(errno));
|
if((srv.cbsock=so._socket(SASOCK(&cbsa), SOCK_STREAM, IPPROTO_TCP))==INVALID_SOCKET) {
|
||||||
if(!srv.silent)(*srv.logfunc)(&defparam, buf);
|
(*srv.logfunc)(&defparam, "Failed to allocate connect back socket");
|
||||||
return -4;
|
return -6;
|
||||||
|
}
|
||||||
|
opt = 1;
|
||||||
|
so._setsockopt(srv.cbsock, SOL_SOCKET, SO_REUSEADDR, (unsigned char *)&opt, sizeof(int));
|
||||||
|
#ifdef SO_REUSEPORT
|
||||||
|
opt = 1;
|
||||||
|
so._setsockopt(srv.cbsock, SOL_SOCKET, SO_REUSEPORT, (unsigned char *)&opt, sizeof(int));
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if(so._bind(srv.cbsock, (struct sockaddr*)&cbsa, sizeof(cbsa))==-1) {
|
||||||
|
(*srv.logfunc)(&defparam, "Failed to bind connect back socket");
|
||||||
|
return -7;
|
||||||
|
}
|
||||||
|
if(so._listen(srv.cbsock, 1 + (srv.maxchild>>4))==-1) {
|
||||||
|
(*srv.logfunc)(&defparam, "Failed to listen connect back socket");
|
||||||
|
return -8;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
defparam.clisock = sock;
|
|
||||||
|
|
||||||
if(!srv.silent){
|
|
||||||
sprintf((char *)buf, "Accepting connections [%u/%u]", (unsigned)getpid(), (unsigned)pthread_self());
|
|
||||||
(*srv.logfunc)(&defparam, buf);
|
|
||||||
}
|
|
||||||
defparam.sinc.sin_addr.s_addr = defparam.sins.sin_addr.s_addr = 0;
|
|
||||||
defparam.sinc.sin_port = defparam.sins.sin_port = 0;
|
|
||||||
|
|
||||||
srv.fds.fd = sock;
|
srv.fds.fd = sock;
|
||||||
srv.fds.events = POLLIN;
|
srv.fds.events = POLLIN;
|
||||||
@@ -392,6 +506,7 @@ int MODULEMAINFUNC (int argc, char** argv){
|
|||||||
}
|
}
|
||||||
usleep(SLEEPTIME);
|
usleep(SLEEPTIME);
|
||||||
}
|
}
|
||||||
|
if (iscbc) break;
|
||||||
if (conf.paused != srv.version) break;
|
if (conf.paused != srv.version) break;
|
||||||
if (srv.fds.events & POLLIN) {
|
if (srv.fds.events & POLLIN) {
|
||||||
error = so._poll(&srv.fds, 1, 1000);
|
error = so._poll(&srv.fds, 1, 1000);
|
||||||
@@ -407,14 +522,43 @@ int MODULEMAINFUNC (int argc, char** argv){
|
|||||||
if(!srv.silent)(*srv.logfunc)(&defparam, buf);
|
if(!srv.silent)(*srv.logfunc)(&defparam, buf);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
if((conf.paused != srv.version) || (error < 0)) break;
|
if((conf.paused != srv.version) || (error < 0)) break;
|
||||||
if(!isudp){
|
if(!isudp){
|
||||||
size = sizeof(defparam.sinc);
|
size = sizeof(defparam.sincr);
|
||||||
new_sock = so._accept(sock, (struct sockaddr*)&defparam.sinc, &size);
|
if(iscbc){
|
||||||
if(new_sock == INVALID_SOCKET){
|
new_sock=so._socket(SASOCK(&defparam.sincr), SOCK_STREAM, IPPROTO_TCP);
|
||||||
sprintf((char *)buf, "accept(): %s", strerror(errno));
|
if(new_sock != INVALID_SOCKET){
|
||||||
|
parsehost(srv.family, cbc_string, (struct sockaddr *)&defparam.sincr);
|
||||||
|
if(so._connect(new_sock,(struct sockaddr *)&defparam.sincr,sizeof(defparam.sincr))) {
|
||||||
|
so._closesocket(new_sock);
|
||||||
|
new_sock = INVALID_SOCKET;
|
||||||
|
usleep(SLEEPTIME);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if(so._recvfrom(new_sock,buf,1,0,(struct sockaddr*)&defparam.sincr, &size) != 1) {
|
||||||
|
so._closesocket(new_sock);
|
||||||
|
new_sock = INVALID_SOCKET;
|
||||||
|
usleep(SLEEPTIME);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
usleep(SLEEPTIME);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
new_sock = so._accept(sock, (struct sockaddr*)&defparam.sincr, &size);
|
||||||
|
if(new_sock == INVALID_SOCKET){
|
||||||
|
sprintf((char *)buf, "accept(): %s", strerror(errno));
|
||||||
|
if(!srv.silent)(*srv.logfunc)(&defparam, buf);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
size = sizeof(defparam.sincl);
|
||||||
|
if(so._getsockname(new_sock, (struct sockaddr *)&defparam.sincl, &size)){
|
||||||
|
sprintf((char *)buf, "getsockname(): %s", strerror(errno));
|
||||||
if(!srv.silent)(*srv.logfunc)(&defparam, buf);
|
if(!srv.silent)(*srv.logfunc)(&defparam, buf);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -426,8 +570,9 @@ int MODULEMAINFUNC (int argc, char** argv){
|
|||||||
so._setsockopt(new_sock, SOL_SOCKET, SO_LINGER, (unsigned char *)&lg, sizeof(lg));
|
so._setsockopt(new_sock, SOL_SOCKET, SO_LINGER, (unsigned char *)&lg, sizeof(lg));
|
||||||
so._setsockopt(new_sock, SOL_SOCKET, SO_OOBINLINE, (unsigned char *)&opt, sizeof(int));
|
so._setsockopt(new_sock, SOL_SOCKET, SO_OOBINLINE, (unsigned char *)&opt, sizeof(int));
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
srv.fds.events = 0;
|
srv.fds.events = 0;
|
||||||
|
}
|
||||||
if(! (newparam = myalloc (sizeof(defparam)))){
|
if(! (newparam = myalloc (sizeof(defparam)))){
|
||||||
if(!isudp) so._closesocket(new_sock);
|
if(!isudp) so._closesocket(new_sock);
|
||||||
defparam.res = 21;
|
defparam.res = 21;
|
||||||
@@ -456,9 +601,9 @@ int MODULEMAINFUNC (int argc, char** argv){
|
|||||||
}
|
}
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#ifndef _WINCE
|
#ifndef _WINCE
|
||||||
h = (HANDLE)_beginthreadex((LPSECURITY_ATTRIBUTES )NULL, (unsigned)16384, (BEGINTHREADFUNC)srv.pf, (void *) newparam, 0, &thread);
|
h = (HANDLE)_beginthreadex((LPSECURITY_ATTRIBUTES )NULL, (unsigned)16384, threadfunc, (void *) newparam, 0, &thread);
|
||||||
#else
|
#else
|
||||||
h = (HANDLE)CreateThread((LPSECURITY_ATTRIBUTES )NULL, (unsigned)32768, (BEGINTHREADFUNC)srv.pf, (void *) newparam, 0, &thread);
|
h = (HANDLE)CreateThread((LPSECURITY_ATTRIBUTES )NULL, (unsigned)16384, threadfunc, (void *) newparam, 0, &thread);
|
||||||
#endif
|
#endif
|
||||||
srv.childcount++;
|
srv.childcount++;
|
||||||
if (h) {
|
if (h) {
|
||||||
@@ -472,7 +617,7 @@ int MODULEMAINFUNC (int argc, char** argv){
|
|||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
|
||||||
error = pthread_create(&thread, &pa, (PTHREADFUNC)srv.pf, (void *)newparam);
|
error = pthread_create(&thread, &pa, threadfunc, (void *)newparam);
|
||||||
srv.childcount++;
|
srv.childcount++;
|
||||||
if(error){
|
if(error){
|
||||||
sprintf((char *)buf, "pthread_create(): %s", strerror(error));
|
sprintf((char *)buf, "pthread_create(): %s", strerror(error));
|
||||||
@@ -484,22 +629,28 @@ int MODULEMAINFUNC (int argc, char** argv){
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
pthread_mutex_unlock(&srv.counter_mutex);
|
pthread_mutex_unlock(&srv.counter_mutex);
|
||||||
memset(&defparam.sinc, 0, sizeof(defparam.sinc));
|
memset(&defparam.sincl, 0, sizeof(defparam.sincl));
|
||||||
|
memset(&defparam.sincr, 0, sizeof(defparam.sincr));
|
||||||
if(isudp) while(!srv.fds.events)usleep(SLEEPTIME);
|
if(isudp) while(!srv.fds.events)usleep(SLEEPTIME);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!srv.silent) srv.logfunc(&defparam, (unsigned char *)"Exiting thread");
|
if(!srv.silent) srv.logfunc(&defparam, (unsigned char *)"Exiting thread");
|
||||||
if(fp) fclose(fp);
|
if(fp) fclose(fp);
|
||||||
|
|
||||||
srvfree(&srv);
|
srvfree(&srv);
|
||||||
if(defparam.hostname)myfree(defparam.hostname);
|
|
||||||
|
|
||||||
#ifndef STDMAIN
|
#ifndef STDMAIN
|
||||||
|
pthread_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;
|
||||||
freeacl(srv.acl);
|
pthread_mutex_unlock(&config_mutex);
|
||||||
freeauth(srv.authfuncs);
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
if(defparam.hostname)myfree(defparam.hostname);
|
||||||
|
if(cbc_string)myfree(cbc_string);
|
||||||
|
if(cbl_string)myfree(cbl_string);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -509,48 +660,67 @@ void srvinit(struct srvparam * srv, struct clientparam *param){
|
|||||||
memset(srv, 0, sizeof(struct srvparam));
|
memset(srv, 0, sizeof(struct srvparam));
|
||||||
srv->version = conf.paused;
|
srv->version = conf.paused;
|
||||||
srv->logfunc = conf.logfunc;
|
srv->logfunc = conf.logfunc;
|
||||||
srv->logformat = conf.logformat;
|
if(srv->logformat)myfree(srv->logformat);
|
||||||
|
srv->logformat = conf.logformat? mystrdup(conf.logformat) : NULL;
|
||||||
srv->authfunc = conf.authfunc;
|
srv->authfunc = conf.authfunc;
|
||||||
srv->usentlm = 0;
|
srv->usentlm = 0;
|
||||||
srv->maxchild = conf.maxchild;
|
srv->maxchild = conf.maxchild;
|
||||||
srv->time_start = time(NULL);
|
srv->time_start = time(NULL);
|
||||||
srv->logtarget = conf.logtarget;
|
if(conf.logtarget){
|
||||||
|
if(srv->logtarget) myfree(srv->logtarget);
|
||||||
|
srv->logtarget = mystrdup(conf.logtarget);
|
||||||
|
}
|
||||||
srv->srvsock = INVALID_SOCKET;
|
srv->srvsock = INVALID_SOCKET;
|
||||||
srv->logdumpsrv = conf.logdumpsrv;
|
srv->logdumpsrv = conf.logdumpsrv;
|
||||||
srv->logdumpcli = conf.logdumpcli;
|
srv->logdumpcli = conf.logdumpcli;
|
||||||
|
srv->cbsock = INVALID_SOCKET;
|
||||||
|
srv->needuser = 1;
|
||||||
memset(param, 0, sizeof(struct clientparam));
|
memset(param, 0, sizeof(struct clientparam));
|
||||||
param->srv = srv;
|
param->srv = srv;
|
||||||
param->remsock = param->clisock = param->ctrlsock = param->ctrlsocksrv = INVALID_SOCKET;
|
param->remsock = param->clisock = param->ctrlsock = param->ctrlsocksrv = INVALID_SOCKET;
|
||||||
param->req.sin_family = param->sins.sin_family = param->sinc.sin_family = 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);
|
pthread_mutex_init(&srv->counter_mutex, NULL);
|
||||||
|
memcpy(&srv->intsa, &conf.intsa, sizeof(srv->intsa));
|
||||||
|
memcpy(&srv->extsa, &conf.extsa, sizeof(srv->extsa));
|
||||||
|
#ifndef NOIPV6
|
||||||
|
memcpy(&srv->extsa6, &conf.extsa6, sizeof(srv->extsa6));
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void srvinit2(struct srvparam * srv, struct clientparam *param){
|
void srvinit2(struct srvparam * srv, struct clientparam *param){
|
||||||
if(srv->logformat){
|
if(srv->logformat){
|
||||||
char *s;
|
char *s;
|
||||||
if(*srv->logformat == '-' && (s = strchr((char *)srv->logformat + 1, '+')) && s[1]){
|
if(*srv->logformat == '-' && (s = strchr((char *)srv->logformat + 1, '+')) && s[1]){
|
||||||
|
char* logformat = srv->logformat;
|
||||||
|
|
||||||
*s = 0;
|
*s = 0;
|
||||||
srv->nonprintable = (unsigned char *)mystrdup((char *)srv->logformat + 1);
|
srv->nonprintable = (unsigned char *)mystrdup((char *)srv->logformat + 1);
|
||||||
srv->replace = s[1];
|
srv->replace = s[1];
|
||||||
srv->logformat = (unsigned char *)mystrdup(s + 2);
|
srv->logformat = (unsigned char *)mystrdup(s + 2);
|
||||||
*s = '+';
|
*s = '+';
|
||||||
|
myfree(logformat);
|
||||||
}
|
}
|
||||||
else srv->logformat = (unsigned char *)mystrdup((char *)srv->logformat);
|
|
||||||
}
|
}
|
||||||
if(srv->logtarget) srv->logtarget = (unsigned char *)mystrdup((char *)srv->logtarget);
|
memset(¶m->sinsl, 0, sizeof(param->sinsl));
|
||||||
if(!srv->intip) srv->intip = conf.intip;
|
memset(¶m->sinsr, 0, sizeof(param->sinsr));
|
||||||
param->sinc.sin_addr.s_addr = srv->intip;
|
memset(¶m->req, 0, sizeof(param->req));
|
||||||
param->sinc.sin_port = srv->intport;
|
*SAFAMILY(¶m->sinsl) = AF_INET;
|
||||||
if(!srv->extip) srv->extip = conf.extip;
|
*SAFAMILY(¶m->sinsr) = AF_INET;
|
||||||
param->sins.sin_addr.s_addr = param->extip = srv->extip;
|
*SAFAMILY(¶m->req) = AF_INET;
|
||||||
if(!srv->extport) srv->extport = htons(conf.extport);
|
memcpy(¶m->sincr, &srv->intsa, sizeof(param->sincr));
|
||||||
param->sins.sin_port = param->extport = srv->extport;
|
memcpy(¶m->sincl, &srv->intsa, sizeof(param->sincl));
|
||||||
|
#ifndef NOIPV6
|
||||||
|
memcpy(¶m->sinsr, (srv->family == 6 || srv->family == 64)? (void *)&srv->extsa6: (void *)&srv->extsa, sizeof(param->sinsl));
|
||||||
|
#else
|
||||||
|
memcpy(¶m->sinsr, &srv->extsa, sizeof(param->sinsl));
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void srvfree(struct srvparam * srv){
|
void srvfree(struct srvparam * srv){
|
||||||
if(srv->srvsock != INVALID_SOCKET) so._closesocket(srv->srvsock);
|
if(srv->srvsock != INVALID_SOCKET) so._closesocket(srv->srvsock);
|
||||||
srv->srvsock = INVALID_SOCKET;
|
srv->srvsock = INVALID_SOCKET;
|
||||||
|
if(srv->cbsock != INVALID_SOCKET) so._closesocket(srv->cbsock);
|
||||||
|
srv->cbsock = INVALID_SOCKET;
|
||||||
srv->service = S_ZOMBIE;
|
srv->service = S_ZOMBIE;
|
||||||
while(srv->child) usleep(SLEEPTIME * 100);
|
while(srv->child) usleep(SLEEPTIME * 100);
|
||||||
#ifndef STDMAIN
|
#ifndef STDMAIN
|
||||||
@@ -563,6 +733,9 @@ void srvfree(struct srvparam * srv){
|
|||||||
}
|
}
|
||||||
myfree(srv->filter);
|
myfree(srv->filter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(srv->acl)freeacl(srv->acl);
|
||||||
|
if(srv->authfuncs)freeauth(srv->authfuncs);
|
||||||
#endif
|
#endif
|
||||||
pthread_mutex_destroy(&srv->counter_mutex);
|
pthread_mutex_destroy(&srv->counter_mutex);
|
||||||
if(srv->target) myfree(srv->target);
|
if(srv->target) myfree(srv->target);
|
||||||
@@ -746,18 +919,11 @@ FILTER_ACTION makefilters (struct srvparam *srv, struct clientparam *param){
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void * itfree(void *data, void * retval){
|
void * itfree(void *data, void * retval){
|
||||||
myfree(data);
|
myfree(data);
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
void freepwl(struct passwords *pwl){
|
|
||||||
for(; pwl; pwl = (struct passwords *)itfree(pwl, pwl->next)){
|
|
||||||
if(pwl->user)myfree(pwl->user);
|
|
||||||
if(pwl->password)myfree(pwl->password);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void freeauth(struct auth * authfuncs){
|
void freeauth(struct auth * authfuncs){
|
||||||
for(; authfuncs; authfuncs = (struct auth *)itfree(authfuncs, authfuncs->next));
|
for(; authfuncs; authfuncs = (struct auth *)itfree(authfuncs, authfuncs->next));
|
||||||
}
|
}
|
||||||
@@ -787,104 +953,6 @@ void freeacl(struct ace *ac){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void freeconf(struct extparam *confp){
|
|
||||||
struct bandlim * bl;
|
|
||||||
struct bandlim * blout;
|
|
||||||
struct trafcount * tc;
|
|
||||||
struct passwords *pw;
|
|
||||||
struct ace *acl;
|
|
||||||
struct filemon *fm;
|
|
||||||
int counterd, archiverc;
|
|
||||||
unsigned char *logname, *logtarget;
|
|
||||||
unsigned char **archiver;
|
|
||||||
unsigned char * logformat;
|
|
||||||
|
|
||||||
int i;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
pthread_mutex_lock(&tc_mutex);
|
|
||||||
confp->trafcountfunc = NULL;
|
|
||||||
tc = confp->trafcounter;
|
|
||||||
confp->trafcounter = NULL;
|
|
||||||
counterd = confp->counterd;
|
|
||||||
confp->counterd = -1;
|
|
||||||
pthread_mutex_unlock(&tc_mutex);
|
|
||||||
if(tc)dumpcounters(tc,counterd);
|
|
||||||
for(; tc; tc = (struct trafcount *) itfree(tc, tc->next)){
|
|
||||||
if(tc->comment)myfree(tc->comment);
|
|
||||||
freeacl(tc->ace);
|
|
||||||
}
|
|
||||||
confp->countertype = NONE;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
logtarget = confp->logtarget;
|
|
||||||
confp->logtarget = NULL;
|
|
||||||
logformat = confp->logformat;
|
|
||||||
confp->logformat = NULL;
|
|
||||||
|
|
||||||
pthread_mutex_lock(&bandlim_mutex);
|
|
||||||
bl = confp->bandlimiter;
|
|
||||||
blout = confp->bandlimiterout;
|
|
||||||
confp->bandlimiter = NULL;
|
|
||||||
confp->bandlimiterout = NULL;
|
|
||||||
confp->bandlimfunc = NULL;
|
|
||||||
pthread_mutex_unlock(&bandlim_mutex);
|
|
||||||
|
|
||||||
logname = confp->logname;
|
|
||||||
confp->logname = NULL;
|
|
||||||
archiverc = confp->archiverc;
|
|
||||||
confp->archiverc = 0;
|
|
||||||
archiver = confp->archiver;
|
|
||||||
confp->archiver = NULL;
|
|
||||||
fm = confp->fmon;
|
|
||||||
confp->fmon = NULL;
|
|
||||||
pw = confp->pwl;
|
|
||||||
confp->pwl = NULL;
|
|
||||||
confp->rotate = 0;
|
|
||||||
confp->logtype = NONE;
|
|
||||||
confp->authfunc = ipauth;
|
|
||||||
confp->bandlimfunc = NULL;
|
|
||||||
confp->intip = confp->extip = 0;
|
|
||||||
confp->intport = confp->extport = 0;
|
|
||||||
confp->singlepacket = 0;
|
|
||||||
confp->maxchild = 100;
|
|
||||||
resolvfunc = NULL;
|
|
||||||
acl = confp->acl;
|
|
||||||
confp->acl = NULL;
|
|
||||||
confp->logtime = confp->time = 0;
|
|
||||||
|
|
||||||
usleep(SLEEPTIME);
|
|
||||||
|
|
||||||
|
|
||||||
freeacl(acl);
|
|
||||||
freepwl(pw);
|
|
||||||
for(; bl; bl = (struct bandlim *) itfree(bl, bl->next)) freeacl(bl->ace);
|
|
||||||
for(; blout; blout = (struct bandlim *) itfree(blout, blout->next))freeacl(blout->ace);
|
|
||||||
|
|
||||||
if(counterd != -1) {
|
|
||||||
close(counterd);
|
|
||||||
}
|
|
||||||
for(; fm; fm = (struct filemon *)itfree(fm, fm->next)){
|
|
||||||
if(fm->path) myfree(fm->path);
|
|
||||||
}
|
|
||||||
if(logtarget) {
|
|
||||||
myfree(logtarget);
|
|
||||||
}
|
|
||||||
if(logname) {
|
|
||||||
myfree(logname);
|
|
||||||
}
|
|
||||||
if(logformat) {
|
|
||||||
myfree(logformat);
|
|
||||||
}
|
|
||||||
if(archiver) {
|
|
||||||
for(i = 0; i < archiverc; i++) myfree(archiver[i]);
|
|
||||||
myfree(archiver);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
FILTER_ACTION handlereqfilters(struct clientparam *param, unsigned char ** buf_p, int * bufsize_p, int offset, int * length_p){
|
FILTER_ACTION handlereqfilters(struct clientparam *param, unsigned char ** buf_p, int * bufsize_p, int offset, int * length_p){
|
||||||
FILTER_ACTION action;
|
FILTER_ACTION action;
|
||||||
int i;
|
int i;
|
||||||
|
|||||||
+2
-2
@@ -191,7 +191,7 @@
|
|||||||
* do nothing else. On the Mac OS X version of gcc this is _STDINT_H_.
|
* do nothing else. On the Mac OS X version of gcc this is _STDINT_H_.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if ((defined(__STDC__) && __STDC__ && __STDC_VERSION__ >= 199901L) || (defined (__WATCOMC__) && (defined (_STDINT_H_INCLUDED) || __WATCOMC__ >= 1250)) || (defined(__GNUC__) && (defined(_STDINT_H) || defined(_STDINT_H_) || defined (__UINT_FAST64_TYPE__)) )) && !defined (_PSTDINT_H_INCLUDED)
|
#if ((defined(__STDC__) && __STDC__ && __STDC_VERSION__ >= 199901L) || (defined (__WATCOMC__) && (defined (_STDINT_H_INCLUDED) || __WATCOMC__ >= 1250)) || (defined(__GNUC__) && (defined(_STDINT_H) || defined(_STDINT_H_) || defined (__UINT_FAST64_TYPE__) || __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ <= 4)) )) && !defined (_PSTDINT_H_INCLUDED)
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#define _PSTDINT_H_INCLUDED
|
#define _PSTDINT_H_INCLUDED
|
||||||
# ifndef PRINTF_INT64_MODIFIER
|
# ifndef PRINTF_INT64_MODIFIER
|
||||||
@@ -797,4 +797,4 @@ int main () {
|
|||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
+12
-13
@@ -4,7 +4,6 @@
|
|||||||
|
|
||||||
please read License Agreement
|
please read License Agreement
|
||||||
|
|
||||||
$Id: smtpp.c,v 1.13 2011-06-10 20:48:46 vlad Exp $
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "proxy.h"
|
#include "proxy.h"
|
||||||
@@ -83,7 +82,7 @@ int readdata (struct clientparam* param) {
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
socksendto(param->remsock, ¶m->sins, buf, i, conf.timeouts[STRING_S]);
|
socksendto(param->remsock, (struct sockaddr *)¶m->sinsr, buf, i, conf.timeouts[STRING_S]);
|
||||||
}
|
}
|
||||||
if(i < 1) {
|
if(i < 1) {
|
||||||
myfree(buf);
|
myfree(buf);
|
||||||
@@ -99,7 +98,6 @@ void * smtppchild(struct clientparam* param) {
|
|||||||
int i=0, res;
|
int i=0, res;
|
||||||
unsigned char buf[320];
|
unsigned char buf[320];
|
||||||
unsigned char username[256];
|
unsigned char username[256];
|
||||||
unsigned long ul;
|
|
||||||
char * command = NULL;
|
char * command = NULL;
|
||||||
int login = 0;
|
int login = 0;
|
||||||
|
|
||||||
@@ -188,10 +186,11 @@ void * smtppchild(struct clientparam* param) {
|
|||||||
if( i < 3 ) {RETURN(671);}
|
if( i < 3 ) {RETURN(671);}
|
||||||
buf[i] = 0;
|
buf[i] = 0;
|
||||||
if(strncasecmp((char *)buf, "220", 3)||!strncasecmp((char *)buf+4, "PROXY", 5)){RETURN(672);}
|
if(strncasecmp((char *)buf, "220", 3)||!strncasecmp((char *)buf+4, "PROXY", 5)){RETURN(672);}
|
||||||
ul = param->extip;
|
i = sprintf(buf, "EHLO [");
|
||||||
i = sprintf(buf, "EHLO [%lu.%lu.%lu.%lu]\r\n", ((ul&0xFF000000)>>24), ((ul&0x00FF0000)>>16), ((ul&0x0000FF00)>>8), ((ul&0x000000FF)));
|
i += myinet_ntop(*SAFAMILY(¶m->sinsl), SAADDR(¶m->sinsl), buf+strlen(buf), 64);
|
||||||
|
i += sprintf(buf+strlen(buf), "]\r\n");
|
||||||
if(socksend(param->remsock, buf, i, conf.timeouts[STRING_S])!= i) {RETURN(673);}
|
if(socksend(param->remsock, buf, i, conf.timeouts[STRING_S])!= i) {RETURN(673);}
|
||||||
param->statscli+=i;
|
param->statscli64+=i;
|
||||||
param->nwrites++;
|
param->nwrites++;
|
||||||
login = 0;
|
login = 0;
|
||||||
do {
|
do {
|
||||||
@@ -209,26 +208,26 @@ void * smtppchild(struct clientparam* param) {
|
|||||||
}
|
}
|
||||||
if ((login & 1)) {
|
if ((login & 1)) {
|
||||||
socksend(param->remsock, "AUTH LOGIN\r\n", 12, conf.timeouts[STRING_S]);
|
socksend(param->remsock, "AUTH LOGIN\r\n", 12, conf.timeouts[STRING_S]);
|
||||||
param->statscli+=12;
|
param->statscli64+=12;
|
||||||
param->nwrites++;
|
param->nwrites++;
|
||||||
i = sockgetlinebuf(param, SERVER, buf, sizeof(buf) - 1, '\n', conf.timeouts[STRING_L]);
|
i = sockgetlinebuf(param, SERVER, buf, sizeof(buf) - 1, '\n', conf.timeouts[STRING_L]);
|
||||||
if(i<4 || strncasecmp((char *)buf, "334", 3)) {RETURN(680);}
|
if(i<4 || strncasecmp((char *)buf, "334", 3)) {RETURN(680);}
|
||||||
en64(param->extusername, buf, (int)strlen(param->extusername));
|
en64(param->extusername, buf, (int)strlen(param->extusername));
|
||||||
socksend(param->remsock, buf, (int)strlen(buf), conf.timeouts[STRING_S]);
|
socksend(param->remsock, buf, (int)strlen(buf), conf.timeouts[STRING_S]);
|
||||||
socksend(param->remsock, "\r\n", 2, conf.timeouts[STRING_S]);
|
socksend(param->remsock, "\r\n", 2, conf.timeouts[STRING_S]);
|
||||||
param->statscli+=(i+2);
|
param->statscli64+=(i+2);
|
||||||
param->nwrites+=2;
|
param->nwrites+=2;
|
||||||
i = sockgetlinebuf(param, SERVER, buf, sizeof(buf) - 1, '\n', conf.timeouts[STRING_L]);
|
i = sockgetlinebuf(param, SERVER, buf, sizeof(buf) - 1, '\n', conf.timeouts[STRING_L]);
|
||||||
if(i<4 || strncasecmp((char *)buf, "334", 3)) {RETURN(681);}
|
if(i<4 || strncasecmp((char *)buf, "334", 3)) {RETURN(681);}
|
||||||
en64(param->extpassword, buf, (int)strlen(param->extpassword));
|
en64(param->extpassword, buf, (int)strlen(param->extpassword));
|
||||||
socksend(param->remsock, buf, (int)strlen(buf), conf.timeouts[STRING_S]);
|
socksend(param->remsock, buf, (int)strlen(buf), conf.timeouts[STRING_S]);
|
||||||
socksend(param->remsock, "\r\n", 2, conf.timeouts[STRING_S]);
|
socksend(param->remsock, "\r\n", 2, conf.timeouts[STRING_S]);
|
||||||
param->statscli+=(i+2);
|
param->statscli64+=(i+2);
|
||||||
param->nwrites+=2;
|
param->nwrites+=2;
|
||||||
}
|
}
|
||||||
else if((login & 2)){
|
else if((login & 2)){
|
||||||
socksend(param->remsock, "AUTH PLAIN\r\n", 12, conf.timeouts[STRING_S]);
|
socksend(param->remsock, "AUTH PLAIN\r\n", 12, conf.timeouts[STRING_S]);
|
||||||
param->statscli+=12;
|
param->statscli64+=(12);
|
||||||
param->nwrites++;
|
param->nwrites++;
|
||||||
i = sockgetlinebuf(param, SERVER, buf, sizeof(buf) - 1, '\n', conf.timeouts[STRING_L]);
|
i = sockgetlinebuf(param, SERVER, buf, sizeof(buf) - 1, '\n', conf.timeouts[STRING_L]);
|
||||||
if(i<4 || strncasecmp((char *)buf, "334", 3)) {RETURN(682);}
|
if(i<4 || strncasecmp((char *)buf, "334", 3)) {RETURN(682);}
|
||||||
@@ -243,7 +242,7 @@ void * smtppchild(struct clientparam* param) {
|
|||||||
i = (int)strlen(buf);
|
i = (int)strlen(buf);
|
||||||
socksend(param->remsock, buf, i, conf.timeouts[STRING_S]);
|
socksend(param->remsock, buf, i, conf.timeouts[STRING_S]);
|
||||||
socksend(param->remsock, "\r\n", 2, conf.timeouts[STRING_S]);
|
socksend(param->remsock, "\r\n", 2, conf.timeouts[STRING_S]);
|
||||||
param->statscli+=(i+2);
|
param->statscli64+=(i+2);
|
||||||
param->nwrites+=2;
|
param->nwrites+=2;
|
||||||
}
|
}
|
||||||
if(command) {
|
if(command) {
|
||||||
@@ -257,7 +256,7 @@ void * smtppchild(struct clientparam* param) {
|
|||||||
if(!strncasecmp(command, "MAIL", 4) || !strncasecmp(command, "RCPT", 4) || !strncasecmp(command, "STARTTLS", 8) || !strncasecmp(command, "TURN", 4)){
|
if(!strncasecmp(command, "MAIL", 4) || !strncasecmp(command, "RCPT", 4) || !strncasecmp(command, "STARTTLS", 8) || !strncasecmp(command, "TURN", 4)){
|
||||||
res = (int)strlen(command);
|
res = (int)strlen(command);
|
||||||
command[res] = 0;
|
command[res] = 0;
|
||||||
res = handlehdrfilterscli(param, &command, &res, 0, &res);
|
res = handlehdrfilterscli(param, (unsigned char **)&command, &res, 0, &res);
|
||||||
if(res != PASS) {
|
if(res != PASS) {
|
||||||
if(res == HANDLED) res = 2;
|
if(res == HANDLED) res = 2;
|
||||||
else RETURN(677);
|
else RETURN(677);
|
||||||
@@ -292,7 +291,7 @@ void * smtppchild(struct clientparam* param) {
|
|||||||
CLEANRET:
|
CLEANRET:
|
||||||
|
|
||||||
if(param->hostname&¶m->extusername) {
|
if(param->hostname&¶m->extusername) {
|
||||||
sprintf((char *)buf, "%.64s@%.128s%c%hu", param->extusername, param->hostname, (ntohs(param->sins.sin_port)==25)?0:':', ntohs(param->sins.sin_port));
|
sprintf((char *)buf, "%.64s@%.128s%c%hu", param->extusername, param->hostname, *SAPORT(¶m->sinsr)==25?0:':',ntohs(*SAPORT(¶m->sinsr)));
|
||||||
(*param->srv->logfunc)(param, buf);
|
(*param->srv->logfunc)(param, buf);
|
||||||
}
|
}
|
||||||
else (*param->srv->logfunc)(param, NULL);
|
else (*param->srv->logfunc)(param, NULL);
|
||||||
|
|||||||
+10
-10
@@ -33,7 +33,7 @@ int socksend(SOCKET sock, unsigned char * buf, int bufsize, int to){
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int socksendto(SOCKET sock, struct sockaddr_in * sin, unsigned char * buf, int bufsize, int to){
|
int socksendto(SOCKET sock, struct sockaddr * sin, unsigned char * buf, int bufsize, int to){
|
||||||
int sent = 0;
|
int sent = 0;
|
||||||
int res;
|
int res;
|
||||||
struct pollfd fds;
|
struct pollfd fds;
|
||||||
@@ -45,7 +45,7 @@ int socksendto(SOCKET sock, struct sockaddr_in * sin, unsigned char * buf, int b
|
|||||||
res = so._poll(&fds, 1, to);
|
res = so._poll(&fds, 1, to);
|
||||||
if(res < 0 && (errno == EAGAIN || errno == EINTR)) continue;
|
if(res < 0 && (errno == EAGAIN || errno == EINTR)) continue;
|
||||||
if(res < 1) break;
|
if(res < 1) break;
|
||||||
res = so._sendto(sock, buf + sent, bufsize - sent, 0, (struct sockaddr *)sin, sizeof(struct sockaddr_in));
|
res = so._sendto(sock, buf + sent, bufsize - sent, 0, sin, SASIZE(sin));
|
||||||
if(res < 0) {
|
if(res < 0) {
|
||||||
if(errno != EAGAIN && errno != EINTR) break;
|
if(errno != EAGAIN && errno != EINTR) break;
|
||||||
continue;
|
continue;
|
||||||
@@ -55,7 +55,7 @@ int socksendto(SOCKET sock, struct sockaddr_in * sin, unsigned char * buf, int b
|
|||||||
return sent;
|
return sent;
|
||||||
}
|
}
|
||||||
|
|
||||||
int sockrecvfrom(SOCKET sock, struct sockaddr_in * sin, unsigned char * buf, int bufsize, int to){
|
int sockrecvfrom(SOCKET sock, struct sockaddr * sin, unsigned char * buf, int bufsize, int to){
|
||||||
struct pollfd fds;
|
struct pollfd fds;
|
||||||
SASIZETYPE sasize;
|
SASIZETYPE sasize;
|
||||||
int res;
|
int res;
|
||||||
@@ -64,7 +64,7 @@ int sockrecvfrom(SOCKET sock, struct sockaddr_in * sin, unsigned char * buf, int
|
|||||||
fds.events = POLLIN;
|
fds.events = POLLIN;
|
||||||
if(conf.timetoexit) return EOF;
|
if(conf.timetoexit) return EOF;
|
||||||
if (so._poll(&fds, 1, to)<1) return 0;
|
if (so._poll(&fds, 1, to)<1) return 0;
|
||||||
sasize = sizeof(struct sockaddr_in);
|
sasize = SASIZE(sin);
|
||||||
do {
|
do {
|
||||||
res = so._recvfrom(sock, buf, bufsize, 0, (struct sockaddr *)sin, &sasize);
|
res = so._recvfrom(sock, buf, bufsize, 0, (struct sockaddr *)sin, &sasize);
|
||||||
} while (res < 0 && (errno == EAGAIN || errno == EINTR));
|
} while (res < 0 && (errno == EAGAIN || errno == EINTR));
|
||||||
@@ -83,7 +83,7 @@ int sockgetcharcli(struct clientparam * param, int timeosec, int timeousec){
|
|||||||
return (int)param->clibuf[param->clioffset++];
|
return (int)param->clibuf[param->clioffset++];
|
||||||
}
|
}
|
||||||
param->clioffset = param->cliinbuf = 0;
|
param->clioffset = param->cliinbuf = 0;
|
||||||
if ((len = sockrecvfrom(param->clisock, ¶m->sinc, param->clibuf, param->clibufsize, timeosec*1000 + timeousec))<=0) return EOF;
|
if ((len = sockrecvfrom(param->clisock, (struct sockaddr *)¶m->sincr, param->clibuf, param->clibufsize, timeosec*1000 + timeousec))<=0) return EOF;
|
||||||
param->cliinbuf = len;
|
param->cliinbuf = len;
|
||||||
param->clioffset = 1;
|
param->clioffset = 1;
|
||||||
return (int)*param->clibuf;
|
return (int)*param->clibuf;
|
||||||
@@ -103,7 +103,7 @@ int sockfillbuffcli(struct clientparam * param, unsigned long size, int timeosec
|
|||||||
}
|
}
|
||||||
if(size <= param->cliinbuf) return size;
|
if(size <= param->cliinbuf) return size;
|
||||||
size -= param->cliinbuf;
|
size -= param->cliinbuf;
|
||||||
if((len = sockrecvfrom(param->clisock, ¶m->sinc, param->clibuf + param->cliinbuf, (param->clibufsize - param->cliinbuf) < size? param->clibufsize - param->cliinbuf:size, timeosec*1000)) > 0){
|
if((len = sockrecvfrom(param->clisock, (struct sockaddr *)¶m->sincr, param->clibuf + param->cliinbuf, (param->clibufsize - param->cliinbuf) < size? param->clibufsize - param->cliinbuf:size, timeosec*1000)) > 0){
|
||||||
param->cliinbuf += len;
|
param->cliinbuf += len;
|
||||||
}
|
}
|
||||||
return param->cliinbuf;
|
return param->cliinbuf;
|
||||||
@@ -123,10 +123,10 @@ int sockfillbuffsrv(struct clientparam * param, unsigned long size, int timeosec
|
|||||||
}
|
}
|
||||||
if(size <= param->srvinbuf) return size;
|
if(size <= param->srvinbuf) return size;
|
||||||
size -= param->srvinbuf;
|
size -= param->srvinbuf;
|
||||||
if((len = sockrecvfrom(param->remsock, ¶m->sinc, param->srvbuf + param->srvinbuf, (param->srvbufsize - param->srvinbuf) < size? param->srvbufsize - param->srvinbuf:size, timeosec*1000)) > 0){
|
if((len = sockrecvfrom(param->remsock, (struct sockaddr *)¶m->sinsr, param->srvbuf + param->srvinbuf, (param->srvbufsize - param->srvinbuf) < size? param->srvbufsize - param->srvinbuf:size, timeosec*1000)) > 0){
|
||||||
param->srvinbuf += len;
|
param->srvinbuf += len;
|
||||||
param->nreads++;
|
param->nreads++;
|
||||||
param->statssrv += len;
|
param->statssrv64 += len;
|
||||||
}
|
}
|
||||||
return param->srvinbuf;
|
return param->srvinbuf;
|
||||||
}
|
}
|
||||||
@@ -148,11 +148,11 @@ int sockgetcharsrv(struct clientparam * param, int timeosec, int timeousec){
|
|||||||
return (int)param->srvbuf[param->srvoffset++];
|
return (int)param->srvbuf[param->srvoffset++];
|
||||||
}
|
}
|
||||||
param->srvoffset = param->srvinbuf = 0;
|
param->srvoffset = param->srvinbuf = 0;
|
||||||
if ((len = sockrecvfrom(param->remsock, ¶m->sins, param->srvbuf, param->srvbufsize, timeosec*1000 + timeousec))<=0) return EOF;
|
if ((len = sockrecvfrom(param->remsock, (struct sockaddr *)¶m->sinsr, param->srvbuf, param->srvbufsize, timeosec*1000 + timeousec))<=0) return EOF;
|
||||||
param->srvinbuf = len;
|
param->srvinbuf = len;
|
||||||
param->srvoffset = 1;
|
param->srvoffset = 1;
|
||||||
param->nreads++;
|
param->nreads++;
|
||||||
param->statssrv += len;
|
param->statssrv64 += len;
|
||||||
return (int)*param->srvbuf;
|
return (int)*param->srvbuf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+25
-26
@@ -4,7 +4,6 @@
|
|||||||
|
|
||||||
please read License Agreement
|
please read License Agreement
|
||||||
|
|
||||||
$Id: sockmap.c,v 1.64 2014-04-07 20:35:09 vlad Exp $
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "proxy.h"
|
#include "proxy.h"
|
||||||
@@ -13,7 +12,7 @@
|
|||||||
|
|
||||||
int sockmap(struct clientparam * param, int timeo){
|
int sockmap(struct clientparam * param, int timeo){
|
||||||
int res=0;
|
int res=0;
|
||||||
unsigned sent=0, received=0;
|
uint64_t sent=0, received=0;
|
||||||
SASIZETYPE sasize;
|
SASIZETYPE sasize;
|
||||||
struct pollfd fds[2];
|
struct pollfd fds[2];
|
||||||
int sleeptime = 0, stop = 0;
|
int sleeptime = 0, stop = 0;
|
||||||
@@ -32,12 +31,12 @@ int sockmap(struct clientparam * param, int timeo){
|
|||||||
#if DEBUGLEVEL > 2
|
#if DEBUGLEVEL > 2
|
||||||
(*param->srv->logfunc)(param, "Starting sockets mapping");
|
(*param->srv->logfunc)(param, "Starting sockets mapping");
|
||||||
#endif
|
#endif
|
||||||
if(!param->waitclient){
|
if(!param->waitclient64){
|
||||||
if(!param->srvbuf && (!(param->srvbuf=myalloc(bufsize)) || !(param->srvbufsize = bufsize))){
|
if(!param->srvbuf && (!(param->srvbuf=myalloc(bufsize)) || !(param->srvbufsize = bufsize))){
|
||||||
return (21);
|
return (21);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(!param->waitserver){
|
if(!param->waitserver64){
|
||||||
if(!param->clibuf && (!(param->clibuf=myalloc(bufsize)) || !(param->clibufsize = bufsize))){
|
if(!param->clibuf && (!(param->clibuf=myalloc(bufsize)) || !(param->clibufsize = bufsize))){
|
||||||
return (21);
|
return (21);
|
||||||
}
|
}
|
||||||
@@ -69,33 +68,33 @@ int sockmap(struct clientparam * param, int timeo){
|
|||||||
|
|
||||||
while (!stop&&!conf.timetoexit){
|
while (!stop&&!conf.timetoexit){
|
||||||
sasize = sizeof(struct sockaddr_in);
|
sasize = sizeof(struct sockaddr_in);
|
||||||
if((param->maxtrafin && param->statssrv >= param->maxtrafin) || (param->maxtrafout && param->statscli >= param->maxtrafout)){
|
if((param->maxtrafin64 && param->statssrv64 >= param->maxtrafin64) || (param->maxtrafout64 && param->statscli64 >= param->maxtrafout64)){
|
||||||
return (10);
|
return (10);
|
||||||
}
|
}
|
||||||
if((param->srv->logdumpsrv && (param->statssrv > param->srv->logdumpsrv)) ||
|
if((param->srv->logdumpsrv && (param->statssrv64 > param->srv->logdumpsrv)) ||
|
||||||
(param->srv->logdumpcli && (param->statscli > param->srv->logdumpcli)))
|
(param->srv->logdumpcli && (param->statscli64 > param->srv->logdumpcli)))
|
||||||
(*param->srv->logfunc)(param, NULL);
|
(*param->srv->logfunc)(param, NULL);
|
||||||
fds[0].events = fds[1].events = 0;
|
fds[0].events = fds[1].events = 0;
|
||||||
if(param->srvinbuf > param->srvoffset && !param->waitclient) {
|
if(param->srvinbuf > param->srvoffset && !param->waitclient64) {
|
||||||
#if DEBUGLEVEL > 2
|
#if DEBUGLEVEL > 2
|
||||||
(*param->srv->logfunc)(param, "will send to client");
|
(*param->srv->logfunc)(param, "will send to client");
|
||||||
#endif
|
#endif
|
||||||
fds[0].events |= POLLOUT;
|
fds[0].events |= POLLOUT;
|
||||||
}
|
}
|
||||||
if((param->srvbufsize - param->srvinbuf) > minsize && !param->waitclient && (!param->waitserver ||(received + param->srvinbuf - param->srvoffset < param->waitserver))) {
|
if((param->srvbufsize - param->srvinbuf) > minsize && !param->waitclient64 && (!param->waitserver64 ||(received + param->srvinbuf - param->srvoffset < param->waitserver64))) {
|
||||||
#if DEBUGLEVEL > 2
|
#if DEBUGLEVEL > 2
|
||||||
(*param->srv->logfunc)(param, "Will recv from server");
|
(*param->srv->logfunc)(param, "Will recv from server");
|
||||||
#endif
|
#endif
|
||||||
fds[1].events |= POLLIN;
|
fds[1].events |= POLLIN;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(param->cliinbuf > param->clioffset && !param->waitserver) {
|
if(param->cliinbuf > param->clioffset && !param->waitserver64) {
|
||||||
#if DEBUGLEVEL > 2
|
#if DEBUGLEVEL > 2
|
||||||
(*param->srv->logfunc)(param, "Will send to server");
|
(*param->srv->logfunc)(param, "Will send to server");
|
||||||
#endif
|
#endif
|
||||||
fds[1].events |= POLLOUT;
|
fds[1].events |= POLLOUT;
|
||||||
}
|
}
|
||||||
if((param->clibufsize - param->cliinbuf) > minsize && !param->waitserver &&(!param->srv->singlepacket || param->service != S_UDPPM) ) {
|
if((param->clibufsize - param->cliinbuf) > minsize && !param->waitserver64 &&(!param->srv->singlepacket || param->service != S_UDPPM) ) {
|
||||||
#if DEBUGLEVEL > 2
|
#if DEBUGLEVEL > 2
|
||||||
(*param->srv->logfunc)(param, "Will recv from client");
|
(*param->srv->logfunc)(param, "Will recv from client");
|
||||||
#endif
|
#endif
|
||||||
@@ -128,7 +127,7 @@ int sockmap(struct clientparam * param, int timeo){
|
|||||||
if(param->bandlimfunc) {
|
if(param->bandlimfunc) {
|
||||||
sleeptime = (*param->bandlimfunc)(param, param->srvinbuf - param->srvoffset, 0);
|
sleeptime = (*param->bandlimfunc)(param, param->srvinbuf - param->srvoffset, 0);
|
||||||
}
|
}
|
||||||
res = so._sendto(param->clisock, param->srvbuf + param->srvoffset,(!param->waitserver || ((unsigned)param->waitserver - received) > (param->srvinbuf - param->srvoffset))? param->srvinbuf - param->srvoffset : param->waitserver - received, 0, (struct sockaddr*)¶m->sinc, sasize);
|
res = so._sendto(param->clisock, param->srvbuf + param->srvoffset,(!param->waitserver64 || (param->waitserver64 - received) > (param->srvinbuf - param->srvoffset))? param->srvinbuf - param->srvoffset : (int)(param->waitserver64 - received), 0, (struct sockaddr*)¶m->sincr, sasize);
|
||||||
if(res < 0) {
|
if(res < 0) {
|
||||||
if(errno != EAGAIN && errno != EINTR) return 96;
|
if(errno != EAGAIN && errno != EINTR) return 96;
|
||||||
if(errno == EINTR) usleep(SLEEPTIME);
|
if(errno == EINTR) usleep(SLEEPTIME);
|
||||||
@@ -137,7 +136,7 @@ int sockmap(struct clientparam * param, int timeo){
|
|||||||
param->srvoffset += res;
|
param->srvoffset += res;
|
||||||
received += res;
|
received += res;
|
||||||
if(param->srvoffset == param->srvinbuf) param->srvoffset = param->srvinbuf = 0;
|
if(param->srvoffset == param->srvinbuf) param->srvoffset = param->srvinbuf = 0;
|
||||||
if(param->waitserver && param->waitserver<= received){
|
if(param->waitserver64 && param->waitserver64<= received){
|
||||||
return (98);
|
return (98);
|
||||||
}
|
}
|
||||||
if(param->service == S_UDPPM && param->srv->singlepacket) {
|
if(param->service == S_UDPPM && param->srv->singlepacket) {
|
||||||
@@ -154,18 +153,18 @@ int sockmap(struct clientparam * param, int timeo){
|
|||||||
sl1 = (*param->bandlimfunc)(param, 0, param->cliinbuf - param->clioffset);
|
sl1 = (*param->bandlimfunc)(param, 0, param->cliinbuf - param->clioffset);
|
||||||
if(sl1 > sleeptime) sleeptime = sl1;
|
if(sl1 > sleeptime) sleeptime = sl1;
|
||||||
}
|
}
|
||||||
res = so._sendto(param->remsock, param->clibuf + param->clioffset, (!param->waitclient || ((unsigned)param->waitclient - sent) > (param->cliinbuf - param->clioffset))? param->cliinbuf - param->clioffset : param->waitclient - sent, 0, (struct sockaddr*)¶m->sins, sasize);
|
res = so._sendto(param->remsock, param->clibuf + param->clioffset, (!param->waitclient64 || (param->waitclient64 - sent) > (param->cliinbuf - param->clioffset))? param->cliinbuf - param->clioffset : (int)(param->waitclient64 - sent), 0, (struct sockaddr*)¶m->sinsr, sasize);
|
||||||
if(res < 0) {
|
if(res < 0) {
|
||||||
if(errno != EAGAIN && errno != EINTR) return 97;
|
if(errno != EAGAIN && errno != EINTR) return 97;
|
||||||
if(errno == EINTR) usleep(SLEEPTIME);
|
if(errno == EINTR) usleep(SLEEPTIME);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
param->clioffset += res;
|
param->clioffset += res;
|
||||||
sent += res;
|
|
||||||
param->statscli += res;
|
|
||||||
param->nwrites++;
|
|
||||||
if(param->clioffset == param->cliinbuf) param->clioffset = param->cliinbuf = 0;
|
if(param->clioffset == param->cliinbuf) param->clioffset = param->cliinbuf = 0;
|
||||||
if(param->waitclient && param->waitclient<= sent) {
|
sent += res;
|
||||||
|
param->nwrites++;
|
||||||
|
param->statscli64 += res;
|
||||||
|
if(param->waitclient64 && param->waitclient64<= sent) {
|
||||||
return (99);
|
return (99);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -173,7 +172,7 @@ int sockmap(struct clientparam * param, int timeo){
|
|||||||
#if DEBUGLEVEL > 2
|
#if DEBUGLEVEL > 2
|
||||||
(*param->srv->logfunc)(param, "recv from client");
|
(*param->srv->logfunc)(param, "recv from client");
|
||||||
#endif
|
#endif
|
||||||
res = so._recvfrom(param->clisock, param->clibuf + param->cliinbuf, param->clibufsize - param->cliinbuf, 0, (struct sockaddr *)¶m->sinc, &sasize);
|
res = so._recvfrom(param->clisock, param->clibuf + param->cliinbuf, param->clibufsize - param->cliinbuf, 0, (struct sockaddr *)¶m->sincr, &sasize);
|
||||||
if (res==0) {
|
if (res==0) {
|
||||||
so._shutdown(param->clisock, SHUT_RDWR);
|
so._shutdown(param->clisock, SHUT_RDWR);
|
||||||
so._closesocket(param->clisock);
|
so._closesocket(param->clisock);
|
||||||
@@ -219,7 +218,7 @@ int sockmap(struct clientparam * param, int timeo){
|
|||||||
}
|
}
|
||||||
param->srvinbuf += res;
|
param->srvinbuf += res;
|
||||||
param->nreads++;
|
param->nreads++;
|
||||||
param->statssrv += res;
|
param->statssrv64 += res;
|
||||||
if(!param->nolongdatfilter){
|
if(!param->nolongdatfilter){
|
||||||
action = handledatfltsrv(param, ¶m->srvbuf, ¶m->srvbufsize, param->srvinbuf - res, ¶m->srvinbuf);
|
action = handledatfltsrv(param, ¶m->srvbuf, ¶m->srvbufsize, param->srvinbuf - res, ¶m->srvinbuf);
|
||||||
if(action == HANDLED){
|
if(action == HANDLED){
|
||||||
@@ -241,26 +240,26 @@ int sockmap(struct clientparam * param, int timeo){
|
|||||||
#if DEBUGLEVEL > 2
|
#if DEBUGLEVEL > 2
|
||||||
(*param->srv->logfunc)(param, "finished with mapping");
|
(*param->srv->logfunc)(param, "finished with mapping");
|
||||||
#endif
|
#endif
|
||||||
while(!param->waitclient && param->srvinbuf > param->srvoffset && param->clisock != INVALID_SOCKET){
|
while(!param->waitclient64 && param->srvinbuf > param->srvoffset && param->clisock != INVALID_SOCKET){
|
||||||
#if DEBUGLEVEL > 2
|
#if DEBUGLEVEL > 2
|
||||||
(*param->srv->logfunc)(param, "flushing buffer to client");
|
(*param->srv->logfunc)(param, "flushing buffer to client");
|
||||||
#endif
|
#endif
|
||||||
res = socksendto(param->clisock, ¶m->sinc, param->srvbuf + param->srvoffset, param->srvinbuf - param->srvoffset, conf.timeouts[STRING_S] * 1000);
|
res = socksendto(param->clisock, (struct sockaddr *)¶m->sincr, param->srvbuf + param->srvoffset, param->srvinbuf - param->srvoffset, conf.timeouts[STRING_S] * 1000);
|
||||||
if(res > 0){
|
if(res > 0){
|
||||||
param->srvoffset += res;
|
param->srvoffset += res;
|
||||||
param->statssrv += res;
|
param->statssrv64 += res;
|
||||||
if(param->srvoffset == param->srvinbuf) param->srvoffset = param->srvinbuf = 0;
|
if(param->srvoffset == param->srvinbuf) param->srvoffset = param->srvinbuf = 0;
|
||||||
}
|
}
|
||||||
else break;
|
else break;
|
||||||
}
|
}
|
||||||
while(!param->waitserver && param->cliinbuf > param->clioffset && param->remsock != INVALID_SOCKET){
|
while(!param->waitserver64 && param->cliinbuf > param->clioffset && param->remsock != INVALID_SOCKET){
|
||||||
#if DEBUGLEVEL > 2
|
#if DEBUGLEVEL > 2
|
||||||
(*param->srv->logfunc)(param, "flushing buffer to server");
|
(*param->srv->logfunc)(param, "flushing buffer to server");
|
||||||
#endif
|
#endif
|
||||||
res = socksendto(param->remsock, ¶m->sins, param->clibuf + param->clioffset, param->cliinbuf - param->clioffset, conf.timeouts[STRING_S] * 1000);
|
res = socksendto(param->remsock, (struct sockaddr *)¶m->sinsr, param->clibuf + param->clioffset, param->cliinbuf - param->clioffset, conf.timeouts[STRING_S] * 1000);
|
||||||
if(res > 0){
|
if(res > 0){
|
||||||
param->clioffset += res;
|
param->clioffset += res;
|
||||||
param->statscli += res;
|
param->statscli64 += res;
|
||||||
if(param->cliinbuf == param->clioffset) param->cliinbuf = param->clioffset = 0;
|
if(param->cliinbuf == param->clioffset) param->cliinbuf = param->clioffset = 0;
|
||||||
}
|
}
|
||||||
else break;
|
else break;
|
||||||
|
|||||||
+145
-108
@@ -4,7 +4,6 @@
|
|||||||
|
|
||||||
please read License Agreement
|
please read License Agreement
|
||||||
|
|
||||||
$Id: socks.c,v 1.34 2009/09/17 12:21:09 v.dubrovin Exp $
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "proxy.h"
|
#include "proxy.h"
|
||||||
@@ -22,17 +21,21 @@ void * sockschild(struct clientparam* param) {
|
|||||||
SOCKET s;
|
SOCKET s;
|
||||||
unsigned size;
|
unsigned size;
|
||||||
SASIZETYPE sasize;
|
SASIZETYPE sasize;
|
||||||
|
unsigned short port = 0;
|
||||||
unsigned char * buf=NULL;
|
unsigned char * buf=NULL;
|
||||||
unsigned char c;
|
unsigned char c;
|
||||||
unsigned char command=0;
|
unsigned char command=0;
|
||||||
struct pollfd fds[3];
|
struct pollfd fds[3];
|
||||||
int ver=0;
|
int ver=0;
|
||||||
int havepass = 0;
|
int havepass = 0;
|
||||||
struct sockaddr_in sin;
|
#ifndef NOIPV6
|
||||||
|
struct sockaddr_in6 sin = {AF_INET6};
|
||||||
|
#else
|
||||||
|
struct sockaddr_in sin = {AF_INET};
|
||||||
|
#endif
|
||||||
int len;
|
int len;
|
||||||
|
|
||||||
|
|
||||||
param->req.sin_addr.s_addr = 0;
|
|
||||||
param->service = S_SOCKS;
|
param->service = S_SOCKS;
|
||||||
|
|
||||||
if(!(buf = myalloc(BUFSIZE))) {RETURN(21);}
|
if(!(buf = myalloc(BUFSIZE))) {RETURN(21);}
|
||||||
@@ -44,29 +47,30 @@ void * sockschild(struct clientparam* param) {
|
|||||||
if(ver == 5){
|
if(ver == 5){
|
||||||
if ((i = sockgetcharcli(param, conf.timeouts[SINGLEBYTE_S], 0)) == EOF) {RETURN(441);} /* nmethods */
|
if ((i = sockgetcharcli(param, conf.timeouts[SINGLEBYTE_S], 0)) == EOF) {RETURN(441);} /* nmethods */
|
||||||
for (; i; i--) {
|
for (; i; i--) {
|
||||||
if ((res = sockgetcharcli(param, conf.timeouts[SINGLEBYTE_S], 0)) == EOF) {RETURN(442);}
|
if ((res = sockgetcharcli(param, conf.timeouts[SINGLEBYTE_S], 0)) == EOF) {RETURN(441);}
|
||||||
if (res == 2 && !param->srv->nouser) {
|
if (res == 2 && param->srv->needuser) {
|
||||||
havepass = res;
|
havepass = res;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
buf[0] = 5;
|
buf[0] = 5;
|
||||||
buf[1] = havepass;
|
buf[1] = (param->srv->needuser > 1 && !havepass)? 255 : havepass;
|
||||||
if(socksend(param->clisock, buf, 2, conf.timeouts[STRING_S])!=2){RETURN(402);}
|
if(socksend(param->clisock, buf, 2, conf.timeouts[STRING_S])!=2){RETURN(401);}
|
||||||
|
if (param->srv->needuser > 1 && !havepass) RETURN(4);
|
||||||
if (havepass) {
|
if (havepass) {
|
||||||
if (((res = sockgetcharcli(param, conf.timeouts[SINGLEBYTE_L], 0))) != 1) {
|
if (((res = sockgetcharcli(param, conf.timeouts[SINGLEBYTE_L], 0))) != 1) {
|
||||||
RETURN(412);
|
RETURN(412);
|
||||||
}
|
}
|
||||||
if ((i = sockgetcharcli(param, conf.timeouts[SINGLEBYTE_S], 0)) == EOF) {RETURN(443);}
|
if ((i = sockgetcharcli(param, conf.timeouts[SINGLEBYTE_S], 0)) == EOF) {RETURN(451);}
|
||||||
if (i && (unsigned)(res = sockgetlinebuf(param, CLIENT, buf, i, 0, conf.timeouts[STRING_S])) != i){RETURN(444);};
|
if (i && (unsigned)(res = sockgetlinebuf(param, CLIENT, buf, i, 0, conf.timeouts[STRING_S])) != i){RETURN(441);};
|
||||||
buf[i] = 0;
|
buf[i] = 0;
|
||||||
if(!param->username)param->username = (unsigned char *)mystrdup((char *)buf);
|
if(!param->username)param->username = (unsigned char *)mystrdup((char *)buf);
|
||||||
if ((i = sockgetcharcli(param, conf.timeouts[SINGLEBYTE_S], 0)) == EOF) {RETURN(445);}
|
if ((i = sockgetcharcli(param, conf.timeouts[SINGLEBYTE_S], 0)) == EOF) {RETURN(445);}
|
||||||
if (i && (unsigned)(res = sockgetlinebuf(param, CLIENT, buf, i, 0, conf.timeouts[STRING_S])) != i){RETURN(446);};
|
if (i && (unsigned)(res = sockgetlinebuf(param, CLIENT, buf, i, 0, conf.timeouts[STRING_S])) != i){RETURN(441);};
|
||||||
buf[i] = 0;
|
buf[i] = 0;
|
||||||
if(!param->password)param->password = (unsigned char *)mystrdup((char *)buf);
|
if(!param->password)param->password = (unsigned char *)mystrdup((char *)buf);
|
||||||
buf[0] = 1;
|
buf[0] = 1;
|
||||||
buf[1] = 0;
|
buf[1] = 0;
|
||||||
if(socksend(param->clisock, buf, 2, conf.timeouts[STRING_S])!=2){RETURN(402);}
|
if(socksend(param->clisock, buf, 2, conf.timeouts[STRING_S])!=2){RETURN(481);}
|
||||||
}
|
}
|
||||||
if ((c = sockgetcharcli(param, conf.timeouts[SINGLEBYTE_L], 0)) != 5) {
|
if ((c = sockgetcharcli(param, conf.timeouts[SINGLEBYTE_L], 0)) != 5) {
|
||||||
RETURN(421);
|
RETURN(421);
|
||||||
@@ -78,113 +82,134 @@ void * sockschild(struct clientparam* param) {
|
|||||||
c = sockgetcharcli(param, conf.timeouts[SINGLEBYTE_S], 0); /* atype */
|
c = sockgetcharcli(param, conf.timeouts[SINGLEBYTE_S], 0); /* atype */
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if ((res = sockgetcharcli(param, conf.timeouts[SINGLEBYTE_S], 0)) == EOF) {RETURN(448);}
|
if ((res = sockgetcharcli(param, conf.timeouts[SINGLEBYTE_S], 0)) == EOF) {RETURN(441);}
|
||||||
buf[0] = (unsigned char) res;
|
buf[0] = (unsigned char) res;
|
||||||
if ((res = sockgetcharcli(param, conf.timeouts[SINGLEBYTE_S], 0)) == EOF) {RETURN(449);}
|
if ((res = sockgetcharcli(param, conf.timeouts[SINGLEBYTE_S], 0)) == EOF) {RETURN(441);}
|
||||||
buf[1] = (unsigned char) res;
|
buf[1] = (unsigned char) res;
|
||||||
param->sins.sin_port = param->req.sin_port = *(unsigned short*)buf;
|
port = *(unsigned short*)buf;
|
||||||
c = 1;
|
c = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size = 4;
|
||||||
|
*SAFAMILY(¶m->sinsr) = *SAFAMILY(¶m->req) = AF_INET;
|
||||||
switch(c) {
|
switch(c) {
|
||||||
|
#ifndef NOIPV6
|
||||||
|
case 4:
|
||||||
|
if(param->srv->family == 4) RETURN(997);
|
||||||
|
size = 16;
|
||||||
|
*SAFAMILY(¶m->sinsr) = *SAFAMILY(¶m->req) = AF_INET6;
|
||||||
|
#endif
|
||||||
case 1:
|
case 1:
|
||||||
for (i = 0; i<4; i++){
|
for (i = 0; i<size; i++){
|
||||||
if ((res = sockgetcharcli(param, conf.timeouts[SINGLEBYTE_S], 0)) == EOF) {RETURN(450);}
|
if ((res = sockgetcharcli(param, conf.timeouts[SINGLEBYTE_S], 0)) == EOF) {RETURN(441);}
|
||||||
buf[i] = (unsigned char)res;
|
buf[i] = (unsigned char)res;
|
||||||
}
|
}
|
||||||
param->sins.sin_addr.s_addr = param->req.sin_addr.s_addr = *(unsigned long *)buf;
|
#ifndef NOIPV6
|
||||||
if(command==1 && !param->req.sin_addr.s_addr) {
|
if (c == 1 && param->srv->family==6){
|
||||||
RETURN(422);
|
char prefix[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255};
|
||||||
|
*SAFAMILY(¶m->sinsr) = *SAFAMILY(¶m->req) = AF_INET6;
|
||||||
|
memcpy(SAADDR(¶m->sinsr), prefix, 12);
|
||||||
|
memcpy(12 + (char *)SAADDR(¶m->sinsr), buf, 4);
|
||||||
|
memcpy(SAADDR(¶m->req), prefix, 12);
|
||||||
|
memcpy(12 + (char *)SAADDR(¶m->req), buf, 4);
|
||||||
}
|
}
|
||||||
myinet_ntoa(param->sins.sin_addr, (char *)buf);
|
else {
|
||||||
|
#endif
|
||||||
|
memcpy(SAADDR(¶m->sinsr), buf, size);
|
||||||
|
memcpy(SAADDR(¶m->req), buf, size);
|
||||||
|
#ifndef NOIPV6
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
if(SAISNULL(¶m->req)) {
|
||||||
|
RETURN(421);
|
||||||
|
}
|
||||||
|
myinet_ntop(*SAFAMILY(¶m->sinsr), SAADDR(¶m->sinsr), (char *)buf, 64);
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
if ((size = sockgetcharcli(param, conf.timeouts[SINGLEBYTE_S], 0)) == EOF) {RETURN(451);} /* nmethods */
|
if ((size = sockgetcharcli(param, conf.timeouts[SINGLEBYTE_S], 0)) == EOF) {RETURN(451);} /* nmethods */
|
||||||
for (i=0; i<size; i++){ /* size < 256 */
|
for (i=0; i<size; i++){ /* size < 256 */
|
||||||
if ((res = sockgetcharcli(param, conf.timeouts[SINGLEBYTE_S], 0)) == EOF) {RETURN(452);}
|
if ((res = sockgetcharcli(param, conf.timeouts[SINGLEBYTE_S], 0)) == EOF) {RETURN(451);}
|
||||||
buf[i] = (unsigned char)res;
|
buf[i] = (unsigned char)res;
|
||||||
}
|
}
|
||||||
buf[i] = 0;
|
buf[i] = 0;
|
||||||
param->sins.sin_addr.s_addr = param->req.sin_addr.s_addr = getip(buf);
|
if(!getip46(param->srv->family, buf, (struct sockaddr *) ¶m->req)) RETURN(100);
|
||||||
if(command==1 && !param->req.sin_addr.s_addr) {
|
memcpy(¶m->sinsr, ¶m->req, sizeof(param->req));
|
||||||
RETURN(100);
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
RETURN(998);
|
RETURN(997);
|
||||||
}
|
}
|
||||||
if(param->hostname)myfree(param->hostname);
|
if(param->hostname)myfree(param->hostname);
|
||||||
param->hostname = (unsigned char *)mystrdup((char *)buf);
|
param->hostname = (unsigned char *)mystrdup((char *)buf);
|
||||||
if (ver == 5) {
|
if (ver == 5) {
|
||||||
if ((res = sockgetcharcli(param, conf.timeouts[SINGLEBYTE_S], 0)) == EOF) {RETURN(453);}
|
if ((res = sockgetcharcli(param, conf.timeouts[SINGLEBYTE_S], 0)) == EOF) {RETURN(441);}
|
||||||
buf[0] = (unsigned char) res;
|
buf[0] = (unsigned char) res;
|
||||||
if ((res = sockgetcharcli(param, conf.timeouts[SINGLEBYTE_S], 0)) == EOF) {RETURN(454);}
|
if ((res = sockgetcharcli(param, conf.timeouts[SINGLEBYTE_S], 0)) == EOF) {RETURN(441);}
|
||||||
buf[1] = (unsigned char) res;
|
buf[1] = (unsigned char) res;
|
||||||
param->sins.sin_port = param->req.sin_port = *(unsigned short*)buf;
|
port = *(unsigned short*)buf;
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
sockgetlinebuf(param, CLIENT, buf, BUFSIZE - 1, 0, conf.timeouts[STRING_S]);
|
sockgetlinebuf(param, CLIENT, buf, BUFSIZE - 1, 0, conf.timeouts[STRING_S]);
|
||||||
buf[127] = 0;
|
buf[127] = 0;
|
||||||
if(!param->srv->nouser && *buf && !param->username)param->username = (unsigned char *)mystrdup((char *)buf);
|
if(param->srv->needuser && *buf && !param->username)param->username = (unsigned char *)mystrdup((char *)buf);
|
||||||
if(param->sins.sin_addr.s_addr && ntohl(param->sins.sin_addr.s_addr)<256){
|
if(!memcmp(SAADDR(¶m->req), "\0\0\0", 3)){
|
||||||
param->service = S_SOCKS45;
|
param->service = S_SOCKS45;
|
||||||
sockgetlinebuf(param, CLIENT, buf, BUFSIZE - 1, 0, conf.timeouts[STRING_S]);
|
sockgetlinebuf(param, CLIENT, buf, BUFSIZE - 1, 0, conf.timeouts[STRING_S]);
|
||||||
buf[127] = 0;
|
buf[127] = 0;
|
||||||
if(param->hostname)myfree(param->hostname);
|
if(param->hostname)myfree(param->hostname);
|
||||||
param->hostname = (unsigned char *)mystrdup((char *)buf);
|
param->hostname = (unsigned char *)mystrdup((char *)buf);
|
||||||
param->sins.sin_addr.s_addr = param->req.sin_addr.s_addr = getip(buf);
|
if(!getip46(param->srv->family, buf, (struct sockaddr *) ¶m->req)) RETURN(100);
|
||||||
|
memcpy(¶m->sinsr, ¶m->req, sizeof(¶m->req));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(command == 1 && !param->req.sin_port) {RETURN(424);}
|
|
||||||
param->sins.sin_family = AF_INET;
|
*SAPORT(¶m->sinsr) = *SAPORT(¶m->req) = port;
|
||||||
|
if(command == 1 && !*SAPORT(¶m->sinsr)) {RETURN(421);}
|
||||||
switch(command) {
|
switch(command) {
|
||||||
case 1:
|
case 1:
|
||||||
param->operation = CONNECT;
|
param->operation = CONNECT;
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
param->sins.sin_addr.s_addr = param->extip;
|
|
||||||
param->sins.sin_port = param->extport?param->extport:param->req.sin_port;
|
|
||||||
if ((param->remsock=so._socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) == INVALID_SOCKET) {RETURN (11);}
|
|
||||||
param->operation = BIND;
|
|
||||||
break;
|
|
||||||
case 3:
|
case 3:
|
||||||
param->sins.sin_port = param->extport?param->extport:param->req.sin_port;
|
|
||||||
param->sins.sin_addr.s_addr = param->extip;
|
#ifndef NOIPV6
|
||||||
if ((param->remsock=so._socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) == INVALID_SOCKET) {RETURN (11);}
|
memcpy(¶m->sinsl, *SAFAMILY(¶m->req)==AF_INET6? (struct sockaddr *)¶m->srv->extsa6:(struct sockaddr *)¶m->srv->extsa, SASIZE(¶m->req));
|
||||||
param->operation = UDPASSOC;
|
#else
|
||||||
|
memcpy(¶m->sinsl, ¶m->srv->extsa, SASIZE(¶m->req));
|
||||||
|
#endif
|
||||||
|
if ((param->remsock=so._socket(SASOCK(¶m->req), command == 2? SOCK_STREAM:SOCK_DGRAM, command == 2?IPPROTO_TCP:IPPROTO_UDP)) == INVALID_SOCKET) {RETURN (11);}
|
||||||
|
param->operation = command == 2?BIND:UDPASSOC;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
RETURN(997);
|
RETURN(997);
|
||||||
}
|
}
|
||||||
|
|
||||||
if((res = (*param->srv->authfunc)(param))) {RETURN(res);}
|
if((res = (*param->srv->authfunc)(param))) {
|
||||||
|
RETURN(res);
|
||||||
|
}
|
||||||
|
|
||||||
if(command > 1) {
|
if(command > 1) {
|
||||||
if(so._bind(param->remsock,(struct sockaddr *)¶m->sins,sizeof(param->sins))) {
|
if(so._bind(param->remsock,(struct sockaddr *)¶m->sinsl,SASIZE(¶m->sinsl))) {
|
||||||
param->sins.sin_port = 0;
|
*SAPORT(¶m->sinsl) = 0;
|
||||||
if(so._bind(param->remsock,(struct sockaddr *)¶m->sins,sizeof(param->sins)))RETURN (12);
|
if(so._bind(param->remsock,(struct sockaddr *)¶m->sinsl,SASIZE(¶m->sinsl)))RETURN (12);
|
||||||
#if SOCKSTRACE > 0
|
#if SOCKSTRACE > 0
|
||||||
fprintf(stderr, "%s:%hu binded to communicate with server\n",
|
fprintf(stderr, "%hu binded to communicate with server\n", *SAPORT(¶m->sins));
|
||||||
inet_ntoa(param->sins.sin_addr),
|
|
||||||
ntohs(param->sins.sin_port)
|
|
||||||
);
|
|
||||||
fflush(stderr);
|
fflush(stderr);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
sasize = sizeof(struct sockaddr_in);
|
sasize = SASIZE(¶m->sinsl);
|
||||||
so._getsockname(param->remsock, (struct sockaddr *)¶m->sins, &sasize);
|
so._getsockname(param->remsock, (struct sockaddr *)¶m->sinsl, &sasize);
|
||||||
if(command == 3) {
|
if(command == 3) {
|
||||||
param->ctrlsock = param->clisock;
|
param->ctrlsock = param->clisock;
|
||||||
param->clisock = so._socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
|
param->clisock = so._socket(SASOCK(¶m->sincr), SOCK_DGRAM, IPPROTO_UDP);
|
||||||
if(param->clisock == INVALID_SOCKET) {RETURN(11);}
|
if(param->clisock == INVALID_SOCKET) {RETURN(11);}
|
||||||
sin.sin_family = AF_INET;
|
memcpy(&sin, ¶m->sincl, sizeof(&sin));
|
||||||
sin.sin_addr.s_addr = param->srv->intip;
|
*SAPORT(&sin) = 0;
|
||||||
sin.sin_port = htons(0);
|
if(so._bind(param->clisock,(struct sockaddr *)&sin,sizeof(sin))) {RETURN (12);}
|
||||||
if(so._bind(param->clisock,(struct sockaddr *)&sin,sizeof(struct sockaddr_in))) {RETURN (12);}
|
|
||||||
#if SOCKSTRACE > 0
|
#if SOCKSTRACE > 0
|
||||||
fprintf(stderr, "%s:%hu binded to communicate with client\n",
|
fprintf(stderr, "%hu binded to communicate with client\n",
|
||||||
inet_ntoa(sin.sin_addr),
|
ntohs(*SAPORT(&sin))
|
||||||
ntohs(sin.sin_port)
|
|
||||||
);
|
);
|
||||||
fflush(stderr);
|
fflush(stderr);
|
||||||
#endif
|
#endif
|
||||||
@@ -195,7 +220,9 @@ fflush(stderr);
|
|||||||
CLEANRET:
|
CLEANRET:
|
||||||
|
|
||||||
if(param->clisock != INVALID_SOCKET){
|
if(param->clisock != INVALID_SOCKET){
|
||||||
sasize = sizeof(struct sockaddr_in);
|
int repcode;
|
||||||
|
|
||||||
|
sasize = sizeof(sin);
|
||||||
if(command != 3) so._getsockname(param->remsock, (struct sockaddr *)&sin, &sasize);
|
if(command != 3) so._getsockname(param->remsock, (struct sockaddr *)&sin, &sasize);
|
||||||
else so._getsockname(param->clisock, (struct sockaddr *)&sin, &sasize);
|
else so._getsockname(param->clisock, (struct sockaddr *)&sin, &sasize);
|
||||||
#if SOCKSTRACE > 0
|
#if SOCKSTRACE > 0
|
||||||
@@ -207,20 +234,27 @@ fprintf(stderr, "Sending confirmation to client with code %d for %s with %s:%hu\
|
|||||||
);
|
);
|
||||||
fflush(stderr);
|
fflush(stderr);
|
||||||
#endif
|
#endif
|
||||||
|
if(!param->res) repcode = 0;
|
||||||
|
else if(param->res <= 10) repcode = 2;
|
||||||
|
else if (param->res < 20) repcode = 5;
|
||||||
|
else if (param->res < 30) repcode = 1;
|
||||||
|
else if (param->res < 100) repcode = 4;
|
||||||
|
else repcode = param->res%10;
|
||||||
|
|
||||||
if(ver == 5){
|
if(ver == 5){
|
||||||
buf[0] = 5;
|
buf[0] = 5;
|
||||||
buf[1] = param->res%10;
|
buf[1] = repcode;
|
||||||
buf[2] = 0;
|
buf[2] = 0;
|
||||||
buf[3] = 1;
|
buf[3] = (*SAFAMILY(&sin) == AF_INET)?1:4;
|
||||||
memcpy(buf+4, &sin.sin_addr.s_addr, 4);
|
memcpy(buf+4, SAADDR(&sin), SAADDRLEN(&sin));
|
||||||
memcpy(buf+8, &sin.sin_port, 2);
|
memcpy(buf+4+SAADDRLEN(&sin), SAPORT(&sin), 2);
|
||||||
socksend((command == 3)?param->ctrlsock:param->clisock, buf, 10, conf.timeouts[STRING_S]);
|
socksend((command == 3)?param->ctrlsock:param->clisock, buf, 6+SAADDRLEN(&sin), conf.timeouts[STRING_S]);
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
buf[0] = 0;
|
buf[0] = 0;
|
||||||
buf[1] = 90 + (param->res%10);
|
buf[1] = 90 + !!(repcode);
|
||||||
memcpy(buf+2, &sin.sin_port, 2);
|
memcpy(buf+2, SAPORT(&sin), 2);
|
||||||
memcpy(buf+4, &sin.sin_addr.s_addr, 4);
|
memcpy(buf+4, SAADDR(&sin), 4);
|
||||||
socksend(param->clisock, buf, 8, conf.timeouts[STRING_S]);
|
socksend(param->clisock, buf, 8, conf.timeouts[STRING_S]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -239,48 +273,48 @@ fflush(stderr);
|
|||||||
fds[0].fd = param->remsock;
|
fds[0].fd = param->remsock;
|
||||||
fds[1].fd = param->clisock;
|
fds[1].fd = param->clisock;
|
||||||
fds[0].events = fds[1].events = POLLIN;
|
fds[0].events = fds[1].events = POLLIN;
|
||||||
res = so._poll(fds, 2, conf.timeouts[(param->req.sin_addr.s_addr)?CONNECTION_S:CONNECTION_L] * 1000);
|
res = so._poll(fds, 2, conf.timeouts[CONNECTION_L] * 1000);
|
||||||
if (res < 1 || fds[1].revents) {
|
if (res < 1 || fds[1].revents) {
|
||||||
res = 460;
|
res = 460;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
sasize = sizeof(param->sins);
|
sasize = sizeof(param->sinsr);
|
||||||
s = so._accept(param->remsock, (struct sockaddr *)¶m->sins, &sasize);
|
s = so._accept(param->remsock, (struct sockaddr *)¶m->sinsr, &sasize);
|
||||||
so._closesocket(param->remsock);
|
so._closesocket(param->remsock);
|
||||||
param->remsock = s;
|
param->remsock = s;
|
||||||
if(s == INVALID_SOCKET) {
|
if(s == INVALID_SOCKET) {
|
||||||
param->res = 462;
|
param->res = 462;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if(param->req.sin_addr.s_addr && param->req.sin_addr.s_addr != param->sins.sin_addr.s_addr) {
|
if(SAISNULL(¶m->req) &&
|
||||||
|
memcmp(SAADDR(¶m->req),SAADDR(¶m->sinsr),SAADDRLEN(¶m->req))) {
|
||||||
param->res = 470;
|
param->res = 470;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#if SOCKSTRACE > 0
|
#if SOCKSTRACE > 0
|
||||||
fprintf(stderr, "Sending incoming connection to client with code %d for %s with %s:%hu\n",
|
fprintf(stderr, "Sending incoming connection to client with code %d for %s with %hu\n",
|
||||||
param->res,
|
param->res,
|
||||||
commands[command],
|
commands[command],
|
||||||
inet_ntoa(param->sins.sin_addr),
|
*SAPORT(param->sins);
|
||||||
ntohs(param->sins.sin_port)
|
|
||||||
);
|
);
|
||||||
fflush(stderr);
|
fflush(stderr);
|
||||||
#endif
|
#endif
|
||||||
if(ver == 5){
|
if(ver == 5){
|
||||||
memcpy (buf+4, ¶m->sins.sin_addr, 4);
|
buf[3] = (*SAFAMILY(¶m->sinsr) == AF_INET)?1:4;
|
||||||
memcpy (buf+8, ¶m->sins.sin_port, 2);
|
memcpy(buf+4, SAADDR(¶m->sinsr), SAADDRLEN(¶m->sinsr));
|
||||||
socksend(param->clisock, buf, 10, conf.timeouts[STRING_S]);
|
memcpy(buf+4+SAADDRLEN(¶m->sinsr), SAPORT(¶m->sinsr), 2);
|
||||||
|
socksend(param->clisock, buf, 6+SAADDRLEN(¶m->sinsr), conf.timeouts[STRING_S]);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
memcpy (buf+2, ¶m->sins.sin_port, 2);
|
memcpy (buf+2, SAPORT(¶m->sinsr), 2);
|
||||||
memcpy (buf+4, ¶m->sins.sin_addr, 4);
|
memcpy (buf+4, SAADDR(¶m->sinsr), 4);
|
||||||
socksend(param->clisock, buf, 8, conf.timeouts[STRING_S]);
|
socksend(param->clisock, buf, 8, conf.timeouts[STRING_S]);
|
||||||
}
|
}
|
||||||
|
|
||||||
param->res = sockmap(param, conf.timeouts[CONNECTION_S]);
|
param->res = sockmap(param, conf.timeouts[CONNECTION_S]);
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
param->sins.sin_addr.s_addr = param->req.sin_addr.s_addr;
|
memcpy(¶m->sinsr, ¶m->req, sizeof(param->sinsr));
|
||||||
param->sins.sin_port = param->req.sin_port;
|
|
||||||
myfree(buf);
|
myfree(buf);
|
||||||
if(!(buf = myalloc(LARGEBUFSIZE))) {RETURN(21);}
|
if(!(buf = myalloc(LARGEBUFSIZE))) {RETURN(21);}
|
||||||
|
|
||||||
@@ -300,12 +334,12 @@ fflush(stderr);
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (fds[1].revents) {
|
if (fds[1].revents) {
|
||||||
sasize = sizeof(struct sockaddr_in);
|
sasize = sizeof(sin);
|
||||||
if((len = so._recvfrom(param->clisock, buf, 65535, 0, (struct sockaddr *)&sin, &sasize)) <= 10) {
|
if((len = so._recvfrom(param->clisock, buf, 65535, 0, (struct sockaddr *)&sin, &sasize)) <= 10) {
|
||||||
param->res = 464;
|
param->res = 464;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if(sin.sin_addr.s_addr != param->sinc.sin_addr.s_addr){
|
if(SAADDRLEN(&sin) != SAADDRLEN(¶m->sincr) || memcmp(SAADDR(&sin), SAADDR(¶m->sincr), SAADDRLEN(&sin))){
|
||||||
param->res = 465;
|
param->res = 465;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -313,10 +347,14 @@ fflush(stderr);
|
|||||||
param->res = 466;
|
param->res = 466;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
size = 4;
|
||||||
switch(buf[3]) {
|
switch(buf[3]) {
|
||||||
|
case 4:
|
||||||
|
size = 16;
|
||||||
case 1:
|
case 1:
|
||||||
i = 8;
|
i = 4+size;
|
||||||
memcpy(¶m->sins.sin_addr.s_addr, buf+4, 4);
|
memcpy(SAADDR(¶m->sinsr), buf+4, size);
|
||||||
|
*SAFAMILY(¶m->sinsr) = (size == 4)?AF_INET:AF_INET6;
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
size = buf[4];
|
size = buf[4];
|
||||||
@@ -324,22 +362,22 @@ fflush(stderr);
|
|||||||
buf[i] = buf[i+1];
|
buf[i] = buf[i+1];
|
||||||
}
|
}
|
||||||
buf[i++] = 0;
|
buf[i++] = 0;
|
||||||
param->sins.sin_addr.s_addr = getip(buf+4);
|
if(!getip46(param->srv->family, buf, (struct sockaddr *) ¶m->sinsr)) RETURN(100);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
RETURN(996);
|
RETURN(997);
|
||||||
}
|
}
|
||||||
|
|
||||||
memcpy(¶m->sins.sin_port, buf+i, 2);
|
memcpy(SAPORT(¶m->sinsr), buf+i, 2);
|
||||||
i+=2;
|
i+=2;
|
||||||
|
|
||||||
sasize = sizeof(param->sins);
|
sasize = sizeof(param->sinsr);
|
||||||
if(len > (int)i){
|
if(len > (int)i){
|
||||||
if(socksendto(param->remsock, ¶m->sins, buf+i, len - i, conf.timeouts[SINGLEBYTE_L]*1000) <= 0){
|
if(socksendto(param->remsock, (struct sockaddr *)¶m->sinsr, buf+i, len - i, conf.timeouts[SINGLEBYTE_L]*1000) <= 0){
|
||||||
param->res = 467;
|
param->res = 467;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
param->statscli+=(len - i);
|
param->statscli64+=(len - i);
|
||||||
param->nwrites++;
|
param->nwrites++;
|
||||||
#if SOCKSTRACE > 1
|
#if SOCKSTRACE > 1
|
||||||
fprintf(stderr, "UDP packet relayed from client to %s:%hu size %d, header %d\n",
|
fprintf(stderr, "UDP packet relayed from client to %s:%hu size %d, header %d\n",
|
||||||
@@ -358,27 +396,25 @@ fflush(stderr);
|
|||||||
|
|
||||||
}
|
}
|
||||||
if (fds[0].revents) {
|
if (fds[0].revents) {
|
||||||
struct sockaddr_in tsin;
|
sasize = sizeof(param->sinsr);
|
||||||
sasize = sizeof(tsin);
|
|
||||||
buf[0]=buf[1]=buf[2]=0;
|
buf[0]=buf[1]=buf[2]=0;
|
||||||
buf[3]=1;
|
buf[3]=(*SAFAMILY(¶m->sinsl) == AF_INET)?1:4;
|
||||||
if((len = so._recvfrom(param->remsock, buf+10, 65535 - 10, 0, (struct sockaddr *)&tsin, &sasize)) <= 0) {
|
if((len = so._recvfrom(param->remsock, buf+6+SAADDRLEN(¶m->sinsl), 65535 - 10, 0, (struct sockaddr *)¶m->sinsr, &sasize)) <= 0) {
|
||||||
param->res = 468;
|
param->res = 468;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
param->statssrv+=len;
|
param->statssrv64+=len;
|
||||||
param->nreads++;
|
param->nreads++;
|
||||||
memcpy(buf+4, &tsin.sin_addr.s_addr, 4);
|
memcpy(buf+4, SAADDR(¶m->sinsr), SAADDRLEN(¶m->sinsr));
|
||||||
memcpy(buf+8, &tsin.sin_port, 2);
|
memcpy(buf+4+SAADDRLEN(¶m->sinsr), SAPORT(¶m->sinsr), 2);
|
||||||
sasize = sizeof(param->sins);
|
sasize = sizeof(sin);
|
||||||
if(socksendto(param->clisock, &sin, buf, len + 10, conf.timeouts[SINGLEBYTE_L]*1000) <=0){
|
if(socksendto(param->clisock, (struct sockaddr *)&sin, buf, len + 6 + SAADDRLEN(¶m->sinsr), conf.timeouts[SINGLEBYTE_L]*1000) <=0){
|
||||||
param->res = 469;
|
param->res = 469;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#if SOCKSTRACE > 1
|
#if SOCKSTRACE > 1
|
||||||
fprintf(stderr, "UDP packet relayed to client from %s:%hu size %d\n",
|
fprintf(stderr, "UDP packet relayed to client from %hu size %d\n",
|
||||||
inet_ntoa(tsin.sin_addr),
|
ntohs(*SAPORT(¶m->sinsr)),
|
||||||
ntohs(tsin.sin_port),
|
|
||||||
len
|
len
|
||||||
);
|
);
|
||||||
fflush(stderr);
|
fflush(stderr);
|
||||||
@@ -400,8 +436,9 @@ fflush(stderr);
|
|||||||
if(param->hostname){
|
if(param->hostname){
|
||||||
sprintf((char *)buf + strlen((char *)buf), "%.265s", param->hostname);
|
sprintf((char *)buf + strlen((char *)buf), "%.265s", param->hostname);
|
||||||
}
|
}
|
||||||
else myinet_ntoa(param->req.sin_addr, (char *)buf+strlen((char *)buf));
|
else
|
||||||
sprintf((char *)buf+strlen((char *)buf), ":%hu", ntohs(param->req.sin_port));
|
myinet_ntop(*SAFAMILY(¶m->req), SAADDR(¶m->req), (char *)buf + strlen((char *)buf), 64);
|
||||||
|
sprintf((char *)buf+strlen((char *)buf), ":%hu", ntohs(*SAPORT(¶m->req)));
|
||||||
(*param->srv->logfunc)(param, buf);
|
(*param->srv->logfunc)(param, buf);
|
||||||
myfree(buf);
|
myfree(buf);
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-3
@@ -4,7 +4,6 @@
|
|||||||
|
|
||||||
please read License Agreement
|
please read License Agreement
|
||||||
|
|
||||||
$Id: stringtable.c,v 1.16 2009/07/20 18:16:03 v.dubrovin Exp $
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
@@ -30,8 +29,9 @@ unsigned char * strings[] = {
|
|||||||
/* 16 */ (unsigned char *)"FTPPR",
|
/* 16 */ (unsigned char *)"FTPPR",
|
||||||
/* 17 */ (unsigned char *)"SMTPP",
|
/* 17 */ (unsigned char *)"SMTPP",
|
||||||
/* 18 */ (unsigned char *)"ICQPR",
|
/* 18 */ (unsigned char *)"ICQPR",
|
||||||
/* 19 */ (unsigned char *)"MSNPR",
|
/* 19 (unsigned char *)"MSNPR", */
|
||||||
/* 20 */ (unsigned char *)"ZOMBIE",
|
/* 19 */ (unsigned char *)"ZOMBIE",
|
||||||
|
/* 20 */ NULL,
|
||||||
/* 21 */ NULL,
|
/* 21 */ NULL,
|
||||||
/* 22 */ NULL,
|
/* 22 */ NULL,
|
||||||
/* 23 */ NULL,
|
/* 23 */ NULL,
|
||||||
|
|||||||
+128
-51
@@ -6,6 +6,12 @@
|
|||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
#ifndef NOPSTDINT
|
||||||
|
#include "pstdint.h"
|
||||||
|
#else
|
||||||
|
typedef unsigned long uint64_t
|
||||||
|
#define PRINTF_INT64_MODIFIER "l"
|
||||||
|
#endif
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
@@ -22,12 +28,12 @@ extern "C" {
|
|||||||
#define INVALID_SOCKET (-1)
|
#define INVALID_SOCKET (-1)
|
||||||
#else
|
#else
|
||||||
#include <winsock2.h>
|
#include <winsock2.h>
|
||||||
|
#include <Ws2tcpip.h>
|
||||||
#define pthread_mutex_t CRITICAL_SECTION
|
#define pthread_mutex_t CRITICAL_SECTION
|
||||||
#define pthread_mutex_init(x, y) InitializeCriticalSection(x)
|
#define pthread_mutex_init(x, y) InitializeCriticalSection(x)
|
||||||
#define pthread_mutex_lock(x) EnterCriticalSection(x)
|
#define pthread_mutex_lock(x) EnterCriticalSection(x)
|
||||||
#define pthread_mutex_unlock(x) LeaveCriticalSection(x)
|
#define pthread_mutex_unlock(x) LeaveCriticalSection(x)
|
||||||
#define pthread_mutex_destroy(x) DeleteCriticalSection(x)
|
#define pthread_mutex_destroy(x) DeleteCriticalSection(x)
|
||||||
typedef unsigned (__stdcall *BEGINTHREADFUNC)(void *);
|
|
||||||
#ifdef MSVC
|
#ifdef MSVC
|
||||||
#pragma warning (disable : 4996)
|
#pragma warning (disable : 4996)
|
||||||
#endif
|
#endif
|
||||||
@@ -92,6 +98,26 @@ int
|
|||||||
#define IM_MSN 0x00400000
|
#define IM_MSN 0x00400000
|
||||||
#define ADMIN 0x01000000
|
#define ADMIN 0x01000000
|
||||||
|
|
||||||
|
|
||||||
|
#define SAFAMILY(sa) (&(((struct sockaddr_in *)sa)->sin_family))
|
||||||
|
|
||||||
|
#ifndef NOIPV6
|
||||||
|
#define SAPORT(sa) (((struct sockaddr_in *)sa)->sin_family == AF_INET6? &((struct sockaddr_in6 *)sa)->sin6_port : &((struct sockaddr_in *)sa)->sin_port)
|
||||||
|
#define SAADDR(sa) (((struct sockaddr_in *)sa)->sin_family == AF_INET6? (unsigned char *)&((struct sockaddr_in6 *)sa)->sin6_addr : (unsigned char *)&((struct sockaddr_in *)sa)->sin_addr.s_addr)
|
||||||
|
#define SAADDRLEN(sa) (((struct sockaddr_in *)sa)->sin_family == AF_INET6? 16:4)
|
||||||
|
#define SASOCK(sa) (((struct sockaddr_in *)sa)->sin_family == AF_INET6? PF_INET6:PF_INET)
|
||||||
|
#define SASIZE(sa) (((struct sockaddr_in *)sa)->sin_family == AF_INET6? sizeof(struct sockaddr_in6):sizeof(struct sockaddr_in))
|
||||||
|
#define SAISNULL(sa) (!memcmp(((struct sockaddr_in *)sa)->sin_family == AF_INET6? (unsigned char *)&((struct sockaddr_in6 *)sa)->sin6_addr : (unsigned char *)&((struct sockaddr_in *)sa)->sin_addr.s_addr, NULLADDR, (((struct sockaddr_in *)sa)->sin_family == AF_INET6? 16:4)))
|
||||||
|
#else
|
||||||
|
#define SAPORT(sa) (&((struct sockaddr_in *)sa)->sin_port)
|
||||||
|
#define SAADDR(sa) ((unsigned char *)&((struct sockaddr_in *)sa)->sin_addr.s_addr)
|
||||||
|
#define SAADDRLEN(sa) (4)
|
||||||
|
#define SASOCK(sa) (PF_INET)
|
||||||
|
#define SASIZE(sa) (sizeof(struct sockaddr_in))
|
||||||
|
#define SAISNULL(sa) (((struct sockaddr_in *)sa)->sin_addr.s_addr == 0)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
extern char* NULLADDR;
|
||||||
typedef enum {
|
typedef enum {
|
||||||
CLIENT,
|
CLIENT,
|
||||||
SERVER
|
SERVER
|
||||||
@@ -113,7 +139,11 @@ typedef enum {
|
|||||||
S_FTPPR,
|
S_FTPPR,
|
||||||
S_SMTPP,
|
S_SMTPP,
|
||||||
S_ICQPR,
|
S_ICQPR,
|
||||||
|
S_REVLI,
|
||||||
|
S_REVCO,
|
||||||
|
/*
|
||||||
S_MSNPR,
|
S_MSNPR,
|
||||||
|
*/
|
||||||
S_ZOMBIE
|
S_ZOMBIE
|
||||||
}PROXYSERVICE;
|
}PROXYSERVICE;
|
||||||
|
|
||||||
@@ -126,14 +156,13 @@ struct srvparam;
|
|||||||
typedef void (*LOGFUNC)(struct clientparam * param, const unsigned char *);
|
typedef void (*LOGFUNC)(struct clientparam * param, const unsigned char *);
|
||||||
typedef int (*AUTHFUNC)(struct clientparam * param);
|
typedef int (*AUTHFUNC)(struct clientparam * param);
|
||||||
typedef void * (*REDIRECTFUNC)(struct clientparam * param);
|
typedef void * (*REDIRECTFUNC)(struct clientparam * param);
|
||||||
typedef unsigned long (*RESOLVFUNC)(unsigned char *);
|
typedef unsigned long (*RESOLVFUNC)(int af, unsigned char *name, unsigned char *value);
|
||||||
typedef unsigned (*BANDLIMFUNC)(struct clientparam * param, unsigned nbytesin, unsigned nbytesout);
|
typedef unsigned (*BANDLIMFUNC)(struct clientparam * param, unsigned nbytesin, unsigned nbytesout);
|
||||||
typedef void (*TRAFCOUNTFUNC)(struct clientparam * param);
|
typedef void (*TRAFCOUNTFUNC)(struct clientparam * param);
|
||||||
typedef void * (*EXTENDFUNC) (struct node *node);
|
typedef void * (*EXTENDFUNC) (struct node *node);
|
||||||
typedef void (*CBFUNC)(void *cb, char * buf, int inbuf);
|
typedef void (*CBFUNC)(void *cb, char * buf, int inbuf);
|
||||||
typedef void (*PRINTFUNC) (struct node *node, CBFUNC cbf, void*cb);
|
typedef void (*PRINTFUNC) (struct node *node, CBFUNC cbf, void*cb);
|
||||||
typedef int (*PLUGINFUNC) (struct pluginlink *pluginlink, int argc, char** argv);
|
typedef int (*PLUGINFUNC) (struct pluginlink *pluginlink, int argc, char** argv);
|
||||||
typedef void * (*PTHREADFUNC)(void *);
|
|
||||||
|
|
||||||
struct auth {
|
struct auth {
|
||||||
struct auth *next;
|
struct auth *next;
|
||||||
@@ -144,8 +173,14 @@ struct auth {
|
|||||||
|
|
||||||
struct iplist {
|
struct iplist {
|
||||||
struct iplist *next;
|
struct iplist *next;
|
||||||
unsigned long ip;
|
int family;
|
||||||
unsigned long mask;
|
#ifndef NOIPV6
|
||||||
|
struct in6_addr ip_from;
|
||||||
|
struct in6_addr ip_to;
|
||||||
|
#else
|
||||||
|
struct in_addr ip_from;
|
||||||
|
struct in_addr ip_to;
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
struct portlist {
|
struct portlist {
|
||||||
@@ -196,8 +231,11 @@ typedef enum {
|
|||||||
struct chain {
|
struct chain {
|
||||||
struct chain * next;
|
struct chain * next;
|
||||||
int type;
|
int type;
|
||||||
unsigned long redirip;
|
#ifndef NOIPV6
|
||||||
unsigned short redirport;
|
struct sockaddr_in6 addr;
|
||||||
|
#else
|
||||||
|
struct sockaddr_in addr;
|
||||||
|
#endif
|
||||||
unsigned short weight;
|
unsigned short weight;
|
||||||
unsigned char * extuser;
|
unsigned char * extuser;
|
||||||
unsigned char * extpass;
|
unsigned char * extpass;
|
||||||
@@ -257,16 +295,24 @@ struct trafcount {
|
|||||||
struct ace *ace;
|
struct ace *ace;
|
||||||
unsigned number;
|
unsigned number;
|
||||||
ROTATION type;
|
ROTATION type;
|
||||||
unsigned long traf;
|
uint64_t traf64;
|
||||||
unsigned long trafgb;
|
uint64_t traflim64;
|
||||||
unsigned long traflim;
|
|
||||||
unsigned long traflimgb;
|
|
||||||
char * comment;
|
char * comment;
|
||||||
int disabled;
|
int disabled;
|
||||||
time_t cleared;
|
time_t cleared;
|
||||||
time_t updated;
|
time_t updated;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct nserver {
|
||||||
|
#ifndef NOIPV6
|
||||||
|
struct sockaddr_in6 addr;
|
||||||
|
#else
|
||||||
|
struct sockaddr_in addr;
|
||||||
|
#endif
|
||||||
|
int usetcp;
|
||||||
|
};
|
||||||
|
extern int numservers;
|
||||||
|
|
||||||
typedef void * (* PROXYFUNC)(struct clientparam *);
|
typedef void * (* PROXYFUNC)(struct clientparam *);
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
@@ -314,20 +360,27 @@ struct srvparam {
|
|||||||
LOGFUNC logfunc;
|
LOGFUNC logfunc;
|
||||||
AUTHFUNC authfunc;
|
AUTHFUNC authfunc;
|
||||||
PROXYFUNC pf;
|
PROXYFUNC pf;
|
||||||
SOCKET srvsock;
|
SOCKET srvsock, cbsock;
|
||||||
int childcount;
|
int childcount;
|
||||||
int maxchild;
|
int maxchild;
|
||||||
int version;
|
int version;
|
||||||
int singlepacket;
|
int singlepacket;
|
||||||
int usentlm;
|
int usentlm;
|
||||||
int nouser;
|
int needuser;
|
||||||
int silent;
|
int silent;
|
||||||
int transparent;
|
int transparent;
|
||||||
int nfilters, nreqfilters, nhdrfilterscli, nhdrfilterssrv, npredatfilters, ndatfilterscli, ndatfilterssrv;
|
int nfilters, nreqfilters, nhdrfilterscli, nhdrfilterssrv, npredatfilters, ndatfilterscli, ndatfilterssrv;
|
||||||
|
int family;
|
||||||
unsigned bufsize;
|
unsigned bufsize;
|
||||||
unsigned logdumpsrv, logdumpcli;
|
unsigned logdumpsrv, logdumpcli;
|
||||||
unsigned long intip;
|
#ifndef NOIPV6
|
||||||
unsigned long extip;
|
struct sockaddr_in6 intsa;
|
||||||
|
struct sockaddr_in6 extsa6;
|
||||||
|
struct sockaddr_in6 extsa;
|
||||||
|
#else
|
||||||
|
struct sockaddr_in intsa;
|
||||||
|
struct sockaddr_in extsa;
|
||||||
|
#endif
|
||||||
pthread_mutex_t counter_mutex;
|
pthread_mutex_t counter_mutex;
|
||||||
struct pollfd fds;
|
struct pollfd fds;
|
||||||
FILE *stdlog;
|
FILE *stdlog;
|
||||||
@@ -340,8 +393,6 @@ struct srvparam {
|
|||||||
unsigned char * logformat;
|
unsigned char * logformat;
|
||||||
unsigned char * logtarget;
|
unsigned char * logtarget;
|
||||||
unsigned char * nonprintable;
|
unsigned char * nonprintable;
|
||||||
unsigned short intport;
|
|
||||||
unsigned short extport;
|
|
||||||
unsigned short targetport;
|
unsigned short targetport;
|
||||||
unsigned char replace;
|
unsigned char replace;
|
||||||
time_t time_start;
|
time_t time_start;
|
||||||
@@ -377,8 +428,8 @@ struct clientparam {
|
|||||||
|
|
||||||
int res,
|
int res,
|
||||||
status;
|
status;
|
||||||
unsigned waitclient,
|
uint64_t waitclient64,
|
||||||
waitserver;
|
waitserver64;
|
||||||
int pwtype,
|
int pwtype,
|
||||||
threadid,
|
threadid,
|
||||||
weight,
|
weight,
|
||||||
@@ -402,26 +453,26 @@ struct clientparam {
|
|||||||
srvoffset,
|
srvoffset,
|
||||||
clibufsize,
|
clibufsize,
|
||||||
srvbufsize,
|
srvbufsize,
|
||||||
msec_start,
|
msec_start;
|
||||||
maxtrafin,
|
uint64_t
|
||||||
maxtrafout;
|
maxtrafin64,
|
||||||
|
maxtrafout64;
|
||||||
|
#ifndef NOIPV6
|
||||||
|
struct sockaddr_in6 sincl, sincr, sinsl, sinsr, req;
|
||||||
|
#else
|
||||||
|
struct sockaddr_in sincl, sincr, sinsl, sinsr, req;
|
||||||
|
#endif
|
||||||
|
|
||||||
struct sockaddr_in sinc,
|
uint64_t statscli64,
|
||||||
sins,
|
statssrv64;
|
||||||
req;
|
unsigned long
|
||||||
|
|
||||||
unsigned long statscli,
|
|
||||||
statssrv,
|
|
||||||
nreads,
|
nreads,
|
||||||
nwrites,
|
nwrites,
|
||||||
nconnects,
|
nconnects;
|
||||||
extip;
|
|
||||||
|
|
||||||
struct bandlim *bandlims[MAXBANDLIMS],
|
struct bandlim *bandlims[MAXBANDLIMS],
|
||||||
*bandlimsout[MAXBANDLIMS];
|
*bandlimsout[MAXBANDLIMS];
|
||||||
|
|
||||||
unsigned short extport;
|
|
||||||
|
|
||||||
time_t time_start;
|
time_t time_start;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -446,8 +497,14 @@ struct extparam {
|
|||||||
unsigned char *logname, **archiver;
|
unsigned char *logname, **archiver;
|
||||||
ROTATION logtype, countertype;
|
ROTATION logtype, countertype;
|
||||||
char * counterfile;
|
char * counterfile;
|
||||||
unsigned long intip, extip;
|
#ifndef NOIPV6
|
||||||
unsigned short intport, extport;
|
struct sockaddr_in6 intsa;
|
||||||
|
struct sockaddr_in6 extsa6;
|
||||||
|
struct sockaddr_in6 extsa;
|
||||||
|
#else
|
||||||
|
struct sockaddr_in intsa;
|
||||||
|
struct sockaddr_in extsa;
|
||||||
|
#endif
|
||||||
struct passwords *pwl;
|
struct passwords *pwl;
|
||||||
struct auth * authenticate;
|
struct auth * authenticate;
|
||||||
AUTHFUNC authfunc;
|
AUTHFUNC authfunc;
|
||||||
@@ -525,6 +582,25 @@ struct child {
|
|||||||
unsigned char **argv;
|
unsigned char **argv;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct hashentry {
|
||||||
|
unsigned char hash[sizeof(unsigned)*4];
|
||||||
|
time_t expires;
|
||||||
|
struct hashentry *next;
|
||||||
|
char value[4];
|
||||||
|
};
|
||||||
|
|
||||||
|
struct hashtable {
|
||||||
|
unsigned hashsize;
|
||||||
|
unsigned recsize;
|
||||||
|
unsigned rnd[4];
|
||||||
|
struct hashentry ** hashtable;
|
||||||
|
void * hashvalues;
|
||||||
|
struct hashentry * hashempty;
|
||||||
|
};
|
||||||
|
|
||||||
|
extern struct hashtable dns_table;
|
||||||
|
extern struct hashtable dns6_table;
|
||||||
|
|
||||||
struct sockfuncs {
|
struct sockfuncs {
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
SOCKET (WINAPI *_socket)(int domain, int type, int protocol);
|
SOCKET (WINAPI *_socket)(int domain, int type, int protocol);
|
||||||
@@ -567,22 +643,22 @@ extern struct sockfuncs so;
|
|||||||
struct pluginlink {
|
struct pluginlink {
|
||||||
struct symbol symbols;
|
struct symbol symbols;
|
||||||
struct extparam *conf;
|
struct extparam *conf;
|
||||||
unsigned long *nservers;
|
struct nserver *nservers;
|
||||||
int * linenum;
|
int * linenum;
|
||||||
struct auth *authfuncs;
|
struct auth *authfuncs;
|
||||||
struct commands * commandhandlers;
|
struct commands * commandhandlers;
|
||||||
void * (*findbyname)(const char *name);
|
void * (*findbyname)(const char *name);
|
||||||
int (*socksend)(SOCKET sock, unsigned char * buf, int bufsize, int to);
|
int (*socksend)(SOCKET sock, unsigned char * buf, int bufsize, int to);
|
||||||
int (*socksendto)(SOCKET sock, struct sockaddr_in * sin, unsigned char * buf, int bufsize, int to);
|
int (*socksendto)(SOCKET sock, struct sockaddr * sin, unsigned char * buf, int bufsize, int to);
|
||||||
int (*sockrecvfrom)(SOCKET sock, struct sockaddr_in * sin, unsigned char * buf, int bufsize, int to);
|
int (*sockrecvfrom)(SOCKET sock, struct sockaddr * sin, unsigned char * buf, int bufsize, int to);
|
||||||
int (*sockgetcharcli)(struct clientparam * param, int timeosec, int timeousec);
|
int (*sockgetcharcli)(struct clientparam * param, int timeosec, int timeousec);
|
||||||
int (*sockgetcharsrv)(struct clientparam * param, int timeosec, int timeousec);
|
int (*sockgetcharsrv)(struct clientparam * param, int timeosec, int timeousec);
|
||||||
int (*sockgetlinebuf)(struct clientparam * param, DIRECTION which, unsigned char * buf, int bufsize, int delim, int to);
|
int (*sockgetlinebuf)(struct clientparam * param, DIRECTION which, unsigned char * buf, int bufsize, int delim, int to);
|
||||||
int (*myinet_ntoa)(struct in_addr in, char * buf);
|
int (*myinet_ntop)(int af, void *src, char *dst, socklen_t size);
|
||||||
int (*dobuf)(struct clientparam * param, unsigned char * buf, const unsigned char *s, const unsigned char * doublec);
|
int (*dobuf)(struct clientparam * param, unsigned char * buf, const unsigned char *s, const unsigned char * doublec);
|
||||||
int (*dobuf2)(struct clientparam * param, unsigned char * buf, const unsigned char *s, const unsigned char * doublec, struct tm* tm, char * format);
|
int (*dobuf2)(struct clientparam * param, unsigned char * buf, const unsigned char *s, const unsigned char * doublec, struct tm* tm, char * format);
|
||||||
int (*scanaddr)(const unsigned char *s, unsigned long * ip, unsigned long * mask);
|
int (*scanaddr)(const unsigned char *s, unsigned long * ip, unsigned long * mask);
|
||||||
unsigned long (*getip)(unsigned char *name);
|
unsigned long (*getip46)(int family, unsigned char *name, struct sockaddr *sa);
|
||||||
int (*sockmap)(struct clientparam * param, int timeo);
|
int (*sockmap)(struct clientparam * param, int timeo);
|
||||||
int (*ACLMatches)(struct ace* acentry, struct clientparam * param);
|
int (*ACLMatches)(struct ace* acentry, struct clientparam * param);
|
||||||
int (*alwaysauth)(struct clientparam * param);
|
int (*alwaysauth)(struct clientparam * param);
|
||||||
@@ -615,6 +691,17 @@ struct pluginlink {
|
|||||||
unsigned char * (*dologname) (unsigned char *buf, unsigned char *name, const unsigned char *ext, ROTATION lt, time_t t);
|
unsigned char * (*dologname) (unsigned char *buf, unsigned char *name, const unsigned char *ext, ROTATION lt, time_t t);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct counter_header {
|
||||||
|
unsigned char sig[4];
|
||||||
|
time_t updated;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct counter_record {
|
||||||
|
uint64_t traf64;
|
||||||
|
time_t cleared;
|
||||||
|
time_t updated;
|
||||||
|
};
|
||||||
|
|
||||||
extern struct pluginlink pluginlink;
|
extern struct pluginlink pluginlink;
|
||||||
extern char *rotations[];
|
extern char *rotations[];
|
||||||
|
|
||||||
@@ -634,9 +721,11 @@ typedef enum {
|
|||||||
TYPE_SHORT,
|
TYPE_SHORT,
|
||||||
TYPE_CHAR,
|
TYPE_CHAR,
|
||||||
TYPE_UNSIGNED,
|
TYPE_UNSIGNED,
|
||||||
|
TYPE_UNSIGNED64,
|
||||||
TYPE_TRAFFIC,
|
TYPE_TRAFFIC,
|
||||||
TYPE_PORT,
|
TYPE_PORT,
|
||||||
TYPE_IP,
|
TYPE_IP,
|
||||||
|
TYPE_SA,
|
||||||
TYPE_CIDR,
|
TYPE_CIDR,
|
||||||
TYPE_STRING,
|
TYPE_STRING,
|
||||||
TYPE_DATETIME,
|
TYPE_DATETIME,
|
||||||
@@ -657,19 +746,7 @@ typedef enum {
|
|||||||
TYPE_SERVER
|
TYPE_SERVER
|
||||||
}DATA_TYPE;
|
}DATA_TYPE;
|
||||||
|
|
||||||
struct hashentry {
|
|
||||||
unsigned char hash[sizeof(unsigned)*4];
|
|
||||||
unsigned long value;
|
|
||||||
time_t expires;
|
|
||||||
struct hashentry *next;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct hashtable {
|
|
||||||
unsigned hashsize;
|
|
||||||
struct hashentry ** hashtable;
|
|
||||||
struct hashentry * hashvalues;
|
|
||||||
struct hashentry * hashempty;
|
|
||||||
};
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,6 @@
|
|||||||
|
|
||||||
please read License Agreement
|
please read License Agreement
|
||||||
|
|
||||||
$Id: tcppm.c,v 1.15 2012-02-05 22:29:02 vlad Exp $
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "proxy.h"
|
#include "proxy.h"
|
||||||
|
|||||||
+15
-14
@@ -4,7 +4,6 @@
|
|||||||
|
|
||||||
please read License Agreement
|
please read License Agreement
|
||||||
|
|
||||||
$Id: udppm.c,v 1.27 2012-02-05 22:29:03 vlad Exp $
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "proxy.h"
|
#include "proxy.h"
|
||||||
@@ -40,7 +39,7 @@ void * udppmchild(struct clientparam* param) {
|
|||||||
|
|
||||||
|
|
||||||
if(!param->hostname)parsehostname((char *)param->srv->target, param, ntohs(param->srv->targetport));
|
if(!param->hostname)parsehostname((char *)param->srv->target, param, ntohs(param->srv->targetport));
|
||||||
if (!param->req.sin_addr.s_addr) {
|
if (SAISNULL(¶m->req)) {
|
||||||
param->srv->fds.events = POLLIN;
|
param->srv->fds.events = POLLIN;
|
||||||
RETURN (100);
|
RETURN (100);
|
||||||
}
|
}
|
||||||
@@ -49,7 +48,7 @@ void * udppmchild(struct clientparam* param) {
|
|||||||
RETURN (21);
|
RETURN (21);
|
||||||
}
|
}
|
||||||
param->cliinbuf = param->clioffset = 0;
|
param->cliinbuf = param->clioffset = 0;
|
||||||
i = sockrecvfrom(param->srv->srvsock, ¶m->sinc, param->clibuf, param->clibufsize, 0);
|
i = sockrecvfrom(param->srv->srvsock, (struct sockaddr *)¶m->sincr, param->clibuf, param->clibufsize, 0);
|
||||||
if(i<=0){
|
if(i<=0){
|
||||||
param->srv->fds.events = POLLIN;
|
param->srv->fds.events = POLLIN;
|
||||||
RETURN (214);
|
RETURN (214);
|
||||||
@@ -57,32 +56,34 @@ void * udppmchild(struct clientparam* param) {
|
|||||||
param->cliinbuf = i;
|
param->cliinbuf = i;
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
if((param->clisock=so._socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) == INVALID_SOCKET) {
|
if((param->clisock=so._socket(SASOCK(¶m->sincr), SOCK_DGRAM, IPPROTO_UDP)) == INVALID_SOCKET) {
|
||||||
RETURN(818);
|
RETURN(818);
|
||||||
}
|
}
|
||||||
if(so._setsockopt(param->clisock, SOL_SOCKET, SO_REUSEADDR, (unsigned char *)&ul, sizeof(int))) {RETURN(820);};
|
if(so._setsockopt(param->clisock, SOL_SOCKET, SO_REUSEADDR, (unsigned char *)&ul, sizeof(int))) {RETURN(820);};
|
||||||
ioctlsocket(param->clisock, FIONBIO, &ul);
|
ioctlsocket(param->clisock, FIONBIO, &ul);
|
||||||
size = sizeof(struct sockaddr_in);
|
size = sizeof(param->sinsl);
|
||||||
if(so._getsockname(param->srv->srvsock, (struct sockaddr *)¶m->sins, &size)) {RETURN(21);};
|
if(so._getsockname(param->srv->srvsock, (struct sockaddr *)¶m->sinsl, &size)) {RETURN(21);};
|
||||||
if(so._bind(param->clisock,(struct sockaddr *)¶m->sins,sizeof(struct sockaddr_in))) {
|
if(so._bind(param->clisock,(struct sockaddr *)¶m->sinsl,sizeof(struct sockaddr_in))) {
|
||||||
RETURN(822);
|
RETURN(822);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
param->clisock = param->srv->srvsock;
|
param->clisock = param->srv->srvsock;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
param->sins.sin_family = AF_INET;
|
#ifndef NOIPV6
|
||||||
param->sins.sin_port = htons(0);
|
memcpy(¶m->sinsl, *SAFAMILY(¶m->req) == AF_INET? (struct sockaddr *)¶m->srv->extsa : (struct sockaddr *)¶m->srv->extsa6, SASIZE(¶m->req));
|
||||||
param->sins.sin_addr.s_addr = param->extip;
|
#else
|
||||||
if ((param->remsock=so._socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) == INVALID_SOCKET) {RETURN (11);}
|
memcpy(¶m->sinsl, ¶m->srv->extsa, SASIZE(¶m->req));
|
||||||
if(so._bind(param->remsock,(struct sockaddr *)¶m->sins,sizeof(param->sins))) {RETURN (12);}
|
#endif
|
||||||
|
*SAPORT(¶m->sinsl) = 0;
|
||||||
|
if ((param->remsock=so._socket(SASOCK(¶m->sinsl), SOCK_DGRAM, IPPROTO_UDP)) == INVALID_SOCKET) {RETURN (11);}
|
||||||
|
if(so._bind(param->remsock,(struct sockaddr *)¶m->sinsl,sizeof(param->sinsl))) {RETURN (12);}
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
ioctlsocket(param->remsock, FIONBIO, &ul);
|
ioctlsocket(param->remsock, FIONBIO, &ul);
|
||||||
#else
|
#else
|
||||||
fcntl(param->remsock,F_SETFL,O_NONBLOCK);
|
fcntl(param->remsock,F_SETFL,O_NONBLOCK);
|
||||||
#endif
|
#endif
|
||||||
param->sins.sin_addr.s_addr = param->req.sin_addr.s_addr;
|
memcpy(¶m->sinsr, ¶m->req, sizeof(param->req));
|
||||||
param->sins.sin_port = param->req.sin_port;
|
|
||||||
|
|
||||||
param->operation = UDPASSOC;
|
param->operation = UDPASSOC;
|
||||||
if((res = (*param->srv->authfunc)(param))) {RETURN(res);}
|
if((res = (*param->srv->authfunc)(param))) {RETURN(res);}
|
||||||
|
|||||||
+2
-2
@@ -1,2 +1,2 @@
|
|||||||
#define VERSION "3proxy-0.7.1.4"
|
#define VERSION "3proxy-0.8.1"
|
||||||
#define BUILDDATE "160123190051"
|
#define BUILDDATE "160121162300"
|
||||||
+10
-17
@@ -4,7 +4,6 @@
|
|||||||
|
|
||||||
please read License Agreement
|
please read License Agreement
|
||||||
|
|
||||||
$Id: webadmin.c,v 1.44 2014-04-07 20:35:12 vlad Exp $
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "proxy.h"
|
#include "proxy.h"
|
||||||
@@ -319,21 +318,15 @@ static int printuserlist(char *buf, int bufsize, struct userlist* ul, char * del
|
|||||||
return printed;
|
return printed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int printiple(char *buf, struct iplist* ipl);
|
||||||
|
|
||||||
static int printiplist(char *buf, int bufsize, struct iplist* ipl, char * delim){
|
static int printiplist(char *buf, int bufsize, struct iplist* ipl, char * delim){
|
||||||
int printed = 0;
|
int printed = 0;
|
||||||
for(; ipl; ipl = ipl->next){
|
for(; ipl; ipl = ipl->next){
|
||||||
if(printed > (bufsize - 64)) break;
|
if(printed > (bufsize - 128)) break;
|
||||||
printed += sprintf(buf+printed, "%u.%u.%u.%u mask %u.%u.%u.%u%s",
|
printed += printiple(buf+printed, ipl);
|
||||||
(unsigned)(ntohl(ipl->ip)&0xff000000)>>24,
|
if(printed > (bufsize - 128)) {
|
||||||
(unsigned)(ntohl(ipl->ip)&0x00ff0000)>>16,
|
|
||||||
(unsigned)(ntohl(ipl->ip)&0x0000ff00)>>8,
|
|
||||||
(unsigned)(ntohl(ipl->ip)&0x000000ff),
|
|
||||||
(unsigned)(ntohl(ipl->mask)&0xff000000)>>24,
|
|
||||||
(unsigned)(ntohl(ipl->mask)&0x00ff0000)>>16,
|
|
||||||
(unsigned)(ntohl(ipl->mask)&0x0000ff00)>>8,
|
|
||||||
(unsigned)(ntohl(ipl->mask)&0x000000ff),
|
|
||||||
ipl->next?delim:"");
|
|
||||||
if(printed > (bufsize - 64)) {
|
|
||||||
printed += sprintf(buf+printed, "...");
|
printed += sprintf(buf+printed, "...");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -476,13 +469,13 @@ void * adminchild(struct clientparam* param) {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
inbuf += sprintf(buf+inbuf,
|
inbuf += sprintf(buf+inbuf,
|
||||||
"</td><td>%.3f</td>"
|
"</td><td>%"PRINTF_INT64_MODIFIER"u</td>"
|
||||||
"<td>MB%s</td>"
|
"<td>MB%s</td>"
|
||||||
"<td>%.3f MB</td>"
|
"<td>%"PRINTF_INT64_MODIFIER"u</td>"
|
||||||
"<td>%s</td>",
|
"<td>%s</td>",
|
||||||
(4 * 1024.0 * (float)cp->traflimgb) + (float)cp->traflim/(1024.*1024.),
|
cp->traflim64,
|
||||||
rotations[cp->type],
|
rotations[cp->type],
|
||||||
(4 * 1024.0 * (float)cp->trafgb) + (float)cp->traf/(1024.*1024.),
|
cp->traf64,
|
||||||
cp->cleared?ctime(&cp->cleared):"never"
|
cp->cleared?ctime(&cp->cleared):"never"
|
||||||
);
|
);
|
||||||
inbuf += sprintf(buf + inbuf,
|
inbuf += sprintf(buf + inbuf,
|
||||||
|
|||||||
Reference in new issue
Block a user