mirror of
https://github.com/3proxy/3proxy.git
synced 2026-11-26 23:59:41 +08:00
Compare commits
151
Commits
3proxy-0.8.3
...
0.8
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e85b064b52 | ||
|
|
9f6c0b5b8d | ||
|
|
3b67dc8447 | ||
|
|
d07500687c | ||
|
|
439373abd3 | ||
|
|
8afad700f8 | ||
|
|
a8b79d5df5 | ||
|
|
10a8febb0d | ||
|
|
747828d3ab | ||
|
|
9b8e6b33c7 | ||
|
|
05b23a840e | ||
|
|
5c9bb58a81 | ||
|
|
f8557187cd | ||
|
|
23623a22ff | ||
|
|
215171ad46 | ||
|
|
c20a04b752 | ||
|
|
3f859fdb11 | ||
|
|
556681a829 | ||
|
|
ee0bb55c06 | ||
|
|
2c0bc19f75 | ||
|
|
286aa51e78 | ||
|
|
145eb580e4 | ||
|
|
46211c26d2 | ||
|
|
e0262c23b0 | ||
|
|
7f80f4f958 | ||
|
|
6a54b37181 | ||
|
|
c0bb608acc | ||
|
|
4631335aca | ||
|
|
94c58b3db4 | ||
|
|
d75dcf0b54 | ||
|
|
28581b1738 | ||
|
|
d3395cf649 | ||
|
|
7b48714993 | ||
|
|
945c30c5ee | ||
|
|
a9fb0ea969 | ||
|
|
afbc27eac4 | ||
|
|
953c7efafc | ||
|
|
c650d32206 | ||
|
|
88af9d6050 | ||
|
|
9c8e18f0b5 | ||
|
|
0f695a4248 | ||
|
|
88263ebde9 | ||
|
|
a8f8a4d624 | ||
|
|
0b2afa1ba7 | ||
|
|
80b9e18588 | ||
|
|
63bafa5a62 | ||
|
|
fd29e887c3 | ||
|
|
ec9d556707 | ||
|
|
9890823664 | ||
|
|
880255093a | ||
|
|
4e96a66093 | ||
|
|
e2b406f27b | ||
|
|
b242d6df8c | ||
|
|
4e4f71712d | ||
|
|
6426ed0c1a | ||
|
|
cdc4210a0a | ||
|
|
7742b08ec5 | ||
|
|
05f39246bf | ||
|
|
84664a203b | ||
|
|
cd35215532 | ||
|
|
f347b37770 | ||
|
|
fbcdcf3d7b | ||
|
|
8cdf341d0e | ||
|
|
ccbc94e06b | ||
|
|
556fea670e | ||
|
|
32ff114787 | ||
|
|
438a5bac9b | ||
|
|
4cb43b438f | ||
|
|
8e820b28c0 | ||
|
|
cfa4d11027 | ||
|
|
8b1c12005f | ||
|
|
3c8c866ac1 | ||
|
|
d3f9d80b65 | ||
|
|
1d162abec3 | ||
|
|
d6f72a51fe | ||
|
|
e210f24194 | ||
|
|
9bfae5faaa | ||
|
|
2fed299b9d | ||
|
|
6cac541e33 | ||
|
|
938b1d1aab | ||
|
|
eeb2d78fb1 | ||
|
|
dcec2cadaa | ||
|
|
f67c9a39f1 | ||
|
|
a44a32c484 | ||
|
|
b513584fdb | ||
|
|
ac13a75721 | ||
|
|
f74da31fb3 | ||
|
|
5d0504cd33 | ||
|
|
cbe3d0cde9 | ||
|
|
5e850b54c3 | ||
|
|
58a64924dd | ||
|
|
75a7d5bb9e | ||
|
|
10a79faa32 | ||
|
|
394ada524a | ||
|
|
1404c63e10 | ||
|
|
3c751f4b75 | ||
|
|
09cfc076e2 | ||
|
|
5d9c1af5ca | ||
|
|
6db42f70e9 | ||
|
|
99781ceb23 | ||
|
|
22524d7876 | ||
|
|
9d85bf75ba | ||
|
|
19643f0d66 | ||
|
|
68e8530f85 | ||
|
|
6a8fee9847 | ||
|
|
364fe22bbb | ||
|
|
e2351034e6 | ||
|
|
49d382c7db | ||
|
|
89fd5a95ae | ||
|
|
57f1140734 | ||
|
|
aa38dd2ad2 | ||
|
|
c96d415020 | ||
|
|
604cc22d16 | ||
|
|
01857354c8 | ||
|
|
021a8928bf | ||
|
|
cf3bae0f6b | ||
|
|
bb206869de | ||
|
|
5c5f4e258f | ||
|
|
f8a7266bdf | ||
|
|
ad9b0046d9 | ||
|
|
b40e8fae4c | ||
|
|
6fcd12cb08 | ||
|
|
9ddc1fb874 | ||
|
|
43a36ec813 | ||
|
|
0d02989cce | ||
|
|
33e0eb5495 | ||
|
|
3b8e7741b3 | ||
|
|
f70a8c0019 | ||
|
|
5fc1d81e5c | ||
|
|
3680f2d3b1 | ||
|
|
6713530fda | ||
|
|
13a7d6be11 | ||
|
|
3cc9796583 | ||
|
|
9db88313c7 | ||
|
|
0263574655 | ||
|
|
0e168f17f9 | ||
|
|
4f7a82ed92 | ||
|
|
4202cee566 | ||
|
|
faf7f665c3 | ||
|
|
852f1abecb | ||
|
|
485ccb3ab4 | ||
|
|
e23dd7b746 | ||
|
|
95efeb8a93 | ||
|
|
43da6cc32b | ||
|
|
0473e1b2f7 | ||
|
|
975b4ac445 | ||
|
|
48361db51c | ||
|
|
ade0df0956 | ||
|
|
c61533aa54 | ||
|
|
0883fb6e34 | ||
|
|
2de3f0c380 |
No files matched your search
+16
-4
@@ -15,17 +15,30 @@ tmp/
|
|||||||
*.swp
|
*.swp
|
||||||
*.o
|
*.o
|
||||||
*.idb
|
*.idb
|
||||||
src/res
|
*.err
|
||||||
|
res
|
||||||
version.c
|
version.c
|
||||||
3proxy.res
|
3proxy.res
|
||||||
|
|
||||||
|
src/3proxy
|
||||||
|
src/proxy
|
||||||
|
src/socks
|
||||||
|
src/tcppm
|
||||||
|
src/udppm
|
||||||
|
src/pop3p
|
||||||
|
src/smtpp
|
||||||
|
src/ftppr
|
||||||
|
src/icqpr
|
||||||
|
src/mycrypt
|
||||||
|
src/dighosts
|
||||||
|
*.ld.so
|
||||||
|
*.dSYM
|
||||||
doc/html/man3/
|
doc/html/man3/
|
||||||
doc/html/man8/
|
doc/html/man8/
|
||||||
doc/html/index.html
|
|
||||||
*.var
|
*.var
|
||||||
verfile.sh
|
verfile.sh
|
||||||
Makefile
|
Makefile
|
||||||
Changelog
|
Changelog
|
||||||
res
|
|
||||||
copytgz.sh
|
copytgz.sh
|
||||||
*~.nib
|
*~.nib
|
||||||
local.properties
|
local.properties
|
||||||
@@ -157,7 +170,6 @@ csx
|
|||||||
AppPackages/
|
AppPackages/
|
||||||
|
|
||||||
# Others
|
# Others
|
||||||
sql/
|
|
||||||
*.Cache
|
*.Cache
|
||||||
ClientBin/
|
ClientBin/
|
||||||
[Ss]tyle[Cc]op.*
|
[Ss]tyle[Cc]op.*
|
||||||
|
|||||||
@@ -1,26 +1,22 @@
|
|||||||
#include "src/version.h"
|
1 VERSIONINFO
|
||||||
|
FILEVERSION 0,8,13,0
|
||||||
LANGUAGE 0x09, 0x01
|
PRODUCTVERSION 0,8,13,0
|
||||||
|
FILETYPE 1
|
||||||
VS_VERSION_INFO VERSIONINFO
|
FILESUBTYPE 0x0L
|
||||||
FILEVERSION 0,8,0,0
|
|
||||||
PRODUCTVERSION 0,8,0,0
|
|
||||||
FILETYPE 0x1L
|
|
||||||
FILESUBTYPE 0x0L
|
|
||||||
BEGIN
|
BEGIN
|
||||||
BLOCK "StringFileInfo"
|
BLOCK "StringFileInfo"
|
||||||
BEGIN
|
BEGIN
|
||||||
BLOCK "000004b0"
|
BLOCK "040904E4"
|
||||||
BEGIN
|
BEGIN
|
||||||
VALUE "Comments", "3proxy - tiny proxy server, http://3proxy.ru/"
|
VALUE "Comments", "3proxy - tiny proxy server, http://3proxy.ru/\0"
|
||||||
VALUE "CompanyName", "Vladimir Dubrovin"
|
VALUE "CompanyName", "Vladimir Dubrovin\0"
|
||||||
VALUE "FileDescription", "3proxy - tiny proxy server"
|
VALUE "FileDescription", "3proxy - tiny proxy server\0"
|
||||||
VALUE "FileVersion", VERSION "-" BUILDDATE
|
VALUE "FileVersion", "0.8.13\0"
|
||||||
VALUE "InternalName", "3proxy"
|
VALUE "InternalName", "3proxy\0"
|
||||||
VALUE "LegalCopyright", "Copyright (C) 2002-2014 Vladimir Dubrovin"
|
VALUE "LegalCopyright", "Copyright (C) 2002-2019 Vladimir Dubrovin\0"
|
||||||
VALUE "OriginalFilename", "3proxy.exe"
|
VALUE "OriginalFilename", "3proxy.exe\0"
|
||||||
VALUE "ProductName", "3proxy - tiny proxy server"
|
VALUE "ProductName", "3proxy\0"
|
||||||
VALUE "ProductVersion", VERSION
|
VALUE "ProductVersion", "0.8.13\0"
|
||||||
END
|
END
|
||||||
END
|
END
|
||||||
BLOCK "VarFileInfo"
|
BLOCK "VarFileInfo"
|
||||||
|
|||||||
+11
-5
@@ -4,21 +4,22 @@
|
|||||||
# You can try to remove -DWITH_STD_MALLOC to CFLAGS to use optimized malloc
|
# You can try to remove -DWITH_STD_MALLOC to CFLAGS to use optimized malloc
|
||||||
# libraries
|
# libraries
|
||||||
#
|
#
|
||||||
# remove -DNOODBC from CFLAGS and add -lodbc to LDFLAGS to compile with ODBC
|
# remove -DNOODBC from CFLAGS and add -lodbc to LIBS to compile with ODBC
|
||||||
# library support. Add -DSAFESQL for poorely written ODBC library / drivers.
|
# library support. Add -DSAFESQL for poorely written ODBC library / drivers.
|
||||||
|
|
||||||
BUILDDIR =
|
BUILDDIR =
|
||||||
CC = gcc
|
CC = gcc
|
||||||
|
|
||||||
CFLAGS = -g -O2 -c -pthread -DGETHOSTBYNAME_R -D_THREAD_SAFE -D_REENTRANT -DNOODBC -DWITH_STD_MALLOC -DFD_SETSIZE=4096 -DWITH_POLL
|
CFLAGS = -g -O2 -fno-strict-aliasing -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 = -O2 -pthread
|
LDFLAGS = -O2 -fno-strict-aliasing -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
|
LIBSPREFIX = -l
|
||||||
|
LIBSSUFFIX =
|
||||||
LNOUT = -o
|
LNOUT = -o
|
||||||
EXESUFFICS =
|
EXESUFFICS =
|
||||||
OBJSUFFICS = .o
|
OBJSUFFICS = .o
|
||||||
@@ -28,7 +29,12 @@ REMOVECOMMAND = rm -f
|
|||||||
TYPECOMMAND = cat
|
TYPECOMMAND = cat
|
||||||
COMPATLIBS =
|
COMPATLIBS =
|
||||||
MAKEFILE = Makefile.Linux
|
MAKEFILE = Makefile.Linux
|
||||||
PLUGINS = SSLPlugin StringsPlugin TrafficPlugin PCREPlugin TransparentPlugin
|
# PamAuth requires libpam, you may require pam-devel package to be installed
|
||||||
|
# SSLPlugin requires -lcrypto -lssl
|
||||||
|
#LIBS = -lcrypto -lssl -ldl
|
||||||
|
LIBS = -ldl
|
||||||
|
#PLUGINS = SSLPlugin StringsPlugin TrafficPlugin PCREPlugin TransparentPlugin PamAuth
|
||||||
|
PLUGINS = StringsPlugin TrafficPlugin PCREPlugin TransparentPlugin
|
||||||
|
|
||||||
include Makefile.inc
|
include Makefile.inc
|
||||||
|
|
||||||
|
|||||||
@@ -17,6 +17,8 @@ DCFLAGS = -fpic
|
|||||||
DLFLAGS = -shared
|
DLFLAGS = -shared
|
||||||
DLSUFFICS = .ld.so
|
DLSUFFICS = .ld.so
|
||||||
LIBS = -lpthread -lsocket -lnsl -lresolv -ldl
|
LIBS = -lpthread -lsocket -lnsl -lresolv -ldl
|
||||||
|
LIBSPREFIX = -l
|
||||||
|
LIBSSUFFIX =
|
||||||
LNOUT = -o ./
|
LNOUT = -o ./
|
||||||
EXESUFFICS =
|
EXESUFFICS =
|
||||||
OBJSUFFICS = .o
|
OBJSUFFICS = .o
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
|
|
||||||
BUILDDIR =
|
BUILDDIR =
|
||||||
CC = gcc
|
CC = gcc
|
||||||
CFLAGS = -O3 -c -D_SOLARIS -D_THREAD_SAFE -DGETHOSTBYNAME_R -D_REENTRANT -DNOODBC -DWITH_STD_MALLOC -DFD_SETSIZE=4096 -DWITH_POLL
|
CFLAGS = -O2 -fno-strict-aliasing -c -D_SOLARIS -D_THREAD_SAFE -DGETHOSTBYNAME_R -D_REENTRANT -DNOODBC -DWITH_STD_MALLOC -DFD_SETSIZE=4096 -DWITH_POLL
|
||||||
COUT = -o ./
|
COUT = -o ./
|
||||||
LN = gcc
|
LN = gcc
|
||||||
LDFLAGS = -O3
|
LDFLAGS = -O3
|
||||||
@@ -18,6 +18,8 @@ DCFLAGS = -fpic
|
|||||||
DLFLAGS = -shared
|
DLFLAGS = -shared
|
||||||
DLSUFFICS = .ld.so
|
DLSUFFICS = .ld.so
|
||||||
LIBS = -lpthread -lsocket -lnsl -lresolv -ldl
|
LIBS = -lpthread -lsocket -lnsl -lresolv -ldl
|
||||||
|
LIBSPREFIX = -l
|
||||||
|
LIBSSUFFIX =
|
||||||
LNOUT = -o ./
|
LNOUT = -o ./
|
||||||
EXESUFFICS =
|
EXESUFFICS =
|
||||||
OBJSUFFICS = .o
|
OBJSUFFICS = .o
|
||||||
|
|||||||
@@ -1,34 +0,0 @@
|
|||||||
#
|
|
||||||
# 3 proxy Makefile for Compaq C Compiler
|
|
||||||
#
|
|
||||||
# You can try to remove -DWITH_STD_MALLOC to CFLAGS to use optimized malloc
|
|
||||||
# libraries
|
|
||||||
#
|
|
||||||
# remove -DNOODBC from CFLAGS and add -lodbc to LDFLAGS to compile with ODBC
|
|
||||||
# library support. Add -DSAFESQL for poorely written ODBC library / drivers.
|
|
||||||
|
|
||||||
BUILDDIR =
|
|
||||||
CC = ccc
|
|
||||||
CFLAGS = -O2 -c -pthread -D_THREAD_SAFE -DNOODBC -DWITH_STD_MALLOC -DFD_SETSIZE=4096 -WITH_POLL
|
|
||||||
COUT = -o
|
|
||||||
LN = ccc
|
|
||||||
LDFLAGS = -O2 -pthread
|
|
||||||
DCFLAGS = -fpic
|
|
||||||
DLFLAGS = -shared
|
|
||||||
DLSUFFICS = .ld.so
|
|
||||||
LIBS =
|
|
||||||
LNOUT = -o
|
|
||||||
EXESUFFICS =
|
|
||||||
OBJSUFFICS = .o
|
|
||||||
DEFINEOPTION = -D
|
|
||||||
COMPFILES = *~
|
|
||||||
REMOVECOMMAND = rm -f
|
|
||||||
TYPECOMMAND = cat
|
|
||||||
COMPATLIBS =
|
|
||||||
MAKEFILE = Makefile.ccc
|
|
||||||
PLUGINS = StringsPlugin TrafficPlugin PCREPlugin
|
|
||||||
|
|
||||||
include Makefile.inc
|
|
||||||
|
|
||||||
allplugins:
|
|
||||||
@list='$(PLUGINS)'; for p in $$list; do cp Makefile Makefile.var plugins/$$p; cd plugins/$$p ; make ; cd ../.. ; done
|
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
#
|
||||||
|
# 3 proxy Makefile for GCC/windows
|
||||||
|
#
|
||||||
|
# You can try to remove -DWITH_STD_MALLOC to CFLAGS to use optimized malloc
|
||||||
|
# libraries
|
||||||
|
#
|
||||||
|
# remove -DNOODBC from CFLAGS and add -lodbc to LDFLAGS to compile with ODBC
|
||||||
|
# library support
|
||||||
|
|
||||||
|
|
||||||
|
BUILDDIR = ../bin/
|
||||||
|
CC = clang
|
||||||
|
CFLAGS = -O2 -fno-strict-aliasing -c -pthread -static -DWITH_STD_MALLOC -DNOIPV6
|
||||||
|
COUT = -o
|
||||||
|
LN = clang
|
||||||
|
LDFLAGS = -O2 -fno-strict-aliasing -static -s
|
||||||
|
DLFLAGS = -shared
|
||||||
|
DLSUFFICS = .dll
|
||||||
|
LIBS = -lws2_32 -lodbc32 -ladvapi32
|
||||||
|
LIBSPREFIX = -l
|
||||||
|
LIBSSUFFIX =
|
||||||
|
LNOUT = -o
|
||||||
|
EXESUFFICS = .exe
|
||||||
|
OBJSUFFICS = .o
|
||||||
|
DEFINEOPTION = -D
|
||||||
|
COMPFILES = *.tmp
|
||||||
|
REMOVECOMMAND = rm -f
|
||||||
|
TYPECOMMAND = cat
|
||||||
|
COMPATLIBS =
|
||||||
|
MAKEFILE = Makefile.win
|
||||||
|
PLUGINS = utf8tocp1251 WindowsAuthentication TrafficPlugin StringsPlugin PCREPlugin
|
||||||
|
|
||||||
|
include Makefile.inc
|
||||||
|
|
||||||
|
allplugins:
|
||||||
|
for /D %%i in ($(PLUGINS)) do (copy Makefile plugins\%%i && copy Makefile.var plugins\%%i && cd plugins\%%i && nmake && del *.o &&cd ..\..)
|
||||||
@@ -16,6 +16,8 @@ DLFLAGS = /DLL
|
|||||||
DLSUFFICS = .dll
|
DLSUFFICS = .dll
|
||||||
LIBS = ws2_32.lib advapi32.lib odbc32.lib user32.lib kernel32.lib Gdi32.lib libeay32MT.lib ssleay32MT.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
|
||||||
|
LIBSPREFIX =
|
||||||
|
LIBSSUFFIX = .lib
|
||||||
LIBEXT = .lib
|
LIBEXT = .lib
|
||||||
LNOUT = /out:
|
LNOUT = /out:
|
||||||
EXESUFFICS = .exe
|
EXESUFFICS = .exe
|
||||||
|
|||||||
@@ -16,6 +16,8 @@ DLFLAGS = /DLL
|
|||||||
DLSUFFICS = .dll
|
DLSUFFICS = .dll
|
||||||
LIBS = ws2_32.lib advapi32.lib odbc32.lib user32.lib kernel32.lib Gdi32.lib libeay32MT.lib ssleay32MT.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
|
||||||
|
LIBSPREFIX =
|
||||||
|
LIBSSUFFIX = .lib
|
||||||
LIBEXT = .lib
|
LIBEXT = .lib
|
||||||
LNOUT = /out:
|
LNOUT = /out:
|
||||||
EXESUFFICS = .exe
|
EXESUFFICS = .exe
|
||||||
|
|||||||
+5
-3
@@ -11,16 +11,18 @@ 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 = -g -O2 -c -pthread -D_THREAD_SAFE -D_REENTRANT -DNOODBC -DWITH_STD_MALLOC -DFD_SETSIZE=4096 -DWITH_POLL
|
CFLAGS = -g -O2 -fno-strict-aliasing -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 = -O2 -pthread
|
LDFLAGS = -O2 -fno-strict-aliasing -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
|
||||||
DLFLAGS = -shared
|
DLFLAGS = -shared
|
||||||
DLSUFFICS = .ld.so
|
DLSUFFICS = .ld.so
|
||||||
LIBS =
|
LIBS =
|
||||||
|
LIBSPREFIX = -l
|
||||||
|
LIBSSUFFIX =
|
||||||
LNOUT = -o
|
LNOUT = -o
|
||||||
EXESUFFICS =
|
EXESUFFICS =
|
||||||
OBJSUFFICS = .o
|
OBJSUFFICS = .o
|
||||||
@@ -30,7 +32,7 @@ REMOVECOMMAND = rm -f
|
|||||||
TYPECOMMAND = cat
|
TYPECOMMAND = cat
|
||||||
COMPATLIBS =
|
COMPATLIBS =
|
||||||
MAKEFILE = Makefile.unix
|
MAKEFILE = Makefile.unix
|
||||||
PLUGINS = StringsPlugin TrafficPlugin PCREPlugin
|
PLUGINS = StringsPlugin TrafficPlugin PCREPlugin PamAuth
|
||||||
|
|
||||||
include Makefile.inc
|
include Makefile.inc
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,43 @@
|
|||||||
|
#
|
||||||
|
# 3 proxy Makefile for Open Watcom 2
|
||||||
|
#
|
||||||
|
# You can try to remove -DWITH_STD_MALLOC to CFLAGS to use optimized malloc
|
||||||
|
# libraries
|
||||||
|
#
|
||||||
|
# Add /DSAFESQL to CFLAGS if you are using poorely written/tested ODBC driver
|
||||||
|
|
||||||
|
BUILDDIR = ../bin/
|
||||||
|
CC = cl
|
||||||
|
CFLAGS = /nologo /Ox /MT /D "NOIPV6" /D "NODEBUG" /D "NOODBC" /D"WATCOM" /D "MSVC" /D "WITH_STD_MALLOC" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "_WIN32" /c
|
||||||
|
COUT = /Fo
|
||||||
|
LN = link
|
||||||
|
LDFLAGS = /nologo /subsystem:console /incremental:no
|
||||||
|
DLFLAGS = /DLL
|
||||||
|
DLSUFFICS = .dll
|
||||||
|
LIBS = ws2_32.lib advapi32.lib user32.lib kernel32.lib
|
||||||
|
LIBSOLD = libeay32MT.lib ssleay32MT.lib
|
||||||
|
LIBSPREFIX =
|
||||||
|
LIBSSUFFIX = .lib
|
||||||
|
LIBEXT = .lib
|
||||||
|
LNOUT = /out:
|
||||||
|
EXESUFFICS = .exe
|
||||||
|
OBJSUFFICS = .obj
|
||||||
|
DEFINEOPTION = /D
|
||||||
|
COMPFILES = *.pch *.idb *.err
|
||||||
|
REMOVECOMMAND = del 2>NUL >NUL
|
||||||
|
TYPECOMMAND = type
|
||||||
|
COMPATLIBS =
|
||||||
|
MAKEFILE = Makefile.watcom
|
||||||
|
PLUGINS = utf8tocp1251 WindowsAuthentication TrafficPlugin StringsPlugin PCREPlugin
|
||||||
|
VERFILE = $(VERFILE)
|
||||||
|
|
||||||
|
include Makefile.inc
|
||||||
|
|
||||||
|
../3proxy.res:
|
||||||
|
rc /fo../3proxy.res ../3proxy.rc
|
||||||
|
|
||||||
|
3proxyres.obj: ../3proxy.res
|
||||||
|
cvtres /out:3proxyres.obj ../3proxy.res
|
||||||
|
|
||||||
|
allplugins:
|
||||||
|
call ../makeplugins.bat
|
||||||
@@ -17,6 +17,8 @@ LDFLAGS = -O2 -s -mthreads
|
|||||||
DLFLAGS = -shared
|
DLFLAGS = -shared
|
||||||
DLSUFFICS = .dll
|
DLSUFFICS = .dll
|
||||||
LIBS = -lws2_32 -lodbc32 -ladvapi32
|
LIBS = -lws2_32 -lodbc32 -ladvapi32
|
||||||
|
LIBSPREFIX = -l
|
||||||
|
LIBSSUFFIX =
|
||||||
LNOUT = -o
|
LNOUT = -o
|
||||||
EXESUFFICS = .exe
|
EXESUFFICS = .exe
|
||||||
OBJSUFFICS = .o
|
OBJSUFFICS = .o
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ users 3APA3A:CL:3apa3a "test:CR:$1$qwer$CHFTUFGqkjue9HyhcMHEe1"
|
|||||||
service
|
service
|
||||||
# service is required under NT if you want 3proxy to start as service
|
# service is required under NT if you want 3proxy to start as service
|
||||||
|
|
||||||
#log /usr/local/etc/3proxy/logs/3proxy.log D
|
#log /var/log/3proxy/log D
|
||||||
log c:\3proxy\logs\3proxy.log D
|
log c:\3proxy\logs\3proxy.log D
|
||||||
# log allows to specify log file location and rotation, D means logfile
|
# log allows to specify log file location and rotation, D means logfile
|
||||||
# is created daily
|
# is created daily
|
||||||
|
|||||||
@@ -0,0 +1,53 @@
|
|||||||
|
# By Mark Dreuband
|
||||||
|
nserver 10.1.2.1
|
||||||
|
nscache 65536
|
||||||
|
|
||||||
|
# we can grab wpad file from provider and feed it to dighosts
|
||||||
|
# to build list of free networks
|
||||||
|
# system "c:\3proxy\dighosts.exe -m http://wpad.security.nnov.ru/wpad.dat c:\3proxy\freenetworks.net"
|
||||||
|
|
||||||
|
service
|
||||||
|
|
||||||
|
internal 192.168.1.1
|
||||||
|
external 10.1.1.1
|
||||||
|
|
||||||
|
dnspr
|
||||||
|
|
||||||
|
log &3proxylog,root
|
||||||
|
#log c:\3proxy\logs\proxy.log D
|
||||||
|
#logformat "Linsert into log (timestamp, username, service, clientip, remoteip, remoteport, bytesin, bytesout,request,error) values (
|
||||||
|
#logformat "%t '%U' '%N' '%C' '%R' %r %I %O '%T' %E"
|
||||||
|
logformat "-\'+_Linsert into log (time, bytesin, bytesout, username, url, host, port, service) values ('%Y-%m-%d %H:%M:%S', %I, %O, '%U', '%T', '%n', %r, '%N');"
|
||||||
|
archiver zip c:\3proxy\zip.exe -m -qq %A %F
|
||||||
|
rotate 50
|
||||||
|
|
||||||
|
|
||||||
|
auth strong
|
||||||
|
users temp:CL:password root:CL:password
|
||||||
|
|
||||||
|
# access free networks directly
|
||||||
|
allow * * $c:\3proxy\freenetworks.net
|
||||||
|
# redirect web traffic for non-free networks to provider's proxy
|
||||||
|
allow * * * 80
|
||||||
|
parent 1000 http 10.1.2.5 3128
|
||||||
|
# allow rest of traffic
|
||||||
|
allow *
|
||||||
|
proxy
|
||||||
|
|
||||||
|
flush
|
||||||
|
|
||||||
|
auth iponly
|
||||||
|
allow *
|
||||||
|
pop3p
|
||||||
|
tcppm 25 mail.security.nnov.ru 25
|
||||||
|
|
||||||
|
flush
|
||||||
|
# redirect port 80 traffic via SOCKS server to local HTTP proxy to
|
||||||
|
# have URLs logged
|
||||||
|
allow * * * 80
|
||||||
|
parent 1000 http 0.0.0.0 0
|
||||||
|
allow *
|
||||||
|
socks
|
||||||
|
|
||||||
|
#daemon
|
||||||
|
|
||||||
@@ -0,0 +1,56 @@
|
|||||||
|
# Connection: localhost
|
||||||
|
# Host: 127.0.0.1
|
||||||
|
# Saved: 2004-04-09 18:53:52
|
||||||
|
#
|
||||||
|
# Host: 127.0.0.1
|
||||||
|
# Database: 3proxy
|
||||||
|
# Table: 'log'
|
||||||
|
#
|
||||||
|
CREATE TABLE `log` (
|
||||||
|
`time` datetime NOT NULL default '0000-00-00 00:00:00',
|
||||||
|
`bytesin` int(11) NOT NULL default '0',
|
||||||
|
`bytesout` int(11) NOT NULL default '0',
|
||||||
|
`username` varchar(20) NOT NULL default '',
|
||||||
|
`service` varchar(7) NOT NULL default '',
|
||||||
|
`host` varchar(100) NOT NULL default '',
|
||||||
|
`port` int(11) NOT NULL default '0',
|
||||||
|
`url` varchar(255) NOT NULL default ''
|
||||||
|
) TYPE=MyISAM;
|
||||||
|
|
||||||
|
CREATE TABLE `services` (
|
||||||
|
`startport` int(11) NOT NULL default '0',
|
||||||
|
`endport` int(11) NOT NULL default '0',
|
||||||
|
`service` varchar(100) NOT NULL default '',
|
||||||
|
`description` varchar(100) NOT NULL default ''
|
||||||
|
) TYPE=MyISAM;
|
||||||
|
|
||||||
|
CREATE TABLE `timelimit` (
|
||||||
|
`datefrom` datetime NOT NULL default '0000-00-00 00:00:00',
|
||||||
|
`dateto` datetime NOT NULL default '0000-00-00 00:00:00'
|
||||||
|
) TYPE=MyISAM;
|
||||||
|
|
||||||
|
INSERT INTO services (80, 80, NULL, 'Access to Web Server');
|
||||||
|
|
||||||
|
INSERT INTO services (443, 443, NULL, 'Secure Access to Web Server');
|
||||||
|
|
||||||
|
INSERT INTO services (3128, 3128, NULL, 'Access to Web server via external Proxy');
|
||||||
|
INSERT INTO services (1080, 1080, NULL, 'Access to external SOCKS server');
|
||||||
|
INSERT INTO services (5190, 5190, NULL, 'Access to ICQ');
|
||||||
|
INSERT INTO services (6666, 6668, NULL, 'Access to IRC');
|
||||||
|
|
||||||
|
INSERT INTO services (119, 119, NULL, 'Access to news server');
|
||||||
|
INSERT INTO services (25, 25, NULL, 'Sent Mail');
|
||||||
|
|
||||||
|
INSERT INTO services (0, 0, 'POP3P', 'Received Mail');
|
||||||
|
INSERT INTO services (0, 0, 'SMTPP', 'Sent Mail');
|
||||||
|
INSERT INTO services (0, 0, 'TCPPM', 'Access to external server via TCP');
|
||||||
|
INSERT INTO services (0, 0, 'UDPPM', 'Access to external server via UDP');
|
||||||
|
INSERT INTO services (0, 0, 'PROXY', 'Access to external server via Proxy');
|
||||||
|
INSERT INTO services (0, 0, 'FTPPR', 'Access to external server via FTP Proxy');
|
||||||
|
INSERT INTO services (0, 0, 'ICQPR', 'Access to external server via ICQ Proxy');
|
||||||
|
INSERT INTO services (0, 0, 'SOCKS4', 'Access to external server via Socks v4');
|
||||||
|
INSERT INTO services (0, 0, 'SOCKS5', 'Access to external server via Socks v5');
|
||||||
|
INSERT INTO services (0, 0, 'DNSPR', 'Name resolution');
|
||||||
|
INSERT INTO services (0, 0, NULL, 'Unknown');
|
||||||
|
|
||||||
|
|
||||||
Binary file not shown.
@@ -1,6 +0,0 @@
|
|||||||
all: isqlodbc$(EXESUFFICS)
|
|
||||||
clean:
|
|
||||||
@$(REMOVECOMMAND) *$(OBJSUFFICS) $(COMPFILES)
|
|
||||||
|
|
||||||
isqlodbc$(EXESUFFICS): isqlodbc$(OBJSUFFICS)
|
|
||||||
$(LN) $(LNOUT)isqlodbc$(EXESUFFICS) $(LDFLAGS) $(VERFILE) isqlodbc$(OBJSUFFICS) $(COMPATLIBS) $(LIBS)
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
CC = gcc
|
|
||||||
CFLAGS = -I /usr/local/include -DUNIX
|
|
||||||
COUT = -o
|
|
||||||
LN = gcc
|
|
||||||
LDFLAGS =
|
|
||||||
LIBS =-L /usr/local/lib -lodbc
|
|
||||||
LNOUT = -o
|
|
||||||
EXESUFFICS =
|
|
||||||
OBJSUFFICS = .o
|
|
||||||
DEFINEOPTION = -D
|
|
||||||
COMPFILES = *~
|
|
||||||
REMOVECOMMAND = rm -f
|
|
||||||
COMPATLIBS =
|
|
||||||
|
|
||||||
include Makefile.inc
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
CC = gcc
|
|
||||||
CFLAGS = -DWIN32
|
|
||||||
COUT = -o
|
|
||||||
LN = gcc
|
|
||||||
LDFLAGS =
|
|
||||||
LIBS = -lodbc32
|
|
||||||
LNOUT = -o
|
|
||||||
EXESUFFICS =
|
|
||||||
OBJSUFFICS = .o
|
|
||||||
DEFINEOPTION = -D
|
|
||||||
COMPFILES = *~
|
|
||||||
REMOVECOMMAND = rm -f
|
|
||||||
COMPATLIBS =
|
|
||||||
|
|
||||||
include Makefile.inc
|
|
||||||
@@ -1,191 +0,0 @@
|
|||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
#ifdef WIN32
|
|
||||||
#include <io.h>
|
|
||||||
#include <windows.h>
|
|
||||||
#endif
|
|
||||||
#ifdef UNIX
|
|
||||||
#include <sqltypes.h>
|
|
||||||
#endif
|
|
||||||
#include <sql.h>
|
|
||||||
#include <sqlext.h>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#define BUF_LENGTH 65000
|
|
||||||
|
|
||||||
/* environment variable */
|
|
||||||
SQLHENV env=NULL;
|
|
||||||
SQLHDBC dbc=NULL;
|
|
||||||
SQLHSTMT stmt=NULL;
|
|
||||||
SQLHSTMT cstmt=NULL;
|
|
||||||
unsigned char *dsn;
|
|
||||||
unsigned char *user;
|
|
||||||
unsigned char *pass;
|
|
||||||
|
|
||||||
RETCODE retcod;
|
|
||||||
|
|
||||||
/*description a columns of result of request */
|
|
||||||
SQLSMALLINT ColumnCount;
|
|
||||||
unsigned int ColNumber;
|
|
||||||
unsigned char ColName[SQL_MAX_COLUMN_NAME_LEN];
|
|
||||||
unsigned int Length;
|
|
||||||
unsigned int Type;
|
|
||||||
unsigned int Size;
|
|
||||||
unsigned int Digits;
|
|
||||||
unsigned int Nullable;
|
|
||||||
|
|
||||||
|
|
||||||
unsigned char data_buf[BUF_LENGTH];
|
|
||||||
unsigned long OutData;
|
|
||||||
|
|
||||||
/* function print error message*/
|
|
||||||
void PrintError(HENV env,HDBC dbc,HSTMT stmt,RETCODE retcod)
|
|
||||||
{
|
|
||||||
SQLINTEGER nError;
|
|
||||||
SQLSMALLINT TextLength;
|
|
||||||
unsigned char BufErrMsg[SQL_MAX_MESSAGE_LENGTH+1];
|
|
||||||
unsigned char SqlState[128];
|
|
||||||
|
|
||||||
SQLError(env,dbc,stmt,SqlState,&nError,BufErrMsg,512, &TextLength);
|
|
||||||
printf("%s\n" ,BufErrMsg);
|
|
||||||
}
|
|
||||||
|
|
||||||
void sqlquery(SQLHDBC dbc,SQLHSTMT stmt, unsigned char *strquery)
|
|
||||||
{
|
|
||||||
retcod=SQLAllocStmt(dbc, &stmt);
|
|
||||||
|
|
||||||
retcod=SQLExecDirect(stmt,strquery,SQL_NTS);
|
|
||||||
if(retcod!=SQL_SUCCESS)
|
|
||||||
{ PrintError(env,dbc,stmt,retcod);}
|
|
||||||
|
|
||||||
SQLNumResultCols(stmt,&ColumnCount);
|
|
||||||
|
|
||||||
while(SQLFetch(stmt)==SQL_SUCCESS)
|
|
||||||
{
|
|
||||||
for(ColNumber=1; ColNumber<=ColumnCount ; ColNumber++)
|
|
||||||
{
|
|
||||||
SQLGetData(stmt,ColNumber,SQL_CHAR,data_buf,BUF_LENGTH,&OutData);
|
|
||||||
printf("%s|",data_buf);
|
|
||||||
}
|
|
||||||
printf("\n",data_buf);
|
|
||||||
strcpy(data_buf,"");
|
|
||||||
}
|
|
||||||
SQLFreeStmt( stmt, SQL_DROP );
|
|
||||||
}
|
|
||||||
|
|
||||||
/* isqlodbc dsn[[,user][,pass]] ["SQLCMD"] */
|
|
||||||
int main(int argc, char *argv[])
|
|
||||||
{
|
|
||||||
unsigned char qbuf[64000];
|
|
||||||
unsigned char *ptr=NULL;
|
|
||||||
|
|
||||||
/* Allocate environment and database connection handles */
|
|
||||||
retcod=SQLAllocEnv( &env );
|
|
||||||
if(retcod!=SQL_SUCCESS)
|
|
||||||
{
|
|
||||||
PrintError(env,dbc,stmt,retcod);
|
|
||||||
SQLFreeEnv(env);
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
retcod = SQLAllocConnect( env, &dbc );
|
|
||||||
if(retcod!=SQL_SUCCESS)
|
|
||||||
{
|
|
||||||
PrintError(env,dbc,stmt,retcod);
|
|
||||||
SQLFreeConnect( dbc );
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if(argc > 1 )
|
|
||||||
{
|
|
||||||
/* parsing command line and get parametrs */
|
|
||||||
dsn = strtok(argv[1],",");
|
|
||||||
user = strtok(NULL, ",");
|
|
||||||
pass = strtok(NULL, ",");
|
|
||||||
|
|
||||||
/* Connect from DSN */
|
|
||||||
retcod=SQLConnect(dbc,dsn,SQL_NTS,user,SQL_NTS,pass,SQL_NTS);
|
|
||||||
|
|
||||||
if(retcod!=SQL_SUCCESS)
|
|
||||||
{ PrintError(env,dbc,stmt,retcod); }
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (argc > 2)
|
|
||||||
{
|
|
||||||
/*sql cmd from command line*/
|
|
||||||
sqlquery(dbc,stmt,argv[2]);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/*sql cmd from stdin */
|
|
||||||
if( isatty(0) ){ printf(".tables - list table\n.q - exit\nsql>"); }
|
|
||||||
while(fgets(qbuf,63000,stdin) != NULL )
|
|
||||||
{
|
|
||||||
ptr=strrchr(qbuf,';');
|
|
||||||
if (ptr!=NULL)
|
|
||||||
{
|
|
||||||
sqlquery(dbc,stmt,qbuf);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/*cmd exit*/
|
|
||||||
if (strstr(qbuf,".q")){ break; };
|
|
||||||
|
|
||||||
/*cmd table list*/
|
|
||||||
if (strstr(qbuf,".tables"))
|
|
||||||
{
|
|
||||||
retcod=SQLAllocStmt(dbc, &stmt);
|
|
||||||
if(retcod!=SQL_SUCCESS){ PrintError(env,dbc,stmt,retcod); }
|
|
||||||
else
|
|
||||||
{
|
|
||||||
retcod=SQLTables(stmt,NULL,0,NULL,0,NULL,0,NULL,0);
|
|
||||||
if(retcod !=SQL_SUCCESS) { PrintError(env,dbc,stmt,retcod);}
|
|
||||||
while(SQLFetch(stmt)==SQL_SUCCESS)
|
|
||||||
{
|
|
||||||
SQLGetData(stmt,3,SQL_CHAR,data_buf,BUF_LENGTH,&OutData);
|
|
||||||
printf("%s|",data_buf);
|
|
||||||
|
|
||||||
/*list columns */
|
|
||||||
retcod=SQLAllocStmt(dbc, &cstmt);
|
|
||||||
retcod=SQLColumns(cstmt,NULL,0,NULL,0,data_buf,strlen(data_buf),NULL,0);
|
|
||||||
|
|
||||||
if(retcod !=SQL_SUCCESS) { PrintError(env,dbc,stmt,retcod);}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
printf("create table %s (",data_buf);
|
|
||||||
while(SQLFetch(cstmt)==SQL_SUCCESS)
|
|
||||||
{
|
|
||||||
SQLGetData(cstmt,4,SQL_CHAR,data_buf,BUF_LENGTH,&OutData);
|
|
||||||
printf("%s ",data_buf);
|
|
||||||
SQLGetData(cstmt,6,SQL_CHAR,data_buf,BUF_LENGTH,&OutData);
|
|
||||||
printf("%s, ",data_buf);
|
|
||||||
}
|
|
||||||
printf(");\n");
|
|
||||||
SQLFreeStmt( cstmt, SQL_DROP );
|
|
||||||
}/*end list columns*/
|
|
||||||
|
|
||||||
}/*end while SQLFetch */
|
|
||||||
SQLFreeStmt( stmt, SQL_DROP );
|
|
||||||
}
|
|
||||||
|
|
||||||
}/*end if (strstr(qbuf,".tables")) */
|
|
||||||
|
|
||||||
|
|
||||||
} /*end else cmd*/
|
|
||||||
if( isatty(0) ){ printf("sql>"); }
|
|
||||||
} /*end while*/
|
|
||||||
}
|
|
||||||
}
|
|
||||||
SQLDisconnect(dbc);
|
|
||||||
} /* if (argc > 2) */
|
|
||||||
else
|
|
||||||
{
|
|
||||||
printf("isqlodbc dsn[[,user][,pass]] [\"SQLCMD\"]\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
SQLFreeConnect( dbc );
|
|
||||||
SQLFreeEnv( env );
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
|
|
||||||
create table log (ldate date,ltime time,username char (30),userip char (16),bytein integer (10),byteout integer (10),service char (8), host char(255), hostport integer (10), url char (255) );
|
|
||||||
|
|
||||||
create index idate on log (ldate);
|
|
||||||
create index iusername on log (username);
|
|
||||||
create index iuserip on log (userip);
|
|
||||||
create index ihost on log (host);
|
|
||||||
|
|
||||||
create table services (port integer(10),service char(100),description char (100));
|
|
||||||
|
|
||||||
INSERT INTO services values (80,'PROXY', 'Access to Web Server');
|
|
||||||
INSERT INTO services values (21,'PROXY', 'Access to Ftp Server via HTTP proxy');
|
|
||||||
INSERT INTO services values (5190,'PROXY', 'Access to ICQ via HTTP proxy');
|
|
||||||
INSERT INTO services values (0, 'POP3P', 'Received Mail via POP3');
|
|
||||||
INSERT INTO services values (0,'FTPPR', 'Access to Ftp server via FTP proxy');
|
|
||||||
INSERT INTO services values (0,'SOCKS4', 'Access to external server via Socks v4');
|
|
||||||
INSERT INTO services values (0,'SOCKS5', 'Access to external server via Socks v5');
|
|
||||||
INSERT INTO services values (0,'TCPPM', 'Access to external server via TCP mapping');
|
|
||||||
INSERT INTO services values (0,'UDPPM', 'Access to external server via UDP mapping');
|
|
||||||
INSERT INTO services values (0, 0, NULL, 'Unknown');
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,63 +0,0 @@
|
|||||||
------------------------------ KOI8-R ------------------------------------
|
|
||||||
Этот архив содержит набор CGI cкриптов и программ для получения
|
|
||||||
статистики работы пользователей прокси сервера "3proxy", посредством анализа
|
|
||||||
лога расположенного в ODBC источнике(базе), через Web интерфейс.
|
|
||||||
|
|
||||||
stat.awk - основной CGI скрипт (Для его испольнения под Win9X/2000 необходима
|
|
||||||
программа awk.exe ,в linux/freebsd она как правило входит в сиситему
|
|
||||||
по умолчанию).
|
|
||||||
isqlodbc - программа для выполнения SQL запросов к базам ODBC
|
|
||||||
(вызывается из stat.awk). компилируется gcc и работает как в
|
|
||||||
win9X/2000 так и в linux/freebsd. (Так же может
|
|
||||||
использоваться независимо от stat.awk как отдельная
|
|
||||||
программа..)
|
|
||||||
log.sql - SQL скрипт создания базы для лога сервера.
|
|
||||||
awk.exe - awk интерпретатор под Win9X/2000.
|
|
||||||
|
|
||||||
Настройка скриптов статистики .
|
|
||||||
|
|
||||||
Для работы вам потребуется:
|
|
||||||
1) любой http сервер подерживающий CGI
|
|
||||||
2) odbc менеджер (под win32 ) или iodbc менеджер (под unix)
|
|
||||||
любая база данных например : sqlite, mysql, postgress или любые другие
|
|
||||||
имеющие ODBC драйвера.(Как настраивать iODBC под linux/freebsd смотрите в
|
|
||||||
файле iodbc.txt в каталоге /doc/ru архива 3proxy.)
|
|
||||||
|
|
||||||
Шаг настройки N1:
|
|
||||||
Создаем базу данных и DSN для хранения лога. ( в нашем случае DSN будет
|
|
||||||
называться "sqlite".) далее выполняя скрипт log.sql создаем необходимые
|
|
||||||
таблицы и индексы:
|
|
||||||
|
|
||||||
isqlodbc sqlite < log.sql
|
|
||||||
|
|
||||||
Шаг настройки N2:
|
|
||||||
Устанавливаем DSN и формат таблицы с логом в файле 3proxy.cfg следующего вида:
|
|
||||||
-----------
|
|
||||||
# create table log (
|
|
||||||
# ldate date,
|
|
||||||
# ltime time,
|
|
||||||
# username char (30),
|
|
||||||
# userip char (16),
|
|
||||||
# bytein integer (10),
|
|
||||||
# byteout integer (10),
|
|
||||||
# service char (8),
|
|
||||||
# host char(255),
|
|
||||||
# hostport integer (10),
|
|
||||||
# url char (255)
|
|
||||||
# );
|
|
||||||
|
|
||||||
log &sqlite
|
|
||||||
logformat "Linsert into log values ('%Y-%m-%d','%H:%M:%S','%U','%C','%I','%O','%N','%n','%r','%T');"
|
|
||||||
-----------
|
|
||||||
|
|
||||||
Шаг настройки N3:
|
|
||||||
Копируем файлы isqlodbc и stat.awk в каталог с CGI скриптами http сервера
|
|
||||||
и меняем в stat.awk путь вызова и DSN на свои значения , например:
|
|
||||||
isql="./isqlodbc.exe sqlite "
|
|
||||||
|
|
||||||
Шаг настройки N4:
|
|
||||||
Пробуем вызвать скрипт из web браузера , например
|
|
||||||
|
|
||||||
http://localhost/cgi/stat.awk?
|
|
||||||
|
|
||||||
------------------------------ KOI8-R ------------------------------------
|
|
||||||
@@ -1,129 +0,0 @@
|
|||||||
#!/usr/bin/awk -f
|
|
||||||
BEGIN {
|
|
||||||
scriptname = ENVIRON["SCRIPT_NAME"]
|
|
||||||
#for win32
|
|
||||||
isql=".\\isqlodbc.exe sqlite "
|
|
||||||
|
|
||||||
#for unix
|
|
||||||
#isql="./isqlodbc sqlite "
|
|
||||||
|
|
||||||
|
|
||||||
print "Content-Type: text/html; charset=koi8-r \n\n"
|
|
||||||
print "<HTML>\n<BODY>\n";
|
|
||||||
|
|
||||||
# query parse
|
|
||||||
query_str = ENVIRON["QUERY_STRING"]
|
|
||||||
n = split(query_str, querys, "&")
|
|
||||||
for (i=1; i<=n; i++)
|
|
||||||
{
|
|
||||||
split(querys[i], data, "=")
|
|
||||||
qr[data[1]] = data[2]
|
|
||||||
}
|
|
||||||
|
|
||||||
printf "<FORM METHOD=PUT action=\"" scriptname "?rep=1\">"
|
|
||||||
printf "datefrom:<INPUT name=\"datefrom\" value=\"2004-06-01\"> "
|
|
||||||
printf "dateto:<INPUT name=\"dateto\" value=\"2004-07-30\"> <br>"
|
|
||||||
printf "<INPUT type=\"radio\" name=\"userid\" value=\"username\" checked> LOGIN user <br>"
|
|
||||||
printf "<INPUT type=\"radio\" name=\"userid\" value=\"userip\"> IP user <br>"
|
|
||||||
printf "<INPUT type=\"hidden\" name=\"rep\" value=\"user\">"
|
|
||||||
printf "<INPUT type=\"submit\" value=\"Report\">"
|
|
||||||
printf "</FORM>"
|
|
||||||
|
|
||||||
|
|
||||||
#printf "query_str=%s\n<br>",query_str
|
|
||||||
#print qr["rep"]
|
|
||||||
|
|
||||||
if(qr["rep"]=="user")
|
|
||||||
{
|
|
||||||
cmd = isql " \"select " qr["userid"] ",sum(bytein),sum(byteout),sum(bytein+byteout) from log \
|
|
||||||
where ldate > '" qr["datefrom"] "' AND ldate < '" qr["dateto"] \
|
|
||||||
"' group by " qr["userid"] " order by sum(bytein+byteout) desc;\""
|
|
||||||
printf " <table WIDTH=100%% BORDER=1><tr><td><b>user</b></td> <td><b>bytein</b></td> <td><b>byteout</b> </td> <td> <b>bytesum</b></td></tr>"
|
|
||||||
while( (cmd|getline result)>0)
|
|
||||||
{
|
|
||||||
split(result, rt, "|")
|
|
||||||
printf "<tr> <td><a href=\"%s?rep=host&datefrom=%s&dateto=%s&userid=%s&selectid=%s\"> %s <\/a></td><td>%d</td><td>%d</td><td>%d</td></tr>",
|
|
||||||
scriptname,qr["datefrom"],qr["dateto"],qr["userid"],rt[1],rt[1],rt[2],rt[3],rt[4]
|
|
||||||
totalbytein=totalbytein+rt[2];
|
|
||||||
totalbyteout=totalbyteout+rt[3];
|
|
||||||
totalbytesum=totalbytesum+rt[4];
|
|
||||||
}
|
|
||||||
printf "<tr> <td><br>Total users</td> <td><br>%d</td> <td><br>%d</td> \
|
|
||||||
<td><br>%d</td></tr> </table> ",totalbytein,totalbyteout, totalbytesum
|
|
||||||
close(cmd)
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if(qr["rep"]=="host")
|
|
||||||
{
|
|
||||||
cmd = isql "\"select sum(bytein+byteout), sum(bytein), sum(byteout),host from log \
|
|
||||||
where ldate > '" qr["datefrom"] "' AND ldate < '"qr["dateto"] \
|
|
||||||
"' AND " qr["userid"] " = '" qr["selectid"] \
|
|
||||||
"' group by host order by sum(bytein+byteout) desc;\""
|
|
||||||
|
|
||||||
printf "<center><b>Detail statistic for user: %s</b></center>",qr["selectid"]
|
|
||||||
printf " <table WIDTH=100%% BORDER=1> <tr><td><b>sum byte</b></td> <td><b>bytein</b></td> <td><b>byteout</b></td><td><b>host</b></td></tr>"
|
|
||||||
while( (cmd|getline result)>0)
|
|
||||||
{
|
|
||||||
split(result, rt, "|")
|
|
||||||
printf "<tr><td>%d</td><td>%d</td><td>%d</td><td>%s</td></tr>",rt[1],rt[2],rt[3],rt[4]
|
|
||||||
totalbytein=totalbytein+rt[1];
|
|
||||||
totalbyteout=totalbyteout+rt[2];
|
|
||||||
totalbytesum=totalbytesum+rt[3];
|
|
||||||
|
|
||||||
}
|
|
||||||
printf "<tr> <td><br>%d</td> <td><br>%d</td> \
|
|
||||||
<td><br>%d</td><td><br>Total host</td></tr> </table> ",totalbytein,totalbyteout, totalbytesum
|
|
||||||
printf " </table> "
|
|
||||||
close(cmd)
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
printf " </BODY> </HTML>";
|
|
||||||
} # end BEGIN
|
|
||||||
|
|
||||||
|
|
||||||
# decode urlencoded string
|
|
||||||
function decode(text, hex, i, hextab, decoded, len, c, c1, c2, code) {
|
|
||||||
|
|
||||||
split("0 1 2 3 4 5 6 7 8 9 a b c d e f", hex, " ")
|
|
||||||
for (i=0; i<16; i++) hextab[hex[i+1]] = i
|
|
||||||
|
|
||||||
# urldecode function from Heiner Steven
|
|
||||||
# http://www.shelldorado.com/scripts/cmds/urldecode
|
|
||||||
|
|
||||||
# decode %xx to ASCII char
|
|
||||||
decoded = ""
|
|
||||||
i = 1
|
|
||||||
len = length(text)
|
|
||||||
|
|
||||||
while ( i <= len ) {
|
|
||||||
c = substr (text, i, 1)
|
|
||||||
if ( c == "%" )
|
|
||||||
{
|
|
||||||
if ( i+2 <= len )
|
|
||||||
{
|
|
||||||
c1 = tolower(substr(text, i+1, 1))
|
|
||||||
c2 = tolower(substr(text, i+2, 1))
|
|
||||||
if ( hextab [c1] != "" || hextab [c2] != "" ) {
|
|
||||||
if ( (c1 >= 2 && (c1 != 7 && c2 != "F")) || (c1 == 0 && c2 ~ "[9acd]") )
|
|
||||||
{
|
|
||||||
code = 0 + hextab [c1] * 16 + hextab [c2] + 0
|
|
||||||
c = sprintf ("%c", code)
|
|
||||||
}
|
|
||||||
else { c = " " }
|
|
||||||
i = i + 2
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if ( c == "+" ) { # special handling: "+" means " "
|
|
||||||
c = " "
|
|
||||||
}
|
|
||||||
decoded = decoded c
|
|
||||||
++i
|
|
||||||
}
|
|
||||||
# change linebreaks to \n
|
|
||||||
gsub(/\r\n/, "\n", decoded)
|
|
||||||
# remove last linebreak
|
|
||||||
sub(/[\n\r]*$/,"",decoded)
|
|
||||||
return decoded
|
|
||||||
}
|
|
||||||
@@ -1,185 +0,0 @@
|
|||||||
#!/usr/bin/perl
|
|
||||||
eval 'exec /usr/bin/perl -S $0 ${1+"$@"}'
|
|
||||||
if $running_under_some_shell;
|
|
||||||
# this emulates #! processing on NIH machines.
|
|
||||||
# (remove #! line above if indigestible)
|
|
||||||
|
|
||||||
eval '$'.$1.'$2;' while $ARGV[0] =~ /^([A-Za-z_0-9]+=)(.*)/ && shift;
|
|
||||||
# process any FOO=bar switches
|
|
||||||
|
|
||||||
$[ = 1; # set array base to 1
|
|
||||||
$, = ' '; # set output field separator
|
|
||||||
$\ = "\n"; # set output record separator
|
|
||||||
|
|
||||||
$scriptname = $ENVIRON{'SCRIPT_NAME'};
|
|
||||||
#for win32
|
|
||||||
$isql = ".\\isqlodbc.exe sqlite ";
|
|
||||||
|
|
||||||
#for unix
|
|
||||||
#isql="./isqlodbc sqlite "
|
|
||||||
|
|
||||||
print "Content-Type: text/html; charset=koi8-r \n\n";
|
|
||||||
print "<HTML>\n<BODY>\n";
|
|
||||||
|
|
||||||
# query parse
|
|
||||||
$query_str = $ENVIRON{'QUERY_STRING'};
|
|
||||||
$n = (@querys = split(/&/, $query_str, 9999));
|
|
||||||
for ($i = 1; $i <= $n; $i++) {
|
|
||||||
@data = split(/=/, $querys[$i], 9999);
|
|
||||||
$qr{$data[1]} = $data[2];
|
|
||||||
}
|
|
||||||
|
|
||||||
printf "<FORM METHOD=PUT action=\"" . $scriptname . "?rep=1\">";
|
|
||||||
printf "datefrom:<INPUT name=\"datefrom\" value=\"2004-06-01\"> ";
|
|
||||||
printf "dateto:<INPUT name=\"dateto\" value=\"2004-07-30\"> <br>";
|
|
||||||
printf
|
|
||||||
|
|
||||||
"<INPUT type=\"radio\" name=\"userid\" value=\"username\" checked> LOGIN user <br>";
|
|
||||||
printf
|
|
||||||
|
|
||||||
"<INPUT type=\"radio\" name=\"userid\" value=\"userip\"> IP user <br>";
|
|
||||||
printf "<INPUT type=\"hidden\" name=\"rep\" value=\"user\">";
|
|
||||||
printf "<INPUT type=\"submit\" value=\"Report\">";
|
|
||||||
printf '</FORM>';
|
|
||||||
|
|
||||||
#printf "query_str=%s\n<br>",query_str
|
|
||||||
#print qr["rep"]
|
|
||||||
|
|
||||||
if ($qr{'rep'} eq 'user') {
|
|
||||||
$cmd = $isql . " \"select " . $qr{'userid'} .
|
|
||||||
|
|
||||||
",sum(bytein),sum(byteout),sum(bytein+byteout) from log where ldate > '"
|
|
||||||
|
|
||||||
. $qr{'datefrom'} . "' AND ldate < '" . $qr{'dateto'} . "' group by " .
|
|
||||||
|
|
||||||
$qr{'userid'} . " order by sum(bytein+byteout) desc;\"";
|
|
||||||
printf
|
|
||||||
|
|
||||||
' <table WIDTH=100%% BORDER=1><tr><td><b>user</b></td> <td><b>bytein</b></td> <td><b>byteout</b> </td> <td> <b>bytesum</b></td></tr>';
|
|
||||||
while ((($result = &Getline3($cmd, '|'),$getline_ok)) > 0) {
|
|
||||||
@rt = split(/\|/, $result, 9999);
|
|
||||||
printf
|
|
||||||
|
|
||||||
"<tr> <td><a href=\"%s?rep=host&datefrom=%s&dateto=%s&userid=%s&selectid=%s\"> %s <\\/a></td><td>%d</td><td>%d</td><td>%d</td></tr>",
|
|
||||||
|
|
||||||
|
|
||||||
$scriptname, $qr{'datefrom'}, $qr{'dateto'}, $qr{'userid'}, $rt[1],
|
|
||||||
|
|
||||||
$rt[1], $rt[2], $rt[3], $rt[4];
|
|
||||||
$totalbytein = $totalbytein + $rt[2];
|
|
||||||
$totalbyteout = $totalbyteout + $rt[3];
|
|
||||||
$totalbytesum = $totalbytesum + $rt[4];
|
|
||||||
}
|
|
||||||
printf
|
|
||||||
|
|
||||||
'<tr> <td><br>Total users</td> <td><br>%d</td> <td><br>%d</td> <td><br>%d</td></tr> </table> ',
|
|
||||||
|
|
||||||
$totalbytein, $totalbyteout, $totalbytesum;
|
|
||||||
delete $opened{$cmd} && close($cmd);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($qr{'rep'} eq 'host') {
|
|
||||||
$cmd = $isql .
|
|
||||||
|
|
||||||
"\"select sum(bytein+byteout), sum(bytein), sum(byteout),host from log where ldate > '"
|
|
||||||
|
|
||||||
. $qr{'datefrom'} . "' AND ldate < '" . $qr{'dateto'} . "' AND " .
|
|
||||||
|
|
||||||
$qr{'userid'} . " = '" . $qr{'selectid'} .
|
|
||||||
|
|
||||||
"' group by host order by sum(bytein+byteout) desc;\"";
|
|
||||||
|
|
||||||
printf '<center><b>Detail statistic for user: %s</b></center>',
|
|
||||||
|
|
||||||
$qr{'selectid'};
|
|
||||||
printf
|
|
||||||
|
|
||||||
' <table WIDTH=100%% BORDER=1> <tr><td><b>sum byte</b></td> <td><b>bytein</b></td> <td><b>byteout</b></td><td><b>host</b></td></tr>';
|
|
||||||
while ((($result = &Getline3($cmd, '|'),$getline_ok)) > 0) {
|
|
||||||
@rt = split(/\|/, $result, 9999);
|
|
||||||
printf '<tr><td>%d</td><td>%d</td><td>%d</td><td>%s</td></tr>',
|
|
||||||
|
|
||||||
$rt[1], $rt[2], $rt[3], $rt[4];
|
|
||||||
$totalbytein = $totalbytein + $rt[1];
|
|
||||||
$totalbyteout = $totalbyteout + $rt[2];
|
|
||||||
$totalbytesum = $totalbytesum + $rt[3];
|
|
||||||
}
|
|
||||||
printf
|
|
||||||
|
|
||||||
'<tr> <td><br>%d</td> <td><br>%d</td> <td><br>%d</td><td><br>Total host</td></tr> </table> ',
|
|
||||||
|
|
||||||
$totalbytein, $totalbyteout, $totalbytesum;
|
|
||||||
printf ' </table> ';
|
|
||||||
delete $opened{$cmd} && close($cmd);
|
|
||||||
}
|
|
||||||
|
|
||||||
printf ' </BODY> </HTML>';
|
|
||||||
|
|
||||||
# end BEGIN
|
|
||||||
|
|
||||||
# decode urlencoded string
|
|
||||||
|
|
||||||
sub decode {
|
|
||||||
local($text, *Hex, $i, *hextab, $decoded, $len, $c, $c1, $c2, $code) = @_;
|
|
||||||
@Hex = split(' ', '0 1 2 3 4 5 6 7 8 9 a b c d e f', 9999);
|
|
||||||
for ($i = 0; $i < 16; $i++) {
|
|
||||||
$hextab{$Hex[$i + 1]} = $i;
|
|
||||||
|
|
||||||
# urldecode function from Heiner Steven
|
|
||||||
# http://www.shelldorado.com/scripts/cmds/urldecode
|
|
||||||
|
|
||||||
# decode %xx to ASCII char
|
|
||||||
;
|
|
||||||
}
|
|
||||||
$decoded = '';
|
|
||||||
$i = 1;
|
|
||||||
$len = length($text);
|
|
||||||
|
|
||||||
while ($i <= $len) { #???
|
|
||||||
$c = substr($text, $i, 1);
|
|
||||||
if ($c eq '%') {
|
|
||||||
if ($i + 2 <= $len) {
|
|
||||||
$c1 = &tolower(substr($text, $i + 1, 1));
|
|
||||||
$c2 = &tolower(substr($text, $i + 2, 1));
|
|
||||||
if ($hextab{$c1} ne '' || $hextab{$c2} ne '') {
|
|
||||||
if (($c1 >= 2 && ($c1 != 7 && $c2 ne 'F')) ||
|
|
||||||
|
|
||||||
($c1 == 0 && $c2 =~ '[9acd]')) {
|
|
||||||
$code = 0 + $hextab{$c1} * 16 + $hextab{$c2} + 0;
|
|
||||||
$c = sprintf('%c', $code);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$c = ' ';
|
|
||||||
}
|
|
||||||
$i = $i + 2;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
elsif ($c eq '+') {
|
|
||||||
# special handling: "+" means " "
|
|
||||||
$c = ' ';
|
|
||||||
}
|
|
||||||
$decoded = $decoded . $c;
|
|
||||||
++$i;
|
|
||||||
}
|
|
||||||
# change linebreaks to \n
|
|
||||||
$decoded =~ s/\r\n/\n/g;
|
|
||||||
# remove last linebreak
|
|
||||||
$decoded =~ s/[\n\r]*$//;
|
|
||||||
$decoded;
|
|
||||||
}
|
|
||||||
|
|
||||||
sub Getline3 {
|
|
||||||
&Pick('',@_);
|
|
||||||
local($_);
|
|
||||||
if ($getline_ok = (($_ = <$fh>) ne '')) {
|
|
||||||
;
|
|
||||||
}
|
|
||||||
$_;
|
|
||||||
}
|
|
||||||
|
|
||||||
sub Pick {
|
|
||||||
local($mode,$name,$pipe) = @_;
|
|
||||||
$fh = $name;
|
|
||||||
open($name,$mode.$name.$pipe) unless $opened{$name}++;
|
|
||||||
}
|
|
||||||
@@ -64,6 +64,14 @@ to automatically reload configuration on address change.
|
|||||||
A: Check you use system DSN.
|
A: Check you use system DSN.
|
||||||
Check SQL request is valid.
|
Check SQL request is valid.
|
||||||
The best way to check is to make file or stdout logging, get SQL request from log file or console and execute this request manually.
|
The best way to check is to make file or stdout logging, get SQL request from log file or console and execute this request manually.
|
||||||
|
Under Unix, you may also want to adjust 'stacksize' parameter.
|
||||||
|
|
||||||
|
<p><i>Q: Why proxy crash on request processing?</a></i></p>
|
||||||
|
<i>A:</i> default stacksize may be insufficient, if some non-default plugins
|
||||||
|
are used (e.g. PAM and ODBC on Linux) or if compiled on some platforms with
|
||||||
|
invalid system defined values (few versionds of FreeBSD on amd64).
|
||||||
|
Problem can be resolved with 'stacksize' command or '-S' option starting 3proxy 0.8.4.
|
||||||
|
|
||||||
|
|
||||||
<p><i>Q: Why doesn't APOP/CRAM-MD5 authentication work with POP3 proxy?</i></p>
|
<p><i>Q: Why doesn't APOP/CRAM-MD5 authentication work with POP3 proxy?</i></p>
|
||||||
A: Any Challenge-response authentication require challenge to be transmitted from server. Pop3p doesn't know which server to use before authentication, it makes it impossible to obtain challenge. You can encrypt your POP3 communications with TLS (i.e. stunnel) or IPSec.
|
A: Any Challenge-response authentication require challenge to be transmitted from server. Pop3p doesn't know which server to use before authentication, it makes it impossible to obtain challenge. You can encrypt your POP3 communications with TLS (i.e. stunnel) or IPSec.
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
<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>
|
||||||
|
<li><a href="#CRASH">Q: Почему прокси крэшится при обработке запроса?</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
<li><a href="#SOCKSREDIR">Перенаправление socks соединений в локальный прокси</a></li>
|
<li><a href="#SOCKSREDIR">Перенаправление socks соединений в локальный прокси</a></li>
|
||||||
<ul>
|
<ul>
|
||||||
@@ -128,6 +129,13 @@
|
|||||||
невозможен. Защитить соединение можно с помощью TLS (например, stunnel) или
|
невозможен. Защитить соединение можно с помощью TLS (например, stunnel) или
|
||||||
IPSec.
|
IPSec.
|
||||||
</p>
|
</p>
|
||||||
|
<li><a name="CRASH"><i>Q: Почему прокси крэшится при обработке запроса?</a></i></li>
|
||||||
|
<p>
|
||||||
|
<i>A:</i> Возможно, недостаточен размер стека потока по-умолчанию, это может
|
||||||
|
быть при использовани каких-либо сторонних плагинов (PAM, ODBC) или на
|
||||||
|
некоторых платформах (некоторые версии FreeBSD на amd64). Можно решить
|
||||||
|
проблему с помощью опции 'stacksize' или '-S', поддерживаемых в 0.8.4 и выше.
|
||||||
|
</p>
|
||||||
</ul>
|
</ul>
|
||||||
<hr>
|
<hr>
|
||||||
<li><b><a name="SOCKSREDIR">Перенаправление socks соединений в локальный прокси</a></b></li>
|
<li><b><a name="SOCKSREDIR">Перенаправление socks соединений в локальный прокси</a></b></li>
|
||||||
|
|||||||
@@ -287,10 +287,10 @@ logformat "L%t.%. %N.%p %E %U %C:%c %R:%r %O %I %h %T"
|
|||||||
<p>
|
<p>
|
||||||
If ODBC used, logformat should specify SQL command,
|
If ODBC used, logformat should specify SQL command,
|
||||||
to insert record into log, for example
|
to insert record into log, for example
|
||||||
<p><font face="courier">
|
<p><pre>
|
||||||
logformat "GINSERT INTO proxystat VALUES (%t, '%c', '%U', %I)"
|
logformat "-\'+_GINSERT INTO proxystat VALUES (%t, '%c', '%U', %I)"</pre>
|
||||||
</font>
|
|
||||||
<br>(no line breaks)
|
<br>(no line breaks)
|
||||||
|
<br>-\'+_ instructs to replace characters \ and ' with _
|
||||||
</p>
|
</p>
|
||||||
<li><A NAME="LOGANALIZERS">How to use log analizers with 3proxy</A>
|
<li><A NAME="LOGANALIZERS">How to use log analizers with 3proxy</A>
|
||||||
<p>
|
<p>
|
||||||
|
|||||||
@@ -304,7 +304,9 @@
|
|||||||
При использовании ODBC, logformat должен задавать формат SQL команды,
|
При использовании ODBC, logformat должен задавать формат SQL команды,
|
||||||
которую необходимо дать для внесения записи в журнал, например:
|
которую необходимо дать для внесения записи в журнал, например:
|
||||||
<pre>
|
<pre>
|
||||||
logformat "GINSERT INTO proxystat VALUES (%t, '%c', '%U', %I)"</pre>
|
logformat "-\'+_GINSERT INTO proxystat VALUES (%t, '%c', '%U', %I)"</pre>
|
||||||
|
префикс -\'+_ указывает, что символы \ и ' следует заменить на _ .
|
||||||
|
|
||||||
</p>
|
</p>
|
||||||
<li><a name="LOGANALIZERS"><i>Как использовать лог-анализаторы с 3proxy</i></a>
|
<li><a name="LOGANALIZERS"><i>Как использовать лог-анализаторы с 3proxy</i></a>
|
||||||
<p>
|
<p>
|
||||||
@@ -783,7 +785,7 @@
|
|||||||
...
|
...
|
||||||
deny * * 127.0.0.2</pre>
|
deny * * 127.0.0.2</pre>
|
||||||
добавляет статическую запись в кэш. Статические записи так же влияют на разрешение через dnspr если не указана опция -s. Начиная с версии 0.8 для dnspr могут быть сконфигурированы родительские прокси.</p>
|
добавляет статическую запись в кэш. Статические записи так же влияют на разрешение через dnspr если не указана опция -s. Начиная с версии 0.8 для dnspr могут быть сконфигурированы родительские прокси.</p>
|
||||||
<li><a name="IPv6"><i>Как использовать IPv6</i></a>
|
<li><a name="IPV6"><i>Как использовать IPv6</i></a>
|
||||||
<p>
|
<p>
|
||||||
IPv6 поддерживается с версии 0.8. Обратите внимание, что в некоторых видах прокси (например SOCKSv4)
|
IPv6 поддерживается с версии 0.8. Обратите внимание, что в некоторых видах прокси (например SOCKSv4)
|
||||||
IPv6 не поддерживает на уровне протокола. В SOCKSv5 есть поддержка IPv6 с помощью отдельного вида
|
IPv6 не поддерживает на уровне протокола. В SOCKSv5 есть поддержка IPv6 с помощью отдельного вида
|
||||||
|
|||||||
@@ -0,0 +1,19 @@
|
|||||||
|
<html><title>3proxy documentation</title><body><h2>3proxy documentation</h2>
|
||||||
|
<a href="securityen.html">Security recommendations</a><br>
|
||||||
|
<a href="highload.html">Optimizing 3proxy for high loads</a><br>
|
||||||
|
<a href="howtoe.html">How To (English, very incomplete)</a><br>
|
||||||
|
<a href="howtor.html">How To (Russian)</a><br>
|
||||||
|
<a href="faqe.html">FAQ (English)</a><br>
|
||||||
|
<a href="faqr.html">FAQ (Russian)</a>
|
||||||
|
<h3>Man pages:</h>
|
||||||
|
<br><A HREF="man8/3proxy.8.html">3proxy.8</A>
|
||||||
|
<br><A HREF="man8/ftppr.8.html">ftppr.8</A>
|
||||||
|
<br><A HREF="man8/icqpr.8.html">icqpr.8</A>
|
||||||
|
<br><A HREF="man8/pop3p.8.html">pop3p.8</A>
|
||||||
|
<br><A HREF="man8/proxy.8.html">proxy.8</A>
|
||||||
|
<br><A HREF="man8/smtpp.8.html">smtpp.8</A>
|
||||||
|
<br><A HREF="man8/socks.8.html">socks.8</A>
|
||||||
|
<br><A HREF="man8/tcppm.8.html">tcppm.8</A>
|
||||||
|
<br><A HREF="man8/udppm.8.html">udppm.8</A>
|
||||||
|
<br><A HREF="man3/3proxy.cfg.3.html">3proxy.cfg.3</A>
|
||||||
|
</body></html>
|
||||||
@@ -2,10 +2,10 @@
|
|||||||
<h3>3proxy strings substitution plugin</h3>
|
<h3>3proxy strings substitution plugin</h3>
|
||||||
May be used to make interface more pretty or to translate proxy server
|
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
|
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
|
moved to external text file (e.g. rus.3ps). On the moment of
|
||||||
writing there are 15 sections. Sections are delimited with "[end]".
|
writing there are 15 sections. Sections are delimited with "[end]".
|
||||||
<h4>Example:</h4>
|
<h4>Example:</h4>
|
||||||
<pre>plugin "StringsPlugin.dll" start c:\3proxy\bin\rus-win1251.3ps
|
<pre>plugin "StringsPlugin.dll" start c:\3proxy\bin\rus.3ps
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
<h4>Download:</h4>
|
<h4>Download:</h4>
|
||||||
|
|||||||
@@ -0,0 +1,28 @@
|
|||||||
|
<h3>3proxy TransparentPlugin plugin (Linux only)</h3>
|
||||||
|
|
||||||
|
Plugin can turn 3proxy into transparent proxy for virtually any TCP-based protocol
|
||||||
|
and use all 3proxy features - redirections, parent proxies, ACLs, traffic limitations,
|
||||||
|
etc. TransparentPlugin plugin takes destination IP:port from Linux and uses this
|
||||||
|
information as a target IP in proxy. An example of usage:
|
||||||
|
|
||||||
|
<pre>
|
||||||
|
plugin /path/to/TransparentPlugin.ld.so transparent_plugin
|
||||||
|
log /path/to/log
|
||||||
|
auth iponly
|
||||||
|
allow * * * 80
|
||||||
|
parent 1000 http 0.0.0.0 0
|
||||||
|
allow *
|
||||||
|
parent 1000 socks5 SOCKS5_IP SOCKS5_PORT USER PASSWORD
|
||||||
|
tcppm -iLOCAL_IP 12345 127.0.0.1 11111
|
||||||
|
</pre>
|
||||||
|
Now, any TCP traffic transparently redirected to port 12345 will be routed via
|
||||||
|
parent SOCKSv5 proxy and logged, all URLs for web requests are visible in logs.
|
||||||
|
Paremeters '127.0.0.1 11111' in this case are not used and are overwritten by
|
||||||
|
destination IP:port for each transparent connection.
|
||||||
|
|
||||||
|
<h4>Download:</h4>
|
||||||
|
<ul>
|
||||||
|
<li>Plugin included into 3proxy 0.8
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
© Vladimir Dubrovin, License: BSD style
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
<h3>Плагин TransparentPlugin 3proxy (только для Linux)</h3>
|
||||||
|
|
||||||
|
Плагин превращает 3proxy в транспарентный прокси для практически любых TCP-соединений
|
||||||
|
и позволяет прозрачно для клиентов использовать весь фунционал прокси - редиректоры,
|
||||||
|
родительские прокси, ACLи, ограничения трафика. TransparentPlugin получает IP:port
|
||||||
|
назначения от Linux и использует эту информацию в качестве конечного адреса назначения.
|
||||||
|
<br>
|
||||||
|
Пример использования:
|
||||||
|
|
||||||
|
<pre>
|
||||||
|
plugin /path/to/TransparentPlugin.ld.so transparent_plugin
|
||||||
|
log /path/to/log
|
||||||
|
auth iponly
|
||||||
|
allow * * * 80
|
||||||
|
parent 1000 http 0.0.0.0 0
|
||||||
|
allow *
|
||||||
|
parent 1000 socks5 SOCKS5_IP SOCKS5_PORT USER PASSWORD
|
||||||
|
tcppm -iLOCAL_IP 12345 127.0.0.1 11111
|
||||||
|
</pre>
|
||||||
|
Теперь любые TCP-соединения транспарентно перенаправленные в локальный порт 12345
|
||||||
|
будут прологгированы и перенаправлены в родительский SOCKSv5 proxy, при этом для
|
||||||
|
HTTP-запросов по порту TCP/80 будут видны параметры HTTP-запроса.
|
||||||
|
Параметры '127.0.0.1 11111' в данном случае не оказывают влияния, т.к.
|
||||||
|
будут перезаписываться IP и портом назначения для каждого TCP-соединения соответственно.
|
||||||
|
<h4>Загрузить:</h4>
|
||||||
|
<ul>
|
||||||
|
<li>Плагин включен в дистрибутив 3proxy 0.8
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
© Vladimir Dubrovin, License: BSD style
|
||||||
+6507
-1738
File diff suppressed because it is too large.
Load diff
@@ -300,6 +300,8 @@ with space and all time based elemnts are in local time zone.
|
|||||||
%R - Remote IP
|
%R - Remote IP
|
||||||
.br
|
.br
|
||||||
%r - Remote port
|
%r - Remote port
|
||||||
|
.br
|
||||||
|
%i - Internal IP used to accept client connection
|
||||||
.br
|
.br
|
||||||
%e - External IP used to establish connection
|
%e - External IP used to establish connection
|
||||||
.br
|
.br
|
||||||
@@ -734,6 +736,17 @@ nolog
|
|||||||
.br
|
.br
|
||||||
Weight may be used for different purposes.
|
Weight may be used for different purposes.
|
||||||
|
|
||||||
|
|
||||||
|
.br
|
||||||
|
.B force
|
||||||
|
.br
|
||||||
|
.B noforce
|
||||||
|
.br
|
||||||
|
If force is specified for service, configuration reload will require all current
|
||||||
|
sessions of this service to be re-authenticated. If ACL is changed or user account
|
||||||
|
is removed, old connections which do not match current are closed.
|
||||||
|
noforce allows to keep previously authenticated connections.
|
||||||
|
|
||||||
.br
|
.br
|
||||||
.B bandlimin
|
.B bandlimin
|
||||||
<rate> <userlist> <sourcelist> <targetlist> <targetportlist> <operationlist>
|
<rate> <userlist> <sourcelist> <targetlist> <targetportlist> <operationlist>
|
||||||
@@ -902,6 +915,20 @@ for all threads.
|
|||||||
<path>
|
<path>
|
||||||
.br
|
.br
|
||||||
calls chroot(path). Unix only.
|
calls chroot(path). Unix only.
|
||||||
|
|
||||||
|
.br
|
||||||
|
.B stacksize
|
||||||
|
<value_to_add_to_default_stack_size>
|
||||||
|
.br
|
||||||
|
Change default size for threads stack. May be required in some situation,
|
||||||
|
e.g. with non-default plugins, on on some platforms (some FreeBSD version
|
||||||
|
may require adjusting stack size due to invalid defined value in system
|
||||||
|
header files, this value is also oftent reqruied to be changed for ODBC and
|
||||||
|
PAM support on Linux. If you experience 3proxy
|
||||||
|
crash on request processing, try to set some positive value. You may start with
|
||||||
|
stacksize 65536
|
||||||
|
and then find the minimal value for service to work. If you experience
|
||||||
|
memory shortage, you can try to experiment with negative values.
|
||||||
.SH PLUGINS
|
.SH PLUGINS
|
||||||
|
|
||||||
.br
|
.br
|
||||||
|
|||||||
@@ -51,6 +51,10 @@ is specified logging is to file. Under Unix, if
|
|||||||
preceeds
|
preceeds
|
||||||
.IR logfile ,
|
.IR logfile ,
|
||||||
syslog is used for logging.
|
syslog is used for logging.
|
||||||
|
.TP
|
||||||
|
.B -S
|
||||||
|
Increase or decrease stack size. You may want to try something like -S8192 if you experience 3proxy
|
||||||
|
crashes.
|
||||||
.SH CLIENTS
|
.SH CLIENTS
|
||||||
You can use any FTP client, regardless of FTP proxy support. For client with
|
You can use any FTP client, regardless of FTP proxy support. For client with
|
||||||
FTP proxy support configure
|
FTP proxy support configure
|
||||||
|
|||||||
@@ -45,6 +45,10 @@ is specified logging is to file. Under Unix, if
|
|||||||
preceeds
|
preceeds
|
||||||
.IR logfile ,
|
.IR logfile ,
|
||||||
syslog is used for logging.
|
syslog is used for logging.
|
||||||
|
.TP
|
||||||
|
.B -S
|
||||||
|
Increase or decrease stack size. You may want to try something like -S8192 if you experience 3proxy
|
||||||
|
crashes.
|
||||||
.SH ARGUMENTS
|
.SH ARGUMENTS
|
||||||
.TP
|
.TP
|
||||||
.I local_port
|
.I local_port
|
||||||
|
|||||||
@@ -51,6 +51,10 @@ is specified logging is to file. Under Unix, if
|
|||||||
preceeds
|
preceeds
|
||||||
.IR logfile ,
|
.IR logfile ,
|
||||||
syslog is used for logging.
|
syslog is used for logging.
|
||||||
|
.TP
|
||||||
|
.B -S
|
||||||
|
Increase or decrease stack size. You may want to try something like -S8192 if you experience 3proxy
|
||||||
|
crashes.
|
||||||
.SH CLIENTS
|
.SH CLIENTS
|
||||||
You can use any MUA (Mail User Agent) with POP3 support. Set client to use
|
You can use any MUA (Mail User Agent) with POP3 support. Set client to use
|
||||||
.I internal_ip
|
.I internal_ip
|
||||||
|
|||||||
@@ -52,6 +52,10 @@ is specified logging is to file. Under Unix, if
|
|||||||
preceeds
|
preceeds
|
||||||
.IR logfile ,
|
.IR logfile ,
|
||||||
syslog is used for logging.
|
syslog is used for logging.
|
||||||
|
.TP
|
||||||
|
.B -S
|
||||||
|
Increase or decrease stack size. You may want to try something like -S8192 if you experience 3proxy
|
||||||
|
crashes.
|
||||||
.SH CLIENTS
|
.SH CLIENTS
|
||||||
You should use client with HTTP proxy support or configure router to redirect
|
You should use client with HTTP proxy support or configure router to redirect
|
||||||
HTTP traffic to proxy (transparent proxy). Configure client to connect to
|
HTTP traffic to proxy (transparent proxy). Configure client to connect to
|
||||||
|
|||||||
@@ -51,6 +51,10 @@ is specified logging is to file. Under Unix, if
|
|||||||
preceeds
|
preceeds
|
||||||
.IR logfile ,
|
.IR logfile ,
|
||||||
syslog is used for logging.
|
syslog is used for logging.
|
||||||
|
.TP
|
||||||
|
.B -S
|
||||||
|
Increase or decrease stack size. You may want to try something like -S8192 if you experience 3proxy
|
||||||
|
crashes.
|
||||||
.SH CLIENTS
|
.SH CLIENTS
|
||||||
You can use any MUA (Mail User Agent) with SMTP authentication support.
|
You can use any MUA (Mail User Agent) with SMTP authentication support.
|
||||||
Set client to use
|
Set client to use
|
||||||
|
|||||||
@@ -48,6 +48,10 @@ is specified logging is to file. Under Unix, if
|
|||||||
preceeds
|
preceeds
|
||||||
.IR logfile ,
|
.IR logfile ,
|
||||||
syslog is used for logging.
|
syslog is used for logging.
|
||||||
|
.TP
|
||||||
|
.B -S
|
||||||
|
Increase or decrease stack size. You may want to try something like -S8192 if you experience 3proxy
|
||||||
|
crashes.
|
||||||
.SH CLIENTS
|
.SH CLIENTS
|
||||||
You should use client with SOCKS support or use some socksification support
|
You should use client with SOCKS support or use some socksification support
|
||||||
(for example
|
(for example
|
||||||
|
|||||||
@@ -40,6 +40,10 @@ is specified logging is to file. Under Unix, if
|
|||||||
preceeds
|
preceeds
|
||||||
.IR logfile ,
|
.IR logfile ,
|
||||||
syslog is used for logging.
|
syslog is used for logging.
|
||||||
|
.TP
|
||||||
|
.B -S
|
||||||
|
Increase or decrease stack size. You may want to try something like -S8192 if you experience 3proxy
|
||||||
|
crashes.
|
||||||
.SH ARGUMENTS
|
.SH ARGUMENTS
|
||||||
.TP
|
.TP
|
||||||
.I local_port
|
.I local_port
|
||||||
|
|||||||
@@ -46,6 +46,10 @@ Single packet. By default only one client can use udppm service, but
|
|||||||
if -s is specified only one packet will be forwarded between client and server.
|
if -s is specified only one packet will be forwarded between client and server.
|
||||||
It allows to share service between multiple clients for single packet services
|
It allows to share service between multiple clients for single packet services
|
||||||
(for example name lookups).
|
(for example name lookups).
|
||||||
|
.TP
|
||||||
|
.B -S
|
||||||
|
Increase or decrease stack size. You may want to try something like -S8192 if you experience 3proxy
|
||||||
|
crashes.
|
||||||
.SH ARGUMENTS
|
.SH ARGUMENTS
|
||||||
.TP
|
.TP
|
||||||
.I local_port
|
.I local_port
|
||||||
|
|||||||
@@ -0,0 +1,256 @@
|
|||||||
|
[--admin--]
|
||||||
|
HTTP/1.0 401 Authentication Required\n
|
||||||
|
WWW-Authenticate: Basic realm="proxy", encoding="utf-8"\n
|
||||||
|
Connection: close\n
|
||||||
|
Content-type: text/html; charset=utf-8\n
|
||||||
|
\n
|
||||||
|
<html><head><title>401 Authentication Required</title></head>\n
|
||||||
|
<body><h2>401 Authentication Required</h2>
|
||||||
|
<h3>Access to requested resource disallowed by administrator or you need valid username/password to use this resource<br><hr>
|
||||||
|
Доступ запрещен администратором или Вы ввели неправильное имя/пароль.
|
||||||
|
</h3></body></html>\n
|
||||||
|
[end]
|
||||||
|
HTTP/1.0 200 OK\n
|
||||||
|
Connection: close\n
|
||||||
|
Expires: Thu, 01 Dec 1994 16:00:00 GMT\n
|
||||||
|
Cache-Control: no-cache\n
|
||||||
|
Content-type: text/html; charset=utf-8\n
|
||||||
|
\n
|
||||||
|
<http><head><title>%s Страница конфигурации</title></head>\n
|
||||||
|
<table width='100%%' border='0'>\n
|
||||||
|
<tr><td width='150' valign='top'>\n
|
||||||
|
<h2>
|
||||||
|
</h2>\n
|
||||||
|
<A HREF='/C'>Счетчики</A><br><br>\n
|
||||||
|
<A HREF='/R'>Перезагрузка конфигурации сервера</A><br><br>\n
|
||||||
|
<A HREF='/S'>Запущенные сервисы</A><br><br>\n
|
||||||
|
<A HREF='/F'>Настройка сервера</A>\n
|
||||||
|
</td><td>
|
||||||
|
<h2>%s %s Конфигурация</h2>
|
||||||
|
[end]
|
||||||
|
HTTP/1.0 200 OK\n
|
||||||
|
Connection: close\n
|
||||||
|
Cache-Control: no-cache\n
|
||||||
|
Content-type: text/xml; charset=utf-8 \n
|
||||||
|
\n
|
||||||
|
<?xml version="1.0"?>\n
|
||||||
|
<?xml-stylesheet href="/SX" type="text/css"?>\n
|
||||||
|
<services>\n
|
||||||
|
<description>Текущие запущенные сервисы и подключившиеся клиенты</description>\n
|
||||||
|
[end]
|
||||||
|
</services>\n
|
||||||
|
[end]
|
||||||
|
HTTP/1.0 200 OK\n
|
||||||
|
Connection: close\n
|
||||||
|
Cache-Control: no-cache\n
|
||||||
|
Content-type: text/css\n
|
||||||
|
\n
|
||||||
|
services {\n
|
||||||
|
display: block;\n
|
||||||
|
margin: 10px auto 10px auto;\n
|
||||||
|
width: 80%;\n
|
||||||
|
background: black;\n"
|
||||||
|
font-family: sans-serif;\n
|
||||||
|
font-size: small;\n
|
||||||
|
color: silver;\n
|
||||||
|
}\n
|
||||||
|
item {\n
|
||||||
|
display: block;\n
|
||||||
|
margin-bottom: 10px;\n
|
||||||
|
border: 2px solid #CCC;\n
|
||||||
|
padding: 10px;\n
|
||||||
|
spacing: 2px;\n
|
||||||
|
}\n
|
||||||
|
parameter {\n
|
||||||
|
display: block;\n
|
||||||
|
padding: 2px;\n
|
||||||
|
margin-top: 10px;\n
|
||||||
|
border: 1px solid grey;\n
|
||||||
|
background: #EEE;\n
|
||||||
|
color: black;\n
|
||||||
|
}\n
|
||||||
|
name {\n
|
||||||
|
display: inline;\n
|
||||||
|
float: left;\n
|
||||||
|
margin-right: 5px;\n
|
||||||
|
font-weight: bold;\n
|
||||||
|
}\n
|
||||||
|
type {\n
|
||||||
|
display: inline;\n
|
||||||
|
font-size: x-small;\n
|
||||||
|
margin-right: 5px;\n
|
||||||
|
color: #666;\n
|
||||||
|
white-space: nowrap;\n
|
||||||
|
font-style: italic;\n
|
||||||
|
}\n
|
||||||
|
description {\n
|
||||||
|
display: inline;\n
|
||||||
|
margin-right: 5px;\n
|
||||||
|
white-space: nowrap;\n
|
||||||
|
}\n
|
||||||
|
value {\n
|
||||||
|
display: block;\n
|
||||||
|
margin-right: 5px;\n
|
||||||
|
}\n
|
||||||
|
[end]
|
||||||
|
<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br />\n
|
||||||
|
<pre><font size='-2'><b>
|
||||||
|
(c)3APA3A, Владимир Дубровин и <A href='http://3proxy.ru/'>3proxy.ru</A>\n
|
||||||
|
</b></font>\n
|
||||||
|
</td></tr></table></body></html>
|
||||||
|
[end]
|
||||||
|
<h3>Счетчики</h3>\n
|
||||||
|
<table border = '1'>\n
|
||||||
|
<tr align='center'><td>Описание</td><td>Активный</td>
|
||||||
|
<td>Пользователи</td><td>Адрес источника</td><td>Адрес назначения</td>
|
||||||
|
<td>Порты</td>
|
||||||
|
<td>Лимит</td><td>Ед.</td><td>Значение</td>
|
||||||
|
<td>Дата сброса</td><td>Дата обновения</td><td>Номер</td></tr>\n
|
||||||
|
[end]
|
||||||
|
</table>\n
|
||||||
|
[end]
|
||||||
|
[/--admin--]
|
||||||
|
[--proxy--]
|
||||||
|
HTTP/1.0 400 Bad Request\n
|
||||||
|
Proxy-Connection: close\n
|
||||||
|
Content-type: text/html; charset=utf-8\n
|
||||||
|
\n
|
||||||
|
<html><head><title>400 Bad Request</title></head>\n
|
||||||
|
<body><h2>400 Bad Request</h2>
|
||||||
|
<h2>400 Ошибка: Неправильный запрос.</h2>
|
||||||
|
</body>
|
||||||
|
</html>\n
|
||||||
|
[end]
|
||||||
|
HTTP/1.0 502 Bad Gateway\n
|
||||||
|
Proxy-Connection: close\n
|
||||||
|
Content-type: text/html; charset=utf-8\n
|
||||||
|
\n
|
||||||
|
<html><head><title>502 Bad Gateway</title></head>\n
|
||||||
|
<body><h2>502 Bad Gateway</h2><h3>Host Not Found or connection failed <br><hr>
|
||||||
|
Ошибка: Удалённый сервер не найден или не удалось связаться с ним.</h3>
|
||||||
|
</body></html>\n
|
||||||
|
[end]
|
||||||
|
HTTP/1.0 503 Service Unavailable\n
|
||||||
|
Proxy-Connection: close\n
|
||||||
|
Content-type: text/html; charset=utf-8\n
|
||||||
|
\n
|
||||||
|
<html><head><title>503 Service Unavailable</title></head>\n
|
||||||
|
<body><h2>503 Service Unavailable</h2><h3>You have exceeded your traffic limit <br><hr>
|
||||||
|
Вы превысили свой лимит трафика.
|
||||||
|
</h3></body></html>\n
|
||||||
|
[end]
|
||||||
|
HTTP/1.0 503 Service Unavailable\n
|
||||||
|
Proxy-Connection: close\n
|
||||||
|
Content-type: text/html; charset=utf-8\n
|
||||||
|
\n
|
||||||
|
<html><head><title>503 Service Unavailable</title></head>\n
|
||||||
|
<body><h2>503 Service Unavailable</h2><h3>Recursion detected<br><hr>
|
||||||
|
Ошибка: Сервис не доступен, обнаружена рекурсия
|
||||||
|
</h3></body></html>\n
|
||||||
|
[end]
|
||||||
|
HTTP/1.0 501 Not Implemented\n
|
||||||
|
Proxy-Connection: close\n
|
||||||
|
Content-type: text/html; charset=utf-8\n
|
||||||
|
\n
|
||||||
|
<html><head><title>501 Not Implemented</title></head>\n
|
||||||
|
<body><h2>501 Not Implemented</h2><h3>Required action is not supported by proxy server <br><hr>
|
||||||
|
Ошибка: Действие не поддерживается в данном proxy сервере
|
||||||
|
</h3></body></html>\n
|
||||||
|
[end]
|
||||||
|
HTTP/1.0 502 Bad Gateway\n
|
||||||
|
Proxy-Connection: close\n
|
||||||
|
Content-type: text/html; charset=utf-8\n
|
||||||
|
\n
|
||||||
|
<html><head><title>502 Bad Gateway</title></head>\n
|
||||||
|
<body><h2>502 Bad Gateway</h2><h3>Failed to connect parent proxy <br><hr>
|
||||||
|
Ошибка: Невозможно соединиться c вышестоящим proxy сервером
|
||||||
|
</h3></body></html>\n",
|
||||||
|
[end]
|
||||||
|
HTTP/1.0 500 Internal Error\n
|
||||||
|
Proxy-Connection: close\n
|
||||||
|
Content-type: text/html; charset=utf-8\n
|
||||||
|
\n
|
||||||
|
<html><head><title>500 Internal Error</title></head>\n
|
||||||
|
<body><h2>500 Internal Error</h2><h3>Internal proxy error during processing your request <br><hr>
|
||||||
|
Ошибка: Возникла внутренняя ошибка proxy сервера при обработке вашего запроса
|
||||||
|
</h3></body></html>\n
|
||||||
|
[end]
|
||||||
|
HTTP/1.0 407 Proxy Authentication Required\n
|
||||||
|
Proxy-Authenticate: Basic realm="proxy", encoding="utf-8"\n
|
||||||
|
Proxy-Connection: close\n
|
||||||
|
Content-type: text/html; charset=utf-8\n
|
||||||
|
\n
|
||||||
|
<html><head><title>407 Proxy Authentication Required</title></head>\n
|
||||||
|
<body><h2>407 Proxy Authentication Required</h2><h3>Access to requested resource disallowed by administrator or you need valid username/password to use this resource.<br><hr>
|
||||||
|
Доступ запрещен администратором или Вы ввели неправильное имя/пароль.
|
||||||
|
</h3></body></html>\n
|
||||||
|
[end]
|
||||||
|
HTTP/1.0 200 Connection established\n\n
|
||||||
|
[end]
|
||||||
|
HTTP/1.0 200 Connection established\n
|
||||||
|
Content-Type: text/html\n\n
|
||||||
|
[end]
|
||||||
|
HTTP/1.0 404 Not Found\n
|
||||||
|
Proxy-Connection: close\n
|
||||||
|
Content-type: text/html; charset=utf-8\n
|
||||||
|
\n
|
||||||
|
<html><head><title>404 Not Found</title></head>\n
|
||||||
|
<body><h2>404 Not Found</h2><h3>File not found <br><hr>
|
||||||
|
Файл не найден
|
||||||
|
</h3></body></html>\n
|
||||||
|
[end]
|
||||||
|
HTTP/1.0 403 Forbidden\n
|
||||||
|
Proxy-Connection: close\n
|
||||||
|
Content-type: text/html; charset=utf-8\n
|
||||||
|
\n
|
||||||
|
<html><head><title>403 Access Denied</title></head>\n
|
||||||
|
<body><h2>403 Access Denied</h2><h3>Access control list denies you to access this resource.<br><hr>
|
||||||
|
Доступ к данному ресурсу запрещен списком доступа на proxy сервер.
|
||||||
|
Если Вы считаете, что это ошибка обратитесь к администратору
|
||||||
|
</h3></body></html>\n
|
||||||
|
[end]
|
||||||
|
HTTP/1.0 407 Proxy Authentication Required\n
|
||||||
|
Proxy-Authenticate: NTLM\n
|
||||||
|
Proxy-Authenticate: basic realm="proxy", encoding="utf-8"\n
|
||||||
|
Proxy-Connection: close\n
|
||||||
|
Content-type: text/html; charset=utf-8\n
|
||||||
|
\n
|
||||||
|
<html><head><title>407 Proxy Authentication Required</title></head>\n
|
||||||
|
<body><h2>407 Proxy Authentication Required</h2><h3>Access to requested resource disallowed by administrator or you need valid username/password to use this resource.<br><hr>
|
||||||
|
Доступ запрещен администратором или Вы ввели неправильное имя/пароль.
|
||||||
|
</h3></body></html>\n
|
||||||
|
[end]
|
||||||
|
HTTP/1.0 407 Proxy Authentication Required\n
|
||||||
|
Proxy-Connection: keep-alive\n
|
||||||
|
Content-Length: 0\n
|
||||||
|
Proxy-Authenticate: NTLM
|
||||||
|
[end]
|
||||||
|
HTTP/1.0 403 Forbidden\n
|
||||||
|
Proxy-Connection: close\n
|
||||||
|
Content-type: text/html; charset=us-ascii\n
|
||||||
|
\n
|
||||||
|
<pre>
|
||||||
|
[end]
|
||||||
|
HTTP/1.0 503 Service Unavailable\n
|
||||||
|
Proxy-Connection: close\n
|
||||||
|
Content-type: text/html; charset=utf-8\n
|
||||||
|
\n
|
||||||
|
<html><head><title>503 Service Unavailable</title></head>\n
|
||||||
|
<body><h2>503 Service Unavailable</h2><h3>Your request violates configured policy<br><hr>
|
||||||
|
Запрос не сответствует сконфигурированной политике.
|
||||||
|
</h3></body></html>\n
|
||||||
|
[end]
|
||||||
|
HTTP/1.0 401 Authentication Required\n
|
||||||
|
WWW-Authenticate: basic realm="FTP Server", encoding="utf-8"\n
|
||||||
|
Proxy-Connection: close\n
|
||||||
|
Content-type: text/html; charset=utf-8\n
|
||||||
|
\n
|
||||||
|
<html><head><title>401 FTP Server requires authentication</title></head>\n
|
||||||
|
<body><h2>401 FTP Server requires authentication</h2><h3>This FTP server rejects anonymous access<br><hr>
|
||||||
|
Этот FTP сервер отвергает анонимный доступ.
|
||||||
|
</h3></body></html>\n
|
||||||
|
[end]
|
||||||
|
HTTP/1.1 100 Continue\n
|
||||||
|
\n
|
||||||
|
[end]
|
||||||
|
[/--proxy--]
|
||||||
+1
-1
@@ -10,7 +10,7 @@ monitor /usr/local/etc/3proxy/counters
|
|||||||
monitor /usr/local/etc/3proxy/passwd
|
monitor /usr/local/etc/3proxy/passwd
|
||||||
monitor /usr/local/etc/3proxy/bandlimiters
|
monitor /usr/local/etc/3proxy/bandlimiters
|
||||||
|
|
||||||
log /usr/local/etc/3proxy/log/log D
|
log /var/log/3proxy/log D
|
||||||
rotate 60
|
rotate 60
|
||||||
counter /usr/local/etc/3proxy/3proxy.3cf
|
counter /usr/local/etc/3proxy/3proxy.3cf
|
||||||
|
|
||||||
|
|||||||
+15
-13
@@ -59,8 +59,8 @@ void __stdcall CommandHandler( DWORD dwCommand )
|
|||||||
case SERVICE_CONTROL_STOP:
|
case SERVICE_CONTROL_STOP:
|
||||||
case SERVICE_CONTROL_SHUTDOWN:
|
case SERVICE_CONTROL_SHUTDOWN:
|
||||||
SetStatus( SERVICE_STOP_PENDING, 0, 1 );
|
SetStatus( SERVICE_STOP_PENDING, 0, 1 );
|
||||||
conf.paused++;
|
|
||||||
conf.timetoexit = 1;
|
conf.timetoexit = 1;
|
||||||
|
conf.paused++;
|
||||||
Sleep(2000);
|
Sleep(2000);
|
||||||
SetStatus( SERVICE_STOPPED, 0, 0 );
|
SetStatus( SERVICE_STOPPED, 0, 0 );
|
||||||
#ifndef NOODBC
|
#ifndef NOODBC
|
||||||
@@ -87,7 +87,7 @@ void __stdcall CommandHandler( DWORD dwCommand )
|
|||||||
void __stdcall ServiceMain(int argc, unsigned char* argv[] )
|
void __stdcall ServiceMain(int argc, unsigned char* argv[] )
|
||||||
{
|
{
|
||||||
|
|
||||||
hSrv = RegisterServiceCtrlHandler(conf.stringtable[1], (LPHANDLER_FUNCTION)CommandHandler);
|
hSrv = RegisterServiceCtrlHandler((LPCSTR)conf.stringtable[1], (LPHANDLER_FUNCTION)CommandHandler);
|
||||||
if( hSrv == 0 ) return;
|
if( hSrv == 0 ) return;
|
||||||
|
|
||||||
SetStatus( SERVICE_START_PENDING, 0, 1 );
|
SetStatus( SERVICE_START_PENDING, 0, 1 );
|
||||||
@@ -139,7 +139,7 @@ int timechanged (time_t oldtime, time_t newtime, ROTATION lt){
|
|||||||
struct tm tmold;
|
struct tm tmold;
|
||||||
struct tm *tm;
|
struct tm *tm;
|
||||||
tm = localtime(&oldtime);
|
tm = localtime(&oldtime);
|
||||||
memcpy(&tmold, tm, sizeof(tmold));
|
tmold = *tm;
|
||||||
tm = localtime(&newtime);
|
tm = localtime(&newtime);
|
||||||
switch(lt){
|
switch(lt){
|
||||||
case MINUTELY:
|
case MINUTELY:
|
||||||
@@ -192,6 +192,7 @@ void doschedule(void){
|
|||||||
|
|
||||||
void dumpcounters(struct trafcount *tlin, int counterd){
|
void dumpcounters(struct trafcount *tlin, int counterd){
|
||||||
|
|
||||||
|
unsigned char tmpbuf[8192];
|
||||||
struct trafcount *tl;
|
struct trafcount *tl;
|
||||||
if(counterd >= 0 && tlin) {
|
if(counterd >= 0 && tlin) {
|
||||||
|
|
||||||
@@ -234,6 +235,7 @@ void dumpcounters(struct trafcount *tlin, int counterd){
|
|||||||
void cyclestep(void){
|
void cyclestep(void){
|
||||||
struct tm *tm;
|
struct tm *tm;
|
||||||
time_t minutecounter;
|
time_t minutecounter;
|
||||||
|
unsigned char tmpbuf[8192];
|
||||||
|
|
||||||
minutecounter = time(0);
|
minutecounter = time(0);
|
||||||
for(;;){
|
for(;;){
|
||||||
@@ -362,6 +364,7 @@ int WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int
|
|||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
unsigned char * arg;
|
unsigned char * arg;
|
||||||
WSADATA wd;
|
WSADATA wd;
|
||||||
|
unsigned char tmpbuf[8192];
|
||||||
|
|
||||||
WSAStartup(MAKEWORD( 1, 1 ), &wd);
|
WSAStartup(MAKEWORD( 1, 1 ), &wd);
|
||||||
osv.dwOSVersionInfoSize = sizeof(osv);
|
osv.dwOSVersionInfoSize = sizeof(osv);
|
||||||
@@ -394,7 +397,7 @@ int WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int
|
|||||||
"By clicking Yes you confirm you read and accepted License Agreement.\n"
|
"By clicking Yes you confirm you read and accepted License Agreement.\n"
|
||||||
"You can use Administration/Services to control %s service.",
|
"You can use Administration/Services to control %s service.",
|
||||||
conf.stringtable[1], conf.stringtable[2]);
|
conf.stringtable[1], conf.stringtable[2]);
|
||||||
if(MessageBox(NULL, (char *)tmpbuf, conf.stringtable[2], MB_YESNO|MB_ICONASTERISK) != IDYES) return 1;
|
if(MessageBox(NULL, (LPCSTR)tmpbuf, (LPCSTR)conf.stringtable[2], MB_YESNO|MB_ICONASTERISK) != IDYES) return 1;
|
||||||
|
|
||||||
|
|
||||||
*tmpbuf = '\"';
|
*tmpbuf = '\"';
|
||||||
@@ -415,7 +418,7 @@ int WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int
|
|||||||
perror("Failed to open Service Manager");
|
perror("Failed to open Service Manager");
|
||||||
RETURN(101);
|
RETURN(101);
|
||||||
}
|
}
|
||||||
if (!(sch = CreateService(sch, conf.stringtable[1], conf.stringtable[2], GENERIC_EXECUTE, SERVICE_WIN32_OWN_PROCESS, SERVICE_AUTO_START, SERVICE_ERROR_IGNORE, (char *)tmpbuf, NULL, NULL, NULL, NULL, NULL))){
|
if (!(sch = CreateService(sch, (LPCSTR)conf.stringtable[1], (LPCSTR)conf.stringtable[2], GENERIC_EXECUTE, SERVICE_WIN32_OWN_PROCESS, SERVICE_AUTO_START, SERVICE_ERROR_IGNORE, (char *)tmpbuf, NULL, NULL, NULL, NULL, NULL))){
|
||||||
perror("Failed to create service");
|
perror("Failed to create service");
|
||||||
RETURN(103);
|
RETURN(103);
|
||||||
}
|
}
|
||||||
@@ -436,10 +439,10 @@ int WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int
|
|||||||
RETURN(104);
|
RETURN(104);
|
||||||
}
|
}
|
||||||
if(RegSetValueEx( runsrv,
|
if(RegSetValueEx( runsrv,
|
||||||
conf.stringtable[1],
|
(LPCSTR)conf.stringtable[1],
|
||||||
0,
|
0,
|
||||||
REG_EXPAND_SZ,
|
REG_EXPAND_SZ,
|
||||||
(char *)tmpbuf,
|
(BYTE *)tmpbuf,
|
||||||
(int)strlen((char *)tmpbuf)+1)!=ERROR_SUCCESS){
|
(int)strlen((char *)tmpbuf)+1)!=ERROR_SUCCESS){
|
||||||
perror("Failed to set registry value");
|
perror("Failed to set registry value");
|
||||||
RETURN(105);
|
RETURN(105);
|
||||||
@@ -457,7 +460,7 @@ int WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int
|
|||||||
perror("Failed to open Service Manager\n");
|
perror("Failed to open Service Manager\n");
|
||||||
RETURN(106);
|
RETURN(106);
|
||||||
}
|
}
|
||||||
if (!(sch = OpenService(sch, conf.stringtable[1], DELETE))){
|
if (!(sch = OpenService(sch, (LPCSTR)conf.stringtable[1], DELETE))){
|
||||||
perror("Failed to open service");
|
perror("Failed to open service");
|
||||||
RETURN(107);
|
RETURN(107);
|
||||||
}
|
}
|
||||||
@@ -476,7 +479,7 @@ int WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int
|
|||||||
perror("Failed to open registry");
|
perror("Failed to open registry");
|
||||||
RETURN(109);
|
RETURN(109);
|
||||||
}
|
}
|
||||||
if(RegDeleteValue(runsrv, conf.stringtable[1]) != ERROR_SUCCESS){
|
if(RegDeleteValue(runsrv, (LPCSTR)conf.stringtable[1]) != ERROR_SUCCESS){
|
||||||
perror("Failed to clear registry");
|
perror("Failed to clear registry");
|
||||||
RETURN(110);
|
RETURN(110);
|
||||||
}
|
}
|
||||||
@@ -510,17 +513,16 @@ int WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
pthread_mutex_init(&log_mutex, NULL);
|
|
||||||
logmutexinit = 1;
|
|
||||||
|
|
||||||
pthread_mutex_init(&config_mutex, NULL);
|
pthread_mutex_init(&config_mutex, NULL);
|
||||||
pthread_mutex_init(&bandlim_mutex, NULL);
|
pthread_mutex_init(&bandlim_mutex, NULL);
|
||||||
pthread_mutex_init(&hash_mutex, NULL);
|
pthread_mutex_init(&hash_mutex, NULL);
|
||||||
pthread_mutex_init(&tc_mutex, NULL);
|
pthread_mutex_init(&tc_mutex, NULL);
|
||||||
pthread_mutex_init(&pwl_mutex, NULL);
|
pthread_mutex_init(&pwl_mutex, NULL);
|
||||||
|
pthread_mutex_init(&log_mutex, NULL);
|
||||||
|
|
||||||
freeconf(&conf);
|
freeconf(&conf);
|
||||||
res = readconfig(fp);
|
res = readconfig(fp);
|
||||||
|
conf.version++;
|
||||||
|
|
||||||
if(res) RETURN(res);
|
if(res) RETURN(res);
|
||||||
if(!writable)fclose(fp);
|
if(!writable)fclose(fp);
|
||||||
@@ -531,7 +533,7 @@ int WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int
|
|||||||
if(service){
|
if(service){
|
||||||
SERVICE_TABLE_ENTRY ste[] =
|
SERVICE_TABLE_ENTRY ste[] =
|
||||||
{
|
{
|
||||||
{ conf.stringtable[1], (LPSERVICE_MAIN_FUNCTION)ServiceMain},
|
{ (LPSTR)conf.stringtable[1], (LPSERVICE_MAIN_FUNCTION)ServiceMain},
|
||||||
{ NULL, NULL }
|
{ NULL, NULL }
|
||||||
};
|
};
|
||||||
if(!StartServiceCtrlDispatcher( ste ))cyclestep();
|
if(!StartServiceCtrlDispatcher( ste ))cyclestep();
|
||||||
|
|||||||
+11
-16
@@ -2,12 +2,7 @@
|
|||||||
# 3 proxy common Makefile
|
# 3 proxy common Makefile
|
||||||
#
|
#
|
||||||
|
|
||||||
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
|
all: $(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:
|
|
||||||
-cd .. && $(TYPECOMMAND) copying
|
|
||||||
$(PREMAKE)
|
|
||||||
|
|
||||||
|
|
||||||
sockmap$(OBJSUFFICS): sockmap.c proxy.h structures.h
|
sockmap$(OBJSUFFICS): sockmap.c proxy.h structures.h
|
||||||
@@ -62,28 +57,28 @@ udppm$(OBJSUFFICS): udppm.c proxy.h structures.h proxymain.c
|
|||||||
$(CC) $(CFLAGS) 3proxy.c
|
$(CC) $(CFLAGS) 3proxy.c
|
||||||
|
|
||||||
$(BUILDDIR)proxy$(EXESUFFICS): sockmap$(OBJSUFFICS) proxy$(OBJSUFFICS) sockgetchar$(OBJSUFFICS) myalloc$(OBJSUFFICS) common$(OBJSUFFICS) base64$(OBJSUFFICS) ftp$(OBJSUFFICS) $(COMPATLIBS)
|
$(BUILDDIR)proxy$(EXESUFFICS): sockmap$(OBJSUFFICS) proxy$(OBJSUFFICS) sockgetchar$(OBJSUFFICS) myalloc$(OBJSUFFICS) common$(OBJSUFFICS) base64$(OBJSUFFICS) ftp$(OBJSUFFICS) $(COMPATLIBS)
|
||||||
$(LN) $(LNOUT)$(BUILDDIR)proxy$(EXESUFFICS) $(LDFLAGS) $(VERFILE) sockmap$(OBJSUFFICS) proxy$(OBJSUFFICS) sockgetchar$(OBJSUFFICS) myalloc$(OBJSUFFICS) common$(OBJSUFFICS) base64$(OBJSUFFICS) ftp$(OBJSUFFICS) $(COMPATLIBS) $(LIBS)
|
$(LN) $(LNOUT)$(BUILDDIR)proxy$(EXESUFFICS) $(LDFLAGS) sockmap$(OBJSUFFICS) proxy$(OBJSUFFICS) sockgetchar$(OBJSUFFICS) myalloc$(OBJSUFFICS) common$(OBJSUFFICS) base64$(OBJSUFFICS) ftp$(OBJSUFFICS) $(COMPATLIBS) $(LIBS)
|
||||||
|
|
||||||
$(BUILDDIR)pop3p$(EXESUFFICS): sockmap$(OBJSUFFICS) pop3p$(OBJSUFFICS) sockgetchar$(OBJSUFFICS) myalloc$(OBJSUFFICS) common$(OBJSUFFICS) $(COMPATLIBS)
|
$(BUILDDIR)pop3p$(EXESUFFICS): sockmap$(OBJSUFFICS) pop3p$(OBJSUFFICS) sockgetchar$(OBJSUFFICS) myalloc$(OBJSUFFICS) common$(OBJSUFFICS) $(COMPATLIBS)
|
||||||
$(LN) $(LNOUT)$(BUILDDIR)pop3p$(EXESUFFICS) $(LDFLAGS) $(VERFILE) sockmap$(OBJSUFFICS) pop3p$(OBJSUFFICS) sockgetchar$(OBJSUFFICS) myalloc$(OBJSUFFICS) common$(OBJSUFFICS) $(COMPATLIBS) $(LIBS)
|
$(LN) $(LNOUT)$(BUILDDIR)pop3p$(EXESUFFICS) $(LDFLAGS) sockmap$(OBJSUFFICS) pop3p$(OBJSUFFICS) sockgetchar$(OBJSUFFICS) myalloc$(OBJSUFFICS) common$(OBJSUFFICS) $(COMPATLIBS) $(LIBS)
|
||||||
|
|
||||||
$(BUILDDIR)smtpp$(EXESUFFICS): sockmap$(OBJSUFFICS) smtpp$(OBJSUFFICS) sockgetchar$(OBJSUFFICS) myalloc$(OBJSUFFICS) common$(OBJSUFFICS) base64$(OBJSUFFICS) $(COMPATLIBS)
|
$(BUILDDIR)smtpp$(EXESUFFICS): sockmap$(OBJSUFFICS) smtpp$(OBJSUFFICS) sockgetchar$(OBJSUFFICS) myalloc$(OBJSUFFICS) common$(OBJSUFFICS) base64$(OBJSUFFICS) $(COMPATLIBS)
|
||||||
$(LN) $(LNOUT)$(BUILDDIR)smtpp$(EXESUFFICS) $(LDFLAGS) $(VERFILE) sockmap$(OBJSUFFICS) smtpp$(OBJSUFFICS) sockgetchar$(OBJSUFFICS) base64$(OBJSUFFICS) myalloc$(OBJSUFFICS) common$(OBJSUFFICS) $(COMPATLIBS) $(LIBS)
|
$(LN) $(LNOUT)$(BUILDDIR)smtpp$(EXESUFFICS) $(LDFLAGS) sockmap$(OBJSUFFICS) smtpp$(OBJSUFFICS) sockgetchar$(OBJSUFFICS) base64$(OBJSUFFICS) myalloc$(OBJSUFFICS) common$(OBJSUFFICS) $(COMPATLIBS) $(LIBS)
|
||||||
|
|
||||||
$(BUILDDIR)ftppr$(EXESUFFICS): sockmap$(OBJSUFFICS) ftppr$(OBJSUFFICS) ftp$(OBJSUFFICS) sockgetchar$(OBJSUFFICS) myalloc$(OBJSUFFICS) common$(OBJSUFFICS) $(COMPATLIBS)
|
$(BUILDDIR)ftppr$(EXESUFFICS): sockmap$(OBJSUFFICS) ftppr$(OBJSUFFICS) ftp$(OBJSUFFICS) sockgetchar$(OBJSUFFICS) myalloc$(OBJSUFFICS) common$(OBJSUFFICS) $(COMPATLIBS)
|
||||||
$(LN) $(LNOUT)$(BUILDDIR)ftppr$(EXESUFFICS) $(LDFLAGS) $(VERFILE) sockmap$(OBJSUFFICS) ftppr$(OBJSUFFICS) sockgetchar$(OBJSUFFICS) myalloc$(OBJSUFFICS) common$(OBJSUFFICS) ftp$(OBJSUFFICS) $(COMPATLIBS) $(LIBS)
|
$(LN) $(LNOUT)$(BUILDDIR)ftppr$(EXESUFFICS) $(LDFLAGS) sockmap$(OBJSUFFICS) ftppr$(OBJSUFFICS) sockgetchar$(OBJSUFFICS) myalloc$(OBJSUFFICS) common$(OBJSUFFICS) ftp$(OBJSUFFICS) $(COMPATLIBS) $(LIBS)
|
||||||
|
|
||||||
$(BUILDDIR)socks$(EXESUFFICS): sockmap$(OBJSUFFICS) socks$(OBJSUFFICS) sockgetchar$(OBJSUFFICS) myalloc$(OBJSUFFICS) common$(OBJSUFFICS)
|
$(BUILDDIR)socks$(EXESUFFICS): sockmap$(OBJSUFFICS) socks$(OBJSUFFICS) sockgetchar$(OBJSUFFICS) myalloc$(OBJSUFFICS) common$(OBJSUFFICS)
|
||||||
$(LN) $(LNOUT)$(BUILDDIR)socks$(EXESUFFICS) $(LDFLAGS) $(VERFILE) sockmap$(OBJSUFFICS) socks$(OBJSUFFICS) sockgetchar$(OBJSUFFICS) myalloc$(OBJSUFFICS) common$(OBJSUFFICS) $(LIBS)
|
$(LN) $(LNOUT)$(BUILDDIR)socks$(EXESUFFICS) $(LDFLAGS) sockmap$(OBJSUFFICS) socks$(OBJSUFFICS) sockgetchar$(OBJSUFFICS) myalloc$(OBJSUFFICS) common$(OBJSUFFICS) $(LIBS)
|
||||||
|
|
||||||
$(BUILDDIR)tcppm$(EXESUFFICS): sockmap$(OBJSUFFICS) sockgetchar$(OBJSUFFICS) tcppm$(OBJSUFFICS) myalloc$(OBJSUFFICS) common$(OBJSUFFICS)
|
$(BUILDDIR)tcppm$(EXESUFFICS): sockmap$(OBJSUFFICS) sockgetchar$(OBJSUFFICS) tcppm$(OBJSUFFICS) myalloc$(OBJSUFFICS) common$(OBJSUFFICS)
|
||||||
$(LN) $(LNOUT)$(BUILDDIR)tcppm$(EXESUFFICS) $(LDFLAGS) $(VERFILE) sockmap$(OBJSUFFICS) sockgetchar$(OBJSUFFICS) tcppm$(OBJSUFFICS) myalloc$(OBJSUFFICS) common$(OBJSUFFICS) $(LIBS)
|
$(LN) $(LNOUT)$(BUILDDIR)tcppm$(EXESUFFICS) $(LDFLAGS) sockmap$(OBJSUFFICS) sockgetchar$(OBJSUFFICS) tcppm$(OBJSUFFICS) myalloc$(OBJSUFFICS) common$(OBJSUFFICS) $(LIBS)
|
||||||
|
|
||||||
$(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) sockmap$(OBJSUFFICS) sockgetchar$(OBJSUFFICS) icqpr$(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) sockmap$(OBJSUFFICS) sockgetchar$(OBJSUFFICS) udppm$(OBJSUFFICS) myalloc$(OBJSUFFICS) common$(OBJSUFFICS) $(LIBS)
|
||||||
|
|
||||||
mainfunc$(OBJSUFFICS): proxy.h structures.h proxymain.c
|
mainfunc$(OBJSUFFICS): proxy.h structures.h proxymain.c
|
||||||
$(CC) $(COUT)mainfunc$(OBJSUFFICS) $(CFLAGS) $(DEFINEOPTION)MODULEMAINFUNC=mainfunc proxymain.c
|
$(CC) $(COUT)mainfunc$(OBJSUFFICS) $(CFLAGS) $(DEFINEOPTION)MODULEMAINFUNC=mainfunc proxymain.c
|
||||||
@@ -136,13 +131,13 @@ dighosts$(OBJSUFFICS): dighosts.c
|
|||||||
$(CC) $(COUT)dighosts$(OBJSUFFICS) $(CFLAGS) dighosts.c
|
$(CC) $(COUT)dighosts$(OBJSUFFICS) $(CFLAGS) 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) dighosts$(OBJSUFFICS) myalloc$(OBJSUFFICS) common$(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
|
||||||
|
|
||||||
$(BUILDDIR)mycrypt$(EXESUFFICS): md4$(OBJSUFFICS) md5$(OBJSUFFICS) mycryptmain$(OBJSUFFICS) base64$(OBJSUFFICS)
|
$(BUILDDIR)mycrypt$(EXESUFFICS): md4$(OBJSUFFICS) md5$(OBJSUFFICS) mycryptmain$(OBJSUFFICS) base64$(OBJSUFFICS)
|
||||||
$(LN) $(LNOUT)$(BUILDDIR)mycrypt$(EXESUFFICS) $(VERFILE) $(LDFLAGS) md4$(OBJSUFFICS) md5$(OBJSUFFICS) base64$(OBJSUFFICS) mycryptmain$(OBJSUFFICS)
|
$(LN) $(LNOUT)$(BUILDDIR)mycrypt$(EXESUFFICS) $(LDFLAGS) md4$(OBJSUFFICS) md5$(OBJSUFFICS) base64$(OBJSUFFICS) mycryptmain$(OBJSUFFICS)
|
||||||
|
|
||||||
|
|
||||||
md4$(OBJSUFFICS): libs/md4.h libs/md4.c
|
md4$(OBJSUFFICS): libs/md4.h libs/md4.c
|
||||||
|
|||||||
+84
-63
@@ -19,10 +19,9 @@ int clientnegotiate(struct chain * redir, struct clientparam * param, struct soc
|
|||||||
|
|
||||||
user = redir->extuser;
|
user = redir->extuser;
|
||||||
pass = redir->extpass;
|
pass = redir->extpass;
|
||||||
if (param->srvinbuf < 4096){
|
if (!param->srvbufsize){
|
||||||
if(param->srvbuf)myfree(param->srvbuf);
|
param->srvbufsize = SRVBUFSIZE;
|
||||||
param->srvbuf = myalloc(4096);
|
param->srvbuf = myalloc(param->srvbufsize);
|
||||||
param->srvbufsize = 4096;
|
|
||||||
}
|
}
|
||||||
buf = param->srvbuf;
|
buf = param->srvbuf;
|
||||||
username = buf + 2048;
|
username = buf + 2048;
|
||||||
@@ -43,9 +42,9 @@ int clientnegotiate(struct chain * redir, struct clientparam * param, struct soc
|
|||||||
len = sprintf((char *)buf, "CONNECT ");
|
len = sprintf((char *)buf, "CONNECT ");
|
||||||
if(redir->type == R_CONNECTP && param->hostname) {
|
if(redir->type == R_CONNECTP && param->hostname) {
|
||||||
char * needreplace;
|
char * needreplace;
|
||||||
needreplace = strchr(param->hostname, ':');
|
needreplace = strchr((char *)param->hostname, ':');
|
||||||
if(needreplace) buf[len++] = '[';
|
if(needreplace) buf[len++] = '[';
|
||||||
len =+ sprintf((char *)buf + len, "%.256s", param->hostname);
|
len += sprintf((char *)buf + len, "%.256s", (char *)param->hostname);
|
||||||
if(needreplace) buf[len++] = ']';
|
if(needreplace) buf[len++] = ']';
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -57,7 +56,7 @@ int clientnegotiate(struct chain * redir, struct clientparam * param, struct soc
|
|||||||
":%hu HTTP/1.0\r\nProxy-Connection: keep-alive\r\n", ntohs(*SAPORT(addr)));
|
":%hu HTTP/1.0\r\nProxy-Connection: keep-alive\r\n", ntohs(*SAPORT(addr)));
|
||||||
if(user){
|
if(user){
|
||||||
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:%.128s", user, pass?pass:(unsigned char *)"");
|
||||||
en64(username, buf+len, (int)strlen((char *)username));
|
en64(username, buf+len, (int)strlen((char *)username));
|
||||||
len = (int)strlen((char *)buf);
|
len = (int)strlen((char *)buf);
|
||||||
len += sprintf((char *)buf + len, "\r\n");
|
len += sprintf((char *)buf + len, "\r\n");
|
||||||
@@ -190,11 +189,21 @@ int clientnegotiate(struct chain * redir, struct clientparam * param, struct soc
|
|||||||
if(buf[1] != 0) {
|
if(buf[1] != 0) {
|
||||||
return 60 + (buf[1] % 10);
|
return 60 + (buf[1] % 10);
|
||||||
}
|
}
|
||||||
if(buf[3] != 1) {
|
switch (buf[3]) {
|
||||||
return 58;
|
case 1:
|
||||||
}
|
if (redir->type == R_SOCKS5B || sockgetlinebuf(param, SERVER, buf, 6, EOF, conf.timeouts[CHAIN_TO]) == 6)
|
||||||
if (redir->type != R_SOCKS5B && sockgetlinebuf(param, SERVER, buf, 6, EOF, conf.timeouts[CHAIN_TO]) != 6){
|
break;
|
||||||
return 59;
|
return 59;
|
||||||
|
case 3:
|
||||||
|
if (sockgetlinebuf(param, SERVER, buf, 256, 0, conf.timeouts[CHAIN_TO]) > 1)
|
||||||
|
break;
|
||||||
|
return 59;
|
||||||
|
case 4:
|
||||||
|
if (sockgetlinebuf(param, SERVER, buf, 18, EOF, conf.timeouts[CHAIN_TO]) == 18)
|
||||||
|
break;
|
||||||
|
return 59;
|
||||||
|
default:
|
||||||
|
return 58;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -241,7 +250,12 @@ 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(SAISNULL(&cur->addr) && !*SAPORT(&cur->addr)){
|
if(cur->type == R_EXTIP){
|
||||||
|
param->sinsl = cur->addr;
|
||||||
|
if(cur->next)continue;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
else 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);
|
||||||
@@ -266,11 +280,9 @@ int handleredirect(struct clientparam * param, struct ace * acentry){
|
|||||||
case R_ICQ:
|
case R_ICQ:
|
||||||
param->redirectfunc = icqprchild;
|
param->redirectfunc = icqprchild;
|
||||||
break;
|
break;
|
||||||
/*
|
case R_SMTP:
|
||||||
case R_MSN:
|
param->redirectfunc = smtppchild;
|
||||||
param->redirectfunc = msnprchild;
|
|
||||||
break;
|
break;
|
||||||
*/
|
|
||||||
default:
|
default:
|
||||||
param->redirectfunc = proxychild;
|
param->redirectfunc = proxychild;
|
||||||
}
|
}
|
||||||
@@ -279,12 +291,12 @@ int handleredirect(struct clientparam * param, struct ace * acentry){
|
|||||||
}
|
}
|
||||||
else if(!*SAPORT(&cur->addr) && !SAISNULL(&cur->addr)) {
|
else if(!*SAPORT(&cur->addr) && !SAISNULL(&cur->addr)) {
|
||||||
unsigned short port = *SAPORT(¶m->sinsr);
|
unsigned short port = *SAPORT(¶m->sinsr);
|
||||||
memcpy(¶m->sinsr, &cur->addr, SASIZE(&cur->addr));
|
param->sinsr = cur->addr;
|
||||||
*SAPORT(¶m->sinsr) = port;
|
*SAPORT(¶m->sinsr) = port;
|
||||||
}
|
}
|
||||||
else if(SAISNULL(&cur->addr) && *SAPORT(&cur->addr)) *SAPORT(¶m->sinsr) = *SAPORT(&cur->addr);
|
else if(SAISNULL(&cur->addr) && *SAPORT(&cur->addr)) *SAPORT(¶m->sinsr) = *SAPORT(&cur->addr);
|
||||||
else {
|
else {
|
||||||
memcpy(¶m->sinsr, &cur->addr, SASIZE(&cur->addr));
|
param->sinsr = cur->addr;
|
||||||
}
|
}
|
||||||
|
|
||||||
if((res = alwaysauth(param))){
|
if((res = alwaysauth(param))){
|
||||||
@@ -314,8 +326,8 @@ int handleredirect(struct clientparam * param, struct ace * acentry){
|
|||||||
connected = 1;
|
connected = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!connected) return 9;
|
if(!connected || !redir) return 0;
|
||||||
return (redir)?clientnegotiate(redir, param, (struct sockaddr *)¶m->req):0;
|
return clientnegotiate(redir, param, (struct sockaddr *)¶m->req);
|
||||||
}
|
}
|
||||||
|
|
||||||
int IPInentry(struct sockaddr *sa, struct iplist *ipentry){
|
int IPInentry(struct sockaddr *sa, struct iplist *ipentry){
|
||||||
@@ -369,19 +381,19 @@ int ACLmatches(struct ace* acentry, struct clientparam * param){
|
|||||||
for(hstentry = acentry->dstnames; hstentry; hstentry = hstentry->next){
|
for(hstentry = acentry->dstnames; hstentry; hstentry = hstentry->next){
|
||||||
switch(hstentry->matchtype){
|
switch(hstentry->matchtype){
|
||||||
case 0:
|
case 0:
|
||||||
if(strstr(param->hostname, hstentry->name)) match = 1;
|
if(strstr((char *)param->hostname, (char *)hstentry->name)) match = 1;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 1:
|
case 1:
|
||||||
if(strstr(param->hostname, hstentry->name) == (char *)param->hostname) match = 1;
|
if(strstr((char *)param->hostname, (char *)hstentry->name) == (char *)param->hostname) match = 1;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 2:
|
case 2:
|
||||||
if(strstr(param->hostname, hstentry->name) == (char *)(param->hostname + i - (strlen(hstentry->name)))) match = 1;
|
if(strstr((char *)param->hostname, (char *)hstentry->name) == (char *)(param->hostname + i - (strlen((char *)hstentry->name)))) match = 1;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
if(!strcmp(param->hostname, hstentry->name)) match = 1;
|
if(!strcmp((char *)param->hostname, (char *)hstentry->name)) match = 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if(match) break;
|
if(match) break;
|
||||||
@@ -473,8 +485,14 @@ unsigned bandlimitfunc(struct clientparam *param, unsigned nbytesin, unsigned nb
|
|||||||
|
|
||||||
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->paused != conf.paused && param->bandlimver != conf.paused){
|
||||||
|
if(!conf.bandlimfunc){
|
||||||
|
param->bandlimfunc = NULL;
|
||||||
|
pthread_mutex_unlock(&bandlim_mutex);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
initbandlims(param);
|
initbandlims(param);
|
||||||
|
param->bandlimver = conf.paused;
|
||||||
}
|
}
|
||||||
for(i=0; nbytesin&& i<MAXBANDLIMS && param->bandlims[i]; i++){
|
for(i=0; nbytesin&& i<MAXBANDLIMS && param->bandlims[i]; i++){
|
||||||
if( !param->bandlims[i]->basetime ||
|
if( !param->bandlims[i]->basetime ||
|
||||||
@@ -555,7 +573,6 @@ int alwaysauth(struct clientparam * param){
|
|||||||
|
|
||||||
res = doconnect(param);
|
res = doconnect(param);
|
||||||
if(!res){
|
if(!res){
|
||||||
if(param->srv->version != conf.paused) return 333;
|
|
||||||
initbandlims(param);
|
initbandlims(param);
|
||||||
for(tc = conf.trafcounter; tc; tc = tc->next) {
|
for(tc = conf.trafcounter; tc; tc = tc->next) {
|
||||||
if(tc->disabled) continue;
|
if(tc->disabled) continue;
|
||||||
@@ -608,7 +625,7 @@ int checkACL(struct clientparam * param){
|
|||||||
if(param->redirected && acentry->chains && SAISNULL(&acentry->chains->addr) && !*SAPORT(&acentry->chains->addr)) {
|
if(param->redirected && acentry->chains && SAISNULL(&acentry->chains->addr) && !*SAPORT(&acentry->chains->addr)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
memcpy(&dup, acentry, sizeof(struct ace));
|
dup = *acentry;
|
||||||
return handleredirect(param, &dup);
|
return handleredirect(param, &dup);
|
||||||
}
|
}
|
||||||
return acentry->action;
|
return acentry->action;
|
||||||
@@ -651,13 +668,13 @@ int cacheauth(struct clientparam * param){
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
}
|
}
|
||||||
if(((!(conf.authcachetype&2)) || (param->username && ac->username && !strcmp(ac->username, param->username))) &&
|
if(((!(conf.authcachetype&2)) || (param->username && ac->username && !strcmp(ac->username, (char *)param->username))) &&
|
||||||
((!(conf.authcachetype&1)) || (*SAFAMILY(&ac->sa) == *SAFAMILY(¶m->sincr) && !memcmp(SAADDR(&ac->sa), ¶m->sincr, SAADDRLEN(&ac->sa)))) &&
|
((!(conf.authcachetype&1)) || (*SAFAMILY(&ac->sa) == *SAFAMILY(¶m->sincr) && !memcmp(SAADDR(&ac->sa), SAADDR(¶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, (char *)param->password)))) {
|
||||||
if(param->username){
|
if(param->username){
|
||||||
myfree(param->username);
|
myfree(param->username);
|
||||||
}
|
}
|
||||||
param->username = mystrdup(ac->username);
|
param->username = (unsigned char *)mystrdup(ac->username);
|
||||||
pthread_mutex_unlock(&hash_mutex);
|
pthread_mutex_unlock(&hash_mutex);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -685,21 +702,21 @@ int doauth(struct clientparam * param){
|
|||||||
if(conf.authcachetype && authfuncs->authenticate && authfuncs->authenticate != cacheauth && param->username && (!(conf.authcachetype&4) || (!param->pwtype && param->password))){
|
if(conf.authcachetype && authfuncs->authenticate && authfuncs->authenticate != cacheauth && param->username && (!(conf.authcachetype&4) || (!param->pwtype && param->password))){
|
||||||
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, (char *)param->username)) &&
|
||||||
(!(conf.authcachetype&1) || (*SAFAMILY(&ac->sa) == *SAFAMILY(¶m->sincr) && !memcmp(SAADDR(&ac->sa), ¶m->sincr, SAADDRLEN(&ac->sa)))) &&
|
(!(conf.authcachetype&1) || (*SAFAMILY(&ac->sa) == *SAFAMILY(¶m->sincr) && !memcmp(SAADDR(&ac->sa), SAADDR(¶m->sincr), SAADDRLEN(&ac->sa)))) &&
|
||||||
(!(conf.authcachetype&4) || (ac->password && !strcmp(ac->password, param->password)))) {
|
(!(conf.authcachetype&4) || (ac->password && !strcmp(ac->password, (char *)param->password)))) {
|
||||||
ac->expires = conf.time + conf.authcachetime;
|
ac->expires = conf.time + conf.authcachetime;
|
||||||
if(strcmp(ac->username, param->username)){
|
if(strcmp(ac->username, (char *)param->username)){
|
||||||
tmp = ac->username;
|
tmp = ac->username;
|
||||||
ac->username = mystrdup(param->username);
|
ac->username = mystrdup((char *)param->username);
|
||||||
myfree(tmp);
|
myfree(tmp);
|
||||||
}
|
}
|
||||||
if((conf.authcachetype&4)){
|
if((conf.authcachetype&4)){
|
||||||
tmp = ac->password;
|
tmp = ac->password;
|
||||||
ac->password = mystrdup(param->password);
|
ac->password = mystrdup((char *)param->password);
|
||||||
myfree(tmp);
|
myfree(tmp);
|
||||||
}
|
}
|
||||||
memcpy(&ac->sa, ¶m->sincr, SASIZE(¶m->sincr));
|
ac->sa = param->sincr;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -707,10 +724,10 @@ int doauth(struct clientparam * param){
|
|||||||
ac = myalloc(sizeof(struct authcache));
|
ac = myalloc(sizeof(struct authcache));
|
||||||
if(ac){
|
if(ac){
|
||||||
ac->expires = conf.time + conf.authcachetime;
|
ac->expires = conf.time + conf.authcachetime;
|
||||||
ac->username = mystrdup(param->username);
|
ac->username = param->username?mystrdup((char *)param->username):NULL;
|
||||||
memcpy(&ac->sa, ¶m->sincr, SASIZE(¶m->sincr));
|
ac->sa = param->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((char *)param->password);
|
||||||
}
|
}
|
||||||
ac->next = authc;
|
ac->next = authc;
|
||||||
authc = ac;
|
authc = ac;
|
||||||
@@ -772,10 +789,14 @@ int dnsauth(struct clientparam * param){
|
|||||||
((u&0xFF000000)>>24));
|
((u&0xFF000000)>>24));
|
||||||
|
|
||||||
}
|
}
|
||||||
if(!udpresolve(*SAFAMILY(¶m->sincr), buf, addr, NULL, param, 1)) return 6;
|
if(!udpresolve(*SAFAMILY(¶m->sincr), (unsigned char *)buf, (unsigned char *)addr, NULL, param, 1)) {
|
||||||
if(!memcmp(SAADDR(¶m->sincr), addr, SAADDRLEN(¶m->sincr))) return 6;
|
return 3;
|
||||||
|
}
|
||||||
|
if(memcmp(SAADDR(¶m->sincr), addr, SAADDRLEN(¶m->sincr))) {
|
||||||
|
return 3;
|
||||||
|
}
|
||||||
|
|
||||||
return param->username? 0:4;
|
return param->username? 0:3;
|
||||||
}
|
}
|
||||||
|
|
||||||
int strongauth(struct clientparam * param){
|
int strongauth(struct clientparam * param){
|
||||||
@@ -1037,17 +1058,18 @@ unsigned long udpresolve(int af, unsigned char * name, unsigned char * value, un
|
|||||||
unsigned ttl;
|
unsigned ttl;
|
||||||
#ifndef NOIPV6
|
#ifndef NOIPV6
|
||||||
struct sockaddr_in6 addr;
|
struct sockaddr_in6 addr;
|
||||||
|
struct sockaddr_in6 *sinsr, *sinsl;
|
||||||
#else
|
#else
|
||||||
struct sockaddr_in addr;
|
struct sockaddr_in addr;
|
||||||
|
struct sockaddr_in *sinsr, *sinsl;
|
||||||
#endif
|
#endif
|
||||||
struct sockaddr *sinsr, *sinsl;
|
|
||||||
int usetcp = 0;
|
int usetcp = 0;
|
||||||
unsigned short serial = 1;
|
unsigned short serial = 1;
|
||||||
|
|
||||||
buf = b+2;
|
buf = b+2;
|
||||||
|
|
||||||
sinsl = (param && !makeauth)? (struct sockaddr *)¶m->sinsl : (struct sockaddr *)&addr;
|
sinsl = (param && !makeauth)? ¶m->sinsl : &addr;
|
||||||
sinsr = (param && !makeauth)? (struct sockaddr *)¶m->sinsr : (struct sockaddr *)&addr;
|
sinsr = (param && !makeauth)? ¶m->sinsr : &addr;
|
||||||
memset(sinsl, 0, sizeof(addr));
|
memset(sinsl, 0, sizeof(addr));
|
||||||
memset(sinsr, 0, sizeof(addr));
|
memset(sinsr, 0, sizeof(addr));
|
||||||
|
|
||||||
@@ -1061,19 +1083,19 @@ unsigned long udpresolve(int af, unsigned char * name, unsigned char * value, un
|
|||||||
*SAFAMILY(sinsl) = *SAFAMILY(&nservers[i].addr);
|
*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((sock=so._socket(SASOCK(sinsl), usetcp?SOCK_STREAM:SOCK_DGRAM, usetcp?IPPROTO_TCP:IPPROTO_UDP)) == INVALID_SOCKET) break;
|
||||||
if(so._bind(sock,sinsl,SASIZE(sinsl))){
|
if(so._bind(sock,(struct sockaddr *)sinsl,SASIZE(sinsl))){
|
||||||
so._shutdown(sock, SHUT_RDWR);
|
so._shutdown(sock, SHUT_RDWR);
|
||||||
so._closesocket(sock);
|
so._closesocket(sock);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if(makeauth && !SAISNULL(&authnserver.addr)){
|
if(makeauth && !SAISNULL(&authnserver.addr)){
|
||||||
memcpy(sinsr, &authnserver.addr, sizeof(authnserver.addr));
|
*sinsr = authnserver.addr;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
memcpy(sinsr, &nservers[i].addr, sizeof(nservers[i].addr));
|
*sinsr = nservers[i].addr;
|
||||||
}
|
}
|
||||||
if(usetcp){
|
if(usetcp){
|
||||||
if(so._connect(sock,sinsr,SASIZE(sinsr))) {
|
if(so._connect(sock,(struct sockaddr *)sinsr,SASIZE(sinsr))) {
|
||||||
so._shutdown(sock, SHUT_RDWR);
|
so._shutdown(sock, SHUT_RDWR);
|
||||||
so._closesocket(sock);
|
so._closesocket(sock);
|
||||||
break;
|
break;
|
||||||
@@ -1109,13 +1131,13 @@ unsigned long udpresolve(int af, unsigned char * name, unsigned char * value, un
|
|||||||
len+=2;
|
len+=2;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(socksendto(sock, sinsr, buf, len, conf.timeouts[SINGLEBYTE_L]*1000) != len){
|
if(socksendto(sock, (struct sockaddr *)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->statscli64 += len;
|
if(param) param->statscli64 += len;
|
||||||
len = sockrecvfrom(sock, sinsr, buf, 4096, conf.timeouts[DNS_TO]*1000);
|
len = sockrecvfrom(sock, (struct sockaddr *)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) {
|
if(len <= 13) {
|
||||||
@@ -1127,7 +1149,7 @@ unsigned long udpresolve(int af, unsigned char * name, unsigned char * value, un
|
|||||||
us = ntohs(*(unsigned short*)buf);
|
us = ntohs(*(unsigned short*)buf);
|
||||||
len-=2;
|
len-=2;
|
||||||
buf+=2;
|
buf+=2;
|
||||||
if(us > 4096 || us < len || (us > len && sockrecvfrom(sock, sinsr, buf+len, us-len, conf.timeouts[DNS_TO]*1000) != us-len)) {
|
if(us > 4096 || us < len || (us > len && sockrecvfrom(sock, (struct sockaddr *)sinsr, buf+len, us-len, conf.timeouts[DNS_TO]*1000) != us-len)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1148,6 +1170,8 @@ unsigned long udpresolve(int af, unsigned char * name, unsigned char * value, un
|
|||||||
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 */
|
||||||
|
while(buf[k] < 192 && buf[k] !=0 && (k+buf[k]+14) < len) k+= (buf[k] + 1);
|
||||||
|
if(!buf[k]) k--;
|
||||||
if((k+(af == AF_INET6?28:16)) > len) {
|
if((k+(af == AF_INET6?28:16)) > len) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -1163,10 +1187,7 @@ unsigned long udpresolve(int af, unsigned char * name, unsigned char * value, un
|
|||||||
ttl = ntohl(*(unsigned long *)(buf + k + 6));
|
ttl = ntohl(*(unsigned long *)(buf + k + 6));
|
||||||
memcpy(value, buf + k + 12, af == AF_INET6? 16:4);
|
memcpy(value, buf + k + 12, af == AF_INET6? 16:4);
|
||||||
if(ttl < 60 || ttl > (3600*12)) ttl = 300;
|
if(ttl < 60 || ttl > (3600*12)) ttl = 300;
|
||||||
if(ttl){
|
|
||||||
hashadd(af == AF_INET6?&dns6_table:&dns_table, name, value, conf.time+ttl);
|
hashadd(af == AF_INET6?&dns6_table:&dns_table, name, value, conf.time+ttl);
|
||||||
|
|
||||||
}
|
|
||||||
if(retttl) *retttl = ttl;
|
if(retttl) *retttl = ttl;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@@ -1183,7 +1204,7 @@ unsigned long udpresolve(int af, unsigned char * name, unsigned char * value, un
|
|||||||
}
|
}
|
||||||
*s2 = 0;
|
*s2 = 0;
|
||||||
if(param->username)myfree(param->username);
|
if(param->username)myfree(param->username);
|
||||||
param->username = mystrdup (buf + k + 13);
|
param->username = (unsigned char *)mystrdup ((char *)buf + k + 13);
|
||||||
|
|
||||||
return udpresolve(af,param->username, value, NULL, NULL, 2);
|
return udpresolve(af,param->username, value, NULL, NULL, 2);
|
||||||
}
|
}
|
||||||
@@ -1320,20 +1341,20 @@ void logsql(struct clientparam * param, const unsigned char *s) {
|
|||||||
|
|
||||||
if(param->nolog) return;
|
if(param->nolog) return;
|
||||||
pthread_mutex_lock(&log_mutex);
|
pthread_mutex_lock(&log_mutex);
|
||||||
len = dobuf(param, tmpbuf, s, "\'");
|
len = dobuf(param, tmpbuf, s, (unsigned char *)"\'");
|
||||||
|
|
||||||
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(tmpbuf);
|
sqlerr((char *)tmpbuf);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(!hstmt){
|
if(!hstmt){
|
||||||
if(!init_sql(sqlstring)) {
|
if(!init_sql(sqlstring)) {
|
||||||
sqlerr(tmpbuf);
|
sqlerr((char *)tmpbuf);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1342,13 +1363,13 @@ void logsql(struct clientparam * param, const unsigned char *s) {
|
|||||||
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(tmpbuf);
|
sqlerr((char *)tmpbuf);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(hstmt) {
|
if(hstmt) {
|
||||||
ret = SQLExecDirect(hstmt, (SQLCHAR *)tmpbuf, (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(tmpbuf);
|
sqlerr((char *)tmpbuf);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
attempt = 0;
|
attempt = 0;
|
||||||
|
|||||||
+57
-42
@@ -17,6 +17,16 @@ int randomizer = 1;
|
|||||||
|
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
pthread_attr_t pa;
|
pthread_attr_t pa;
|
||||||
|
|
||||||
|
|
||||||
|
void daemonize(void){
|
||||||
|
if(fork() > 0) {
|
||||||
|
usleep(SLEEPTIME);
|
||||||
|
_exit(0);
|
||||||
|
}
|
||||||
|
setsid();
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
unsigned char **stringtable = NULL;
|
unsigned char **stringtable = NULL;
|
||||||
@@ -58,7 +68,12 @@ struct extparam conf = {
|
|||||||
NULL, NULL,
|
NULL, NULL,
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
0, -1, 0, 0, 0, 0, 0, 500, 0, 0, 0,
|
#ifdef __FreeBSD__
|
||||||
|
8192,
|
||||||
|
#else
|
||||||
|
0,
|
||||||
|
#endif
|
||||||
|
0, -1, 0, 0, 0, 0, 0, 500, 0, 0, 0, 0, 0,
|
||||||
6, 600,
|
6, 600,
|
||||||
1048576,
|
1048576,
|
||||||
NULL, NULL,
|
NULL, NULL,
|
||||||
@@ -84,7 +99,7 @@ struct extparam conf = {
|
|||||||
NULL,
|
NULL,
|
||||||
(time_t)0, (time_t)0,
|
(time_t)0, (time_t)0,
|
||||||
0,0,
|
0,0,
|
||||||
'@'
|
'@',
|
||||||
};
|
};
|
||||||
|
|
||||||
int numservers=0;
|
int numservers=0;
|
||||||
@@ -157,10 +172,10 @@ struct sockfuncs so = {
|
|||||||
#else
|
#else
|
||||||
mypoll,
|
mypoll,
|
||||||
#endif
|
#endif
|
||||||
send,
|
(void *)send,
|
||||||
sendto,
|
(void *)sendto,
|
||||||
recv,
|
(void *)recv,
|
||||||
recvfrom,
|
(void *)recvfrom,
|
||||||
shutdown,
|
shutdown,
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
closesocket
|
closesocket
|
||||||
@@ -216,30 +231,34 @@ int ceparseargs(const char *str){
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void parsehost(int family, char *host, struct sockaddr *sa){
|
int parsehost(int family, unsigned char *host, struct sockaddr *sa){
|
||||||
char *sp=NULL,*se=NULL;
|
char *sp=NULL,*se=NULL;
|
||||||
unsigned short port;
|
unsigned short port=0;
|
||||||
|
int ret = 0;
|
||||||
|
|
||||||
if(*host == '[') se=strchr(host, ']');
|
if(!host) return 2;
|
||||||
if ( (sp = strchr(se?se:host, ':')) ) *sp = 0;
|
if(*host == '[') se=strchr((char *)host, ']');
|
||||||
|
if ( (sp = strchr(se?se:(char *)host, ':')) && !strchr(sp+1, ':')) *sp = 0;
|
||||||
if(se){
|
if(se){
|
||||||
*se = 0;
|
*se = 0;
|
||||||
}
|
}
|
||||||
if(sp){
|
if(sp){
|
||||||
port = atoi(sp+1);
|
port = atoi(sp+1);
|
||||||
}
|
}
|
||||||
getip46(family, host + (se!=0), (struct sockaddr *)sa);
|
ret = !getip46(family, host + (se!=0), (struct sockaddr *)sa);
|
||||||
if(se) *se = ']';
|
if(se) *se = ']';
|
||||||
if(sp) *sp = ':';
|
if(sp) *sp = ':';
|
||||||
*SAPORT(sa) = htons(port);
|
if(port)*SAPORT(sa) = htons(port);
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int parsehostname(char *hostname, struct clientparam *param, unsigned short port){
|
int parsehostname(char *hostname, struct clientparam *param, unsigned short port){
|
||||||
char *sp=NULL,*se=NULL;
|
char *sp=NULL,*se=NULL;
|
||||||
|
int ret = 0;
|
||||||
|
|
||||||
if(!hostname || !*hostname)return 1;
|
if(!hostname || !*hostname)return 2;
|
||||||
if(*hostname == '[') se=strchr(hostname, ']');
|
if(*hostname == '[') se=strchr(hostname, ']');
|
||||||
if ( (sp = strchr(se?se:hostname, ':')) ) *sp = 0;
|
if ( (sp = strchr(se?se:hostname, ':')) && !strchr(sp+1, ':')) *sp = 0;
|
||||||
if(se){
|
if(se){
|
||||||
*se = 0;
|
*se = 0;
|
||||||
}
|
}
|
||||||
@@ -250,12 +269,12 @@ int parsehostname(char *hostname, struct clientparam *param, unsigned short port
|
|||||||
if(sp){
|
if(sp){
|
||||||
port = atoi(sp+1);
|
port = atoi(sp+1);
|
||||||
}
|
}
|
||||||
getip46(param->srv->family, param->hostname, (struct sockaddr *)¶m->req);
|
ret = !getip46(param->srv->family, param->hostname, (struct sockaddr *)¶m->req);
|
||||||
if(se) *se = ']';
|
if(se) *se = ']';
|
||||||
if(sp) *sp = ':';
|
if(sp) *sp = ':';
|
||||||
*SAPORT(¶m->req) = htons(port);
|
*SAPORT(¶m->req) = htons(port);
|
||||||
memset(¶m->sinsr, 0, sizeof(param->sinsr));
|
memset(¶m->sinsr, 0, sizeof(param->sinsr));
|
||||||
return 0;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int parseusername(char *username, struct clientparam *param, int extpasswd){
|
int parseusername(char *username, struct clientparam *param, int extpasswd){
|
||||||
@@ -297,7 +316,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);
|
if(param->hostname)parsehostname((char *)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;
|
||||||
@@ -449,7 +468,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 && !strchr((char *)param->hostname, ':')) for(len = 0; param->hostname[len] && i < 4000; len++, i++){
|
if (len > 0 && !strchr((char *)param->hostname, ':')) for(len = 0; param->hostname[len] && i < 256; 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])) {
|
||||||
@@ -461,12 +480,11 @@ int dobuf2(struct clientparam * param, unsigned char * buf, const unsigned char
|
|||||||
buf[i++] = '[';
|
buf[i++] = '[';
|
||||||
i += myinet_ntop(*SAFAMILY(¶m->req), SAADDR(¶m->req), (char *)buf + i, 64);
|
i += myinet_ntop(*SAFAMILY(¶m->req), SAADDR(¶m->req), (char *)buf + i, 64);
|
||||||
buf[i++] = ']';
|
buf[i++] = ']';
|
||||||
buf[i++] = 0;
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'N':
|
case 'N':
|
||||||
if(param->service >=0 && param->service < 15) {
|
if(param->service < 15) {
|
||||||
len = (conf.stringtable)? (int)strlen((char *)conf.stringtable[SERVICES + param->service]) : 0;
|
len = (conf.stringtable)? (int)strlen((char *)conf.stringtable[SERVICES + param->service]) : 0;
|
||||||
if(len > 20) len = 20;
|
if(len > 20) len = 20;
|
||||||
memcpy(buf+i, (len)?conf.stringtable[SERVICES + param->service]:(unsigned char*)"-", (len)?len:1);
|
memcpy(buf+i, (len)?conf.stringtable[SERVICES + param->service]:(unsigned char*)"-", (len)?len:1);
|
||||||
@@ -493,6 +511,9 @@ int dobuf2(struct clientparam * param, unsigned char * buf, const unsigned char
|
|||||||
case 'e':
|
case 'e':
|
||||||
i += myinet_ntop(*SAFAMILY(¶m->sinsl), SAADDR(¶m->sinsl), (char *)buf + i, 64);
|
i += myinet_ntop(*SAFAMILY(¶m->sinsl), SAADDR(¶m->sinsl), (char *)buf + i, 64);
|
||||||
break;
|
break;
|
||||||
|
case 'i':
|
||||||
|
i += myinet_ntop(*SAFAMILY(¶m->sincl), SAADDR(¶m->sincl), (char *)buf + i, 64);
|
||||||
|
break;
|
||||||
case 'C':
|
case 'C':
|
||||||
i += myinet_ntop(*SAFAMILY(¶m->sincr), SAADDR(¶m->sincr), (char *)buf + i, 64);
|
i += myinet_ntop(*SAFAMILY(¶m->sincr), SAADDR(¶m->sincr), (char *)buf + i, 64);
|
||||||
break;
|
break;
|
||||||
@@ -601,17 +622,11 @@ 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];
|
unsigned char tmpbuf[8192];
|
||||||
|
|
||||||
void logstdout(struct clientparam * param, const unsigned char *s) {
|
void logstdout(struct clientparam * param, const unsigned char *s) {
|
||||||
FILE *log;
|
FILE *log;
|
||||||
|
|
||||||
if(!logmutexinit){
|
|
||||||
pthread_mutex_init(&log_mutex, NULL);
|
|
||||||
logmutexinit = 1;
|
|
||||||
}
|
|
||||||
pthread_mutex_lock(&log_mutex);
|
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, tmpbuf, s, NULL);
|
dobuf(param, tmpbuf, s, NULL);
|
||||||
@@ -624,10 +639,6 @@ void logstdout(struct clientparam * param, const unsigned char *s) {
|
|||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
void logsyslog(struct clientparam * param, const unsigned char *s) {
|
void logsyslog(struct clientparam * param, const unsigned char *s) {
|
||||||
|
|
||||||
if(!logmutexinit){
|
|
||||||
pthread_mutex_init(&log_mutex, NULL);
|
|
||||||
logmutexinit = 1;
|
|
||||||
}
|
|
||||||
pthread_mutex_lock(&log_mutex);
|
pthread_mutex_lock(&log_mutex);
|
||||||
dobuf(param, tmpbuf, s, NULL);
|
dobuf(param, tmpbuf, s, NULL);
|
||||||
if(!param->nolog)syslog(LOG_INFO, "%s", tmpbuf);
|
if(!param->nolog)syslog(LOG_INFO, "%s", tmpbuf);
|
||||||
@@ -636,14 +647,16 @@ void logsyslog(struct clientparam * param, const unsigned char *s) {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
int doconnect(struct clientparam * param){
|
int doconnect(struct clientparam * param){
|
||||||
SASIZETYPE size = sizeof(param->sinsr);
|
SASIZETYPE size;
|
||||||
|
|
||||||
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 (*SAFAMILY(¶m->sincl) == *SAFAMILY(¶m->req) && !memcmp(SAADDR(¶m->sincl), SAADDR(¶m->req), SAADDRLEN(¶m->req)) &&
|
||||||
|
*SAPORT(¶m->sincl) == *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){
|
||||||
|
size = sizeof(param->sinsr);
|
||||||
if(so._getpeername(param->remsock, (struct sockaddr *)¶m->sinsr, &size)==-1) {return (15);}
|
if(so._getpeername(param->remsock, (struct sockaddr *)¶m->sinsr, &size)==-1) {return (15);}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -658,14 +671,14 @@ int doconnect(struct clientparam * param){
|
|||||||
}
|
}
|
||||||
if(!*SAPORT(¶m->sinsr))*SAPORT(¶m->sinsr) = *SAPORT(¶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);}
|
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, (char *)&lg, sizeof(lg));
|
||||||
#ifdef REUSE
|
#ifdef REUSE
|
||||||
{
|
{
|
||||||
int opt;
|
int opt;
|
||||||
|
|
||||||
#ifdef SO_REUSEADDR
|
#ifdef SO_REUSEADDR
|
||||||
opt = 1;
|
opt = 1;
|
||||||
so._setsockopt(param->remsock, SOL_SOCKET, SO_REUSEADDR, (unsigned char *)&opt, sizeof(int));
|
so._setsockopt(param->remsock, SOL_SOCKET, SO_REUSEADDR, (char *)&opt, sizeof(int));
|
||||||
#endif
|
#endif
|
||||||
#ifdef SO_REUSEPORT
|
#ifdef SO_REUSEPORT
|
||||||
opt = 1;
|
opt = 1;
|
||||||
@@ -674,11 +687,13 @@ int doconnect(struct clientparam * param){
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
if(SAISNULL(¶m->sinsl)){
|
||||||
#ifndef NOIPV6
|
#ifndef NOIPV6
|
||||||
if(*SAFAMILY(¶m->sinsr) == AF_INET6) memcpy(¶m->sinsl, ¶m->srv->extsa6, sizeof(param->srv->extsa6));
|
if(*SAFAMILY(¶m->sinsr) == AF_INET6) param->sinsl = param->srv->extsa6;
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
memcpy(¶m->sinsl, ¶m->srv->extsa, sizeof(param->srv->extsa));
|
param->sinsl = param->srv->extsa;
|
||||||
|
}
|
||||||
*SAPORT(¶m->sinsl) = 0;
|
*SAPORT(¶m->sinsl) = 0;
|
||||||
if(so._bind(param->remsock, (struct sockaddr*)¶m->sinsl, SASIZE(¶m->sinsl))==-1) {
|
if(so._bind(param->remsock, (struct sockaddr*)¶m->sinsl, SASIZE(¶m->sinsl))==-1) {
|
||||||
return 12;
|
return 12;
|
||||||
@@ -697,8 +712,8 @@ int doconnect(struct clientparam * param){
|
|||||||
#else
|
#else
|
||||||
fcntl(param->remsock,F_SETFL,O_NONBLOCK);
|
fcntl(param->remsock,F_SETFL,O_NONBLOCK);
|
||||||
#endif
|
#endif
|
||||||
size = sizeof(param->sinsl);
|
|
||||||
}
|
}
|
||||||
|
size = sizeof(param->sinsl);
|
||||||
if(so._getsockname(param->remsock, (struct sockaddr *)¶m->sinsl, &size)==-1) {return (15);}
|
if(so._getsockname(param->remsock, (struct sockaddr *)¶m->sinsl, &size)==-1) {return (15);}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
@@ -828,11 +843,11 @@ unsigned long getip46(int family, unsigned char *name, struct sockaddr *sa){
|
|||||||
if(!name[i]){
|
if(!name[i]){
|
||||||
if(ndots == 3 && ncols == 0 && nhex == 0){
|
if(ndots == 3 && ncols == 0 && nhex == 0){
|
||||||
*SAFAMILY(sa)=(family == 6)?AF_INET6 : AF_INET;
|
*SAFAMILY(sa)=(family == 6)?AF_INET6 : AF_INET;
|
||||||
return inet_pton(*SAFAMILY(sa), name, SAADDR(sa))? *SAFAMILY(sa) : 0;
|
return inet_pton(*SAFAMILY(sa), (char *)name, SAADDR(sa))? *SAFAMILY(sa) : 0;
|
||||||
}
|
}
|
||||||
if(ncols >= 2) {
|
if(ncols >= 2) {
|
||||||
*SAFAMILY(sa)=AF_INET6;
|
*SAFAMILY(sa)=AF_INET6;
|
||||||
return inet_pton(AF_INET6, name, SAADDR(sa))?(family==4? 0:AF_INET6) : 0;
|
return inet_pton(AF_INET6, (char *)name, SAADDR(sa))?(family==4? 0:AF_INET6) : 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if((tmpresolv = resolvfunc)){
|
if((tmpresolv = resolvfunc)){
|
||||||
@@ -847,10 +862,10 @@ unsigned long getip46(int family, unsigned char *name, struct sockaddr *sa){
|
|||||||
}
|
}
|
||||||
memset(&hint, 0, sizeof(hint));
|
memset(&hint, 0, sizeof(hint));
|
||||||
hint.ai_family = (family == 6 || family == 64)?AF_INET6:AF_INET;
|
hint.ai_family = (family == 6 || family == 64)?AF_INET6:AF_INET;
|
||||||
if (getaddrinfo(name, NULL, &hint, &ai)) {
|
if (getaddrinfo((char *)name, NULL, &hint, &ai)) {
|
||||||
if(family == 64 || family == 46){
|
if(family == 64 || family == 46){
|
||||||
hint.ai_family = (family == 64)?AF_INET:AF_INET6;
|
hint.ai_family = (family == 64)?AF_INET:AF_INET6;
|
||||||
if (getaddrinfo(name, NULL, &hint, &ai)) return 0;
|
if (getaddrinfo((char *)name, NULL, &hint, &ai)) return 0;
|
||||||
}
|
}
|
||||||
else return 0;
|
else return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
+62
-32
@@ -32,6 +32,7 @@ struct proxydef childdef = {NULL, 0, 0, S_NOSERVICE, ""};
|
|||||||
|
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
char *chrootp = NULL;
|
char *chrootp = NULL;
|
||||||
|
static pthread_attr_t pa;
|
||||||
#endif
|
#endif
|
||||||
char * curconf = NULL;
|
char * curconf = NULL;
|
||||||
|
|
||||||
@@ -142,16 +143,17 @@ int start_proxy_thread(struct child * chp){
|
|||||||
conf.threadinit = 1;
|
conf.threadinit = 1;
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#ifndef _WINCE
|
#ifndef _WINCE
|
||||||
h = (HANDLE)_beginthreadex((LPSECURITY_ATTRIBUTES )NULL, 16384, startsrv, (void *) chp, (DWORD)0, &thread);
|
h = (HANDLE)_beginthreadex((LPSECURITY_ATTRIBUTES )NULL, 16384+conf.stacksize, (void *)startsrv, (void *) chp, (DWORD)0, &thread);
|
||||||
#else
|
#else
|
||||||
h = (HANDLE)CreateThread((LPSECURITY_ATTRIBUTES )NULL, 16384, startsrv, (void *) chp, (DWORD)0, &thread);
|
h = (HANDLE)CreateThread((LPSECURITY_ATTRIBUTES )NULL, 16384+conf.stacksize, (void *)startsrv, (void *) chp, (DWORD)0, &thread);
|
||||||
#endif
|
#endif
|
||||||
if(h)CloseHandle(h);
|
if(h)CloseHandle(h);
|
||||||
#else
|
#else
|
||||||
pthread_attr_init(&pa);
|
pthread_attr_init(&pa);
|
||||||
pthread_attr_setstacksize(&pa,PTHREAD_STACK_MIN + 16384);
|
pthread_attr_setstacksize(&pa,PTHREAD_STACK_MIN + (16384+conf.stacksize));
|
||||||
pthread_attr_setdetachstate(&pa,PTHREAD_CREATE_DETACHED);
|
pthread_attr_setdetachstate(&pa,PTHREAD_CREATE_DETACHED);
|
||||||
pthread_create(&thread, &pa, startsrv, (void *)chp);
|
pthread_create(&thread, &pa, startsrv, (void *)chp);
|
||||||
|
pthread_attr_destroy(&pa);
|
||||||
#endif
|
#endif
|
||||||
while(conf.threadinit)usleep(SLEEPTIME);
|
while(conf.threadinit)usleep(SLEEPTIME);
|
||||||
if(haveerror) {
|
if(haveerror) {
|
||||||
@@ -271,17 +273,19 @@ static int h_external(int argc, unsigned char ** argv){
|
|||||||
int res;
|
int res;
|
||||||
#ifndef NOIPV6
|
#ifndef NOIPV6
|
||||||
struct sockaddr_in6 sa6;
|
struct sockaddr_in6 sa6;
|
||||||
|
memset(&sa6, 0, sizeof(sa6));
|
||||||
res = getip46(46, argv[1], (struct sockaddr *)&sa6);
|
res = getip46(46, argv[1], (struct sockaddr *)&sa6);
|
||||||
if(!res) return 1;
|
if(!res) return 1;
|
||||||
memcpy((*SAFAMILY(&sa6)==AF_INET)?(void *)&conf.extsa:(void *)&conf.extsa6, &sa6, SASIZE(&sa6));
|
if (*SAFAMILY(&sa6)==AF_INET) conf.extsa = sa6;
|
||||||
|
else conf.extsa6 = sa6;
|
||||||
#else
|
#else
|
||||||
res = getip46(46, argv[1], (struct sockaddr *)&conf.extsa);
|
res = getip46(46, argv[1], (struct sockaddr *)&conf.extsa);
|
||||||
if(!res) return 1;
|
|
||||||
#endif
|
#endif
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int h_log(int argc, unsigned char ** argv){
|
static int h_log(int argc, unsigned char ** argv){
|
||||||
|
unsigned char tmpbuf[8192];
|
||||||
conf.logfunc = logstdout;
|
conf.logfunc = logstdout;
|
||||||
if(conf.logtarget){
|
if(conf.logtarget){
|
||||||
myfree(conf.logtarget);
|
myfree(conf.logtarget);
|
||||||
@@ -314,14 +318,12 @@ static int h_log(int argc, unsigned char ** argv){
|
|||||||
conf.logname = (unsigned char *)mystrdup((char *)argv[1]);
|
conf.logname = (unsigned char *)mystrdup((char *)argv[1]);
|
||||||
fp = fopen((char *)dologname (tmpbuf, conf.logname, NULL, conf.logtype, conf.logtime), "a");
|
fp = fopen((char *)dologname (tmpbuf, conf.logname, NULL, conf.logtype, conf.logtime), "a");
|
||||||
if(!fp){
|
if(!fp){
|
||||||
perror("fopen()");
|
perror((char *)tmpbuf);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
pthread_mutex_lock(&log_mutex);
|
|
||||||
if(conf.stdlog)fclose(conf.stdlog);
|
if(conf.stdlog)fclose(conf.stdlog);
|
||||||
conf.stdlog = fp;
|
conf.stdlog = fp;
|
||||||
pthread_mutex_unlock(&log_mutex);
|
|
||||||
#ifdef _WINCE
|
#ifdef _WINCE
|
||||||
freopen(tmpbuf, "w", stdout);
|
freopen(tmpbuf, "w", stdout);
|
||||||
freopen(tmpbuf, "w", stderr);
|
freopen(tmpbuf, "w", stderr);
|
||||||
@@ -332,6 +334,22 @@ static int h_log(int argc, unsigned char ** argv){
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int h_stacksize(int argc, unsigned char **argv){
|
||||||
|
conf.stacksize = atoi((char *)argv[1]);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int h_force(int argc, unsigned char **argv){
|
||||||
|
conf.noforce = 0;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int h_noforce(int argc, unsigned char **argv){
|
||||||
|
conf.noforce = 1;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static int h_service(int argc, unsigned char **argv){
|
static int h_service(int argc, unsigned char **argv){
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -387,17 +405,22 @@ static int h_counter(int argc, unsigned char **argv){
|
|||||||
fprintf(stderr, "Not a counter file %s, line %d\n", argv[1], linenum);
|
fprintf(stderr, "Not a counter file %s, line %d\n", argv[1], linenum);
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
#ifdef _MSC_VER
|
|
||||||
#ifdef _TIME64_T_DEFINED
|
#ifdef _TIME64_T_DEFINED
|
||||||
#ifndef _MAX__TIME64_T
|
#ifdef _MAX__TIME64_T
|
||||||
#define _MAX__TIME64_T 0x793406fffi64
|
#define MAX_COUNTER_TIME (_MAX__TIME64_T)
|
||||||
|
#elif defined (MAX__TIME64_T)
|
||||||
|
#define MAX_COUNTER_TIME (MAX__TIME64_T)
|
||||||
|
#else
|
||||||
|
#define MAX_COUNTER_TIME (0x793406fff)
|
||||||
#endif
|
#endif
|
||||||
|
#else
|
||||||
|
#define MAX_COUNTER_TIME ((sizeof(time_t)>4)?(time_t)0x793406fff:(time_t)0x7fffffff)
|
||||||
#endif
|
#endif
|
||||||
if(ch1.updated >= _MAX__TIME64_T){
|
|
||||||
|
if(ch1.updated < 0 || ch1.updated >= MAX_COUNTER_TIME){
|
||||||
fprintf(stderr, "Invalid or corrupted counter file %s. Use countersutil utility to convert from older version\n", argv[1]);
|
fprintf(stderr, "Invalid or corrupted counter file %s. Use countersutil utility to convert from older version\n", argv[1]);
|
||||||
return 3;
|
return 3;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
cheader.updated = ch1.updated;
|
cheader.updated = ch1.updated;
|
||||||
}
|
}
|
||||||
if(argc >=4) {
|
if(argc >=4) {
|
||||||
@@ -540,8 +563,8 @@ static int h_nserver(int argc, unsigned char **argv){
|
|||||||
if(numservers < MAXNSERVERS) {
|
if(numservers < MAXNSERVERS) {
|
||||||
if((str = strchr((char *)argv[1], '/')))
|
if((str = strchr((char *)argv[1], '/')))
|
||||||
*str = 0;
|
*str = 0;
|
||||||
if(!getip46(46, argv[1], (struct sockaddr *)&nservers[numservers].addr)) return 1;
|
|
||||||
*SAPORT(&nservers[numservers].addr) = htons(53);
|
*SAPORT(&nservers[numservers].addr) = htons(53);
|
||||||
|
if(parsehost(46, argv[1], (struct sockaddr *)&nservers[numservers].addr)) return 1;
|
||||||
if(str) {
|
if(str) {
|
||||||
nservers[numservers].usetcp = strstr(str + 1, "tcp")? 1:0;
|
nservers[numservers].usetcp = strstr(str + 1, "tcp")? 1:0;
|
||||||
*str = '/';
|
*str = '/';
|
||||||
@@ -558,7 +581,7 @@ static int h_authnserver(int argc, unsigned char **argv){
|
|||||||
|
|
||||||
if((str = strchr((char *)argv[1], '/')))
|
if((str = strchr((char *)argv[1], '/')))
|
||||||
*str = 0;
|
*str = 0;
|
||||||
if(!getip46(46, argv[1], (struct sockaddr *)&authnserver.addr)) return 1;
|
if(parsehost(46, argv[1], (struct sockaddr *)&authnserver.addr)) return 1;
|
||||||
*SAPORT(&authnserver.addr) = htons(53);
|
*SAPORT(&authnserver.addr) = htons(53);
|
||||||
if(str) {
|
if(str) {
|
||||||
authnserver.usetcp = strstr(str + 1, "tcp")? 1:0;
|
authnserver.usetcp = strstr(str + 1, "tcp")? 1:0;
|
||||||
@@ -704,7 +727,8 @@ static int h_parent(int argc, unsigned char **argv){
|
|||||||
else if(!strcmp((char *)argv[2], "ftp"))chains->type = R_FTP;
|
else if(!strcmp((char *)argv[2], "ftp"))chains->type = R_FTP;
|
||||||
else if(!strcmp((char *)argv[2], "admin"))chains->type = R_ADMIN;
|
else if(!strcmp((char *)argv[2], "admin"))chains->type = R_ADMIN;
|
||||||
else if(!strcmp((char *)argv[2], "icq"))chains->type = R_ICQ;
|
else if(!strcmp((char *)argv[2], "icq"))chains->type = R_ICQ;
|
||||||
else if(!strcmp((char *)argv[2], "msn"))chains->type = R_MSN;
|
else if(!strcmp((char *)argv[2], "extip"))chains->type = R_EXTIP;
|
||||||
|
else if(!strcmp((char *)argv[2], "smtp"))chains->type = R_SMTP;
|
||||||
else {
|
else {
|
||||||
fprintf(stderr, "Chaining error: bad chain type (%s)\n", argv[2]);
|
fprintf(stderr, "Chaining error: bad chain type (%s)\n", argv[2]);
|
||||||
return(4);
|
return(4);
|
||||||
@@ -726,7 +750,7 @@ static int h_nolog(int argc, unsigned char **argv){
|
|||||||
return(1);
|
return(1);
|
||||||
}
|
}
|
||||||
while(acl->next) acl = acl->next;
|
while(acl->next) acl = acl->next;
|
||||||
if(!strcmp(argv[0],"nolog")) acl->nolog = 1;
|
if(!strcmp((char *)argv[0],"nolog")) acl->nolog = 1;
|
||||||
else acl->weight = atoi((char*)argv[1]);
|
else acl->weight = atoi((char*)argv[1]);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -739,14 +763,14 @@ int scanipl(unsigned char *arg, struct iplist *dst){
|
|||||||
#endif
|
#endif
|
||||||
char * slash, *dash;
|
char * slash, *dash;
|
||||||
int masklen, addrlen;
|
int masklen, addrlen;
|
||||||
if((slash = strchr(arg, '/'))) *slash = 0;
|
if((slash = strchr((char *)arg, '/'))) *slash = 0;
|
||||||
if((dash = strchr(arg,'-'))) *dash = 0;
|
if((dash = strchr((char *)arg,'-'))) *dash = 0;
|
||||||
|
|
||||||
if(!getip46(46, arg, (struct sockaddr *)&sa)) return 1;
|
if(!getip46(46, arg, (struct sockaddr *)&sa)) return 1;
|
||||||
memcpy(&dst->ip_from, SAADDR(&sa), SAADDRLEN(&sa));
|
memcpy(&dst->ip_from, SAADDR(&sa), SAADDRLEN(&sa));
|
||||||
dst->family = *SAFAMILY(&sa);
|
dst->family = *SAFAMILY(&sa);
|
||||||
if(dash){
|
if(dash){
|
||||||
if(!getip46(46, dash+1, (struct sockaddr *)&sa)) return 2;
|
if(!getip46(46, (unsigned char *)dash+1, (struct sockaddr *)&sa)) return 2;
|
||||||
memcpy(&dst->ip_to, SAADDR(&sa), SAADDRLEN(&sa));
|
memcpy(&dst->ip_to, SAADDR(&sa), SAADDRLEN(&sa));
|
||||||
if(*SAFAMILY(&sa) != dst->family || memcmp(&dst->ip_to, &dst->ip_from, SAADDRLEN(&sa)) < 0) return 3;
|
if(*SAFAMILY(&sa) != dst->family || memcmp(&dst->ip_to, &dst->ip_from, SAADDRLEN(&sa)) < 0) return 3;
|
||||||
return 0;
|
return 0;
|
||||||
@@ -1190,12 +1214,10 @@ static int h_ace(int argc, unsigned char **argv){
|
|||||||
tl->traf64 = crecord.traf64;
|
tl->traf64 = crecord.traf64;
|
||||||
tl->cleared = crecord.cleared;
|
tl->cleared = crecord.cleared;
|
||||||
tl->updated = crecord.updated;
|
tl->updated = crecord.updated;
|
||||||
#ifdef _MAX__TIME64_T
|
if(tl->cleared < 0 || tl->cleared >= MAX_COUNTER_TIME || tl->updated < 0 || tl->updated >= MAX_COUNTER_TIME){
|
||||||
if(tl->cleared >= _MAX__TIME64_T || tl->updated >= _MAX__TIME64_T){
|
fprintf(stderr, "Invalid, incompatible or corrupted counter file.\n");
|
||||||
fprintf(stderr, "Invalid or corrupted counter file. Use countersutil utility to convert from older version\n");
|
|
||||||
return(6);
|
return(6);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pthread_mutex_lock(&tc_mutex);
|
pthread_mutex_lock(&tc_mutex);
|
||||||
@@ -1253,7 +1275,7 @@ static int h_plugin(int argc, unsigned char **argv){
|
|||||||
#ifdef _WINCE
|
#ifdef _WINCE
|
||||||
hi = LoadLibraryW((LPCWSTR)CEToUnicode(argv[1]));
|
hi = LoadLibraryW((LPCWSTR)CEToUnicode(argv[1]));
|
||||||
#else
|
#else
|
||||||
hi = LoadLibrary(argv[1]);
|
hi = LoadLibrary((char *)argv[1]);
|
||||||
#endif
|
#endif
|
||||||
if(!hi) {
|
if(!hi) {
|
||||||
fprintf(stderr, "Failed to load %s, code %d\n", argv[1], (int)GetLastError());
|
fprintf(stderr, "Failed to load %s, code %d\n", argv[1], (int)GetLastError());
|
||||||
@@ -1262,7 +1284,7 @@ static int h_plugin(int argc, unsigned char **argv){
|
|||||||
#ifdef _WINCE
|
#ifdef _WINCE
|
||||||
fp = GetProcAddressW(hi, (LPCWSTR)CEToUnicode(argv[2]));
|
fp = GetProcAddressW(hi, (LPCWSTR)CEToUnicode(argv[2]));
|
||||||
#else
|
#else
|
||||||
fp = GetProcAddress(hi, argv[2]);
|
fp = GetProcAddress(hi, (char *)argv[2]);
|
||||||
#endif
|
#endif
|
||||||
if(!fp) {
|
if(!fp) {
|
||||||
printf("%s not found in %s, code: %d\n", argv[2], argv[1], (int)GetLastError());
|
printf("%s not found in %s, code: %d\n", argv[2], argv[1], (int)GetLastError());
|
||||||
@@ -1284,7 +1306,7 @@ static int h_plugin(int argc, unsigned char **argv){
|
|||||||
static int h_setuid(int argc, unsigned char **argv){
|
static int h_setuid(int argc, unsigned char **argv){
|
||||||
int res;
|
int res;
|
||||||
res = atoi((char *)argv[1]);
|
res = atoi((char *)argv[1]);
|
||||||
if(!res || setuid(res)) {
|
if(!res || setreuid(res,res)) {
|
||||||
fprintf(stderr, "Unable to set uid %d", res);
|
fprintf(stderr, "Unable to set uid %d", res);
|
||||||
return(1);
|
return(1);
|
||||||
}
|
}
|
||||||
@@ -1295,7 +1317,7 @@ static int h_setgid(int argc, unsigned char **argv){
|
|||||||
int res;
|
int res;
|
||||||
|
|
||||||
res = atoi((char *)argv[1]);
|
res = atoi((char *)argv[1]);
|
||||||
if(!res || setgid(res)) {
|
if(!res || setregid(res,res)) {
|
||||||
fprintf(stderr, "Unable to set gid %d", res);
|
fprintf(stderr, "Unable to set gid %d", res);
|
||||||
return(1);
|
return(1);
|
||||||
}
|
}
|
||||||
@@ -1389,6 +1411,9 @@ struct commands commandhandlers[]={
|
|||||||
{commandhandlers+55, "msnpr", h_proxy, 4, 0},
|
{commandhandlers+55, "msnpr", h_proxy, 4, 0},
|
||||||
{commandhandlers+56, "delimchar",h_delimchar, 2, 2},
|
{commandhandlers+56, "delimchar",h_delimchar, 2, 2},
|
||||||
{commandhandlers+57, "authnserver", h_authnserver, 2, 2},
|
{commandhandlers+57, "authnserver", h_authnserver, 2, 2},
|
||||||
|
{commandhandlers+58, "stacksize", h_stacksize, 2, 2},
|
||||||
|
{commandhandlers+59, "force", h_force, 1, 1},
|
||||||
|
{commandhandlers+60, "noforce", h_noforce, 1, 1},
|
||||||
{specificcommands, "", h_noop, 1, 0}
|
{specificcommands, "", h_noop, 1, 0}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -1400,7 +1425,6 @@ int parsestr (unsigned char *str, unsigned char **argm, int nitems, unsigned cha
|
|||||||
unsigned char * incbegin = 0;
|
unsigned char * incbegin = 0;
|
||||||
int fd;
|
int fd;
|
||||||
int res, len;
|
int res, len;
|
||||||
int i = 1;
|
|
||||||
unsigned char *str1;
|
unsigned char *str1;
|
||||||
|
|
||||||
for(;;str++){
|
for(;;str++){
|
||||||
@@ -1419,7 +1443,14 @@ int parsestr (unsigned char *str, unsigned char **argm, int nitems, unsigned cha
|
|||||||
argm[argc] = 0;
|
argm[argc] = 0;
|
||||||
return argc;
|
return argc;
|
||||||
case '$':
|
case '$':
|
||||||
if(!comment && !included){
|
if(comment){
|
||||||
|
if(space){
|
||||||
|
argm[argc++] = str;
|
||||||
|
if(argc >= nitems) return argc;
|
||||||
|
space = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(!included){
|
||||||
incbegin = str;
|
incbegin = str;
|
||||||
*str = 0;
|
*str = 0;
|
||||||
}
|
}
|
||||||
@@ -1431,7 +1462,6 @@ int parsestr (unsigned char *str, unsigned char **argm, int nitems, unsigned cha
|
|||||||
if(!comment){
|
if(!comment){
|
||||||
*str = 0;
|
*str = 0;
|
||||||
space = 1;
|
space = 1;
|
||||||
i = 0;
|
|
||||||
if(incbegin){
|
if(incbegin){
|
||||||
argc--;
|
argc--;
|
||||||
if((fd = open((char *)incbegin+1, O_RDONLY)) <= 0){
|
if((fd = open((char *)incbegin+1, O_RDONLY)) <= 0){
|
||||||
@@ -1469,7 +1499,6 @@ int parsestr (unsigned char *str, unsigned char **argm, int nitems, unsigned cha
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
i++;
|
|
||||||
if(space) {
|
if(space) {
|
||||||
if(comment && *str == '\"' && str[1] != '\"'){
|
if(comment && *str == '\"' && str[1] != '\"'){
|
||||||
str++;
|
str++;
|
||||||
@@ -1676,6 +1705,7 @@ int reload (void){
|
|||||||
fp = confopen();
|
fp = confopen();
|
||||||
if(fp){
|
if(fp){
|
||||||
error = readconfig(fp);
|
error = readconfig(fp);
|
||||||
|
conf.version++;
|
||||||
if(error) {
|
if(error) {
|
||||||
freeconf(&conf);
|
freeconf(&conf);
|
||||||
}
|
}
|
||||||
|
|||||||
+23
-19
@@ -61,20 +61,22 @@ static void pr_ip(struct node *node, CBFUNC cbf, void*cb){
|
|||||||
if(node->value)(*cbf)(cb, buf, myinet_ntop(AF_INET, node -> value, buf, 4));
|
if(node->value)(*cbf)(cb, buf, myinet_ntop(AF_INET, node -> value, buf, 4));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef NOIPV6
|
||||||
static void pr_ip6(struct node *node, CBFUNC cbf, void*cb){
|
static void pr_ip6(struct node *node, CBFUNC cbf, void*cb){
|
||||||
char buf[64];
|
char buf[64];
|
||||||
if(node->value)(*cbf)(cb, buf, myinet_ntop(AF_INET6, node -> value, buf, 16));
|
if(node->value)(*cbf)(cb, buf, myinet_ntop(AF_INET6, node -> value, buf, 16));
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static void pr_sa(struct node *node, CBFUNC cbf, void*cb){
|
static void pr_sa(struct node *node, CBFUNC cbf, void*cb){
|
||||||
#ifdef NOIPV6
|
#ifdef NOIPV6
|
||||||
if(node->value)return pr_ip(node, cbf, cb);
|
if(node->value)pr_ip(node, cbf, cb);
|
||||||
#else
|
#else
|
||||||
char buf[64];
|
char buf[64];
|
||||||
buf[0] = '[';
|
buf[0] = '[';
|
||||||
buf[1] = 0;
|
buf[1] = 0;
|
||||||
inet_ntop(*SAFAMILY(node->value), node->value, buf+1, sizeof(buf)-10);
|
inet_ntop(*SAFAMILY(node->value), SAADDR(node->value), buf+1, sizeof(buf)-10);
|
||||||
sprintf(buf + strlen(buf), "]:hu", (unsigned short)*SAPORT(node->value));
|
sprintf(buf + strlen(buf), "]:%hu", (unsigned short)*SAPORT(node->value));
|
||||||
if(node->value)(*cbf)(cb, buf, strlen(buf));
|
if(node->value)(*cbf)(cb, buf, strlen(buf));
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@@ -741,21 +743,23 @@ 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, "intsa", ef_server_intsa, TYPE_SA, "ip address of internal interface"},
|
{prop_server + 5, "auth", ef_server_auth, TYPE_STRING, "service authentication type"},
|
||||||
{prop_server + 6, "extsa", ef_server_extsa, TYPE_SA, "ip address of external interface"},
|
{prop_server + 6, "acl", ef_server_acl, TYPE_ACE, "access control list"},
|
||||||
{prop_server + 7, "auth", ef_server_auth, TYPE_STRING, "service authentication type"},
|
{prop_server + 7, "singlepacket", ef_server_singlepacket, TYPE_INTEGER, "is single packet redirection"},
|
||||||
{prop_server + 8, "acl", ef_server_acl, TYPE_ACE, "access control list"},
|
{prop_server + 8, "usentlm", ef_server_usentlm, TYPE_INTEGER, "allow NTLM authentication"},
|
||||||
{prop_server + 9, "singlepacket", ef_server_singlepacket, TYPE_INTEGER, "is single packet redirection"},
|
{prop_server + 9, "log", ef_server_log, TYPE_STRING, "type of logging"},
|
||||||
{prop_server + 10, "usentlm", ef_server_usentlm, TYPE_INTEGER, "allow NTLM authentication"},
|
{prop_server + 10, "logtarget", ef_server_logtarget, TYPE_STRING, "log target options"},
|
||||||
{prop_server + 11, "log", ef_server_log, TYPE_STRING, "type of logging"},
|
{prop_server + 11, "logformat", ef_server_logformat, TYPE_STRING, "logging format string"},
|
||||||
{prop_server + 12, "logtarget", ef_server_logtarget, TYPE_STRING, "log target options"},
|
{prop_server + 12, "nonprintable", ef_server_nonprintable, TYPE_STRING, "non printable characters"},
|
||||||
{prop_server + 13, "logformat", ef_server_logformat, TYPE_STRING, "logging format string"},
|
{prop_server + 13, "replacement", ef_server_replacement, TYPE_CHAR, "replacement character"},
|
||||||
{prop_server + 14, "nonprintable", ef_server_nonprintable, TYPE_STRING, "non printable characters"},
|
{prop_server + 14, "childcount", ef_server_childcount, TYPE_INTEGER, "number of servers connected"},
|
||||||
{prop_server + 15, "replacement", ef_server_replacement, TYPE_CHAR, "replacement character"},
|
{prop_server + 15, "intsa", ef_server_intsa, TYPE_SA, "ip address of internal interface"},
|
||||||
{prop_server + 16, "childcount", ef_server_childcount, TYPE_INTEGER, "number of servers connected"},
|
{prop_server + 16, "extsa", ef_server_extsa, TYPE_SA, "ip address of external interface"},
|
||||||
{prop_server + 17, "child", ef_server_child, TYPE_CLIENT, "connected clients"},
|
|
||||||
#ifndef NOIPV6
|
#ifndef NOIPV6
|
||||||
{prop_server + 18, "extsa6", ef_server_extsa6, TYPE_SA, "ipv6 address of external interface"},
|
{prop_server + 17, "extsa6", ef_server_extsa6, TYPE_SA, "ipv6 address of external interface"},
|
||||||
|
{prop_server + 18, "child", ef_server_child, TYPE_CLIENT, "connected clients"},
|
||||||
|
#else
|
||||||
|
{prop_server + 17, "child", ef_server_child, TYPE_CLIENT, "connected clients"},
|
||||||
#endif
|
#endif
|
||||||
{NULL, "next", ef_server_next, TYPE_SERVER, "next"}
|
{NULL, "next", ef_server_next, TYPE_SERVER, "next"}
|
||||||
};
|
};
|
||||||
@@ -774,8 +778,8 @@ static struct property prop_client[] = {
|
|||||||
{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, "clisa", ef_client_clisa, TYPE_SA, "client sa"},
|
{prop_client + 12, "clisa", ef_client_clisa, TYPE_SA, "client sa"},
|
||||||
{prop_client + 13, "srvsa", ef_client_srvsa, TYPE_IP, "target server sa"},
|
{prop_client + 13, "srvsa", ef_client_srvsa, TYPE_SA, "target server sa"},
|
||||||
{prop_client + 14, "reqsa", ef_client_reqsa, TYPE_IP, "requested server sa"},
|
{prop_client + 14, "reqsa", ef_client_reqsa, TYPE_SA, "requested server sa"},
|
||||||
{prop_client + 15, "bytesin", ef_client_bytesin64, TYPE_UNSIGNED64, "bytes from server to client"},
|
{prop_client + 15, "bytesin", ef_client_bytesin64, TYPE_UNSIGNED64, "bytes from server to client"},
|
||||||
{prop_client + 16, "bytesout", ef_client_bytesout64, TYPE_UNSIGNED64, "bytes from client to server"},
|
{prop_client + 16, "bytesout", ef_client_bytesout64, TYPE_UNSIGNED64, "bytes from client to server"},
|
||||||
{prop_client + 17, "maxtrafin", ef_client_maxtrafin64, TYPE_UNSIGNED64, "maximum traffic allowed for download"},
|
{prop_client + 17, "maxtrafin", ef_client_maxtrafin64, TYPE_UNSIGNED64, "maximum traffic allowed for download"},
|
||||||
|
|||||||
+3
-2
@@ -6,6 +6,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "proxy.h"
|
#include "proxy.h"
|
||||||
|
pthread_mutex_t log_mutex;
|
||||||
|
|
||||||
|
|
||||||
int sockgetchar(SOCKET sock, int timeosec, int timeousec){
|
int sockgetchar(SOCKET sock, int timeosec, int timeousec){
|
||||||
@@ -18,7 +19,7 @@ int sockgetchar(SOCKET sock, int timeosec, int timeousec){
|
|||||||
FD_ZERO(&fds);
|
FD_ZERO(&fds);
|
||||||
FD_SET(sock, &fds);
|
FD_SET(sock, &fds);
|
||||||
if (select (((int)sock)+1, &fds, NULL, NULL, &tv)!=1) return EOF;
|
if (select (((int)sock)+1, &fds, NULL, NULL, &tv)!=1) return EOF;
|
||||||
if (recv(sock, &buf, 1, 0)!=1) return EOF;
|
if (recv(sock, (char *)&buf, 1, 0)!=1) return EOF;
|
||||||
return((int)buf);
|
return((int)buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -94,7 +95,7 @@ int main(int argc, char *argv[]){
|
|||||||
fprintf(stderr, "Unable to connect: %s\n", host);
|
fprintf(stderr, "Unable to connect: %s\n", host);
|
||||||
return 8;
|
return 8;
|
||||||
}
|
}
|
||||||
if(send(sock, buf, (int)strlen((char *)buf), 0) != (int)strlen((char *)buf)) return 9;
|
if(send(sock, (char *)buf, (int)strlen((char *)buf), 0) != (int)strlen((char *)buf)) return 9;
|
||||||
while( (i = sockgetline(sock, buf, sizeof(buf) - 1, '\n', 30)) > 2);
|
while( (i = sockgetline(sock, buf, sizeof(buf) - 1, '\n', 30)) > 2);
|
||||||
if(i<1) return 9;
|
if(i<1) return 9;
|
||||||
if(!(fp = fopen(argv[argc-1], "w"))) {
|
if(!(fp = fopen(argv[argc-1], "w"))) {
|
||||||
|
|||||||
+5
-5
@@ -39,7 +39,7 @@ void * dnsprchild(struct clientparam* param) {
|
|||||||
}
|
}
|
||||||
buf = bbuf+2;
|
buf = bbuf+2;
|
||||||
size = sizeof(param->sincr);
|
size = sizeof(param->sincr);
|
||||||
i = so._recvfrom(param->srv->srvsock, buf, BUFSIZE, 0, (struct sockaddr *)¶m->sincr, &size);
|
i = so._recvfrom(param->srv->srvsock, (char *)buf, BUFSIZE, 0, (struct sockaddr *)¶m->sincr, &size);
|
||||||
size = sizeof(param->sinsl);
|
size = sizeof(param->sinsl);
|
||||||
getsockname(param->srv->srvsock, (struct sockaddr *)¶m->sincl, &size);
|
getsockname(param->srv->srvsock, (struct sockaddr *)¶m->sincl, &size);
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
@@ -47,7 +47,7 @@ void * dnsprchild(struct clientparam* param) {
|
|||||||
RETURN(818);
|
RETURN(818);
|
||||||
}
|
}
|
||||||
ioctlsocket(param->clisock, FIONBIO, &ul);
|
ioctlsocket(param->clisock, FIONBIO, &ul);
|
||||||
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, (char *)&ul, sizeof(int))) {RETURN(820);};
|
||||||
if(so._bind(param->clisock,(struct sockaddr *)¶m->sincl,SASIZE(¶m->sincl))) {
|
if(so._bind(param->clisock,(struct sockaddr *)¶m->sincl,SASIZE(¶m->sincl))) {
|
||||||
RETURN(822);
|
RETURN(822);
|
||||||
}
|
}
|
||||||
@@ -138,7 +138,7 @@ void * dnsprchild(struct clientparam* param) {
|
|||||||
if(so._bind(param->remsock,(struct sockaddr *)¶m->sinsl,SASIZE(¶m->sinsl))) {
|
if(so._bind(param->remsock,(struct sockaddr *)¶m->sinsl,SASIZE(¶m->sinsl))) {
|
||||||
RETURN(819);
|
RETURN(819);
|
||||||
}
|
}
|
||||||
memcpy(¶m->sinsr, &nservers[0].addr, sizeof(param->sinsr));
|
param->sinsr = nservers[0].addr;
|
||||||
if(nservers[0].usetcp) {
|
if(nservers[0].usetcp) {
|
||||||
if(so._connect(param->remsock,(struct sockaddr *)¶m->sinsr,SASIZE(¶m->sinsr))) RETURN(830);
|
if(so._connect(param->remsock,(struct sockaddr *)¶m->sinsr,SASIZE(¶m->sinsr))) RETURN(830);
|
||||||
buf-=2;
|
buf-=2;
|
||||||
@@ -195,8 +195,8 @@ CLEANRET:
|
|||||||
sprintf((char *)buf, "%04x/%s/",
|
sprintf((char *)buf, "%04x/%s/",
|
||||||
(unsigned)type,
|
(unsigned)type,
|
||||||
host?host:"");
|
host?host:"");
|
||||||
if(ip && type == 0x01 || type == 0x1c){
|
if((ip && type == 0x01) || type == 0x1c){
|
||||||
myinet_ntop(type == 0x01? AF_INET:AF_INET6, addr, buf+strlen(buf), 64);
|
myinet_ntop(type == 0x01? AF_INET:AF_INET6, addr, (char *)buf+strlen((char *)buf), 64);
|
||||||
}
|
}
|
||||||
(*param->srv->logfunc)(param, buf);
|
(*param->srv->logfunc)(param, buf);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,17 +9,17 @@
|
|||||||
|
|
||||||
|
|
||||||
int ftplogin(struct clientparam *param, char *nbuf, int *innbuf) {
|
int ftplogin(struct clientparam *param, char *nbuf, int *innbuf) {
|
||||||
char tbuf[1024];
|
char tbuf[256];
|
||||||
int i;
|
int i;
|
||||||
char *buf;
|
char *buf;
|
||||||
int len;
|
int len;
|
||||||
int res;
|
int res;
|
||||||
|
|
||||||
buf = nbuf?nbuf:tbuf;
|
buf = nbuf?nbuf:tbuf;
|
||||||
len = nbuf?*innbuf:1024;
|
len = nbuf?*innbuf:sizeof(tbuf);
|
||||||
|
|
||||||
if(innbuf)*innbuf = 0;
|
if(innbuf)*innbuf = 0;
|
||||||
if(len < 48) return 707;
|
if(len < 140) return 707;
|
||||||
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] == '-')){
|
||||||
}
|
}
|
||||||
if(i < 3) return 706;
|
if(i < 3) return 706;
|
||||||
@@ -28,7 +28,7 @@ int ftplogin(struct clientparam *param, char *nbuf, int *innbuf) {
|
|||||||
*innbuf = i;
|
*innbuf = i;
|
||||||
return 702;
|
return 702;
|
||||||
}
|
}
|
||||||
sprintf(buf, "USER %.32s\r\n", param->extusername?param->extusername:(unsigned char *)"anonymous");
|
sprintf(buf, "USER %.128s\r\n", param->extusername?param->extusername:(unsigned char *)"anonymous");
|
||||||
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;
|
||||||
}
|
}
|
||||||
@@ -40,7 +40,7 @@ int ftplogin(struct clientparam *param, char *nbuf, int *innbuf) {
|
|||||||
buf[i] = 0;
|
buf[i] = 0;
|
||||||
res = atoi(buf)/100;
|
res = atoi(buf)/100;
|
||||||
if(res == 3){
|
if(res == 3){
|
||||||
sprintf(buf, "PASS %.32s\r\n",
|
sprintf(buf, "PASS %.128s\r\n",
|
||||||
param->extusername?
|
param->extusername?
|
||||||
(param->extpassword?
|
(param->extpassword?
|
||||||
param->extpassword:(unsigned char *)"")
|
param->extpassword:(unsigned char *)"")
|
||||||
@@ -174,6 +174,7 @@ SOCKET ftpdata(struct clientparam *param){
|
|||||||
SOCKET s = INVALID_SOCKET, rem;
|
SOCKET s = INVALID_SOCKET, rem;
|
||||||
unsigned long b1, b2, b3, b4;
|
unsigned long b1, b2, b3, b4;
|
||||||
unsigned short b5, b6;
|
unsigned short b5, b6;
|
||||||
|
SASIZETYPE sasize;
|
||||||
|
|
||||||
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;
|
||||||
@@ -187,16 +188,28 @@ SOCKET ftpdata(struct clientparam *param){
|
|||||||
buf[i-2] = 0;
|
buf[i-2] = 0;
|
||||||
if(!(sb = strchr(buf+4, '(')) || !(se= strchr(sb, ')'))) return INVALID_SOCKET;
|
if(!(sb = strchr(buf+4, '(')) || !(se= strchr(sb, ')'))) return INVALID_SOCKET;
|
||||||
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;
|
||||||
|
sasize = sizeof(param->sinsl);
|
||||||
|
if(so._getsockname(param->remsock, (struct sockaddr *)¶m->sinsl, &sasize)){return INVALID_SOCKET;}
|
||||||
|
sasize = sizeof(param->sinsr);
|
||||||
|
if(so._getpeername(param->remsock, (struct sockaddr *)¶m->sinsr, &sasize)){return INVALID_SOCKET;}
|
||||||
rem = param->remsock;
|
rem = param->remsock;
|
||||||
param->remsock = INVALID_SOCKET;
|
param->remsock = INVALID_SOCKET;
|
||||||
memcpy(¶m->req,¶m->sinsr,sizeof(param->req));
|
param->req = param->sinsr;
|
||||||
*SAPORT(¶m->req) = *SAPORT(¶m->sinsr) = htons((unsigned short)((b5<<8)^b6));
|
*SAPORT(¶m->req) = *SAPORT(¶m->sinsr) = htons((unsigned short)((b5<<8)^b6));
|
||||||
|
*SAPORT(¶m->sinsl) = 0;
|
||||||
i = param->operation;
|
i = param->operation;
|
||||||
param->operation = FTP_DATA;
|
param->operation = FTP_DATA;
|
||||||
|
if((param->res = (*param->srv->authfunc)(param))) {
|
||||||
|
if(param->remsock != INVALID_SOCKET) {
|
||||||
|
so._closesocket(param->remsock);
|
||||||
|
param->remsock = INVALID_SOCKET;
|
||||||
|
}
|
||||||
|
memset(¶m->sinsl, 0, sizeof(param->sinsl));
|
||||||
if((param->res = (*param->srv->authfunc)(param))) {
|
if((param->res = (*param->srv->authfunc)(param))) {
|
||||||
param->remsock = rem;
|
param->remsock = rem;
|
||||||
return INVALID_SOCKET;
|
return INVALID_SOCKET;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
param->operation = i;
|
param->operation = i;
|
||||||
s = param->remsock;
|
s = param->remsock;
|
||||||
param->remsock = rem;
|
param->remsock = rem;
|
||||||
|
|||||||
+16
-8
@@ -70,13 +70,13 @@ 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(*SAPORT(¶m->sinsr))==21)?0:':', ntohs(*SAPORT(¶m->sinsr)));
|
sprintf((char *)buf, "%.128s@%.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
|
||||||
{
|
{
|
||||||
int action, reqbufsize, reqsize;
|
int action, reqbufsize, reqsize;
|
||||||
reqbufsize = BUFSIZE;
|
reqbufsize = BUFSIZE;
|
||||||
reqsize = (int)strlen(buf) + 1;
|
reqsize = (int)strlen((char *)buf) + 1;
|
||||||
|
|
||||||
action = handlereqfilters(param, &buf, &reqbufsize, 0, &reqsize);
|
action = handlereqfilters(param, &buf, &reqbufsize, 0, &reqsize);
|
||||||
if(action == HANDLED){
|
if(action == HANDLED){
|
||||||
@@ -88,13 +88,14 @@ void * ftpprchild(struct clientparam* param) {
|
|||||||
}
|
}
|
||||||
else if (status >= 3 && (
|
else if (status >= 3 && (
|
||||||
(!strncasecmp((char *)buf, "PASV", 4) && (pasv = 1)) ||
|
(!strncasecmp((char *)buf, "PASV", 4) && (pasv = 1)) ||
|
||||||
|
(!strncasecmp((char *)buf, "EPSV", 4) && (pasv = 2)) ||
|
||||||
(!strncasecmp((char *)buf, "PORT ", 5) && !(pasv = 0))
|
(!strncasecmp((char *)buf, "PORT ", 5) && !(pasv = 0))
|
||||||
)){
|
)){
|
||||||
#ifndef WITHMAIN
|
#ifndef WITHMAIN
|
||||||
{
|
{
|
||||||
int action, reqbufsize, reqsize;
|
int action, reqbufsize, reqsize;
|
||||||
reqbufsize = BUFSIZE;
|
reqbufsize = BUFSIZE;
|
||||||
reqsize = (int)strlen(buf) + 1;
|
reqsize = (int)strlen((char *)buf) + 1;
|
||||||
|
|
||||||
action = handlehdrfilterscli(param, &buf, &reqbufsize, 0, &reqsize);
|
action = handlehdrfilterscli(param, &buf, &reqbufsize, 0, &reqsize);
|
||||||
if(action == HANDLED){
|
if(action == HANDLED){
|
||||||
@@ -125,6 +126,7 @@ void * ftpprchild(struct clientparam* param) {
|
|||||||
if(so._listen(clidatasock, 1)) {RETURN(823);}
|
if(so._listen(clidatasock, 1)) {RETURN(823);}
|
||||||
sasize = sizeof(param->sincl);
|
sasize = sizeof(param->sincl);
|
||||||
if(so._getsockname(clidatasock, (struct sockaddr *)¶m->sincl, &sasize)){RETURN(824);}
|
if(so._getsockname(clidatasock, (struct sockaddr *)¶m->sincl, &sasize)){RETURN(824);}
|
||||||
|
if(pasv == 1){
|
||||||
if(*SAFAMILY(¶m->sincl) == AF_INET)
|
if(*SAFAMILY(¶m->sincl) == AF_INET)
|
||||||
sprintf((char *)buf, "227 OK (%u,%u,%u,%u,%u,%u)\r\n",
|
sprintf((char *)buf, "227 OK (%u,%u,%u,%u,%u,%u)\r\n",
|
||||||
(unsigned)(((unsigned char *)(SAADDR(¶m->sincl)))[0]),
|
(unsigned)(((unsigned char *)(SAADDR(¶m->sincl)))[0]),
|
||||||
@@ -139,6 +141,12 @@ void * ftpprchild(struct clientparam* param) {
|
|||||||
(unsigned)(((unsigned char *)(SAPORT(¶m->sincl)))[1])
|
(unsigned)(((unsigned char *)(SAPORT(¶m->sincl)))[1])
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
sprintf((char *)buf, "229 OK (|||%u|)\r\n",
|
||||||
|
(unsigned)ntohs(*SAPORT(¶m->sincl))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
unsigned long b1, b2, b3, b4;
|
unsigned long b1, b2, b3, b4;
|
||||||
unsigned short b5, b6;
|
unsigned short b5, b6;
|
||||||
@@ -150,13 +158,13 @@ void * ftpprchild(struct clientparam* param) {
|
|||||||
clidatasock = INVALID_SOCKET;
|
clidatasock = INVALID_SOCKET;
|
||||||
RETURN(826);
|
RETURN(826);
|
||||||
}
|
}
|
||||||
sprintf(buf, "200 OK\r\n");
|
sprintf((char *)buf, "200 OK\r\n");
|
||||||
}
|
}
|
||||||
#ifndef WITHMAIN
|
#ifndef WITHMAIN
|
||||||
{
|
{
|
||||||
int action, reqbufsize, reqsize;
|
int action, reqbufsize, reqsize;
|
||||||
reqbufsize = BUFSIZE;
|
reqbufsize = BUFSIZE;
|
||||||
reqsize = (int)strlen(buf) + 1;
|
reqsize = (int)strlen((char *)buf) + 1;
|
||||||
|
|
||||||
action = handlehdrfilterssrv(param, &buf, &reqbufsize, 0, &reqsize);
|
action = handlehdrfilterssrv(param, &buf, &reqbufsize, 0, &reqsize);
|
||||||
if(action == HANDLED){
|
if(action == HANDLED){
|
||||||
@@ -184,7 +192,7 @@ void * ftpprchild(struct clientparam* param) {
|
|||||||
{
|
{
|
||||||
int action, reqbufsize, reqsize;
|
int action, reqbufsize, reqsize;
|
||||||
reqbufsize = BUFSIZE;
|
reqbufsize = BUFSIZE;
|
||||||
reqsize = (int)strlen(buf) + 1;
|
reqsize = (int)strlen((char *)buf) + 1;
|
||||||
|
|
||||||
action = handlehdrfilterscli(param, &buf, &reqbufsize, 0, &reqsize);
|
action = handlehdrfilterscli(param, &buf, &reqbufsize, 0, &reqsize);
|
||||||
if(action == HANDLED){
|
if(action == HANDLED){
|
||||||
@@ -239,8 +247,8 @@ void * ftpprchild(struct clientparam* param) {
|
|||||||
}
|
}
|
||||||
sc = param->remsock;
|
sc = param->remsock;
|
||||||
param->remsock = ss;
|
param->remsock = ss;
|
||||||
so._setsockopt(param->remsock, SOL_SOCKET, SO_LINGER, (unsigned char *)&lg, sizeof(lg));
|
so._setsockopt(param->remsock, SOL_SOCKET, SO_LINGER, (char *)&lg, sizeof(lg));
|
||||||
so._setsockopt(clidatasock, SOL_SOCKET, SO_LINGER, (unsigned char *)&lg, sizeof(lg));
|
so._setsockopt(clidatasock, SOL_SOCKET, SO_LINGER, (char *)&lg, sizeof(lg));
|
||||||
param->clisock = clidatasock;
|
param->clisock = clidatasock;
|
||||||
res = sockmap(param, conf.timeouts[CONNECTION_S]);
|
res = sockmap(param, conf.timeouts[CONNECTION_S]);
|
||||||
if(param->remsock != INVALID_SOCKET) {
|
if(param->remsock != INVALID_SOCKET) {
|
||||||
|
|||||||
+13
-13
@@ -25,20 +25,20 @@ struct flap_header {
|
|||||||
unsigned char chan;
|
unsigned char chan;
|
||||||
unsigned short seq;
|
unsigned short seq;
|
||||||
unsigned short size;
|
unsigned short size;
|
||||||
char data[0];
|
char data[1];
|
||||||
};
|
};
|
||||||
|
|
||||||
struct snack_header {
|
struct snack_header {
|
||||||
unsigned family;
|
unsigned family;
|
||||||
unsigned short flags;
|
unsigned short flags;
|
||||||
unsigned id;
|
unsigned id;
|
||||||
char data[0];
|
char data[1];
|
||||||
};
|
};
|
||||||
|
|
||||||
struct tlv_header {
|
struct tlv_header {
|
||||||
unsigned short type;
|
unsigned short type;
|
||||||
unsigned short size;
|
unsigned short size;
|
||||||
char data[0];
|
char data[1];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -128,11 +128,11 @@ static int searchcookie(struct clientparam *param, struct flap_header * flap, in
|
|||||||
icq_cookie_mutex_init = 1;
|
icq_cookie_mutex_init = 1;
|
||||||
}
|
}
|
||||||
pthread_mutex_lock(&icq_cookie_mutex);
|
pthread_mutex_lock(&icq_cookie_mutex);
|
||||||
for(ic = icq_cookies; ic; ic = ic->next)if(!strcmp(param->username, ic->id))break;
|
for(ic = icq_cookies; ic; ic = ic->next)if(!strcmp((char *)param->username, ic->id))break;
|
||||||
if(!ic){
|
if(!ic){
|
||||||
ic = myalloc(sizeof(struct icq_cookie));
|
ic = myalloc(sizeof(struct icq_cookie));
|
||||||
memset(ic, 0, sizeof(struct icq_cookie));
|
memset(ic, 0, sizeof(struct icq_cookie));
|
||||||
ic->id = mystrdup(param->username);
|
ic->id = mystrdup((char *)param->username);
|
||||||
ic->next = icq_cookies;
|
ic->next = icq_cookies;
|
||||||
icq_cookies = ic;
|
icq_cookies = ic;
|
||||||
}
|
}
|
||||||
@@ -202,10 +202,10 @@ static FILTER_ACTION icq_srv(void *fc, struct clientparam * param, unsigned char
|
|||||||
state->state = ONCHAN;
|
state->state = ONCHAN;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if(!state->leftinstate)param->srv->logfunc(param, "Warning: need resync");
|
if(!state->leftinstate)param->srv->logfunc(param, (unsigned char *)"Warning: need resync");
|
||||||
state->leftinstate++;
|
state->leftinstate++;
|
||||||
if(state->leftinstate > 65535){
|
if(state->leftinstate > 65535){
|
||||||
param->srv->logfunc(param, "Out of Sync");
|
param->srv->logfunc(param, (unsigned char *)"Out of Sync");
|
||||||
return REJECT;
|
return REJECT;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -214,7 +214,7 @@ static FILTER_ACTION icq_srv(void *fc, struct clientparam * param, unsigned char
|
|||||||
break;
|
break;
|
||||||
case ONCHAN:
|
case ONCHAN:
|
||||||
if (*start >= 10){
|
if (*start >= 10){
|
||||||
param->srv->logfunc(param, "Warning: Wrong channel");
|
param->srv->logfunc(param, (unsigned char *)"Warning: Wrong channel");
|
||||||
state->state = ONBEGIN;
|
state->state = ONBEGIN;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -234,15 +234,15 @@ static FILTER_ACTION icq_srv(void *fc, struct clientparam * param, unsigned char
|
|||||||
case ONSEQ2:
|
case ONSEQ2:
|
||||||
state->gotseq += *start;
|
state->gotseq += *start;
|
||||||
if(state->gotseq != state->srvseq){
|
if(state->gotseq != state->srvseq){
|
||||||
char smallbuf[64];
|
unsigned char smallbuf[64];
|
||||||
if(((state->gotseq < state->srvseq) || ((state->gotseq - state->srvseq) > 10 )) && (!state->resyncseq || state->gotseq != state->resyncseq)){
|
if(((state->gotseq < state->srvseq) || ((state->gotseq - state->srvseq) > 10 )) && (!state->resyncseq || state->gotseq != state->resyncseq)){
|
||||||
sprintf(smallbuf, "Warning: Wrong sequence, expected: %04hx got: %04hx", state->srvseq, state->gotseq);
|
sprintf((char *)smallbuf, "Warning: Wrong sequence, expected: %04hx got: %04hx", state->srvseq, state->gotseq);
|
||||||
param->srv->logfunc(param, smallbuf);
|
param->srv->logfunc(param, smallbuf);
|
||||||
state->state = ONBEGIN;
|
state->state = ONBEGIN;
|
||||||
state->resyncseq = state->gotseq;
|
state->resyncseq = state->gotseq;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
sprintf(smallbuf, "Warning: %hu flaps are lost on resync", state->gotseq - state->srvseq );
|
sprintf((char *)smallbuf, "Warning: %d flaps are lost on resync", state->gotseq - state->srvseq );
|
||||||
param->srv->logfunc(param, smallbuf);
|
param->srv->logfunc(param, smallbuf);
|
||||||
state->srvseq = state->gotseq;
|
state->srvseq = state->gotseq;
|
||||||
*(start-1) = (state->seq>>8);
|
*(start-1) = (state->seq>>8);
|
||||||
@@ -339,7 +339,7 @@ static int readflap(struct clientparam * param, int direction, unsigned char *bu
|
|||||||
if(flap->id != 0x2a) return 2;
|
if(flap->id != 0x2a) return 2;
|
||||||
len = ntohs(flap->size);
|
len = ntohs(flap->size);
|
||||||
if(len > buflen-6) return 3;
|
if(len > buflen-6) return 3;
|
||||||
i = sockgetlinebuf(param, direction, flap->data, len, EOF, conf.timeouts[STRING_S]);
|
i = sockgetlinebuf(param, direction, (unsigned char *)flap->data, len, EOF, conf.timeouts[STRING_S]);
|
||||||
if(len != i) return 4;
|
if(len != i) return 4;
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
@@ -418,7 +418,7 @@ void * icqprchild(struct clientparam* param) {
|
|||||||
for(ic = icq_cookies; ic; ic=ic->next){
|
for(ic = icq_cookies; ic; ic=ic->next){
|
||||||
if(ic->size && ic->size == tlv->size && !memcmp(ic->cookie, tlv->data, ntohs(tlv->size))){
|
if(ic->size && ic->size == tlv->size && !memcmp(ic->cookie, tlv->data, ntohs(tlv->size))){
|
||||||
parsehostname((char *)ic->connectstring, param, ntohs(param->srv->targetport));
|
parsehostname((char *)ic->connectstring, param, ntohs(param->srv->targetport));
|
||||||
if(!param->username && ic->id) param->username = mystrdup(ic->id);
|
if(!param->username && ic->id) param->username = (unsigned char *)mystrdup(ic->id);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -878,13 +878,13 @@ static struct commands file_commandhandlers[] = {
|
|||||||
|
|
||||||
static int file_loaded=0;
|
static int file_loaded=0;
|
||||||
|
|
||||||
|
#ifdef WATCOM
|
||||||
#ifdef _WIN32
|
#pragma aux file_plugin "*" parm caller [ ] value struct float struct routine [eax] modify [eax ecx edx]
|
||||||
__declspec(dllexport)
|
#undef PLUGINCALL
|
||||||
|
#define PLUGINCALL
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
PLUGINAPI int PLUGINCALL file_plugin (struct pluginlink * pluginlink,
|
||||||
int file_plugin (struct pluginlink * pluginlink,
|
|
||||||
int argc, char** argv){
|
int argc, char** argv){
|
||||||
|
|
||||||
if(!file_loaded){
|
if(!file_loaded){
|
||||||
|
|||||||
@@ -677,13 +677,18 @@ static struct commands lfm_commandhandlers[] = {
|
|||||||
{NULL, "lfm_format", h_lfm_format, 2, 2}
|
{NULL, "lfm_format", h_lfm_format, 2, 2}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
#ifdef _WIN32
|
|
||||||
__declspec(dllexport)
|
#ifdef WATCOM
|
||||||
|
#pragma aux lfm_plugin "*" parm caller [ ] value struct float struct routine [eax] modify [eax ecx edx]
|
||||||
|
#undef PLUGINCALL
|
||||||
|
#define PLUGINCALL
|
||||||
#endif
|
#endif
|
||||||
int lfm_plugin( struct pluginlink * pluginlink, int argc, char** argv )
|
|
||||||
|
PLUGINAPI int PLUGINCALL lfm_plugin( struct pluginlink * pluginlink, int argc, char** argv )
|
||||||
{
|
{
|
||||||
pl = pluginlink;
|
pl = pluginlink;
|
||||||
myOutputDebugStringA1( "lfm_plugin" );
|
myOutputDebugStringA1( "lfm_plugin" );
|
||||||
|
|||||||
@@ -0,0 +1,7 @@
|
|||||||
|
all: $(BUILDDIR)ldapauth$(DLSUFFICS)
|
||||||
|
|
||||||
|
ldapauth$(OBJSUFFICS): ldapauth.c
|
||||||
|
$(CC) $(DCFLAGS) $(CFLAGS) ldapauth.c
|
||||||
|
|
||||||
|
$(BUILDDIR)ldapauth$(DLSUFFICS): ldapauth$(OBJSUFFICS)
|
||||||
|
$(LN) $(LNOUT)../../$(BUILDDIR)ldapauth$(DLSUFFICS) $(LDFLAGS) $(DLFLAGS) $(LIBSPREFIX)ldap$(LIBSSUFFIX) ldapauth$(OBJSUFFICS)
|
||||||
@@ -1,25 +1,15 @@
|
|||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <stdlib.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <ldap.h>
|
|
||||||
|
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
|
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "../../proxy.h"
|
|
||||||
#include "../../structures.h"
|
#include "../../structures.h"
|
||||||
|
#define LDAP_DEPRECATED 1
|
||||||
struct counter_record
|
#include <ldap.h>
|
||||||
{
|
|
||||||
unsigned long traf;
|
|
||||||
unsigned long trafgb;
|
|
||||||
time_t cleared;
|
|
||||||
time_t updated;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
int already_loaded = 0;
|
int already_loaded = 0;
|
||||||
|
|
||||||
@@ -62,7 +52,7 @@ void lower (char *string)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* -------------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------------- */
|
||||||
int savecouters(void)
|
int savecounters(void)
|
||||||
{
|
{
|
||||||
struct trafcount *tc=mypluginlink->conf->trafcounter;
|
struct trafcount *tc=mypluginlink->conf->trafcounter;
|
||||||
struct trafcount *tcd;
|
struct trafcount *tcd;
|
||||||
@@ -82,8 +72,8 @@ int savecouters(void)
|
|||||||
sprintf(tmpbuf,pat_file,ldap_dircount,tcd->ace->users->user);
|
sprintf(tmpbuf,pat_file,ldap_dircount,tcd->ace->users->user);
|
||||||
f=fopen(tmpbuf,"w+b");
|
f=fopen(tmpbuf,"w+b");
|
||||||
fseek(f,0,SEEK_SET);
|
fseek(f,0,SEEK_SET);
|
||||||
fprintf(f,"%10lu %10lu %lu %lu\n",tcd->trafgb,tcd->traf,
|
fprintf(f,"%"PRINTF_INT64_MODIFIER"u %lu %lu\n",tcd->traf64,
|
||||||
tcd->cleared,tcd->updated);
|
(unsigned long)tcd->cleared,(unsigned long)tcd->updated);
|
||||||
|
|
||||||
fclose(f);
|
fclose(f);
|
||||||
mypluginlink->myfree(tmpbuf);
|
mypluginlink->myfree(tmpbuf);
|
||||||
@@ -100,17 +90,7 @@ int savecouters(void)
|
|||||||
|
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
|
|
||||||
#ifdef _WIN32
|
|
||||||
__declspec(dllexport) int start(struct pluginlink * pluginlink,
|
|
||||||
int argc, char** argv);
|
|
||||||
#else
|
|
||||||
|
|
||||||
int start(struct pluginlink * pluginlink,
|
|
||||||
int argc, char** argv);
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------*/
|
/* --------------------------------------------------------------------------*/
|
||||||
static int ldapfunc(struct clientparam *param)
|
static int ldapfunc(struct clientparam *param)
|
||||||
@@ -395,8 +375,7 @@ int h_trafgroup(int argc, unsigned char ** argv)
|
|||||||
memset(newtrafcount, 0, sizeof(struct trafcount));
|
memset(newtrafcount, 0, sizeof(struct trafcount));
|
||||||
newtrafcount->ace = newace;
|
newtrafcount->ace = newace;
|
||||||
newtrafcount->type=rtype;
|
newtrafcount->type=rtype;
|
||||||
newtrafcount->traflimgb =(traflimit/(1024*4));
|
newtrafcount->traflim64 = traflimit;
|
||||||
newtrafcount->traflim = ((traflimit - (newtrafcount->traflimgb*(1024*4)))*(1024*1024));
|
|
||||||
newtrafcount->comment=(*mypluginlink->mystrdup)("ldapcounters");
|
newtrafcount->comment=(*mypluginlink->mystrdup)("ldapcounters");
|
||||||
newtrafcount->number=0;
|
newtrafcount->number=0;
|
||||||
tmpbuf=(*mypluginlink->myalloc)(strlen(pat_file)+strlen(ldap_dircount)+strlen(vals[0]));
|
tmpbuf=(*mypluginlink->myalloc)(strlen(pat_file)+strlen(ldap_dircount)+strlen(vals[0]));
|
||||||
@@ -408,12 +387,11 @@ int h_trafgroup(int argc, unsigned char ** argv)
|
|||||||
|
|
||||||
fseek(f,0,SEEK_SET);
|
fseek(f,0,SEEK_SET);
|
||||||
fgets(buf, 256, f);
|
fgets(buf, 256, f);
|
||||||
sscanf(buf,"%10lu %10lu %lu %lu\n",&rcounter.trafgb, &rcounter.traf,
|
sscanf(buf,"%"PRINTF_INT64_MODIFIER"u %lu %lu\n",&rcounter.traf64,
|
||||||
&rcounter.cleared, &rcounter.updated);
|
&rcounter.cleared, &rcounter.updated);
|
||||||
|
|
||||||
|
|
||||||
newtrafcount->trafgb=rcounter.trafgb;
|
newtrafcount->traf64=rcounter.traf64;
|
||||||
newtrafcount->traf=rcounter.traf;
|
|
||||||
newtrafcount->cleared=rcounter.cleared;
|
newtrafcount->cleared=rcounter.cleared;
|
||||||
newtrafcount->updated=rcounter.updated;
|
newtrafcount->updated=rcounter.updated;
|
||||||
fclose(f);
|
fclose(f);
|
||||||
@@ -467,7 +445,16 @@ int h_dircount(int argc, unsigned char ** argv)
|
|||||||
|
|
||||||
/*------------------------------- MAIN --------------------------------------
|
/*------------------------------- MAIN --------------------------------------
|
||||||
start plugin init */
|
start plugin init */
|
||||||
int start(struct pluginlink * pluginlink, int argc, char** argv)
|
|
||||||
|
#ifdef WATCOM
|
||||||
|
#pragma aux start "*" parm caller [ ] value struct float struct routine [eax] modify [eax ecx edx]
|
||||||
|
#undef PLUGINCALL
|
||||||
|
#define PLUGINCALL
|
||||||
|
#endif
|
||||||
|
|
||||||
|
PLUGINAPI int PLUGINCALL start(struct pluginlink * pluginlink,
|
||||||
|
int argc, char** argv)
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
@@ -566,7 +553,7 @@ int start(struct pluginlink * pluginlink, int argc, char** argv)
|
|||||||
/*create job shedule for processing reload, save counters to file */
|
/*create job shedule for processing reload, save counters to file */
|
||||||
memset(&myschedule,0,sizeof(struct schedule));
|
memset(&myschedule,0,sizeof(struct schedule));
|
||||||
myschedule.type=MINUTELY;
|
myschedule.type=MINUTELY;
|
||||||
myschedule.function=savecouters;
|
myschedule.function=savecounters;
|
||||||
myschedule.next = *pluginlink->schedule;
|
myschedule.next = *pluginlink->schedule;
|
||||||
*pluginlink->schedule=&myschedule;
|
*pluginlink->schedule=&myschedule;
|
||||||
|
|
||||||
|
|||||||
@@ -144,7 +144,7 @@ static FILTER_ACTION pcre_filter_buffer(void *fc, struct clientparam *param, uns
|
|||||||
if(!pcrefd->re) return pcrefd->action;
|
if(!pcrefd->re) return pcrefd->action;
|
||||||
for(; offset < *length_p; nreplaces++){
|
for(; offset < *length_p; nreplaces++){
|
||||||
|
|
||||||
count = pcre_exec(pcrefd->re, NULL, *buf_p, *length_p, offset, 0, ovector, 48);
|
count = pcre_exec(pcrefd->re, NULL, (char *)*buf_p, *length_p, offset, 0, ovector, 48);
|
||||||
if(count <= 0) break;
|
if(count <= 0) break;
|
||||||
if(!(replace = pcrefd->replace) || param->nooverwritefilter) return pcrefd->action;
|
if(!(replace = pcrefd->replace) || param->nooverwritefilter) return pcrefd->action;
|
||||||
|
|
||||||
@@ -195,7 +195,7 @@ static FILTER_ACTION pcre_filter_buffer(void *fc, struct clientparam *param, uns
|
|||||||
}
|
}
|
||||||
memcpy(newbuf, *buf_p, ovector[0]);
|
memcpy(newbuf, *buf_p, ovector[0]);
|
||||||
(*pl->myfree)(*buf_p);
|
(*pl->myfree)(*buf_p);
|
||||||
*buf_p = newbuf;
|
*buf_p = (unsigned char *)newbuf;
|
||||||
*bufsize_p = ovector[0] + replen + 1;
|
*bufsize_p = ovector[0] + replen + 1;
|
||||||
}
|
}
|
||||||
memcpy(*buf_p + ovector[0], tmpbuf, replen);
|
memcpy(*buf_p + ovector[0], tmpbuf, replen);
|
||||||
@@ -229,15 +229,15 @@ static int h_pcre(int argc, unsigned char **argv){
|
|||||||
struct filter *newf;
|
struct filter *newf;
|
||||||
char *replace = NULL;
|
char *replace = NULL;
|
||||||
|
|
||||||
if(!strncmp(argv[2], "allow",5)) action = PASS;
|
if(!strncmp((char *)argv[2], "allow",5)) action = PASS;
|
||||||
else if(!strncmp(argv[2], "deny",4)) action = REJECT;
|
else if(!strncmp((char *)argv[2], "deny",4)) action = REJECT;
|
||||||
else if(!strncmp(argv[2], "remove",6)) action = REMOVE;
|
else if(!strncmp((char *)argv[2], "remove",6)) action = REMOVE;
|
||||||
else if(!strncmp(argv[2], "dunno",5)) action = CONTINUE;
|
else if(!strncmp((char *)argv[2], "dunno",5)) action = CONTINUE;
|
||||||
else return 1;
|
else return 1;
|
||||||
if(!strncmp(argv[0], "pcre_rewrite", 12)) {
|
if(!strncmp((char *)argv[0], "pcre_rewrite", 12)) {
|
||||||
int i,j;
|
int i,j;
|
||||||
offset = 5;
|
offset = 5;
|
||||||
replace = pl->mystrdup(argv[4]);
|
replace = pl->mystrdup((char *)argv[4]);
|
||||||
if(!replace) return 9;
|
if(!replace) return 9;
|
||||||
for(i=0, j=0; replace[i]; i++, j++){
|
for(i=0, j=0; replace[i]; i++, j++){
|
||||||
if(replace[i] == '\\'){
|
if(replace[i] == '\\'){
|
||||||
@@ -266,7 +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);
|
acl->nolog = (strstr((char *)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) {
|
||||||
@@ -296,11 +296,11 @@ static int h_pcre(int argc, unsigned char **argv){
|
|||||||
newf->data = flt;
|
newf->data = flt;
|
||||||
newf->filter_open = pcre_filter_open;
|
newf->filter_open = pcre_filter_open;
|
||||||
newf->filter_client = pcre_filter_client;
|
newf->filter_client = pcre_filter_client;
|
||||||
if(strstr(argv[1], "request"))newf->filter_request = pcre_filter_buffer;
|
if(strstr((char *)argv[1], "request"))newf->filter_request = pcre_filter_buffer;
|
||||||
if(strstr(argv[1], "cliheader"))newf->filter_header_cli = pcre_filter_buffer;
|
if(strstr((char *)argv[1], "cliheader"))newf->filter_header_cli = pcre_filter_buffer;
|
||||||
if(strstr(argv[1], "clidata"))newf->filter_data_cli = pcre_filter_buffer;
|
if(strstr((char *)argv[1], "clidata"))newf->filter_data_cli = pcre_filter_buffer;
|
||||||
if(strstr(argv[1], "srvheader"))newf->filter_header_srv = pcre_filter_buffer;
|
if(strstr((char *)argv[1], "srvheader"))newf->filter_header_srv = pcre_filter_buffer;
|
||||||
if(strstr(argv[1], "srvdata"))newf->filter_data_srv = pcre_filter_buffer;
|
if(strstr((char *)argv[1], "srvdata"))newf->filter_data_srv = pcre_filter_buffer;
|
||||||
newf->filter_clear = pcre_filter_clear;
|
newf->filter_clear = pcre_filter_clear;
|
||||||
newf->filter_close = pcre_filter_close;
|
newf->filter_close = pcre_filter_close;
|
||||||
|
|
||||||
@@ -334,7 +334,7 @@ static int h_pcre_options(int argc, unsigned char **argv){
|
|||||||
pcre_options = 0;
|
pcre_options = 0;
|
||||||
for(j=1; j<argc; j++)
|
for(j=1; j<argc; j++)
|
||||||
for(i=0; pcreopts[i].name; i++)
|
for(i=0; pcreopts[i].name; i++)
|
||||||
if(!strcmp(pcreopts[i].name, argv[j]))
|
if(!strcmp(pcreopts[i].name, (char *)argv[j]))
|
||||||
pcre_options |= pcreopts[i].value;
|
pcre_options |= pcreopts[i].value;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@@ -358,12 +358,15 @@ static struct symbol regexp_symbols[] = {
|
|||||||
{NULL, "pcre_free", NULL},
|
{NULL, "pcre_free", NULL},
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef WATCOM
|
||||||
__declspec(dllexport)
|
#pragma aux pcre_plugin "*" parm caller [ ] value struct float struct routine [eax] modify [eax ecx edx]
|
||||||
|
#undef PLUGINCALL
|
||||||
|
#define PLUGINCALL
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int pcre_plugin (struct pluginlink * pluginlink,
|
PLUGINAPI int PLUGINCALL pcre_plugin (struct pluginlink * pluginlink,
|
||||||
int argc, char** argv){
|
int argc, char** argv){
|
||||||
|
|
||||||
struct filter *flt, *tmpflt;
|
struct filter *flt, *tmpflt;
|
||||||
pl = pluginlink;
|
pl = pluginlink;
|
||||||
pcre_options = 0;
|
pcre_options = 0;
|
||||||
|
|||||||
@@ -4,4 +4,4 @@ pamauth$(OBJSUFFICS): pamauth.c
|
|||||||
$(CC) $(DCFLAGS) $(CFLAGS) pamauth.c
|
$(CC) $(DCFLAGS) $(CFLAGS) pamauth.c
|
||||||
|
|
||||||
$(BUILDDIR)pamauth$(DLSUFFICS): pamauth$(OBJSUFFICS)
|
$(BUILDDIR)pamauth$(DLSUFFICS): pamauth$(OBJSUFFICS)
|
||||||
$(LN) $(LNOUT)../../$(BUILDDIR)pamauth$(DLSUFFICS) $(LDFLAGS) $(DLFLAGS) -lpam pamauth$(OBJSUFFICS)
|
$(LN) $(LNOUT)../../$(BUILDDIR)pamauth$(DLSUFFICS) $(LDFLAGS) $(DLFLAGS) $(LIBSPREFIX)pam$(LIBSSUFFIX) pamauth$(OBJSUFFICS)
|
||||||
@@ -12,7 +12,7 @@ Kirill Lopuchov <lopuchov@mail.ru>
|
|||||||
#include <security/pam_appl.h>
|
#include <security/pam_appl.h>
|
||||||
|
|
||||||
|
|
||||||
|
pthread_mutex_t pam_mutex;
|
||||||
|
|
||||||
static int already_loaded = 0;
|
static int already_loaded = 0;
|
||||||
|
|
||||||
@@ -89,6 +89,7 @@ static int pamfunc(struct clientparam *param)
|
|||||||
/*start process auth */
|
/*start process auth */
|
||||||
conv.appdata_ptr = (char *) param->password;
|
conv.appdata_ptr = (char *) param->password;
|
||||||
|
|
||||||
|
pthread_mutex_lock(&pam_mutex);
|
||||||
if (!pamh)
|
if (!pamh)
|
||||||
{
|
{
|
||||||
retval = pam_start ((char *)service, "3proxy@" , &conv, &pamh);
|
retval = pam_start ((char *)service, "3proxy@" , &conv, &pamh);
|
||||||
@@ -110,26 +111,34 @@ static int pamfunc(struct clientparam *param)
|
|||||||
retval = pam_end (pamh, retval);
|
retval = pam_end (pamh, retval);
|
||||||
if (retval != PAM_SUCCESS)
|
if (retval != PAM_SUCCESS)
|
||||||
{ pamh = NULL; }
|
{ pamh = NULL; }
|
||||||
|
pthread_mutex_unlock(&pam_mutex);
|
||||||
|
|
||||||
return rc;
|
return rc;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef WATCOM
|
||||||
|
#pragma aux start "*" parm caller [ ] value struct float struct routine [eax] modify [eax ecx edx]
|
||||||
|
#undef PLUGINCALL
|
||||||
|
#define PLUGINCALL
|
||||||
|
#endif
|
||||||
|
|
||||||
/*------------------------------- MAIN --------------------------------------
|
/*------------------------------- MAIN --------------------------------------
|
||||||
start plugin init */
|
start plugin init */
|
||||||
int start(struct pluginlink * pluginlink, int argc, unsigned char** argv)
|
PLUGINAPI int PLUGINCALL start(struct pluginlink * pluginlink, int argc, unsigned char** argv)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
if(argc < 2) return 1;
|
if(argc < 2) return 1;
|
||||||
pl = pluginlink;
|
pl = pluginlink;
|
||||||
if(service) pl->myfree(service);
|
if(service) pl->myfree(service);
|
||||||
service=pl->mystrdup(argv[1]);
|
service=(unsigned char *)pl->mystrdup((char *)argv[1]);
|
||||||
|
|
||||||
if (already_loaded) { return (0); }
|
if (already_loaded) { return (0); }
|
||||||
|
|
||||||
already_loaded = 1;
|
already_loaded = 1;
|
||||||
|
|
||||||
|
pthread_mutex_init(&pam_mutex, NULL);
|
||||||
pamauth.authenticate = pamfunc;
|
pamauth.authenticate = pamfunc;
|
||||||
pamauth.authorize = pluginlink->checkACL;
|
pamauth.authorize = pluginlink->checkACL;
|
||||||
pamauth.desc = "pam";
|
pamauth.desc = "pam";
|
||||||
|
|||||||
@@ -112,8 +112,8 @@ SSL_CERT ssl_copy_cert(SSL_CERT cert)
|
|||||||
unsigned char p2[] = "3proxy";
|
unsigned char p2[] = "3proxy";
|
||||||
unsigned char p3[] = "3proxy CA";
|
unsigned char p3[] = "3proxy CA";
|
||||||
|
|
||||||
static char hash_name[sizeof(src_cert->sha1_hash)*2 + 1];
|
char hash_name[sizeof(src_cert->sha1_hash)*2 + 1];
|
||||||
static char cache_name[200];
|
char cache_name[200];
|
||||||
|
|
||||||
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);
|
||||||
|
|||||||
@@ -326,8 +326,13 @@ static struct filter ssl_filter = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
int mitm = 0;
|
int mitm = 0;
|
||||||
|
int ssl_inited = 0;
|
||||||
|
|
||||||
static int h_mitm(int argc, unsigned char **argv){
|
static int h_mitm(int argc, unsigned char **argv){
|
||||||
|
if(!ssl_inited) {
|
||||||
|
ssl_init();
|
||||||
|
ssl_inited = 1;
|
||||||
|
}
|
||||||
if((mitm&1)) return 1;
|
if((mitm&1)) return 1;
|
||||||
if(mitm) usleep(100*SLEEPTIME);
|
if(mitm) usleep(100*SLEEPTIME);
|
||||||
ssl_filter.next = pl->conf->filters;
|
ssl_filter.next = pl->conf->filters;
|
||||||
@@ -367,12 +372,15 @@ static struct commands ssl_commandhandlers[] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef WATCOM
|
||||||
__declspec(dllexport)
|
#pragma aux ssl_plugin "*" parm caller [ ] value struct float struct routine [eax] modify [eax ecx edx]
|
||||||
|
#undef PLUGINCALL
|
||||||
|
#define PLUGINCALL
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int ssl_plugin (struct pluginlink * pluginlink,
|
PLUGINAPI int PLUGINCALL ssl_plugin (struct pluginlink * pluginlink,
|
||||||
int argc, char** argv){
|
int argc, char** argv){
|
||||||
|
|
||||||
pl = pluginlink;
|
pl = pluginlink;
|
||||||
if(!ssl_loaded){
|
if(!ssl_loaded){
|
||||||
ssl_loaded = 1;
|
ssl_loaded = 1;
|
||||||
@@ -389,9 +397,9 @@ __declspec(dllexport)
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
ssl_release();
|
ssl_release();
|
||||||
|
ssl_inited = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
ssl_init();
|
|
||||||
tcppmfunc = (PROXYFUNC)pl->findbyname("tcppm");
|
tcppmfunc = (PROXYFUNC)pl->findbyname("tcppm");
|
||||||
if(!tcppmfunc){return 13;}
|
if(!tcppmfunc){return 13;}
|
||||||
proxyfunc = (PROXYFUNC)pl->findbyname("proxy");
|
proxyfunc = (PROXYFUNC)pl->findbyname("proxy");
|
||||||
|
|||||||
@@ -151,8 +151,6 @@ static int restore_old_table(void * v)
|
|||||||
/*-------------------------------------------------------------------*/
|
/*-------------------------------------------------------------------*/
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
__declspec(dllexport) int start(struct pluginlink * pluginlink,
|
|
||||||
int argc, char** argv);
|
|
||||||
BOOL WINAPI DllMain( HINSTANCE hModule,
|
BOOL WINAPI DllMain( HINSTANCE hModule,
|
||||||
DWORD ul_reason_for_call,
|
DWORD ul_reason_for_call,
|
||||||
LPVOID lpReserved
|
LPVOID lpReserved
|
||||||
@@ -165,17 +163,17 @@ BOOL WINAPI DllMain( HINSTANCE hModule,
|
|||||||
}
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
|
|
||||||
int start(struct pluginlink * pluginlink,
|
|
||||||
int argc, char** argv);
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef WATCOM
|
||||||
|
#pragma aux start "*" parm caller [ ] value struct float struct routine [eax] modify [eax ecx edx]
|
||||||
|
#undef PLUGINCALL
|
||||||
|
#define PLUGINCALL
|
||||||
|
#endif
|
||||||
|
|
||||||
|
PLUGINAPI int PLUGINCALL start(struct pluginlink * pluginlink,
|
||||||
/*---------------------- start plugin init ------------------------------ */
|
int argc, char** argv)
|
||||||
int start(struct pluginlink * pluginlink, int argc, char** argv)
|
|
||||||
{
|
{
|
||||||
FILE *f=NULL;
|
FILE *f=NULL;
|
||||||
|
|
||||||
|
|||||||
@@ -266,11 +266,16 @@ BOOL WINAPI DllMain( HINSTANCE hModule,
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
__declspec(dllexport)
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int start(struct pluginlink * pluginlink, int argc, char** argv) {
|
#ifdef WATCOM
|
||||||
|
#pragma aux start "*" parm caller [ ] value struct float struct routine [eax] modify [eax ecx edx]
|
||||||
|
#undef PLUGINCALL
|
||||||
|
#define PLUGINCALL
|
||||||
|
#endif
|
||||||
|
|
||||||
|
PLUGINAPI int PLUGINCALL start(struct pluginlink * pluginlink, int argc, char** argv) {
|
||||||
|
|
||||||
struct commands * starthandler;
|
struct commands * starthandler;
|
||||||
conf = pluginlink->conf;
|
conf = pluginlink->conf;
|
||||||
commandhandlers = pluginlink->commandhandlers;
|
commandhandlers = pluginlink->commandhandlers;
|
||||||
|
|||||||
@@ -47,7 +47,6 @@ static FILTER_ACTION transparent_filter_client(void *fo, struct clientparam * pa
|
|||||||
|
|
||||||
len = sizeof(addr);
|
len = sizeof(addr);
|
||||||
if(getsockopt(param->clisock, SOL_IP, SO_ORIGINAL_DST,(struct sockaddr *) &addr, &len) || !addr.sin_addr.s_addr){
|
if(getsockopt(param->clisock, SOL_IP, SO_ORIGINAL_DST,(struct sockaddr *) &addr, &len) || !addr.sin_addr.s_addr){
|
||||||
perror("getsockopt()");
|
|
||||||
return PASS;
|
return PASS;
|
||||||
}
|
}
|
||||||
u = ntohl(addr.sin_addr.s_addr);
|
u = ntohl(addr.sin_addr.s_addr);
|
||||||
@@ -59,8 +58,6 @@ perror("getsockopt()");
|
|||||||
((u&0x000000FF)),
|
((u&0x000000FF)),
|
||||||
p);
|
p);
|
||||||
|
|
||||||
param->srv->logfunc(param, (unsigned char *)"transparent_filter_client() Success");
|
|
||||||
param->srv->logfunc(param, (unsigned char *)addrbuf);
|
|
||||||
pl->parsehostname(addrbuf, param, 0);
|
pl->parsehostname(addrbuf, param, 0);
|
||||||
return PASS;
|
return PASS;
|
||||||
#else
|
#else
|
||||||
@@ -92,11 +89,13 @@ static struct filter transparent_filter = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef WATCOM
|
||||||
__declspec(dllexport)
|
#pragma aux transparent_plugin "*" parm caller [ ] value struct float struct routine [eax] modify [eax ecx edx]
|
||||||
|
#undef PLUGINCALL
|
||||||
|
#define PLUGINCALL
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int transparent_plugin (struct pluginlink * pluginlink,
|
PLUGINAPI int PLUGINCALL transparent_plugin (struct pluginlink * pluginlink,
|
||||||
int argc, char** argv){
|
int argc, char** argv){
|
||||||
pl = pluginlink;
|
pl = pluginlink;
|
||||||
if(!transparent_loaded){
|
if(!transparent_loaded){
|
||||||
|
|||||||
@@ -15,10 +15,6 @@
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
__declspec(dllexport) int WindowsAuthentication(struct pluginlink * pluginlink,
|
|
||||||
int argc, char** argv);
|
|
||||||
|
|
||||||
|
|
||||||
static struct auth alwaysauth;
|
static struct auth alwaysauth;
|
||||||
|
|
||||||
static char sidbuf[4096];
|
static char sidbuf[4096];
|
||||||
@@ -41,7 +37,7 @@ extern "C" {
|
|||||||
if(dom)*dom++=0;
|
if(dom)*dom++=0;
|
||||||
if(!LogonUser( dom?dom:(char *)param->username,
|
if(!LogonUser( dom?dom:(char *)param->username,
|
||||||
dom?(char *)param->username:NULL,
|
dom?(char *)param->username:NULL,
|
||||||
param->password,
|
(char *)param->password,
|
||||||
LOGON32_LOGON_NETWORK,
|
LOGON32_LOGON_NETWORK,
|
||||||
LOGON32_PROVIDER_DEFAULT,
|
LOGON32_PROVIDER_DEFAULT,
|
||||||
&h))return 5;
|
&h))return 5;
|
||||||
@@ -54,7 +50,7 @@ extern "C" {
|
|||||||
if(GetLengthSid(ptg->Groups[i].Sid)==sidlen){
|
if(GetLengthSid(ptg->Groups[i].Sid)==sidlen){
|
||||||
if(!memcmp((void *)ptg->Groups[i].Sid, (void *)psid, sidlen)) {
|
if(!memcmp((void *)ptg->Groups[i].Sid, (void *)psid, sidlen)) {
|
||||||
setlocale(LC_CTYPE, ".ACP");
|
setlocale(LC_CTYPE, ".ACP");
|
||||||
_strlwr(param->username);
|
_strlwr((char *)param->username);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -62,12 +58,13 @@ extern "C" {
|
|||||||
return 7;
|
return 7;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef WATCOM
|
||||||
}
|
#pragma aux WindowsAuthentication "*" parm caller [ ] value struct float struct routine [eax] modify [eax ecx edx]
|
||||||
|
#undef PLUGINCALL
|
||||||
|
#define PLUGINCALL
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
PLUGINAPI int PLUGINCALL WindowsAuthentication(struct pluginlink * pluginlink, int argc, char** argv){
|
||||||
int WindowsAuthentication(struct pluginlink * pluginlink, int argc, char** argv){
|
|
||||||
char tmpbuf[4096];
|
char tmpbuf[4096];
|
||||||
DWORD dlen, sidlen;
|
DWORD dlen, sidlen;
|
||||||
SID_NAME_USE snu;
|
SID_NAME_USE snu;
|
||||||
@@ -91,4 +88,7 @@ int WindowsAuthentication(struct pluginlink * pluginlink, int argc, char** argv)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
@@ -14,9 +14,6 @@
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
__declspec(dllexport) int utf8tocp1251(struct pluginlink * pluginlink,
|
|
||||||
int argc, char** argv);
|
|
||||||
|
|
||||||
static struct auth alwaysauth;
|
static struct auth alwaysauth;
|
||||||
|
|
||||||
|
|
||||||
@@ -26,7 +23,7 @@ extern "C" {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
unsigned char * conv_utf8_to_cp1251(unsigned char *s){
|
unsigned char * conv_utf8_to_cp1251(unsigned char *s){
|
||||||
int i, j=0, n=(int)strlen(s);
|
int i, j=0, n=(int)strlen((char *)s);
|
||||||
int byte2 = 0;
|
int byte2 = 0;
|
||||||
int c1, new_c1, new_c2, new_i;
|
int c1, new_c1, new_c2, new_i;
|
||||||
for(i = 0; i < n; i++){
|
for(i = 0; i < n; i++){
|
||||||
@@ -64,12 +61,14 @@ unsigned char * conv_utf8_to_cp1251(unsigned char *s){
|
|||||||
return 4;
|
return 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
#ifdef WATCOM
|
||||||
|
#pragma aux utf8tocp1251 "*" parm caller [ ] value struct float struct routine [eax] modify [eax ecx edx]
|
||||||
|
#undef PLUGINCALL
|
||||||
|
#define PLUGINCALL
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
PLUGINAPI int PLUGINCALL utf8tocp1251(struct pluginlink * pluginlink, int argc, char** argv){
|
||||||
int utf8tocp1251(struct pluginlink * pluginlink, int argc, char** argv){
|
|
||||||
static int loaded = 0;
|
static int loaded = 0;
|
||||||
|
|
||||||
|
|
||||||
@@ -85,4 +84,7 @@ int utf8tocp1251(struct pluginlink * pluginlink, int argc, char** argv){
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
+1
-1
@@ -48,7 +48,7 @@ void * pop3pchild(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, (*SAPORT(¶m->sinsr)==110)?0:':', ntohs(*SAPORT(¶m->sinsr)));
|
sprintf((char *)buf, "%.128s@%.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);
|
||||||
|
|||||||
+48
-36
@@ -14,49 +14,49 @@
|
|||||||
char * proxy_stringtable[] = {
|
char * proxy_stringtable[] = {
|
||||||
/* 0 */ "HTTP/1.0 400 Bad Request\r\n"
|
/* 0 */ "HTTP/1.0 400 Bad Request\r\n"
|
||||||
"Proxy-Connection: close\r\n"
|
"Proxy-Connection: close\r\n"
|
||||||
"Content-type: text/html; charset=us-ascii\r\n"
|
"Content-type: text/html; charset=utf-8\r\n"
|
||||||
"\r\n"
|
"\r\n"
|
||||||
"<html><head><title>400 Bad Request</title></head>\r\n"
|
"<html><head><title>400 Bad Request</title></head>\r\n"
|
||||||
"<body><h2>400 Bad Request</h2></body></html>\r\n",
|
"<body><h2>400 Bad Request</h2></body></html>\r\n",
|
||||||
|
|
||||||
/* 1 */ "HTTP/1.0 502 Bad Gateway\r\n"
|
/* 1 */ "HTTP/1.0 502 Bad Gateway\r\n"
|
||||||
"Proxy-Connection: close\r\n"
|
"Proxy-Connection: close\r\n"
|
||||||
"Content-type: text/html; charset=us-ascii\r\n"
|
"Content-type: text/html; charset=utf-8\r\n"
|
||||||
"\r\n"
|
"\r\n"
|
||||||
"<html><head><title>502 Bad Gateway</title></head>\r\n"
|
"<html><head><title>502 Bad Gateway</title></head>\r\n"
|
||||||
"<body><h2>502 Bad Gateway</h2><h3>Host Not Found or connection failed</h3></body></html>\r\n",
|
"<body><h2>502 Bad Gateway</h2><h3>Host Not Found or connection failed</h3></body></html>\r\n",
|
||||||
|
|
||||||
/* 2 */ "HTTP/1.0 503 Service Unavailable\r\n"
|
/* 2 */ "HTTP/1.0 503 Service Unavailable\r\n"
|
||||||
"Proxy-Connection: close\r\n"
|
"Proxy-Connection: close\r\n"
|
||||||
"Content-type: text/html; charset=us-ascii\r\n"
|
"Content-type: text/html; charset=utf-8\r\n"
|
||||||
"\r\n"
|
"\r\n"
|
||||||
"<html><head><title>503 Service Unavailable</title></head>\r\n"
|
"<html><head><title>503 Service Unavailable</title></head>\r\n"
|
||||||
"<body><h2>503 Service Unavailable</h2><h3>You have exceeded your traffic limit</h3></body></html>\r\n",
|
"<body><h2>503 Service Unavailable</h2><h3>You have exceeded your traffic limit</h3></body></html>\r\n",
|
||||||
|
|
||||||
/* 3 */ "HTTP/1.0 503 Service Unavailable\r\n"
|
/* 3 */ "HTTP/1.0 503 Service Unavailable\r\n"
|
||||||
"Proxy-Connection: close\r\n"
|
"Proxy-Connection: close\r\n"
|
||||||
"Content-type: text/html; charset=us-ascii\r\n"
|
"Content-type: text/html; charset=utf-8\r\n"
|
||||||
"\r\n"
|
"\r\n"
|
||||||
"<html><head><title>503 Service Unavailable</title></head>\r\n"
|
"<html><head><title>503 Service Unavailable</title></head>\r\n"
|
||||||
"<body><h2>503 Service Unavailable</h2><h3>Recursion detected</h3></body></html>\r\n",
|
"<body><h2>503 Service Unavailable</h2><h3>Recursion detected</h3></body></html>\r\n",
|
||||||
|
|
||||||
/* 4 */ "HTTP/1.0 501 Not Implemented\r\n"
|
/* 4 */ "HTTP/1.0 501 Not Implemented\r\n"
|
||||||
"Proxy-Connection: close\r\n"
|
"Proxy-Connection: close\r\n"
|
||||||
"Content-type: text/html; charset=us-ascii\r\n"
|
"Content-type: text/html; charset=utf-8\r\n"
|
||||||
"\r\n"
|
"\r\n"
|
||||||
"<html><head><title>501 Not Implemented</title></head>\r\n"
|
"<html><head><title>501 Not Implemented</title></head>\r\n"
|
||||||
"<body><h2>501 Not Implemented</h2><h3>Required action is not supported by proxy server</h3></body></html>\r\n",
|
"<body><h2>501 Not Implemented</h2><h3>Required action is not supported by proxy server</h3></body></html>\r\n",
|
||||||
|
|
||||||
/* 5 */ "HTTP/1.0 502 Bad Gateway\r\n"
|
/* 5 */ "HTTP/1.0 502 Bad Gateway\r\n"
|
||||||
"Proxy-Connection: close\r\n"
|
"Proxy-Connection: close\r\n"
|
||||||
"Content-type: text/html; charset=us-ascii\r\n"
|
"Content-type: text/html; charset=utf-8\r\n"
|
||||||
"\r\n"
|
"\r\n"
|
||||||
"<html><head><title>502 Bad Gateway</title></head>\r\n"
|
"<html><head><title>502 Bad Gateway</title></head>\r\n"
|
||||||
"<body><h2>502 Bad Gateway</h2><h3>Failed to connect parent proxy</h3></body></html>\r\n",
|
"<body><h2>502 Bad Gateway</h2><h3>Failed to connect parent proxy</h3></body></html>\r\n",
|
||||||
|
|
||||||
/* 6 */ "HTTP/1.0 500 Internal Error\r\n"
|
/* 6 */ "HTTP/1.0 500 Internal Error\r\n"
|
||||||
"Proxy-Connection: close\r\n"
|
"Proxy-Connection: close\r\n"
|
||||||
"Content-type: text/html; charset=us-ascii\r\n"
|
"Content-type: text/html; charset=utf-8\r\n"
|
||||||
"\r\n"
|
"\r\n"
|
||||||
"<html><head><title>500 Internal Error</title></head>\r\n"
|
"<html><head><title>500 Internal Error</title></head>\r\n"
|
||||||
"<body><h2>500 Internal Error</h2><h3>Internal proxy error during processing your request</h3></body></html>\r\n",
|
"<body><h2>500 Internal Error</h2><h3>Internal proxy error during processing your request</h3></body></html>\r\n",
|
||||||
@@ -64,7 +64,7 @@ char * proxy_stringtable[] = {
|
|||||||
/* 7 */ "HTTP/1.0 407 Proxy Authentication Required\r\n"
|
/* 7 */ "HTTP/1.0 407 Proxy Authentication Required\r\n"
|
||||||
"Proxy-Authenticate: Basic realm=\"proxy\"\r\n"
|
"Proxy-Authenticate: Basic realm=\"proxy\"\r\n"
|
||||||
"Proxy-Connection: close\r\n"
|
"Proxy-Connection: close\r\n"
|
||||||
"Content-type: text/html; charset=us-ascii\r\n"
|
"Content-type: text/html; charset=utf-8\r\n"
|
||||||
"\r\n"
|
"\r\n"
|
||||||
"<html><head><title>407 Proxy Authentication Required</title></head>\r\n"
|
"<html><head><title>407 Proxy Authentication Required</title></head>\r\n"
|
||||||
"<body><h2>407 Proxy Authentication Required</h2><h3>Access to requested resource disallowed by administrator or you need valid username/password to use this resource</h3></body></html>\r\n",
|
"<body><h2>407 Proxy Authentication Required</h2><h3>Access to requested resource disallowed by administrator or you need valid username/password to use this resource</h3></body></html>\r\n",
|
||||||
@@ -76,14 +76,14 @@ char * proxy_stringtable[] = {
|
|||||||
|
|
||||||
/* 10*/ "HTTP/1.0 404 Not Found\r\n"
|
/* 10*/ "HTTP/1.0 404 Not Found\r\n"
|
||||||
"Proxy-Connection: close\r\n"
|
"Proxy-Connection: close\r\n"
|
||||||
"Content-type: text/html; charset=us-ascii\r\n"
|
"Content-type: text/html; charset=utf-8\r\n"
|
||||||
"\r\n"
|
"\r\n"
|
||||||
"<html><head><title>404 Not Found</title></head>\r\n"
|
"<html><head><title>404 Not Found</title></head>\r\n"
|
||||||
"<body><h2>404 Not Found</h2><h3>File not found</body></html>\r\n",
|
"<body><h2>404 Not Found</h2><h3>File not found</body></html>\r\n",
|
||||||
|
|
||||||
/* 11*/ "HTTP/1.0 403 Forbidden\r\n"
|
/* 11*/ "HTTP/1.0 403 Forbidden\r\n"
|
||||||
"Proxy-Connection: close\r\n"
|
"Proxy-Connection: close\r\n"
|
||||||
"Content-type: text/html; charset=us-ascii\r\n"
|
"Content-type: text/html; charset=utf-8\r\n"
|
||||||
"\r\n"
|
"\r\n"
|
||||||
"<html><head><title>403 Access Denied</title></head>\r\n"
|
"<html><head><title>403 Access Denied</title></head>\r\n"
|
||||||
"<body><h2>403 Access Denied</h2><h3>Access control list denies you to access this resource</body></html>\r\n",
|
"<body><h2>403 Access Denied</h2><h3>Access control list denies you to access this resource</body></html>\r\n",
|
||||||
@@ -94,7 +94,7 @@ char * proxy_stringtable[] = {
|
|||||||
#endif
|
#endif
|
||||||
"Proxy-Authenticate: basic realm=\"proxy\"\r\n"
|
"Proxy-Authenticate: basic realm=\"proxy\"\r\n"
|
||||||
"Proxy-Connection: close\r\n"
|
"Proxy-Connection: close\r\n"
|
||||||
"Content-type: text/html; charset=us-ascii\r\n"
|
"Content-type: text/html; charset=utf-8\r\n"
|
||||||
"\r\n"
|
"\r\n"
|
||||||
"<html><head><title>407 Proxy Authentication Required</title></head>\r\n"
|
"<html><head><title>407 Proxy Authentication Required</title></head>\r\n"
|
||||||
"<body><h2>407 Proxy Authentication Required</h2><h3>Access to requested resource disallowed by administrator or you need valid username/password to use this resource</h3></body></html>\r\n",
|
"<body><h2>407 Proxy Authentication Required</h2><h3>Access to requested resource disallowed by administrator or you need valid username/password to use this resource</h3></body></html>\r\n",
|
||||||
@@ -106,13 +106,13 @@ char * proxy_stringtable[] = {
|
|||||||
|
|
||||||
/* 14*/ "HTTP/1.0 403 Forbidden\r\n"
|
/* 14*/ "HTTP/1.0 403 Forbidden\r\n"
|
||||||
"Proxy-Connection: close\r\n"
|
"Proxy-Connection: close\r\n"
|
||||||
"Content-type: text/html; charset=us-ascii\r\n"
|
"Content-type: text/html; charset=utf-8\r\n"
|
||||||
"\r\n"
|
"\r\n"
|
||||||
"<pre>",
|
"<pre>",
|
||||||
|
|
||||||
/* 15*/ "HTTP/1.0 503 Service Unavailable\r\n"
|
/* 15*/ "HTTP/1.0 503 Service Unavailable\r\n"
|
||||||
"Proxy-Connection: close\r\n"
|
"Proxy-Connection: close\r\n"
|
||||||
"Content-type: text/html; charset=us-ascii\r\n"
|
"Content-type: text/html; charset=utf-8\r\n"
|
||||||
"\r\n"
|
"\r\n"
|
||||||
"<html><head><title>503 Service Unavailable</title></head>\r\n"
|
"<html><head><title>503 Service Unavailable</title></head>\r\n"
|
||||||
"<body><h2>503 Service Unavailable</h2><h3>Your request violates configured policy</h3></body></html>\r\n",
|
"<body><h2>503 Service Unavailable</h2><h3>Your request violates configured policy</h3></body></html>\r\n",
|
||||||
@@ -120,7 +120,7 @@ char * proxy_stringtable[] = {
|
|||||||
/* 16*/ "HTTP/1.0 401 Authentication Required\r\n"
|
/* 16*/ "HTTP/1.0 401 Authentication Required\r\n"
|
||||||
"WWW-Authenticate: basic realm=\"FTP Server\"\r\n"
|
"WWW-Authenticate: basic realm=\"FTP Server\"\r\n"
|
||||||
"Proxy-Connection: close\r\n"
|
"Proxy-Connection: close\r\n"
|
||||||
"Content-type: text/html; charset=us-ascii\r\n"
|
"Content-type: text/html; charset=utf-8\r\n"
|
||||||
"\r\n"
|
"\r\n"
|
||||||
"<html><head><title>401 FTP Server requires authentication</title></head>\r\n"
|
"<html><head><title>401 FTP Server requires authentication</title></head>\r\n"
|
||||||
"<body><h2>401 FTP Server requires authentication</h2><h3>This FTP server rejects anonymous access</h3></body></html>\r\n",
|
"<body><h2>401 FTP Server requires authentication</h2><h3>This FTP server rejects anonymous access</h3></body></html>\r\n",
|
||||||
@@ -131,8 +131,8 @@ char * proxy_stringtable[] = {
|
|||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
#define BUFSIZE 8192
|
|
||||||
#define LINESIZE 4096
|
#define LINESIZE 4096
|
||||||
|
#define BUFSIZE (LINESIZE*2)
|
||||||
#define FTPBUFSIZE 1536
|
#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){
|
||||||
@@ -152,7 +152,7 @@ static void logurl(struct clientparam * param, char * buf, char * req, int ftp){
|
|||||||
strcpy(se, sb);
|
strcpy(se, sb);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(param->res != 555)(*param->srv->logfunc)(param, (unsigned char *)(req?buf:NULL));
|
if(param->res != 555 && param->res != 508)(*param->srv->logfunc)(param, (unsigned char *)(req?buf:NULL));
|
||||||
}
|
}
|
||||||
|
|
||||||
void decodeurl(unsigned char *s, int allowcr){
|
void decodeurl(unsigned char *s, int allowcr){
|
||||||
@@ -264,6 +264,9 @@ for(;;){
|
|||||||
param->remsock = INVALID_SOCKET;
|
param->remsock = INVALID_SOCKET;
|
||||||
param->redirected = 0;
|
param->redirected = 0;
|
||||||
param->redirtype = 0;
|
param->redirtype = 0;
|
||||||
|
memset(¶m->sinsl, 0, sizeof(param->sinsl));
|
||||||
|
memset(¶m->sinsr, 0, sizeof(param->sinsr));
|
||||||
|
memset(¶m->req, 0, sizeof(param->req));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -275,7 +278,7 @@ for(;;){
|
|||||||
buf[i] = 0;
|
buf[i] = 0;
|
||||||
|
|
||||||
if(req) {
|
if(req) {
|
||||||
if(!param->transparent && !param->srv->transparent && param->redirtype != R_HTTP && (i<=prefix || strncasecmp((char *)buf, (char *)req, prefix))){
|
if(!param->transparent && !param->srv->transparent && (i<=prefix || strncasecmp((char *)buf, (char *)req, prefix))){
|
||||||
ckeepalive = 0;
|
ckeepalive = 0;
|
||||||
if(param->remsock != INVALID_SOCKET){
|
if(param->remsock != INVALID_SOCKET){
|
||||||
so._shutdown(param->remsock, SHUT_RDWR);
|
so._shutdown(param->remsock, SHUT_RDWR);
|
||||||
@@ -284,6 +287,9 @@ for(;;){
|
|||||||
param->remsock = INVALID_SOCKET;
|
param->remsock = INVALID_SOCKET;
|
||||||
param->redirected = 0;
|
param->redirected = 0;
|
||||||
param->redirtype = 0;
|
param->redirtype = 0;
|
||||||
|
memset(¶m->sinsl, 0, sizeof(param->sinsl));
|
||||||
|
memset(¶m->sinsr, 0, sizeof(param->sinsr));
|
||||||
|
memset(¶m->req, 0, sizeof(param->req));
|
||||||
}
|
}
|
||||||
myfree(req);
|
myfree(req);
|
||||||
}
|
}
|
||||||
@@ -328,12 +334,12 @@ for(;;){
|
|||||||
prefix = (int)(se - buf);
|
prefix = (int)(se - buf);
|
||||||
su = (unsigned char*)strrchr((char *)sb, '@');
|
su = (unsigned char*)strrchr((char *)sb, '@');
|
||||||
if(su) {
|
if(su) {
|
||||||
su = mystrdup(sb);
|
su = (unsigned char *)mystrdup((char *)sb);
|
||||||
decodeurl(su, 0);
|
decodeurl(su, 0);
|
||||||
parseconnusername((char *)su, (struct clientparam *)param, 1, (unsigned short)((ftp)?21:80));
|
if(parseconnusername((char *)su, (struct clientparam *)param, 1, (unsigned short)((ftp)?21:80))) RETURN (100);
|
||||||
myfree(su);
|
myfree(su);
|
||||||
}
|
}
|
||||||
else parsehostname((char *)sb, (struct clientparam *)param, (unsigned short)((ftp)? 21:80));
|
else if(parsehostname((char *)sb, (struct clientparam *)param, (unsigned short)((ftp)? 21:80))) RETURN(100);
|
||||||
if(!isconnect){
|
if(!isconnect){
|
||||||
if(se==sg)*se-- = ' ';
|
if(se==sg)*se-- = ' ';
|
||||||
*se = '/';
|
*se = '/';
|
||||||
@@ -443,14 +449,18 @@ for(;;){
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if(param->transparent && i > 6 && !strncasecmp((char *)buf + inbuf, "Host:", 5)){
|
if(param->transparent && i > 6 && !strncasecmp((char *)buf + inbuf, "Host:", 5)){
|
||||||
|
unsigned char c;
|
||||||
sb = (unsigned char *)strchr((char *)(buf+inbuf), ':');
|
sb = (unsigned char *)strchr((char *)(buf+inbuf), ':');
|
||||||
if(!sb)continue;
|
if(!sb)continue;
|
||||||
++sb;
|
++sb;
|
||||||
while(isspace(*sb))sb++;
|
while(isspace(*sb))sb++;
|
||||||
se = (unsigned char *)strchr((char *)sb, '\r');
|
(se = (unsigned char *)strchr((char *)sb, '\r')) || (se = (unsigned char *)strchr((char *)sb, '\n'));
|
||||||
if(se) *se = 0;
|
if(se) {
|
||||||
|
c = *se;
|
||||||
|
*se = 0;
|
||||||
|
}
|
||||||
if(!param->hostname){
|
if(!param->hostname){
|
||||||
parsehostname((char *)sb, param, 80);
|
if(parsehostname((char *)sb, param, 80)) RETURN(100);
|
||||||
}
|
}
|
||||||
newbuf = myalloc(strlen((char *)req) + strlen((char *)(buf+inbuf)) + 8);
|
newbuf = myalloc(strlen((char *)req) + strlen((char *)(buf+inbuf)) + 8);
|
||||||
if(newbuf){
|
if(newbuf){
|
||||||
@@ -460,7 +470,7 @@ for(;;){
|
|||||||
myfree(req);
|
myfree(req);
|
||||||
req = newbuf;
|
req = newbuf;
|
||||||
}
|
}
|
||||||
if(se)*se = '\r';
|
if(se)*se = c;
|
||||||
}
|
}
|
||||||
if(ftp && i > 13 && (!strncasecmp((char *)(buf+inbuf), "authorization", 13))){
|
if(ftp && i > 13 && (!strncasecmp((char *)(buf+inbuf), "authorization", 13))){
|
||||||
sb = (unsigned char *)strchr((char *)(buf+inbuf), ':');
|
sb = (unsigned char *)strchr((char *)(buf+inbuf), ':');
|
||||||
@@ -490,7 +500,7 @@ for(;;){
|
|||||||
if(!sb)continue;
|
if(!sb)continue;
|
||||||
++sb;
|
++sb;
|
||||||
while(isspace(*sb))sb++;
|
while(isspace(*sb))sb++;
|
||||||
sscanf(sb, "%"PRINTF_INT64_MODIFIER"u",&contentlength64);
|
sscanf((char *)sb, "%"PRINTF_INT64_MODIFIER"u",&contentlength64);
|
||||||
if(param->maxtrafout64 && (param->maxtrafout64 < param->statscli64 || contentlength64 > param->maxtrafout64 - param->statscli64)){
|
if(param->maxtrafout64 && (param->maxtrafout64 < param->statscli64 || contentlength64 > param->maxtrafout64 - param->statscli64)){
|
||||||
RETURN(10);
|
RETURN(10);
|
||||||
}
|
}
|
||||||
@@ -510,7 +520,7 @@ for(;;){
|
|||||||
|
|
||||||
buf[inbuf] = 0;
|
buf[inbuf] = 0;
|
||||||
|
|
||||||
reqsize = (int)strlen(req);
|
reqsize = (int)strlen((char *)req);
|
||||||
reqbufsize = reqsize + 1;
|
reqbufsize = reqsize + 1;
|
||||||
|
|
||||||
#ifndef WITHMAIN
|
#ifndef WITHMAIN
|
||||||
@@ -529,7 +539,7 @@ for(;;){
|
|||||||
uint64_t newlen64;
|
uint64_t newlen64;
|
||||||
newlen64 = sockfillbuffcli(param, (unsigned long)contentlength64, CONNECTION_S);
|
newlen64 = sockfillbuffcli(param, (unsigned long)contentlength64, CONNECTION_S);
|
||||||
if(newlen64 == contentlength64) {
|
if(newlen64 == contentlength64) {
|
||||||
action = handledatfltcli(param, ¶m->clibuf, ¶m->clibufsize, 0, ¶m->cliinbuf);
|
action = handledatfltcli(param, ¶m->clibuf, (int *)¶m->clibufsize, 0, (int *)¶m->cliinbuf);
|
||||||
if(action == HANDLED){
|
if(action == HANDLED){
|
||||||
RETURN(0);
|
RETURN(0);
|
||||||
}
|
}
|
||||||
@@ -542,6 +552,7 @@ for(;;){
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
if(param->srv->needuser > 1 && !param->username) {RETURN(4);}
|
||||||
if((res = (*param->srv->authfunc)(param))) {RETURN(res);}
|
if((res = (*param->srv->authfunc)(param))) {RETURN(res);}
|
||||||
|
|
||||||
if(ftp && param->redirtype != R_HTTP){
|
if(ftp && param->redirtype != R_HTTP){
|
||||||
@@ -803,7 +814,8 @@ for(;;){
|
|||||||
|
|
||||||
else {
|
else {
|
||||||
redirect = 1;
|
redirect = 1;
|
||||||
if(socksend(param->remsock, req , (res = (int)strlen((char *)req)), conf.timeouts[STRING_L]) != res) {
|
res = (int)strlen((char *)req);
|
||||||
|
if(socksend(param->remsock, req , res, conf.timeouts[STRING_L]) != res) {
|
||||||
RETURN(518);
|
RETURN(518);
|
||||||
}
|
}
|
||||||
param->statscli64 += res;
|
param->statscli64 += res;
|
||||||
@@ -838,7 +850,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, "%.128s:%.64s", param->extusername, param->extpassword?param->extpassword:(unsigned char*)"");
|
sprintf((char*)username, "%.128s:%.128s", 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");
|
||||||
}
|
}
|
||||||
@@ -893,7 +905,7 @@ for(;;){
|
|||||||
if(!sb)continue;
|
if(!sb)continue;
|
||||||
++sb;
|
++sb;
|
||||||
while(isspace(*sb))sb++;
|
while(isspace(*sb))sb++;
|
||||||
sscanf(sb, "%"PRINTF_INT64_MODIFIER"u", &contentlength64);
|
sscanf((char *)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;
|
||||||
@@ -909,7 +921,7 @@ for(;;){
|
|||||||
if(!sb)continue;
|
if(!sb)continue;
|
||||||
++sb;
|
++sb;
|
||||||
while(isspace(*sb))sb++;
|
while(isspace(*sb))sb++;
|
||||||
if(!strncasecmp(sb, "chunked", 7)){
|
if(!strncasecmp((char *)sb, "chunked", 7)){
|
||||||
param->chunked = 1;
|
param->chunked = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -959,7 +971,7 @@ for(;;){
|
|||||||
uint64_t newlen;
|
uint64_t newlen;
|
||||||
newlen = (uint64_t)sockfillbuffsrv(param, (unsigned long) contentlength64, CONNECTION_S);
|
newlen = (uint64_t)sockfillbuffsrv(param, (unsigned long) contentlength64, CONNECTION_S);
|
||||||
if(newlen == contentlength64) {
|
if(newlen == contentlength64) {
|
||||||
action = handledatfltsrv(param, ¶m->srvbuf, ¶m->srvbufsize, 0, ¶m->srvinbuf);
|
action = handledatfltsrv(param, ¶m->srvbuf, (int *)¶m->srvbufsize, 0, (int *)¶m->srvinbuf);
|
||||||
param->nolongdatfilter = 1;
|
param->nolongdatfilter = 1;
|
||||||
if(action == HANDLED){
|
if(action == HANDLED){
|
||||||
RETURN(0);
|
RETURN(0);
|
||||||
@@ -992,7 +1004,7 @@ for(;;){
|
|||||||
if((param->chunked || contentlength64 > 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];
|
unsigned char smallbuf[32];
|
||||||
while ((i = sockgetlinebuf(param, SERVER, smallbuf, 30, '\n', conf.timeouts[STRING_S])) == 2) {
|
while ((i = sockgetlinebuf(param, SERVER, smallbuf, 30, '\n', conf.timeouts[STRING_S])) == 2) {
|
||||||
if (socksend(param->clisock, smallbuf, i, conf.timeouts[STRING_S]) != i){
|
if (socksend(param->clisock, smallbuf, i, conf.timeouts[STRING_S]) != i){
|
||||||
RETURN(533);
|
RETURN(533);
|
||||||
@@ -1015,7 +1027,7 @@ for(;;){
|
|||||||
}
|
}
|
||||||
smallbuf[i] = 0;
|
smallbuf[i] = 0;
|
||||||
contentlength64 = 0;
|
contentlength64 = 0;
|
||||||
sscanf(smallbuf, "%"PRINTF_INT64_MODIFIER"x", &contentlength64);
|
sscanf((char *)smallbuf, "%"PRINTF_INT64_MODIFIER"x", &contentlength64);
|
||||||
if(contentlength64 == 0) {
|
if(contentlength64 == 0) {
|
||||||
param->chunked = 2;
|
param->chunked = 2;
|
||||||
}
|
}
|
||||||
@@ -1048,7 +1060,7 @@ REQUESTEND:
|
|||||||
RETURN(0);
|
RETURN(0);
|
||||||
}
|
}
|
||||||
if(param->transparent && (!ckeepalive || !keepalive)) {RETURN (0);}
|
if(param->transparent && (!ckeepalive || !keepalive)) {RETURN (0);}
|
||||||
logurl(param, buf, (char *)req, ftp);
|
logurl(param, (char *)buf, (char *)req, ftp);
|
||||||
param->status = 0;
|
param->status = 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1095,7 +1107,7 @@ CLEANRET:
|
|||||||
socksend(param->clisock, (unsigned char *)proxy_stringtable[0], (int)strlen(proxy_stringtable[0]), conf.timeouts[STRING_S]);
|
socksend(param->clisock, (unsigned char *)proxy_stringtable[0], (int)strlen(proxy_stringtable[0]), conf.timeouts[STRING_S]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
logurl(param, buf, (char *)req, ftp);
|
logurl(param, (char *)buf, (char *)req, ftp);
|
||||||
if(req)myfree(req);
|
if(req)myfree(req);
|
||||||
if(buf)myfree(buf);
|
if(buf)myfree(buf);
|
||||||
if(ftpbase)myfree(ftpbase);
|
if(ftpbase)myfree(ftpbase);
|
||||||
|
|||||||
+6
-19
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define COPYRIGHT "(c)2000-2009 3APA3A, Vladimir Dubrovin & 3proxy.ru\n"\
|
#define COPYRIGHT "(c)3APA3A, Vladimir Dubrovin & 3proxy.ru\n"\
|
||||||
"Documentation and sources: http://3proxy.ru/\n"\
|
"Documentation and sources: http://3proxy.ru/\n"\
|
||||||
"Please read license agreement in \'copying\' file.\n"\
|
"Please read license agreement in \'copying\' file.\n"\
|
||||||
"You may not use this program without accepting license agreement"
|
"You may not use this program without accepting license agreement"
|
||||||
@@ -21,7 +21,6 @@
|
|||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <sys/timeb.h>
|
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
|
||||||
@@ -30,22 +29,14 @@
|
|||||||
#define _PASSWORD_LEN 256
|
#define _PASSWORD_LEN 256
|
||||||
#define MAXNSERVERS 5
|
#define MAXNSERVERS 5
|
||||||
|
|
||||||
#define ALLOW 0
|
|
||||||
#define DENY 1
|
|
||||||
#define REDIRECT 2
|
|
||||||
#define BANDLIM 3
|
|
||||||
#define NOBANDLIM 4
|
|
||||||
#define COUNTIN 5
|
|
||||||
#define NOCOUNTIN 6
|
|
||||||
#define COUNTOUT 7
|
|
||||||
#define NOCOUNTOUT 8
|
|
||||||
|
|
||||||
#define UDPBUFSIZE 16384
|
#define UDPBUFSIZE 16384
|
||||||
#define TCPBUFSIZE 8192
|
#define TCPBUFSIZE 8192
|
||||||
|
#define SRVBUFSIZE (param->srv->bufsize?param->srv->bufsize:((param->service == S_UDPPM)?UDPBUFSIZE:TCPBUFSIZE))
|
||||||
|
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#include <winsock2.h>
|
#include <winsock2.h>
|
||||||
|
#include <sys/timeb.h>
|
||||||
#ifndef _WINCE
|
#ifndef _WINCE
|
||||||
#include <io.h>
|
#include <io.h>
|
||||||
#else
|
#else
|
||||||
@@ -104,7 +95,7 @@
|
|||||||
#define PTHREAD_STACK_MIN 32768
|
#define PTHREAD_STACK_MIN 32768
|
||||||
#define sockerror strerror
|
#define sockerror strerror
|
||||||
#endif
|
#endif
|
||||||
#define daemonize() daemon(1,1)
|
void daemonize(void);
|
||||||
#define SLEEPTIME 1000
|
#define SLEEPTIME 1000
|
||||||
#ifndef O_BINARY
|
#ifndef O_BINARY
|
||||||
#define O_BINARY 0
|
#define O_BINARY 0
|
||||||
@@ -122,8 +113,6 @@
|
|||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#define strcasecmp stricmp
|
#define strcasecmp stricmp
|
||||||
#define strncasecmp strnicmp
|
#define strncasecmp strnicmp
|
||||||
#else
|
|
||||||
extern pthread_attr_t pa;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef SOCKET_ERROR
|
#ifndef SOCKET_ERROR
|
||||||
@@ -190,7 +179,7 @@ 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_ntop(int af, void *src, char *dst, socklen_t size);
|
int myinet_ntop(int af, void *src, char *dst, socklen_t size);
|
||||||
extern struct nserver nservers[MAXNSERVERS];
|
extern struct nserver nservers[MAXNSERVERS];
|
||||||
struct nserver authnserver;
|
extern struct nserver authnserver;
|
||||||
unsigned long getip(unsigned char *name);
|
unsigned long getip(unsigned char *name);
|
||||||
unsigned long getip46(int family, unsigned char *name, struct sockaddr *sa);
|
unsigned long getip46(int family, unsigned char *name, struct sockaddr *sa);
|
||||||
unsigned long myresolver(int, unsigned char *, unsigned char *);
|
unsigned long myresolver(int, unsigned char *, unsigned char *);
|
||||||
@@ -235,7 +224,7 @@ void mschap(const unsigned char *win_password,
|
|||||||
struct hashtable;
|
struct hashtable;
|
||||||
void hashadd(struct hashtable *ht, const unsigned char* name, unsigned char* 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 parsehost(int family, unsigned 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);
|
||||||
@@ -316,8 +305,6 @@ 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;
|
||||||
extern pthread_mutex_t log_mutex;
|
extern pthread_mutex_t log_mutex;
|
||||||
extern int logmutexinit;
|
|
||||||
|
|
||||||
extern struct datatype datatypes[64];
|
extern struct datatype datatypes[64];
|
||||||
|
|
||||||
extern struct commands commandhandlers[];
|
extern struct commands commandhandlers[];
|
||||||
|
|||||||
+115
-54
@@ -8,6 +8,7 @@
|
|||||||
|
|
||||||
#include "proxy.h"
|
#include "proxy.h"
|
||||||
|
|
||||||
|
pthread_mutex_t log_mutex;
|
||||||
|
|
||||||
#define param ((struct clientparam *) p)
|
#define param ((struct clientparam *) p)
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
@@ -22,21 +23,21 @@ void * threadfunc (void *p) {
|
|||||||
param->remsock = so._accept(param->srv->cbsock, (struct sockaddr*)¶m->sinsr, &size);
|
param->remsock = so._accept(param->srv->cbsock, (struct sockaddr*)¶m->sinsr, &size);
|
||||||
if(param->remsock == INVALID_SOCKET) {
|
if(param->remsock == INVALID_SOCKET) {
|
||||||
param->res = 13;
|
param->res = 13;
|
||||||
param->srv->logfunc(param, "Connect back accept() failed");
|
param->srv->logfunc(param, (unsigned char *)"Connect back accept() failed");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
#ifndef WITHMAIN
|
#ifndef WITHMAIN
|
||||||
memcpy(¶m->req, ¶m->sinsr, size);
|
param->req = param->sinsr;
|
||||||
if(param->srv->acl) param->res = checkACL(param);
|
if(param->srv->acl) param->res = checkACL(param);
|
||||||
if(param->res){
|
if(param->res){
|
||||||
param->srv->logfunc(param, "Connect back ACL failed");
|
param->srv->logfunc(param, (unsigned char *)"Connect back ACL failed");
|
||||||
so._closesocket(param->remsock);
|
so._closesocket(param->remsock);
|
||||||
param->remsock = INVALID_SOCKET;
|
param->remsock = INVALID_SOCKET;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
if(so._sendto(param->remsock, "C", 1, 0, (struct sockaddr*)¶m->sinsr, size) != 1){
|
if(so._sendto(param->remsock, "C", 1, 0, (struct sockaddr*)¶m->sinsr, size) != 1){
|
||||||
param->srv->logfunc(param, "Connect back sending command failed");
|
param->srv->logfunc(param, (unsigned char *)"Connect back sending command failed");
|
||||||
so._closesocket(param->remsock);
|
so._closesocket(param->remsock);
|
||||||
param->remsock = INVALID_SOCKET;
|
param->remsock = INVALID_SOCKET;
|
||||||
continue;
|
continue;
|
||||||
@@ -124,7 +125,8 @@ int MODULEMAINFUNC (int argc, char** argv){
|
|||||||
" -fFORMAT logging format (see documentation)\n"
|
" -fFORMAT logging format (see documentation)\n"
|
||||||
" -l log to stderr\n"
|
" -l log to stderr\n"
|
||||||
" -lFILENAME log to FILENAME\n"
|
" -lFILENAME log to FILENAME\n"
|
||||||
" -bBUFSIZE size of network buffer (default 4096 for TCP, 16384 for UDP)\n"
|
" -b(BUFSIZE) size of network buffer (default 4096 for TCP, 16384 for UDP)\n"
|
||||||
|
" -S(STACKSIZE) value to add to default client thread stack size\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"
|
||||||
@@ -138,6 +140,7 @@ int MODULEMAINFUNC (int argc, char** argv){
|
|||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
unsigned long ul = 1;
|
unsigned long ul = 1;
|
||||||
#else
|
#else
|
||||||
|
pthread_attr_t pa;
|
||||||
#ifdef STDMAIN
|
#ifdef STDMAIN
|
||||||
int inetd = 0;
|
int inetd = 0;
|
||||||
#endif
|
#endif
|
||||||
@@ -173,13 +176,9 @@ int MODULEMAINFUNC (int argc, char** argv){
|
|||||||
#else
|
#else
|
||||||
signal(SIGPIPE, SIG_IGN);
|
signal(SIGPIPE, SIG_IGN);
|
||||||
|
|
||||||
pthread_attr_init(&pa);
|
|
||||||
pthread_attr_setstacksize(&pa,PTHREAD_STACK_MIN + 8192);
|
|
||||||
pthread_attr_setdetachstate(&pa,PTHREAD_CREATE_DETACHED);
|
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
srvinit(&srv, &defparam);
|
srvinit(&srv, &defparam);
|
||||||
srv.pf = childdef.pf;
|
srv.pf = childdef.pf;
|
||||||
isudp = childdef.isudp;
|
isudp = childdef.isudp;
|
||||||
@@ -197,6 +196,7 @@ int MODULEMAINFUNC (int argc, char** argv){
|
|||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
srv.needuser = 0;
|
srv.needuser = 0;
|
||||||
|
pthread_mutex_init(&log_mutex, NULL);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
for (i=1; i<argc; i++) {
|
for (i=1; i<argc; i++) {
|
||||||
@@ -209,7 +209,7 @@ int MODULEMAINFUNC (int argc, char** argv){
|
|||||||
case 'l':
|
case 'l':
|
||||||
srv.logfunc = logstdout;
|
srv.logfunc = logstdout;
|
||||||
if(srv.logtarget) myfree(srv.logtarget);
|
if(srv.logtarget) myfree(srv.logtarget);
|
||||||
srv.logtarget = mystrdup((unsigned char*)argv[i] + 2);
|
srv.logtarget = (unsigned char *)mystrdup(argv[i] + 2);
|
||||||
if(argv[i][2]) {
|
if(argv[i][2]) {
|
||||||
if(argv[i][2]=='@'){
|
if(argv[i][2]=='@'){
|
||||||
|
|
||||||
@@ -232,16 +232,20 @@ int MODULEMAINFUNC (int argc, char** argv){
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'i':
|
case 'i':
|
||||||
getip46(46, argv[i]+2, (struct sockaddr *)&srv.intsa);
|
getip46(46, (unsigned char *)argv[i]+2, (struct sockaddr *)&srv.intsa);
|
||||||
break;
|
break;
|
||||||
case 'e':
|
case 'e':
|
||||||
{
|
{
|
||||||
#ifndef NOIPV6
|
#ifndef NOIPV6
|
||||||
struct sockaddr_in6 sa6;
|
struct sockaddr_in6 sa6;
|
||||||
error = !getip46(46, argv[i]+2, (struct sockaddr *)&sa6);
|
memset(&sa6, 0, sizeof(sa6));
|
||||||
if(!error) memcpy((*SAFAMILY(&sa6)==AF_INET)?(void *)&srv.extsa:(void *)&srv.extsa6, &sa6, SASIZE(&sa6));
|
error = !getip46(46, (unsigned char *)argv[i]+2, (struct sockaddr *)&sa6);
|
||||||
|
if(!error) {
|
||||||
|
if (*SAFAMILY(&sa6)==AF_INET) srv.extsa = sa6;
|
||||||
|
else srv.extsa6 = sa6;
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
error = !getip46(46, argv[i]+2, (struct sockaddr *)&srv.extsa);
|
error = !getip46(46, (unsigned char *)argv[i]+2, (struct sockaddr *)&srv.extsa);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -263,7 +267,7 @@ int MODULEMAINFUNC (int argc, char** argv){
|
|||||||
case 'I':
|
case 'I':
|
||||||
size = sizeof(defparam.sincl);
|
size = sizeof(defparam.sincl);
|
||||||
if(so._getsockname(0, (struct sockaddr*)&defparam.sincl, &size) ||
|
if(so._getsockname(0, (struct sockaddr*)&defparam.sincl, &size) ||
|
||||||
SAFAMILY(&defparam.sincl) != AF_INET) error = 1;
|
*SAFAMILY(&defparam.sincl) != AF_INET) error = 1;
|
||||||
|
|
||||||
else inetd = 1;
|
else inetd = 1;
|
||||||
break;
|
break;
|
||||||
@@ -271,7 +275,7 @@ int MODULEMAINFUNC (int argc, char** argv){
|
|||||||
#endif
|
#endif
|
||||||
case 'f':
|
case 'f':
|
||||||
if(srv.logformat)myfree(srv.logformat);
|
if(srv.logformat)myfree(srv.logformat);
|
||||||
srv.logformat = mystrdup((unsigned char *)argv[i] + 2);
|
srv.logformat = (unsigned char *)mystrdup(argv[i] + 2);
|
||||||
break;
|
break;
|
||||||
case 't':
|
case 't':
|
||||||
srv.silent = 1;
|
srv.silent = 1;
|
||||||
@@ -280,11 +284,11 @@ int MODULEMAINFUNC (int argc, char** argv){
|
|||||||
hostname = argv[i] + 2;
|
hostname = argv[i] + 2;
|
||||||
break;
|
break;
|
||||||
case 'r':
|
case 'r':
|
||||||
cbc_string = mystrdup(argv[i] + 2);
|
cbc_string = (unsigned char *)mystrdup(argv[i] + 2);
|
||||||
iscbc = 1;
|
iscbc = 1;
|
||||||
break;
|
break;
|
||||||
case 'R':
|
case 'R':
|
||||||
cbl_string = mystrdup(argv[i] + 2);
|
cbl_string = (unsigned char *)mystrdup(argv[i] + 2);
|
||||||
iscbl = 1;
|
iscbl = 1;
|
||||||
break;
|
break;
|
||||||
case 'u':
|
case 'u':
|
||||||
@@ -294,6 +298,9 @@ int MODULEMAINFUNC (int argc, char** argv){
|
|||||||
case 'T':
|
case 'T':
|
||||||
srv.transparent = 1;
|
srv.transparent = 1;
|
||||||
break;
|
break;
|
||||||
|
case 'S':
|
||||||
|
srv.stacksize = atoi(argv[i]+2);
|
||||||
|
break;
|
||||||
case 's':
|
case 's':
|
||||||
case 'a':
|
case 'a':
|
||||||
srv.singlepacket = 1 + atoi(argv[i]+2);
|
srv.singlepacket = 1 + atoi(argv[i]+2);
|
||||||
@@ -385,7 +392,7 @@ int MODULEMAINFUNC (int argc, char** argv){
|
|||||||
if(! (newparam = myalloc (sizeof(defparam)))){
|
if(! (newparam = myalloc (sizeof(defparam)))){
|
||||||
return 2;
|
return 2;
|
||||||
};
|
};
|
||||||
memcpy(newparam, &defparam, sizeof(defparam));
|
*newparam = defparam;
|
||||||
return((*srv.pf)((void *)newparam)? 1:0);
|
return((*srv.pf)((void *)newparam)? 1:0);
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -437,10 +444,10 @@ int MODULEMAINFUNC (int argc, char** argv){
|
|||||||
#endif
|
#endif
|
||||||
srv.srvsock = sock;
|
srv.srvsock = sock;
|
||||||
opt = 1;
|
opt = 1;
|
||||||
if(so._setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (unsigned char *)&opt, sizeof(int)))perror("setsockopt()");
|
if(so._setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (char *)&opt, sizeof(int)))perror("setsockopt()");
|
||||||
#ifdef SO_REUSEPORT
|
#ifdef SO_REUSEPORT
|
||||||
opt = 1;
|
opt = 1;
|
||||||
so._setsockopt(sock, SOL_SOCKET, SO_REUSEPORT, (unsigned char *)&opt, sizeof(int));
|
so._setsockopt(sock, SOL_SOCKET, SO_REUSEPORT, (char *)&opt, sizeof(int));
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
size = sizeof(srv.intsa);
|
size = sizeof(srv.intsa);
|
||||||
@@ -471,22 +478,22 @@ int MODULEMAINFUNC (int argc, char** argv){
|
|||||||
if(iscbl){
|
if(iscbl){
|
||||||
parsehost(srv.family, cbl_string, (struct sockaddr *)&cbsa);
|
parsehost(srv.family, cbl_string, (struct sockaddr *)&cbsa);
|
||||||
if((srv.cbsock=so._socket(SASOCK(&cbsa), SOCK_STREAM, IPPROTO_TCP))==INVALID_SOCKET) {
|
if((srv.cbsock=so._socket(SASOCK(&cbsa), SOCK_STREAM, IPPROTO_TCP))==INVALID_SOCKET) {
|
||||||
(*srv.logfunc)(&defparam, "Failed to allocate connect back socket");
|
(*srv.logfunc)(&defparam, (unsigned char *)"Failed to allocate connect back socket");
|
||||||
return -6;
|
return -6;
|
||||||
}
|
}
|
||||||
opt = 1;
|
opt = 1;
|
||||||
so._setsockopt(srv.cbsock, SOL_SOCKET, SO_REUSEADDR, (unsigned char *)&opt, sizeof(int));
|
so._setsockopt(srv.cbsock, SOL_SOCKET, SO_REUSEADDR, (char *)&opt, sizeof(int));
|
||||||
#ifdef SO_REUSEPORT
|
#ifdef SO_REUSEPORT
|
||||||
opt = 1;
|
opt = 1;
|
||||||
so._setsockopt(srv.cbsock, SOL_SOCKET, SO_REUSEPORT, (unsigned char *)&opt, sizeof(int));
|
so._setsockopt(srv.cbsock, SOL_SOCKET, SO_REUSEPORT, (char *)&opt, sizeof(int));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if(so._bind(srv.cbsock, (struct sockaddr*)&cbsa, SASIZE(&cbsa))==-1) {
|
if(so._bind(srv.cbsock, (struct sockaddr*)&cbsa, SASIZE(&cbsa))==-1) {
|
||||||
(*srv.logfunc)(&defparam, "Failed to bind connect back socket");
|
(*srv.logfunc)(&defparam, (unsigned char *)"Failed to bind connect back socket");
|
||||||
return -7;
|
return -7;
|
||||||
}
|
}
|
||||||
if(so._listen(srv.cbsock, 1 + (srv.maxchild>>4))==-1) {
|
if(so._listen(srv.cbsock, 1 + (srv.maxchild>>4))==-1) {
|
||||||
(*srv.logfunc)(&defparam, "Failed to listen connect back socket");
|
(*srv.logfunc)(&defparam, (unsigned char *)"Failed to listen connect back socket");
|
||||||
return -8;
|
return -8;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -494,20 +501,25 @@ int MODULEMAINFUNC (int argc, char** argv){
|
|||||||
srv.fds.fd = sock;
|
srv.fds.fd = sock;
|
||||||
srv.fds.events = POLLIN;
|
srv.fds.events = POLLIN;
|
||||||
|
|
||||||
|
#ifndef _WIN32
|
||||||
|
pthread_attr_init(&pa);
|
||||||
|
pthread_attr_setstacksize(&pa,PTHREAD_STACK_MIN + (16384 + srv.stacksize));
|
||||||
|
pthread_attr_setdetachstate(&pa,PTHREAD_CREATE_DETACHED);
|
||||||
|
#endif
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
for(;;){
|
for(;;){
|
||||||
while((conf.paused == srv.version && srv.childcount >= srv.maxchild)){
|
while((conf.paused == srv.paused && srv.childcount >= srv.maxchild)){
|
||||||
nlog++;
|
nlog++;
|
||||||
if(nlog > 5000) {
|
if(!srv.silent && nlog > 5000) {
|
||||||
sprintf((char *)buf, "Warning: too many connected clients (%d/%d)", srv.childcount, srv.maxchild);
|
sprintf((char *)buf, "Warning: too many connected clients (%d/%d)", srv.childcount, srv.maxchild);
|
||||||
if(!srv.silent)(*srv.logfunc)(&defparam, buf);
|
(*srv.logfunc)(&defparam, buf);
|
||||||
nlog = 0;
|
nlog = 0;
|
||||||
}
|
}
|
||||||
usleep(SLEEPTIME);
|
usleep(SLEEPTIME);
|
||||||
}
|
}
|
||||||
if (iscbc) break;
|
if (iscbc) break;
|
||||||
if (conf.paused != srv.version) break;
|
if (conf.paused != srv.paused) 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);
|
||||||
}
|
}
|
||||||
@@ -523,7 +535,8 @@ int MODULEMAINFUNC (int argc, char** argv){
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if((conf.paused != srv.version) || (error < 0)) break;
|
if((conf.paused != srv.paused) || (error < 0)) break;
|
||||||
|
error = 0;
|
||||||
if(!isudp){
|
if(!isudp){
|
||||||
size = sizeof(defparam.sincr);
|
size = sizeof(defparam.sincr);
|
||||||
if(iscbc){
|
if(iscbc){
|
||||||
@@ -536,7 +549,7 @@ int MODULEMAINFUNC (int argc, char** argv){
|
|||||||
usleep(SLEEPTIME);
|
usleep(SLEEPTIME);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if(so._recvfrom(new_sock,buf,1,0,(struct sockaddr*)&defparam.sincr, &size) != 1) {
|
if(so._recvfrom(new_sock,(char *)buf,1,0,(struct sockaddr*)&defparam.sincr, &size) != 1) {
|
||||||
so._closesocket(new_sock);
|
so._closesocket(new_sock);
|
||||||
new_sock = INVALID_SOCKET;
|
new_sock = INVALID_SOCKET;
|
||||||
usleep(SLEEPTIME);
|
usleep(SLEEPTIME);
|
||||||
@@ -551,8 +564,47 @@ int MODULEMAINFUNC (int argc, char** argv){
|
|||||||
else {
|
else {
|
||||||
new_sock = so._accept(sock, (struct sockaddr*)&defparam.sincr, &size);
|
new_sock = so._accept(sock, (struct sockaddr*)&defparam.sincr, &size);
|
||||||
if(new_sock == INVALID_SOCKET){
|
if(new_sock == INVALID_SOCKET){
|
||||||
|
#ifdef _WIN32
|
||||||
|
switch(WSAGetLastError()){
|
||||||
|
case WSAEMFILE:
|
||||||
|
case WSAENOBUFS:
|
||||||
|
case WSAENETDOWN:
|
||||||
|
usleep(SLEEPTIME * 10);
|
||||||
|
break;
|
||||||
|
case WSAEINTR:
|
||||||
|
error = 1;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
switch (errno){
|
||||||
|
#ifdef EMFILE
|
||||||
|
case EMFILE:
|
||||||
|
#endif
|
||||||
|
#ifdef ENFILE
|
||||||
|
case ENFILE:
|
||||||
|
#endif
|
||||||
|
#ifdef ENOBUFS
|
||||||
|
case ENOBUFS:
|
||||||
|
#endif
|
||||||
|
#ifdef ENOMEM
|
||||||
|
case ENOMEM:
|
||||||
|
#endif
|
||||||
|
usleep(SLEEPTIME * 10);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
nlog++;
|
||||||
|
if(!srv.silent && (error || nlog > 5000)) {
|
||||||
sprintf((char *)buf, "accept(): %s", strerror(errno));
|
sprintf((char *)buf, "accept(): %s", strerror(errno));
|
||||||
if(!srv.silent)(*srv.logfunc)(&defparam, buf);
|
(*srv.logfunc)(&defparam, buf);
|
||||||
|
nlog = 0;
|
||||||
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -567,8 +619,8 @@ int MODULEMAINFUNC (int argc, char** argv){
|
|||||||
#else
|
#else
|
||||||
fcntl(new_sock,F_SETFL,O_NONBLOCK);
|
fcntl(new_sock,F_SETFL,O_NONBLOCK);
|
||||||
#endif
|
#endif
|
||||||
so._setsockopt(new_sock, SOL_SOCKET, SO_LINGER, (unsigned char *)&lg, sizeof(lg));
|
so._setsockopt(new_sock, SOL_SOCKET, SO_LINGER, (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, (char *)&opt, sizeof(int));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
srv.fds.events = 0;
|
srv.fds.events = 0;
|
||||||
@@ -580,8 +632,8 @@ int MODULEMAINFUNC (int argc, char** argv){
|
|||||||
usleep(SLEEPTIME);
|
usleep(SLEEPTIME);
|
||||||
continue;
|
continue;
|
||||||
};
|
};
|
||||||
memcpy(newparam, &defparam, sizeof(defparam));
|
*newparam = defparam;
|
||||||
if(defparam.hostname)newparam->hostname=strdup(defparam.hostname);
|
if(defparam.hostname)newparam->hostname=(unsigned char *)mystrdup((char *)defparam.hostname);
|
||||||
clearstat(newparam);
|
clearstat(newparam);
|
||||||
if(!isudp) newparam->clisock = new_sock;
|
if(!isudp) newparam->clisock = new_sock;
|
||||||
#ifndef STDMAIN
|
#ifndef STDMAIN
|
||||||
@@ -591,6 +643,7 @@ int MODULEMAINFUNC (int argc, char** argv){
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
newparam->prev = newparam->next = NULL;
|
newparam->prev = newparam->next = NULL;
|
||||||
|
error = 0;
|
||||||
pthread_mutex_lock(&srv.counter_mutex);
|
pthread_mutex_lock(&srv.counter_mutex);
|
||||||
if(!srv.child){
|
if(!srv.child){
|
||||||
srv.child = newparam;
|
srv.child = newparam;
|
||||||
@@ -601,9 +654,9 @@ int MODULEMAINFUNC (int argc, char** argv){
|
|||||||
}
|
}
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#ifndef _WINCE
|
#ifndef _WINCE
|
||||||
h = (HANDLE)_beginthreadex((LPSECURITY_ATTRIBUTES )NULL, (unsigned)16384, threadfunc, (void *) newparam, 0, &thread);
|
h = (HANDLE)_beginthreadex((LPSECURITY_ATTRIBUTES )NULL, (unsigned)(16384 + srv.stacksize), (void *)threadfunc, (void *) newparam, 0, &thread);
|
||||||
#else
|
#else
|
||||||
h = (HANDLE)CreateThread((LPSECURITY_ATTRIBUTES )NULL, (unsigned)16384, threadfunc, (void *) newparam, 0, &thread);
|
h = (HANDLE)CreateThread((LPSECURITY_ATTRIBUTES )NULL, (unsigned)(16384 + srv.stacksize), (void *)threadfunc, (void *) newparam, 0, &thread);
|
||||||
#endif
|
#endif
|
||||||
srv.childcount++;
|
srv.childcount++;
|
||||||
if (h) {
|
if (h) {
|
||||||
@@ -613,7 +666,7 @@ int MODULEMAINFUNC (int argc, char** argv){
|
|||||||
else {
|
else {
|
||||||
sprintf((char *)buf, "_beginthreadex(): %s", _strerror(NULL));
|
sprintf((char *)buf, "_beginthreadex(): %s", _strerror(NULL));
|
||||||
if(!srv.silent)(*srv.logfunc)(&defparam, buf);
|
if(!srv.silent)(*srv.logfunc)(&defparam, buf);
|
||||||
freeparam(newparam);
|
error = 1;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
|
||||||
@@ -622,13 +675,14 @@ int MODULEMAINFUNC (int argc, char** argv){
|
|||||||
if(error){
|
if(error){
|
||||||
sprintf((char *)buf, "pthread_create(): %s", strerror(error));
|
sprintf((char *)buf, "pthread_create(): %s", strerror(error));
|
||||||
if(!srv.silent)(*srv.logfunc)(&defparam, buf);
|
if(!srv.silent)(*srv.logfunc)(&defparam, buf);
|
||||||
freeparam(newparam);
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
newparam->threadid = (unsigned)thread;
|
newparam->threadid = (unsigned)thread;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
pthread_mutex_unlock(&srv.counter_mutex);
|
pthread_mutex_unlock(&srv.counter_mutex);
|
||||||
|
if(error) freeparam(newparam);
|
||||||
|
|
||||||
memset(&defparam.sincl, 0, sizeof(defparam.sincl));
|
memset(&defparam.sincl, 0, sizeof(defparam.sincl));
|
||||||
memset(&defparam.sincr, 0, sizeof(defparam.sincr));
|
memset(&defparam.sincr, 0, sizeof(defparam.sincr));
|
||||||
if(isudp) while(!srv.fds.events)usleep(SLEEPTIME);
|
if(isudp) while(!srv.fds.events)usleep(SLEEPTIME);
|
||||||
@@ -647,6 +701,9 @@ int MODULEMAINFUNC (int argc, char** argv){
|
|||||||
pthread_mutex_unlock(&config_mutex);
|
pthread_mutex_unlock(&config_mutex);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef _WIN32
|
||||||
|
pthread_attr_destroy(&pa);
|
||||||
|
#endif
|
||||||
if(defparam.hostname)myfree(defparam.hostname);
|
if(defparam.hostname)myfree(defparam.hostname);
|
||||||
if(cbc_string)myfree(cbc_string);
|
if(cbc_string)myfree(cbc_string);
|
||||||
if(cbl_string)myfree(cbl_string);
|
if(cbl_string)myfree(cbl_string);
|
||||||
@@ -658,17 +715,20 @@ int MODULEMAINFUNC (int argc, char** argv){
|
|||||||
void srvinit(struct srvparam * srv, struct clientparam *param){
|
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.version + 1;
|
||||||
|
srv->paused = conf.paused;
|
||||||
srv->logfunc = conf.logfunc;
|
srv->logfunc = conf.logfunc;
|
||||||
|
srv->noforce = conf.noforce;
|
||||||
if(srv->logformat)myfree(srv->logformat);
|
if(srv->logformat)myfree(srv->logformat);
|
||||||
srv->logformat = conf.logformat? mystrdup(conf.logformat) : NULL;
|
srv->logformat = conf.logformat? (unsigned char *)mystrdup((char *)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->stacksize = conf.stacksize;
|
||||||
srv->time_start = time(NULL);
|
srv->time_start = time(NULL);
|
||||||
if(conf.logtarget){
|
if(conf.logtarget){
|
||||||
if(srv->logtarget) myfree(srv->logtarget);
|
if(srv->logtarget) myfree(srv->logtarget);
|
||||||
srv->logtarget = mystrdup(conf.logtarget);
|
srv->logtarget = (unsigned char *)mystrdup((char *)conf.logtarget);
|
||||||
}
|
}
|
||||||
srv->srvsock = INVALID_SOCKET;
|
srv->srvsock = INVALID_SOCKET;
|
||||||
srv->logdumpsrv = conf.logdumpsrv;
|
srv->logdumpsrv = conf.logdumpsrv;
|
||||||
@@ -677,13 +737,15 @@ void srvinit(struct srvparam * srv, struct clientparam *param){
|
|||||||
srv->needuser = 1;
|
srv->needuser = 1;
|
||||||
memset(param, 0, sizeof(struct clientparam));
|
memset(param, 0, sizeof(struct clientparam));
|
||||||
param->srv = srv;
|
param->srv = srv;
|
||||||
|
param->version = srv->version;
|
||||||
|
param->paused = srv->paused;
|
||||||
param->remsock = param->clisock = param->ctrlsock = param->ctrlsocksrv = INVALID_SOCKET;
|
param->remsock = param->clisock = param->ctrlsock = param->ctrlsocksrv = INVALID_SOCKET;
|
||||||
*SAFAMILY(¶m->req) = *SAFAMILY(¶m->sinsl) = *SAFAMILY(¶m->sinsr) = *SAFAMILY(¶m->sincr) = *SAFAMILY(¶m->sincl) = AF_INET;
|
*SAFAMILY(¶m->req) = *SAFAMILY(¶m->sinsl) = *SAFAMILY(¶m->sinsr) = *SAFAMILY(¶m->sincr) = *SAFAMILY(¶m->sincl) = AF_INET;
|
||||||
pthread_mutex_init(&srv->counter_mutex, NULL);
|
pthread_mutex_init(&srv->counter_mutex, NULL);
|
||||||
memcpy(&srv->intsa, &conf.intsa, sizeof(srv->intsa));
|
srv->intsa = conf.intsa;
|
||||||
memcpy(&srv->extsa, &conf.extsa, sizeof(srv->extsa));
|
srv->extsa = conf.extsa;
|
||||||
#ifndef NOIPV6
|
#ifndef NOIPV6
|
||||||
memcpy(&srv->extsa6, &conf.extsa6, sizeof(srv->extsa6));
|
srv->extsa6 = conf.extsa6;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -691,7 +753,7 @@ 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;
|
unsigned 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);
|
||||||
@@ -707,13 +769,12 @@ void srvinit2(struct srvparam * srv, struct clientparam *param){
|
|||||||
*SAFAMILY(¶m->sinsl) = AF_INET;
|
*SAFAMILY(¶m->sinsl) = AF_INET;
|
||||||
*SAFAMILY(¶m->sinsr) = AF_INET;
|
*SAFAMILY(¶m->sinsr) = AF_INET;
|
||||||
*SAFAMILY(¶m->req) = AF_INET;
|
*SAFAMILY(¶m->req) = AF_INET;
|
||||||
memcpy(¶m->sincr, &srv->intsa, sizeof(param->sincr));
|
param->sincr = param->sincl = srv->intsa;
|
||||||
memcpy(¶m->sincl, &srv->intsa, sizeof(param->sincl));
|
|
||||||
#ifndef NOIPV6
|
#ifndef NOIPV6
|
||||||
memcpy(¶m->sinsr, (srv->family == 6 || srv->family == 64)? (void *)&srv->extsa6: (void *)&srv->extsa, sizeof(param->sinsl));
|
if (srv->family == 6 || srv->family == 64) param->sinsr = srv->extsa6;
|
||||||
#else
|
else
|
||||||
memcpy(¶m->sinsr, &srv->extsa, sizeof(param->sinsl));
|
|
||||||
#endif
|
#endif
|
||||||
|
param->sinsr = srv->extsa;
|
||||||
}
|
}
|
||||||
|
|
||||||
void srvfree(struct srvparam * srv){
|
void srvfree(struct srvparam * srv){
|
||||||
@@ -870,7 +931,7 @@ void copyfilter (struct filter *filter, struct srvparam *srv){
|
|||||||
|
|
||||||
if(!filter->filter_open || !(data = (*filter->filter_open)(filter->data, srv))) continue;
|
if(!filter->filter_open || !(data = (*filter->filter_open)(filter->data, srv))) continue;
|
||||||
|
|
||||||
memcpy(srv->filter + srv->nfilters, filter, sizeof(struct filter));
|
srv->filter[srv->nfilters] = *filter;
|
||||||
srv->filter[srv->nfilters].data = data;
|
srv->filter[srv->nfilters].data = data;
|
||||||
if(srv->nfilters>0)srv->filter[srv->nfilters - 1].next = srv->filter + srv->nfilters;
|
if(srv->nfilters>0)srv->filter[srv->nfilters - 1].next = srv->filter + srv->nfilters;
|
||||||
srv->nfilters++;
|
srv->nfilters++;
|
||||||
|
|||||||
+31
-31
@@ -37,7 +37,7 @@ int readreply (struct clientparam* param) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
buf[i] = 0;
|
buf[i] = 0;
|
||||||
res = atoi(buf);
|
res = atoi((char *)buf);
|
||||||
myfree(buf);
|
myfree(buf);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
@@ -51,7 +51,7 @@ int readcommand (struct clientparam* param) {
|
|||||||
i = sockgetlinebuf(param, CLIENT, buf, bufsize-1, '\n', conf.timeouts[STRING_L]);
|
i = sockgetlinebuf(param, CLIENT, buf, bufsize-1, '\n', conf.timeouts[STRING_L]);
|
||||||
if(i < 4) return 0;
|
if(i < 4) return 0;
|
||||||
#ifndef WITHMAIN
|
#ifndef WITHMAIN
|
||||||
if(!strncasecmp(buf, "MAIL", 4) || !strncasecmp(buf, "RCPT", 4) || !strncasecmp(buf, "STARTTLS", 8) || !strncasecmp(buf, "TURN", 4)){
|
if(!strncasecmp((char *)buf, "MAIL", 4) || !strncasecmp((char *)buf, "RCPT", 4) || !strncasecmp((char *)buf, "STARTTLS", 8) || !strncasecmp((char *)buf, "TURN", 4)){
|
||||||
res = handlehdrfilterscli(param, &buf, &bufsize, 0, &i);
|
res = handlehdrfilterscli(param, &buf, &bufsize, 0, &i);
|
||||||
if(res != PASS) {
|
if(res != PASS) {
|
||||||
myfree(buf);
|
myfree(buf);
|
||||||
@@ -62,7 +62,7 @@ int readcommand (struct clientparam* param) {
|
|||||||
#endif
|
#endif
|
||||||
socksend(param->remsock, buf, i, conf.timeouts[STRING_S]);
|
socksend(param->remsock, buf, i, conf.timeouts[STRING_S]);
|
||||||
myfree(buf);
|
myfree(buf);
|
||||||
if(!strncasecmp(buf, "STARTTLS", 8) || !strncasecmp(buf, "TURN", 4)){
|
if(!strncasecmp((char *)buf, "STARTTLS", 8) || !strncasecmp((char *)buf, "TURN", 4)){
|
||||||
ret = 22;
|
ret = 22;
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
@@ -118,22 +118,22 @@ void * smtppchild(struct clientparam* param) {
|
|||||||
else {
|
else {
|
||||||
login = -1;
|
login = -1;
|
||||||
buf[i] = 0;
|
buf[i] = 0;
|
||||||
command = mystrdup(buf);
|
command = mystrdup((char *)buf);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
i = sockgetlinebuf(param, CLIENT, buf, sizeof(buf) - 10, '\n', conf.timeouts[STRING_S]);
|
i = sockgetlinebuf(param, CLIENT, buf, sizeof(buf) - 10, '\n', conf.timeouts[STRING_S]);
|
||||||
}
|
}
|
||||||
if(!login) {RETURN(662);}
|
if(!login) {RETURN(662);}
|
||||||
if(login == 1){
|
if(login == 1){
|
||||||
socksend(param->clisock, "334 VXNlcm5hbWU6\r\n", 18,conf.timeouts[STRING_S]);
|
socksend(param->clisock, (unsigned char *)"334 VXNlcm5hbWU6\r\n", 18,conf.timeouts[STRING_S]);
|
||||||
i = sockgetlinebuf(param, CLIENT, buf, sizeof(buf) - 10, '\n', conf.timeouts[STRING_S]);
|
i = sockgetlinebuf(param, CLIENT, buf, sizeof(buf) - 10, '\n', conf.timeouts[STRING_S]);
|
||||||
if(i < 3) {RETURN(663);}
|
if(i < 3) {RETURN(663);}
|
||||||
buf[i-2] = 0;
|
buf[i-2] = 0;
|
||||||
i = de64(buf,username,255);
|
i = de64(buf,username,255);
|
||||||
if(i < 1) {RETURN(664);}
|
if(i < 1) {RETURN(664);}
|
||||||
username[i] = 0;
|
username[i] = 0;
|
||||||
parseconnusername(username, param, 0, 25);
|
parseconnusername((char *)username, param, 0, 25);
|
||||||
socksend(param->clisock, "334 UGFzc3dvcmQ6\r\n", 18,conf.timeouts[STRING_S]);
|
socksend(param->clisock, (unsigned char *)"334 UGFzc3dvcmQ6\r\n", 18,conf.timeouts[STRING_S]);
|
||||||
i = sockgetlinebuf(param, CLIENT, buf, sizeof(buf) - 10, '\n', conf.timeouts[STRING_S]);
|
i = sockgetlinebuf(param, CLIENT, buf, sizeof(buf) - 10, '\n', conf.timeouts[STRING_S]);
|
||||||
if(i < 2) {RETURN(665);}
|
if(i < 2) {RETURN(665);}
|
||||||
buf[i-2] = 0;
|
buf[i-2] = 0;
|
||||||
@@ -141,7 +141,7 @@ void * smtppchild(struct clientparam* param) {
|
|||||||
if(i < 0) {RETURN(666);}
|
if(i < 0) {RETURN(666);}
|
||||||
username[i] = 0;
|
username[i] = 0;
|
||||||
if(param->extpassword) myfree(param->extpassword);
|
if(param->extpassword) myfree(param->extpassword);
|
||||||
param->extpassword = mystrdup(username);
|
param->extpassword = (unsigned char *)mystrdup((char *)username);
|
||||||
}
|
}
|
||||||
else if(login == 2){
|
else if(login == 2){
|
||||||
if(i > 13) {
|
if(i > 13) {
|
||||||
@@ -149,7 +149,7 @@ void * smtppchild(struct clientparam* param) {
|
|||||||
i = de64(buf+11,username,255);
|
i = de64(buf+11,username,255);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
socksend(param->clisock, "334\r\n", 5,conf.timeouts[STRING_S]);
|
socksend(param->clisock, (unsigned char *)"334\r\n", 5,conf.timeouts[STRING_S]);
|
||||||
i = sockgetlinebuf(param, CLIENT, buf, sizeof(buf) - 10, '\n', conf.timeouts[STRING_S]);
|
i = sockgetlinebuf(param, CLIENT, buf, sizeof(buf) - 10, '\n', conf.timeouts[STRING_S]);
|
||||||
if(i < 3) {RETURN(667);}
|
if(i < 3) {RETURN(667);}
|
||||||
buf[i-2] = 0;
|
buf[i-2] = 0;
|
||||||
@@ -157,18 +157,18 @@ void * smtppchild(struct clientparam* param) {
|
|||||||
}
|
}
|
||||||
if(i < 3 || *username) {RETURN(668);}
|
if(i < 3 || *username) {RETURN(668);}
|
||||||
username[i] = 0;
|
username[i] = 0;
|
||||||
parseconnusername(username+1, param, 0, 25);
|
parseconnusername((char *)username+1, param, 0, 25);
|
||||||
res = (int)strlen(username+1) + 2;
|
res = (int)strlen((char *)username+1) + 2;
|
||||||
if(res < i){
|
if(res < i){
|
||||||
if(param->extpassword) myfree(param->extpassword);
|
if(param->extpassword) myfree(param->extpassword);
|
||||||
param->extpassword = mystrdup(username + res);
|
param->extpassword = (unsigned char *)mystrdup((char *)username + res);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef WITHMAIN
|
#ifndef WITHMAIN
|
||||||
{
|
{
|
||||||
int action, reqbufsize, reqsize;
|
int action, reqbufsize, reqsize;
|
||||||
reqbufsize = reqsize = (int)strlen(param->hostname) + 1;
|
reqbufsize = reqsize = (int)strlen((char *)param->hostname) + 1;
|
||||||
action = handlereqfilters(param, ¶m->hostname, &reqbufsize, 0, &reqsize);
|
action = handlereqfilters(param, ¶m->hostname, &reqbufsize, 0, &reqsize);
|
||||||
if(action == HANDLED){
|
if(action == HANDLED){
|
||||||
RETURN(0);
|
RETURN(0);
|
||||||
@@ -186,9 +186,9 @@ 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);}
|
||||||
i = sprintf(buf, "EHLO [");
|
i = sprintf((char *)buf, "EHLO [");
|
||||||
i += myinet_ntop(*SAFAMILY(¶m->sinsl), SAADDR(¶m->sinsl), buf+strlen(buf), 64);
|
i += myinet_ntop(*SAFAMILY(¶m->sinsl), SAADDR(¶m->sinsl), (char *)buf+strlen((char *)buf), 64);
|
||||||
i += sprintf(buf+strlen(buf), "]\r\n");
|
i += sprintf((char *)buf+strlen((char *)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->statscli64+=i;
|
param->statscli64+=i;
|
||||||
param->nwrites++;
|
param->nwrites++;
|
||||||
@@ -204,44 +204,44 @@ void * smtppchild(struct clientparam* param) {
|
|||||||
if(i<3) {RETURN(672);}
|
if(i<3) {RETURN(672);}
|
||||||
if(!command || (param->extusername && param->extpassword)){
|
if(!command || (param->extusername && param->extpassword)){
|
||||||
if(!param->extusername || !*param->extusername || !param->extpassword || !*param->extpassword || !login){
|
if(!param->extusername || !*param->extusername || !param->extpassword || !*param->extpassword || !login){
|
||||||
socksend(param->clisock, "235 auth required\r\n", 19,conf.timeouts[STRING_S]);
|
socksend(param->clisock, (unsigned char *)"235 auth required\r\n", 19,conf.timeouts[STRING_S]);
|
||||||
}
|
}
|
||||||
if ((login & 1)) {
|
if ((login & 1)) {
|
||||||
socksend(param->remsock, "AUTH LOGIN\r\n", 12, conf.timeouts[STRING_S]);
|
socksend(param->remsock, (unsigned char *)"AUTH LOGIN\r\n", 12, conf.timeouts[STRING_S]);
|
||||||
param->statscli64+=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((char *)param->extusername));
|
||||||
socksend(param->remsock, buf, (int)strlen(buf), conf.timeouts[STRING_S]);
|
socksend(param->remsock, buf, (int)strlen((char *)buf), conf.timeouts[STRING_S]);
|
||||||
socksend(param->remsock, "\r\n", 2, conf.timeouts[STRING_S]);
|
socksend(param->remsock, (unsigned char *)"\r\n", 2, conf.timeouts[STRING_S]);
|
||||||
param->statscli64+=(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((char *)param->extpassword));
|
||||||
socksend(param->remsock, buf, (int)strlen(buf), conf.timeouts[STRING_S]);
|
socksend(param->remsock, buf, (int)strlen((char *)buf), conf.timeouts[STRING_S]);
|
||||||
socksend(param->remsock, "\r\n", 2, conf.timeouts[STRING_S]);
|
socksend(param->remsock, (unsigned char *)"\r\n", 2, conf.timeouts[STRING_S]);
|
||||||
param->statscli64+=(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, (unsigned char *)"AUTH PLAIN\r\n", 12, conf.timeouts[STRING_S]);
|
||||||
param->statscli64+=(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);}
|
||||||
*username = 0;
|
*username = 0;
|
||||||
i = (int)strlen(param->extusername) + 1;
|
i = (int)strlen((char *)param->extusername) + 1;
|
||||||
memcpy(username+1, param->extusername, i);
|
memcpy(username+1, param->extusername, i);
|
||||||
i++;
|
i++;
|
||||||
res = (int)strlen(param->extpassword);
|
res = (int)strlen((char *)param->extpassword);
|
||||||
memcpy(username + i, param->extpassword, res);
|
memcpy(username + i, param->extpassword, res);
|
||||||
i+=res;
|
i+=res;
|
||||||
en64(username, buf, i);
|
en64(username, buf, i);
|
||||||
i = (int)strlen(buf);
|
i = (int)strlen((char *)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, (unsigned char *)"\r\n", 2, conf.timeouts[STRING_S]);
|
||||||
param->statscli64+=(i+2);
|
param->statscli64+=(i+2);
|
||||||
param->nwrites+=2;
|
param->nwrites+=2;
|
||||||
}
|
}
|
||||||
@@ -266,7 +266,7 @@ void * smtppchild(struct clientparam* param) {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
i = (int)strlen(command);
|
i = (int)strlen(command);
|
||||||
if(res != 2) socksend(param->remsock, command, i, conf.timeouts[STRING_S]);
|
if(res != 2) socksend(param->remsock, (unsigned char *)command, i, conf.timeouts[STRING_S]);
|
||||||
}
|
}
|
||||||
#ifndef WITHMAIN
|
#ifndef WITHMAIN
|
||||||
|
|
||||||
@@ -291,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, *SAPORT(¶m->sinsr)==25?0:':',ntohs(*SAPORT(¶m->sinsr)));
|
sprintf((char *)buf, "%.128s@%.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);
|
||||||
|
|||||||
+6
-9
@@ -7,9 +7,6 @@
|
|||||||
|
|
||||||
#include "proxy.h"
|
#include "proxy.h"
|
||||||
|
|
||||||
#define BUFSIZE (param->srv->bufsize?param->srv->bufsize:((param->service == S_UDPPM)?UDPBUFSIZE:TCPBUFSIZE))
|
|
||||||
|
|
||||||
|
|
||||||
int socksend(SOCKET sock, unsigned char * buf, int bufsize, int to){
|
int socksend(SOCKET sock, unsigned char * buf, int bufsize, int to){
|
||||||
int sent = 0;
|
int sent = 0;
|
||||||
int res;
|
int res;
|
||||||
@@ -22,7 +19,7 @@ int socksend(SOCKET sock, unsigned char * buf, int bufsize, int to){
|
|||||||
res = so._poll(&fds, 1, to*1000);
|
res = so._poll(&fds, 1, to*1000);
|
||||||
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._send(sock, buf + sent, bufsize - sent, 0);
|
res = so._send(sock, (char *)buf + sent, bufsize - sent, 0);
|
||||||
if(res < 0) {
|
if(res < 0) {
|
||||||
if(errno == EAGAIN || errno == EINTR) continue;
|
if(errno == EAGAIN || errno == EINTR) continue;
|
||||||
break;
|
break;
|
||||||
@@ -45,7 +42,7 @@ int socksendto(SOCKET sock, struct sockaddr * sin, unsigned char * buf, int bufs
|
|||||||
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, sin, SASIZE(sin));
|
res = so._sendto(sock, (char *)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;
|
||||||
@@ -66,7 +63,7 @@ int sockrecvfrom(SOCKET sock, struct sockaddr * sin, unsigned char * buf, int bu
|
|||||||
if (so._poll(&fds, 1, to)<1) return 0;
|
if (so._poll(&fds, 1, to)<1) return 0;
|
||||||
sasize = SASIZE(sin);
|
sasize = SASIZE(sin);
|
||||||
do {
|
do {
|
||||||
res = so._recvfrom(sock, buf, bufsize, 0, (struct sockaddr *)sin, &sasize);
|
res = so._recvfrom(sock, (char *)buf, bufsize, 0, (struct sockaddr *)sin, &sasize);
|
||||||
} while (res < 0 && (errno == EAGAIN || errno == EINTR));
|
} while (res < 0 && (errno == EAGAIN || errno == EINTR));
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
@@ -75,8 +72,8 @@ int sockgetcharcli(struct clientparam * param, int timeosec, int timeousec){
|
|||||||
int len;
|
int len;
|
||||||
|
|
||||||
if(!param->clibuf){
|
if(!param->clibuf){
|
||||||
if(!(param->clibuf = myalloc(BUFSIZE))) return 0;
|
if(!(param->clibuf = myalloc(SRVBUFSIZE))) return 0;
|
||||||
param->clibufsize = BUFSIZE;
|
param->clibufsize = SRVBUFSIZE;
|
||||||
param->clioffset = param->cliinbuf = 0;
|
param->clioffset = param->cliinbuf = 0;
|
||||||
}
|
}
|
||||||
if(param->cliinbuf && param->clioffset < param->cliinbuf){
|
if(param->cliinbuf && param->clioffset < param->cliinbuf){
|
||||||
@@ -137,7 +134,7 @@ int sockgetcharsrv(struct clientparam * param, int timeosec, int timeousec){
|
|||||||
int bufsize;
|
int bufsize;
|
||||||
|
|
||||||
if(!param->srvbuf){
|
if(!param->srvbuf){
|
||||||
bufsize = BUFSIZE;
|
bufsize = SRVBUFSIZE;
|
||||||
if(param->ndatfilterssrv > 0 && bufsize < 32768) bufsize = 32768;
|
if(param->ndatfilterssrv > 0 && bufsize < 32768) bufsize = 32768;
|
||||||
if(!(param->srvbuf = myalloc(bufsize))) return 0;
|
if(!(param->srvbuf = myalloc(bufsize))) return 0;
|
||||||
param->srvbufsize = bufsize;
|
param->srvbufsize = bufsize;
|
||||||
|
|||||||
+17
-11
@@ -8,8 +8,6 @@
|
|||||||
|
|
||||||
#include "proxy.h"
|
#include "proxy.h"
|
||||||
|
|
||||||
#define BUFSIZE (param->srv->bufsize?param->srv->bufsize:((param->service == S_UDPPM)?UDPBUFSIZE:TCPBUFSIZE))
|
|
||||||
|
|
||||||
int sockmap(struct clientparam * param, int timeo){
|
int sockmap(struct clientparam * param, int timeo){
|
||||||
int res=0;
|
int res=0;
|
||||||
uint64_t sent=0, received=0;
|
uint64_t sent=0, received=0;
|
||||||
@@ -21,13 +19,16 @@ int sockmap(struct clientparam * param, int timeo){
|
|||||||
FILTER_ACTION action;
|
FILTER_ACTION action;
|
||||||
int retcode = 0;
|
int retcode = 0;
|
||||||
|
|
||||||
bufsize = BUFSIZE;
|
bufsize = SRVBUFSIZE;
|
||||||
|
|
||||||
minsize = (param->service == S_UDPPM || param->service == S_TCPPM)? bufsize - 1 : (bufsize>>2);
|
minsize = (param->service == S_UDPPM || param->service == S_TCPPM)? bufsize - 1 : (bufsize>>2);
|
||||||
|
|
||||||
fds[0].fd = param->clisock;
|
fds[0].fd = param->clisock;
|
||||||
fds[1].fd = param->remsock;
|
fds[1].fd = param->remsock;
|
||||||
|
|
||||||
|
|
||||||
|
if(param->cliinbuf == param->clioffset) param->cliinbuf = param->clioffset = 0;
|
||||||
|
if(param->srvinbuf == param->srvoffset) param->srvinbuf = param->srvoffset = 0;
|
||||||
#if DEBUGLEVEL > 2
|
#if DEBUGLEVEL > 2
|
||||||
(*param->srv->logfunc)(param, "Starting sockets mapping");
|
(*param->srv->logfunc)(param, "Starting sockets mapping");
|
||||||
#endif
|
#endif
|
||||||
@@ -49,14 +50,14 @@ int sockmap(struct clientparam * param, int timeo){
|
|||||||
if(action != PASS) return 19;
|
if(action != PASS) return 19;
|
||||||
if(!param->nolongdatfilter){
|
if(!param->nolongdatfilter){
|
||||||
if(param->cliinbuf > param->clioffset){
|
if(param->cliinbuf > param->clioffset){
|
||||||
action = handledatfltcli(param, ¶m->clibuf, ¶m->clibufsize, param->clioffset, ¶m->cliinbuf);
|
action = handledatfltcli(param, ¶m->clibuf, (int *)¶m->clibufsize, param->clioffset, (int *)¶m->cliinbuf);
|
||||||
if(action == HANDLED){
|
if(action == HANDLED){
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if(action != PASS) return 19;
|
if(action != PASS) return 19;
|
||||||
}
|
}
|
||||||
if(param->srvinbuf > param->srvoffset){
|
if(param->srvinbuf > param->srvoffset){
|
||||||
action = handledatfltsrv(param, ¶m->srvbuf, ¶m->srvbufsize, param->srvoffset, ¶m->srvinbuf);
|
action = handledatfltsrv(param, ¶m->srvbuf, (int *)¶m->srvbufsize, param->srvoffset, (int *)¶m->srvinbuf);
|
||||||
if(action == HANDLED){
|
if(action == HANDLED){
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -68,6 +69,11 @@ 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->version < conf.version){
|
||||||
|
if((res = (*param->srv->authfunc)(param)) && res != 2 && !param->srv->noforce) {return(res);}
|
||||||
|
param->paused = conf.paused;
|
||||||
|
param->version = conf.version;
|
||||||
|
}
|
||||||
if((param->maxtrafin64 && param->statssrv64 >= param->maxtrafin64) || (param->maxtrafout64 && param->statscli64 >= param->maxtrafout64)){
|
if((param->maxtrafin64 && param->statssrv64 >= param->maxtrafin64) || (param->maxtrafout64 && param->statscli64 >= param->maxtrafout64)){
|
||||||
return (10);
|
return (10);
|
||||||
}
|
}
|
||||||
@@ -127,7 +133,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->waitserver64 || (param->waitserver64 - received) > (param->srvinbuf - param->srvoffset))? param->srvinbuf - param->srvoffset : (int)(param->waitserver64 - received), 0, (struct sockaddr*)¶m->sincr, sasize);
|
res = so._sendto(param->clisock, (char *)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);
|
||||||
@@ -153,7 +159,7 @@ 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->waitclient64 || (param->waitclient64 - sent) > (param->cliinbuf - param->clioffset))? param->cliinbuf - param->clioffset : (int)(param->waitclient64 - sent), 0, (struct sockaddr*)¶m->sinsr, sasize);
|
res = so._sendto(param->remsock, (char *)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);
|
||||||
@@ -172,7 +178,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->sincr, &sasize);
|
res = so._recvfrom(param->clisock, (char *)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);
|
||||||
@@ -187,7 +193,7 @@ int sockmap(struct clientparam * param, int timeo){
|
|||||||
}
|
}
|
||||||
param->cliinbuf += res;
|
param->cliinbuf += res;
|
||||||
if(!param->nolongdatfilter){
|
if(!param->nolongdatfilter){
|
||||||
action = handledatfltcli(param, ¶m->clibuf, ¶m->clibufsize, param->cliinbuf - res, ¶m->cliinbuf);
|
action = handledatfltcli(param, ¶m->clibuf, (int *)¶m->clibufsize, param->cliinbuf - res, (int *)¶m->cliinbuf);
|
||||||
if(action == HANDLED){
|
if(action == HANDLED){
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -203,7 +209,7 @@ int sockmap(struct clientparam * param, int timeo){
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
sasize = sizeof(sin);
|
sasize = sizeof(sin);
|
||||||
res = so._recvfrom(param->remsock, param->srvbuf + param->srvinbuf, param->srvbufsize - param->srvinbuf, 0, (struct sockaddr *)&sin, &sasize);
|
res = so._recvfrom(param->remsock, (char *)param->srvbuf + param->srvinbuf, param->srvbufsize - param->srvinbuf, 0, (struct sockaddr *)&sin, &sasize);
|
||||||
if (res==0) {
|
if (res==0) {
|
||||||
so._shutdown(param->remsock, SHUT_RDWR);
|
so._shutdown(param->remsock, SHUT_RDWR);
|
||||||
so._closesocket(param->remsock);
|
so._closesocket(param->remsock);
|
||||||
@@ -220,7 +226,7 @@ int sockmap(struct clientparam * param, int timeo){
|
|||||||
param->nreads++;
|
param->nreads++;
|
||||||
param->statssrv64 += 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, (int *)¶m->srvbufsize, param->srvinbuf - res, (int *)¶m->srvinbuf);
|
||||||
if(action == HANDLED){
|
if(action == HANDLED){
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
+12
-12
@@ -120,8 +120,8 @@ void * sockschild(struct clientparam* param) {
|
|||||||
#ifndef NOIPV6
|
#ifndef NOIPV6
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
if(SAISNULL(¶m->req)) {
|
if(command == 1 && SAISNULL(¶m->req)) {
|
||||||
RETURN(421);
|
RETURN(431);
|
||||||
}
|
}
|
||||||
myinet_ntop(*SAFAMILY(¶m->sinsr), SAADDR(¶m->sinsr), (char *)buf, 64);
|
myinet_ntop(*SAFAMILY(¶m->sinsr), SAADDR(¶m->sinsr), (char *)buf, 64);
|
||||||
break;
|
break;
|
||||||
@@ -133,7 +133,7 @@ void * sockschild(struct clientparam* param) {
|
|||||||
}
|
}
|
||||||
buf[i] = 0;
|
buf[i] = 0;
|
||||||
if(!getip46(param->srv->family, buf, (struct sockaddr *) ¶m->req)) RETURN(100);
|
if(!getip46(param->srv->family, buf, (struct sockaddr *) ¶m->req)) RETURN(100);
|
||||||
memcpy(¶m->sinsr, ¶m->req, sizeof(param->req));
|
param->sinsr = param->req;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
RETURN(997);
|
RETURN(997);
|
||||||
@@ -159,12 +159,12 @@ void * sockschild(struct clientparam* param) {
|
|||||||
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(!getip46(param->srv->family, buf, (struct sockaddr *) ¶m->req)) RETURN(100);
|
if(!getip46(param->srv->family, buf, (struct sockaddr *) ¶m->req)) RETURN(100);
|
||||||
memcpy(¶m->sinsr, ¶m->req, sizeof(¶m->req));
|
param->sinsr = param->req;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
*SAPORT(¶m->sinsr) = *SAPORT(¶m->req) = port;
|
*SAPORT(¶m->sinsr) = *SAPORT(¶m->req) = port;
|
||||||
if(command == 1 && !*SAPORT(¶m->sinsr)) {RETURN(421);}
|
if(command == 1 && !*SAPORT(¶m->sinsr)) {RETURN(461);}
|
||||||
switch(command) {
|
switch(command) {
|
||||||
case 1:
|
case 1:
|
||||||
param->operation = CONNECT;
|
param->operation = CONNECT;
|
||||||
@@ -173,9 +173,9 @@ void * sockschild(struct clientparam* param) {
|
|||||||
case 3:
|
case 3:
|
||||||
|
|
||||||
#ifndef NOIPV6
|
#ifndef NOIPV6
|
||||||
memcpy(¶m->sinsl, *SAFAMILY(¶m->req)==AF_INET6? (struct sockaddr *)¶m->srv->extsa6:(struct sockaddr *)¶m->srv->extsa, SASIZE(¶m->req));
|
param->sinsl = *SAFAMILY(¶m->req)==AF_INET6? param->srv->extsa6 : param->srv->extsa;
|
||||||
#else
|
#else
|
||||||
memcpy(¶m->sinsl, ¶m->srv->extsa, SASIZE(¶m->req));
|
param->sinsl = param->srv->extsa;
|
||||||
#endif
|
#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);}
|
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;
|
param->operation = command == 2?BIND:UDPASSOC;
|
||||||
@@ -218,7 +218,7 @@ fflush(stderr);
|
|||||||
param->ctrlsock = param->clisock;
|
param->ctrlsock = param->clisock;
|
||||||
param->clisock = so._socket(SASOCK(¶m->sincr), 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);}
|
||||||
memcpy(&sin, ¶m->sincl, sizeof(&sin));
|
sin = param->sincl;
|
||||||
*SAPORT(&sin) = 0;
|
*SAPORT(&sin) = 0;
|
||||||
if(so._bind(param->clisock,(struct sockaddr *)&sin,SASIZE(&sin))) {RETURN (12);}
|
if(so._bind(param->clisock,(struct sockaddr *)&sin,SASIZE(&sin))) {RETURN (12);}
|
||||||
#if SOCKSTRACE > 0
|
#if SOCKSTRACE > 0
|
||||||
@@ -328,7 +328,7 @@ fflush(stderr);
|
|||||||
param->res = sockmap(param, conf.timeouts[CONNECTION_S]);
|
param->res = sockmap(param, conf.timeouts[CONNECTION_S]);
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
memcpy(¶m->sinsr, ¶m->req, sizeof(param->sinsr));
|
param->sinsr = param->req;
|
||||||
myfree(buf);
|
myfree(buf);
|
||||||
if(!(buf = myalloc(LARGEBUFSIZE))) {RETURN(21);}
|
if(!(buf = myalloc(LARGEBUFSIZE))) {RETURN(21);}
|
||||||
|
|
||||||
@@ -349,7 +349,7 @@ fflush(stderr);
|
|||||||
}
|
}
|
||||||
if (fds[1].revents) {
|
if (fds[1].revents) {
|
||||||
sasize = sizeof(sin);
|
sasize = sizeof(sin);
|
||||||
if((len = so._recvfrom(param->clisock, buf, 65535, 0, (struct sockaddr *)&sin, &sasize)) <= 10) {
|
if((len = so._recvfrom(param->clisock, (char *)buf, 65535, 0, (struct sockaddr *)&sin, &sasize)) <= 10) {
|
||||||
param->res = 464;
|
param->res = 464;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -376,7 +376,7 @@ fflush(stderr);
|
|||||||
buf[i] = buf[i+1];
|
buf[i] = buf[i+1];
|
||||||
}
|
}
|
||||||
buf[i++] = 0;
|
buf[i++] = 0;
|
||||||
if(!getip46(param->srv->family, buf, (struct sockaddr *) ¶m->sinsr)) RETURN(100);
|
if(!getip46(param->srv->family, buf+4, (struct sockaddr *) ¶m->sinsr)) RETURN(100);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
RETURN(997);
|
RETURN(997);
|
||||||
@@ -413,7 +413,7 @@ fflush(stderr);
|
|||||||
sasize = sizeof(param->sinsr);
|
sasize = sizeof(param->sinsr);
|
||||||
buf[0]=buf[1]=buf[2]=0;
|
buf[0]=buf[1]=buf[2]=0;
|
||||||
buf[3]=(*SAFAMILY(¶m->sinsl) == AF_INET)?1:4;
|
buf[3]=(*SAFAMILY(¶m->sinsl) == AF_INET)?1:4;
|
||||||
if((len = so._recvfrom(param->remsock, buf+6+SAADDRLEN(¶m->sinsl), 65535 - 10, 0, (struct sockaddr *)¶m->sinsr, &sasize)) <= 0) {
|
if((len = so._recvfrom(param->remsock, (char *)buf+6+SAADDRLEN(¶m->sinsl), 65535 - 10, 0, (struct sockaddr *)¶m->sinsr, &sasize)) <= 0) {
|
||||||
param->res = 468;
|
param->res = 468;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
+48
-17
@@ -76,6 +76,18 @@ int
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#define ALLOW 0
|
||||||
|
#define DENY 1
|
||||||
|
#define REDIRECT 2
|
||||||
|
#define BANDLIM 3
|
||||||
|
#define NOBANDLIM 4
|
||||||
|
#define COUNTIN 5
|
||||||
|
#define NOCOUNTIN 6
|
||||||
|
#define COUNTOUT 7
|
||||||
|
#define NOCOUNTOUT 8
|
||||||
|
#define CONNLIM 9
|
||||||
|
#define NOCONNLIM 10
|
||||||
|
|
||||||
#define CONNECT 0x00000001
|
#define CONNECT 0x00000001
|
||||||
#define BIND 0x00000002
|
#define BIND 0x00000002
|
||||||
#define UDPASSOC 0x00000004
|
#define UDPASSOC 0x00000004
|
||||||
@@ -162,7 +174,21 @@ 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);
|
|
||||||
|
#ifdef WIN32
|
||||||
|
|
||||||
|
#define PLUGINAPI __declspec(dllexport)
|
||||||
|
typedef int (__cdecl *PLUGINFUNC) (struct pluginlink *pluginlink, int argc, char** argv);
|
||||||
|
#define PLUGINCALL __cdecl
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
#define PLUGINCALL
|
||||||
|
#define PLUGINAPI
|
||||||
|
typedef int (*PLUGINFUNC)(struct pluginlink *pluginlink, int argc, char** argv);
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
struct auth {
|
struct auth {
|
||||||
struct auth *next;
|
struct auth *next;
|
||||||
@@ -217,6 +243,7 @@ typedef enum {
|
|||||||
R_SOCKS5,
|
R_SOCKS5,
|
||||||
R_HTTP,
|
R_HTTP,
|
||||||
R_POP3,
|
R_POP3,
|
||||||
|
R_SMTP,
|
||||||
R_FTP,
|
R_FTP,
|
||||||
R_CONNECTP,
|
R_CONNECTP,
|
||||||
R_SOCKS4P,
|
R_SOCKS4P,
|
||||||
@@ -225,7 +252,7 @@ typedef enum {
|
|||||||
R_SOCKS5B,
|
R_SOCKS5B,
|
||||||
R_ADMIN,
|
R_ADMIN,
|
||||||
R_ICQ,
|
R_ICQ,
|
||||||
R_MSN
|
R_EXTIP
|
||||||
} REDIRTYPE;
|
} REDIRTYPE;
|
||||||
|
|
||||||
struct chain {
|
struct chain {
|
||||||
@@ -363,7 +390,7 @@ struct srvparam {
|
|||||||
SOCKET srvsock, cbsock;
|
SOCKET srvsock, cbsock;
|
||||||
int childcount;
|
int childcount;
|
||||||
int maxchild;
|
int maxchild;
|
||||||
int version;
|
int paused, version;
|
||||||
int singlepacket;
|
int singlepacket;
|
||||||
int usentlm;
|
int usentlm;
|
||||||
int needuser;
|
int needuser;
|
||||||
@@ -371,6 +398,8 @@ struct srvparam {
|
|||||||
int transparent;
|
int transparent;
|
||||||
int nfilters, nreqfilters, nhdrfilterscli, nhdrfilterssrv, npredatfilters, ndatfilterscli, ndatfilterssrv;
|
int nfilters, nreqfilters, nhdrfilterscli, nhdrfilterssrv, npredatfilters, ndatfilterscli, ndatfilterssrv;
|
||||||
int family;
|
int family;
|
||||||
|
int stacksize;
|
||||||
|
int noforce;
|
||||||
unsigned bufsize;
|
unsigned bufsize;
|
||||||
unsigned logdumpsrv, logdumpcli;
|
unsigned logdumpsrv, logdumpcli;
|
||||||
#ifndef NOIPV6
|
#ifndef NOIPV6
|
||||||
@@ -421,15 +450,17 @@ struct clientparam {
|
|||||||
|
|
||||||
REDIRTYPE redirtype;
|
REDIRTYPE redirtype;
|
||||||
|
|
||||||
|
uint64_t waitclient64,
|
||||||
|
waitserver64;
|
||||||
|
|
||||||
int redirected,
|
int redirected,
|
||||||
operation,
|
operation,
|
||||||
nfilters, nreqfilters, nhdrfilterscli, nhdrfilterssrv, npredatfilters, ndatfilterscli, ndatfilterssrv,
|
nfilters, nreqfilters, nhdrfilterscli, nhdrfilterssrv, npredatfilters, ndatfilterscli, ndatfilterssrv,
|
||||||
unsafefilter;
|
unsafefilter,
|
||||||
|
bandlimver;
|
||||||
|
|
||||||
int res,
|
int res,
|
||||||
status;
|
status;
|
||||||
uint64_t waitclient64,
|
|
||||||
waitserver64;
|
|
||||||
int pwtype,
|
int pwtype,
|
||||||
threadid,
|
threadid,
|
||||||
weight,
|
weight,
|
||||||
@@ -437,7 +468,9 @@ struct clientparam {
|
|||||||
nolongdatfilter,
|
nolongdatfilter,
|
||||||
nooverwritefilter,
|
nooverwritefilter,
|
||||||
transparent,
|
transparent,
|
||||||
chunked;
|
chunked,
|
||||||
|
paused,
|
||||||
|
version;
|
||||||
|
|
||||||
unsigned char *hostname,
|
unsigned char *hostname,
|
||||||
*username,
|
*username,
|
||||||
@@ -490,8 +523,8 @@ struct extparam {
|
|||||||
struct bandlim * bandlimiter, *bandlimiterout;
|
struct bandlim * bandlimiter, *bandlimiterout;
|
||||||
struct trafcount * trafcounter;
|
struct trafcount * trafcounter;
|
||||||
struct srvparam *services;
|
struct srvparam *services;
|
||||||
int threadinit, counterd, haveerror, rotate, paused, archiverc,
|
int stacksize, threadinit, counterd, haveerror, rotate, paused, archiverc,
|
||||||
demon, maxchild, singlepacket, needreload, timetoexit;
|
demon, maxchild, singlepacket, needreload, timetoexit, version, noforce;
|
||||||
int authcachetype, authcachetime;
|
int authcachetype, authcachetime;
|
||||||
int filtermaxsize;
|
int filtermaxsize;
|
||||||
unsigned char *logname, **archiver;
|
unsigned char *logname, **archiver;
|
||||||
@@ -610,13 +643,13 @@ struct sockfuncs {
|
|||||||
int (WINAPI *_connect)(SOCKET s, const struct sockaddr *name, int namelen);
|
int (WINAPI *_connect)(SOCKET s, const struct sockaddr *name, int namelen);
|
||||||
int (WINAPI *_getpeername)(SOCKET s, struct sockaddr * name, int * namelen);
|
int (WINAPI *_getpeername)(SOCKET s, struct sockaddr * name, int * namelen);
|
||||||
int (WINAPI *_getsockname)(SOCKET s, struct sockaddr * name, int * namelen);
|
int (WINAPI *_getsockname)(SOCKET s, struct sockaddr * name, int * namelen);
|
||||||
int (WINAPI *_getsockopt)(SOCKET s, int level, int optname, void * optval, int * optlen);
|
int (WINAPI *_getsockopt)(SOCKET s, int level, int optname, char * optval, int * optlen);
|
||||||
int (WINAPI *_setsockopt)(SOCKET s, int level, int optname, const void *optval, int optlen);
|
int (WINAPI *_setsockopt)(SOCKET s, int level, int optname, const char *optval, int optlen);
|
||||||
int (WINAPI *_poll)(struct pollfd *fds, unsigned int nfds, int timeout);
|
int (WINAPI *_poll)(struct pollfd *fds, unsigned int nfds, int timeout);
|
||||||
int (WINAPI *_send)(SOCKET s, const void *msg, int len, int flags);
|
int (WINAPI *_send)(SOCKET s, const char *msg, int len, int flags);
|
||||||
int (WINAPI *_sendto)(SOCKET s, const void *msg, int len, int flags, const struct sockaddr *to, int tolen);
|
int (WINAPI *_sendto)(SOCKET s, const char *msg, int len, int flags, const struct sockaddr *to, int tolen);
|
||||||
int (WINAPI *_recv)(SOCKET s, void *buf, int len, int flags);
|
int (WINAPI *_recv)(SOCKET s, char *buf, int len, int flags);
|
||||||
int (WINAPI *_recvfrom)(SOCKET s, void * buf, int len, int flags, struct sockaddr * from, int * fromlen);
|
int (WINAPI *_recvfrom)(SOCKET s, char * buf, int len, int flags, struct sockaddr * from, int * fromlen);
|
||||||
int (WINAPI *_shutdown)(SOCKET s, int how);
|
int (WINAPI *_shutdown)(SOCKET s, int how);
|
||||||
int (WINAPI *_closesocket)(SOCKET s);
|
int (WINAPI *_closesocket)(SOCKET s);
|
||||||
#else
|
#else
|
||||||
@@ -746,8 +779,6 @@ typedef enum {
|
|||||||
TYPE_SERVER
|
TYPE_SERVER
|
||||||
}DATA_TYPE;
|
}DATA_TYPE;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
+1
-1
@@ -23,7 +23,7 @@ void * tcppmchild(struct clientparam* param) {
|
|||||||
RETURN (sockmap(param, conf.timeouts[CONNECTION_L]));
|
RETURN (sockmap(param, conf.timeouts[CONNECTION_L]));
|
||||||
CLEANRET:
|
CLEANRET:
|
||||||
|
|
||||||
(*param->srv->logfunc)(param, NULL);
|
(*param->srv->logfunc)(param, param->hostname);
|
||||||
freeparam(param);
|
freeparam(param);
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -59,7 +59,7 @@ void * udppmchild(struct clientparam* param) {
|
|||||||
if((param->clisock=so._socket(SASOCK(¶m->sincr), 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, (char *)&ul, sizeof(int))) {RETURN(820);};
|
||||||
ioctlsocket(param->clisock, FIONBIO, &ul);
|
ioctlsocket(param->clisock, FIONBIO, &ul);
|
||||||
size = sizeof(param->sinsl);
|
size = sizeof(param->sinsl);
|
||||||
if(so._getsockname(param->srv->srvsock, (struct sockaddr *)¶m->sinsl, &size)) {RETURN(21);};
|
if(so._getsockname(param->srv->srvsock, (struct sockaddr *)¶m->sinsl, &size)) {RETURN(21);};
|
||||||
|
|||||||
+2
-2
@@ -1,2 +1,2 @@
|
|||||||
#define VERSION "3proxy-0.8.3"
|
#define VERSION "3proxy-0.8.13"
|
||||||
#define BUILDDATE "160126120751"
|
#define BUILDDATE "190801174904"
|
||||||
+11
-11
@@ -10,7 +10,7 @@
|
|||||||
|
|
||||||
#define RETURN(xxx) { param->res = xxx; goto CLEANRET; }
|
#define RETURN(xxx) { param->res = xxx; goto CLEANRET; }
|
||||||
|
|
||||||
#define LINESIZE 2048
|
#define LINESIZE 65536
|
||||||
|
|
||||||
extern FILE *writable;
|
extern FILE *writable;
|
||||||
FILE * confopen();
|
FILE * confopen();
|
||||||
@@ -341,7 +341,7 @@ void * adminchild(struct clientparam* param) {
|
|||||||
char *sb;
|
char *sb;
|
||||||
char *req = NULL;
|
char *req = NULL;
|
||||||
struct printparam pp;
|
struct printparam pp;
|
||||||
int contentlen = 0;
|
unsigned contentlen = 0;
|
||||||
int isform = 0;
|
int isform = 0;
|
||||||
|
|
||||||
pp.inbuf = 0;
|
pp.inbuf = 0;
|
||||||
@@ -390,7 +390,8 @@ void * adminchild(struct clientparam* param) {
|
|||||||
else if(i > 15 && (!strncasecmp(buf, "content-length:", 15))){
|
else if(i > 15 && (!strncasecmp(buf, "content-length:", 15))){
|
||||||
sb = buf + 15;
|
sb = buf + 15;
|
||||||
while(isspace(*sb))sb++;
|
while(isspace(*sb))sb++;
|
||||||
contentlen = atoi(sb);
|
sscanf(sb, "%u", &contentlen);
|
||||||
|
if(contentlen > LINESIZE*1024) contentlen = 0;
|
||||||
}
|
}
|
||||||
else if(i > 13 && (!strncasecmp(buf, "content-type:", 13))){
|
else if(i > 13 && (!strncasecmp(buf, "content-type:", 13))){
|
||||||
sb = buf + 13;
|
sb = buf + 13;
|
||||||
@@ -473,7 +474,7 @@ void * adminchild(struct clientparam* param) {
|
|||||||
"<td>MB%s</td>"
|
"<td>MB%s</td>"
|
||||||
"<td>%"PRINTF_INT64_MODIFIER"u</td>"
|
"<td>%"PRINTF_INT64_MODIFIER"u</td>"
|
||||||
"<td>%s</td>",
|
"<td>%s</td>",
|
||||||
cp->traflim64,
|
cp->traflim64 / (1024 * 1024),
|
||||||
rotations[cp->type],
|
rotations[cp->type],
|
||||||
cp->traf64,
|
cp->traf64,
|
||||||
cp->cleared?ctime(&cp->cleared):"never"
|
cp->cleared?ctime(&cp->cleared):"never"
|
||||||
@@ -520,7 +521,7 @@ void * adminchild(struct clientparam* param) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
printstr(&pp, "<h3>Please be careful editing config file remotely</h3>");
|
printstr(&pp, "<h3>Please be careful editing config file remotely</h3>");
|
||||||
printstr(&pp, "<form method=\"POST\" action=\"/U\"><textarea cols=\"80\" rows=\"30\" name=\"conffile\">");
|
printstr(&pp, "<form method=\"POST\" action=\"/U\" enctype=\"application/x-www-form-urlencoded\"><textarea cols=\"80\" rows=\"30\" name=\"conffile\">");
|
||||||
while(fgets(buf, 256, fp)){
|
while(fgets(buf, 256, fp)){
|
||||||
printstr(&pp, buf);
|
printstr(&pp, buf);
|
||||||
}
|
}
|
||||||
@@ -530,24 +531,23 @@ void * adminchild(struct clientparam* param) {
|
|||||||
}
|
}
|
||||||
case 'U':
|
case 'U':
|
||||||
{
|
{
|
||||||
int l=0;
|
unsigned l=0;
|
||||||
int error = 0;
|
int error = 0;
|
||||||
|
|
||||||
if(!writable || fseek(writable, 0, 0)){
|
if(!writable || !contentlen || fseek(writable, 0, 0)){
|
||||||
error = 1;
|
error = 1;
|
||||||
}
|
}
|
||||||
while((i = sockgetlinebuf(param, CLIENT, (unsigned char *)buf, LINESIZE - 1, '+', conf.timeouts[STRING_S])) > 0){
|
while(l < contentlen && (i = sockgetlinebuf(param, CLIENT, (unsigned char *)buf, (contentlen - l) > LINESIZE - 1?LINESIZE - 1:contentlen - l, '+', conf.timeouts[STRING_S])) > 0){
|
||||||
if(i > (contentlen - l)) i = (contentlen - l);
|
if(i > (contentlen - l)) i = (contentlen - l);
|
||||||
buf[i] = 0;
|
|
||||||
if(!l){
|
if(!l){
|
||||||
if(strncasecmp(buf, "conffile=", 9)) error = 1;
|
if(i<9 || strncasecmp(buf, "conffile=", 9)) error = 1;
|
||||||
}
|
}
|
||||||
if(!error){
|
if(!error){
|
||||||
|
buf[i] = 0;
|
||||||
decodeurl((unsigned char *)buf, 1);
|
decodeurl((unsigned char *)buf, 1);
|
||||||
fprintf(writable, "%s", l? buf : buf + 9);
|
fprintf(writable, "%s", l? buf : buf + 9);
|
||||||
}
|
}
|
||||||
l += i;
|
l += i;
|
||||||
if(l >= contentlen) break;
|
|
||||||
}
|
}
|
||||||
if(writable && !error){
|
if(writable && !error){
|
||||||
fflush(writable);
|
fflush(writable);
|
||||||
|
|||||||
Reference in new issue
Block a user