Compare commits

...
Author SHA1 Message Date
z3APA3A ac13a75721 publish as 0.8.6 2016-03-07 16:54:55 +03:00
z3APA3A f74da31fb3 Merge remote-tracking branch 'refs/remotes/origin/devel' 2016-03-04 13:45:46 +03:00
z3APA3A 5d0504cd33 Always reset bind sa on connect 2016-03-04 13:44:53 +03:00
z3APA3A cbe3d0cde9 publish as 0.8.5 2016-03-02 23:12:32 +03:00
z3APA3A 5e850b54c3 Merge remote-tracking branch 'refs/remotes/origin/devel'
# Conflicts:
#	src/version.h
2016-03-02 22:57:05 +03:00
z3APA3A 58a64924dd log_mutex used prior to initialization 2016-03-02 19:00:28 +03:00
z3APA3A 75a7d5bb9e Remove SSLPlugin and PamAuth from default Linux makefile 2016-03-02 19:00:01 +03:00
z3APA3A 10a79faa32 publish as devel 2016-02-28 15:10:38 +03:00
z3APA3A 394ada524a publish as 0.8.4 2016-02-28 13:52:53 +03:00
z3APA3A 1404c63e10 add index.html to repro 2016-02-28 13:40:25 +03:00
z3APA3A 3c751f4b75 add index.html to repro 2016-02-28 13:38:43 +03:00
z3APA3A 09cfc076e2 Merge remote-tracking branch 'refs/remotes/origin/devel' 2016-02-28 13:24:48 +03:00
z3APA3A 5d9c1af5ca Build PamAuth plugin by default in *nix 2016-02-26 13:17:15 +03:00
z3APA3A 6db42f70e9 fix compilation warnings in PamAuth 2016-02-26 13:15:34 +03:00
z3APA3A 99781ceb23 ignore more binary files 2016-02-26 11:44:10 +03:00
z3APA3A 22524d7876 ignore some files under *nix / Mac OS 2016-02-26 11:41:43 +03:00
z3APA3A 9d85bf75ba Ignore *nix binaries 2016-02-23 19:10:32 +03:00
z3APA3A 19643f0d66 Documentation update + add SQL example to git 2016-02-22 23:08:31 +03:00
z3APA3A 68e8530f85 remove contrib because of outdated content 2016-02-22 22:53:50 +03:00
z3APA3A 6a8fee9847 minor 3ps file modification 2016-02-22 22:48:02 +03:00
z3APA3A 364fe22bbb add rus.3ps to git 2016-02-22 22:44:59 +03:00
z3APA3A e2351034e6 Change encoding to utf-8 in strings 2016-02-22 22:43:22 +03:00
z3APA3A 49d382c7db Build PamAuth in Linux by default 2016-02-22 22:41:52 +03:00
z3APA3A 89fd5a95ae minor gitignore modifications 2016-02-22 22:18:15 +03:00
z3APA3A 57f1140734 Changes in makefiles to support LDAP plugin compilation 2016-02-22 21:46:32 +03:00
z3APA3A aa38dd2ad2 Merge remote-tracking branch 'refs/remotes/origin/master' into devel 2016-02-22 21:16:18 +03:00
z3APA3A c96d415020 Defer SSL init to first command in ssl_plugin 2016-02-22 21:14:17 +03:00
z3APA3A 604cc22d16 mark as 0.8.4 2016-02-22 00:53:10 +03:00
z3APA3A 01857354c8 Merge remote-tracking branch 'refs/remotes/origin/devel' 2016-02-22 00:22:01 +03:00
z3APA3A 021a8928bf Avoid windows compilation warnings 2016-02-22 00:18:45 +03:00
z3APA3A cf3bae0f6b Revert "additional memset for hint on retry"
This reverts commit bb206869de.
2016-02-22 00:14:54 +03:00
z3APA3A bb206869de additional memset for hint on retry 2016-02-20 15:45:44 +03:00
z3APA3A 5c5f4e258f Increase default stack size for *nix 2016-02-20 09:11:03 +03:00
z3APA3A f8a7266bdf Handle malformed HTTP headers without \r 2016-02-19 20:47:56 +03:00
z3APA3A ad9b0046d9 Fix thread init bug introduced 2016-02-19 20:21:16 +03:00
z3APA3A b40e8fae4c increase stack size for FreeBSD 2016-02-19 19:44:38 +03:00
z3APA3A 6fcd12cb08 TransparentPlugin - remove debug output 2016-02-19 17:10:15 +03:00
Vladimir Dubrovin 9ddc1fb874 fix *nix warnings 2016-02-18 17:01:18 +03:00
z3APA3A 43a36ec813 Warnings cleanup 2016-02-18 16:43:37 +03:00
z3APA3A 0d02989cce minor man updates 2016-02-17 18:23:29 +03:00
z3APA3A 33e0eb5495 Documentation update for stacksize / -S 2016-02-17 17:52:18 +03:00
z3APA3A 3b8e7741b3 Compilation warnings cleanup 2016-02-16 15:29:51 +03:00
z3APA3A f70a8c0019 Makefile for Windows llvm build 2016-02-16 01:03:15 +03:00
z3APA3A 5fc1d81e5c add stack size configuration
'stacksize' command and -S configuration option added
2016-02-11 16:16:44 +03:00
z3APA3A 3680f2d3b1 Do not negotiate handshake for extip redirection 2016-02-08 14:39:29 +03:00
z3APA3A 6713530fda log_mutex init moved to proxymain 2016-02-05 19:04:16 +03:00
z3APA3A 13a7d6be11 Replace memcpy with assignment where appropriate 2016-02-05 18:31:17 +03:00
z3APA3A 3cc9796583 Support for 'extip' and 'smtp' parent types added 2016-02-05 01:52:45 +03:00
z3APA3A 9db88313c7 minor documentation correction 2016-01-31 23:22:45 +03:00
z3APA3A 0263574655 minor documentation correction 2016-01-31 23:22:02 +03:00
z3APA3A 0e168f17f9 Merge remote-tracking branch 'refs/remotes/origin/devel' 2016-01-31 15:08:21 +03:00
z3APA3A 4f7a82ed92 Update rc for 0.8.4 2016-01-31 15:07:08 +03:00
z3APA3A 4202cee566 Merge remote-tracking branch 'refs/remotes/origin/devel'
# Conflicts:
#	src/version.h
2016-01-31 15:04:22 +03:00
z3APA3A faf7f665c3 do memset for 'external' sockaddr structures 2016-01-31 15:01:17 +03:00
z3APA3A 852f1abecb Documentation for TransparentPlugin added 2016-01-30 00:00:00 +03:00
z3APA3A 485ccb3ab4 publish as devel 2016-01-28 01:21:13 +03:00
z3APA3A e23dd7b746 minor logging changes 2016-01-28 01:18:16 +03:00
z3APA3A 95efeb8a93 Handle accept() errors more accurate 2016-01-28 01:07:09 +03:00
z3APA3A 43da6cc32b remove premake from makefile 2016-01-28 01:04:25 +03:00
z3APA3A 0473e1b2f7 publish as devel 2016-01-27 23:08:17 +03:00
z3APA3A 975b4ac445 Remove date from copyright notice in proxy.h 2016-01-27 17:56:01 +03:00
z3APA3A 48361db51c Add versioning information only to 3proxy.exe 2016-01-27 17:55:40 +03:00
z3APA3A ade0df0956 Add builddate to rc file for devel version 2016-01-27 17:55:11 +03:00
z3APA3A c61533aa54 .rc file updated 2016-01-27 17:30:54 +03:00
z3APA3A 0883fb6e34 Show traffic limit in MBs 2016-01-27 15:38:47 +03:00
z3APA3A 79170af2bc publish as 0.8.3 2016-01-26 12:10:55 +03:00
z3APA3A 331c933508 publish as 0.8.3 2016-01-25 22:55:08 +03:00
z3APA3A 2de3f0c380 publish as devel 2016-01-25 22:48:09 +03:00
z3APA3A d1334e5157 Merge remote-tracking branch 'refs/remotes/origin/devel'
# Conflicts:
#	src/version.h
2016-01-25 15:06:42 +03:00
z3APA3A fec0da52af fixed: use SASIZE() instead of sizeof() in connect() for FreeBSD compatibility 2016-01-25 14:49:17 +03:00
z3APA3A 7a7cd9bc25 README updated 2016-01-23 20:44:01 +03:00
z3APA3A bb8e5832eb update README 2016-01-23 20:38:10 +03:00
z3APA3A c2a7fdc2a2 release as devel 2016-01-23 19:26:20 +03:00
z3APA3A 3cbbe1aef7 publish as 0.8.2 2016-01-23 19:17:36 +03:00
z3APA3A 69cb310481 Merge remote-tracking branch 'refs/remotes/origin/devel' 2016-01-23 18:48:28 +03:00
z3APA3A 375a2c9f6e Do not use SO_REUSEADDR by default
to avoid misbehavior in some glibc versions
2016-01-23 18:43:30 +03:00
z3APA3A 1ed5229a54 Do not use SO_REUSEADDR by default
to avoid misbehavior in some glibc versions
2016-01-23 18:41:20 +03:00
z3APA3A d6f29ac6df reset transparent flag on keep-alive connection 2016-01-23 17:16:49 +03:00
z3APA3A 82e76d1d2a Merge remote-tracking branch 'refs/remotes/origin/devel' 2016-01-22 16:20:12 +03:00
z3APA3A 4af5f2fde7 Use SASIZE() instead of sizeof() in bind() for FreeBSD compatibility 2016-01-22 15:59:40 +03:00
z3APA3A 95a07c1b46 minor documentation update 2016-01-21 16:53:38 +03:00
z3APA3A 3a4f3b5cd1 publish as 0.8.1 2016-01-21 16:26:08 +03:00
z3APA3A a6383bbd10 Merge remote-tracking branch 'refs/remotes/origin/devel'
# Conflicts:
#	src/version.h
2016-01-21 15:50:17 +03:00
z3APA3A 359026cb5f !!Fix: destination IP may be not checked against ACL 2016-01-21 15:45:39 +03:00
z3APA3A 244be50405 publish as 0.8.0
only version number is changed
2016-01-20 01:20:05 +03:00
z3APA3A e3fb268b64 publish as 0.8 2016-01-20 01:08:48 +03:00
z3APA3A 5e440b4482 publish as 0.9-devel 2016-01-20 01:04:03 +03:00
z3APA3A 94f3b1fe30 Merge remote-tracking branch 'refs/remotes/origin/devel' 2016-01-19 17:04:56 +03:00
z3APA3A ee407adf42 update man for -6 2016-01-19 16:41:04 +03:00
z3APA3A e5dd28003c Merge remote-tracking branch 'refs/remotes/origin/devel' 2016-01-17 02:14:16 +03:00
z3APA3A fcbccf39ef Use configured timeouts for DNS operations instead static ones 2016-01-17 02:13:17 +03:00
z3APA3A 928f67aed1 Merge remote-tracking branch 'refs/remotes/origin/devel' 2016-01-16 00:39:58 +03:00
z3APA3A e59ccd22b1 typo corrected in last update 2016-01-16 00:38:53 +03:00
z3APA3A 75c63d2de6 add support for -u2 in socks 2016-01-15 15:29:57 +03:00
z3APA3A 999f9e856b Merge remote-tracking branch 'refs/remotes/origin/devel' 2016-01-15 03:07:59 +03:00
z3APA3A 08be6b9f98 minor documentations updates 2016-01-15 03:06:06 +03:00
z3APA3A 0be4ee932b Merge remote-tracking branch 'refs/remotes/origin/master' into devel 2016-01-15 02:41:55 +03:00
z3APA3A 08aa876ecd minor man changes 2016-01-15 02:41:14 +03:00
z3APA3A 87c947987c Merge remote-tracking branch 'refs/remotes/origin/devel' 2016-01-15 02:27:40 +03:00
z3APA3A 1ef7308cbf Update documentation for connect back 2016-01-15 02:26:56 +03:00
z3APA3A d1f8180eab IPv6 and name resolution documentation updated for 0.8 2016-01-15 01:24:08 +03:00
z3APA3A 1000d80fc0 Merge remote-tracking branch 'refs/remotes/origin/devel' 2016-01-13 23:54:57 +03:00
z3APA3A 27a190cd04 Russian plugin documentation added 2016-01-13 23:53:18 +03:00
z3APA3A e78d9f8327 plugins documentation added 2016-01-13 23:35:35 +03:00
z3APA3A ae25aac635 Merge remote-tracking branch 'refs/remotes/origin/devel' 2016-01-13 02:15:59 +03:00
z3APA3A b6dadc1954 Merge remote-tracking branch 'refs/remotes/origin/devel' 2016-01-13 02:14:15 +03:00
z3APA3A 8b7c95ff93 Update man pages 2016-01-13 02:13:49 +03:00
z3APA3A 5a89997d6e convert russian documentation to UTF-8 2016-01-13 01:53:22 +03:00
z3APA3A c2d012bf71 Merge remote-tracking branch 'refs/remotes/origin/master' into devel 2016-01-13 01:46:07 +03:00
z3APA3A b3923593ed Convert russian documentation to utf-8 2016-01-13 01:41:51 +03:00
z3APA3A 9dd2170d6f publish as 0.8-pre 2016-01-13 00:42:48 +03:00
81 changed files with 2810 additions and 2126 deletions

No files matched your search

+15 -4
View File
@@ -15,17 +15,29 @@ tmp/
*.swp
*.o
*.idb
src/res
res
version.c
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/man8/
doc/html/index.html
*.var
verfile.sh
Makefile
Changelog
res
copytgz.sh
*~.nib
local.properties
@@ -157,7 +169,6 @@ csx
AppPackages/
# Others
sql/
*.Cache
ClientBin/
[Ss]tyle[Cc]op.*
+15 -16
View File
@@ -1,26 +1,25 @@
#include "src/version.h"
LANGUAGE 0x09, 0x01
VS_VERSION_INFO VERSIONINFO
FILEVERSION 0,8,0,0
PRODUCTVERSION 0,8,0,0
FILETYPE 0x1L
FILESUBTYPE 0x0L
1 VERSIONINFO
FILEVERSION 0,8,6,0
PRODUCTVERSION 0,8,6,0
FILETYPE 1
FILESUBTYPE 0x0L
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "000004b0"
BLOCK "040904E4"
BEGIN
VALUE "Comments", "3proxy - tiny proxy server, http://3proxy.ru/"
VALUE "CompanyName", "Vladimir Dubrovin"
VALUE "FileDescription", "3proxy - tiny proxy server"
VALUE "FileVersion", VERSION "-" BUILDDATE
VALUE "InternalName", "3proxy"
VALUE "LegalCopyright", "Copyright (C) 2002-2014 Vladimir Dubrovin"
VALUE "OriginalFilename", "3proxy.exe"
VALUE "ProductName", "3proxy - tiny proxy server"
VALUE "ProductVersion", VERSION
VALUE "Comments", "3proxy - tiny proxy server, http://3proxy.ru/\0"
VALUE "CompanyName", "Vladimir Dubrovin\0"
VALUE "FileDescription", "3proxy - tiny proxy server\0"
VALUE "FileVersion", "0.8.6\0"
VALUE "InternalName", "3proxy\0"
VALUE "LegalCopyright", "Copyright (C) 2002-2016 Vladimir Dubrovin\0"
VALUE "OriginalFilename", "3proxy.exe\0"
VALUE "ProductName", "3proxy\0"
VALUE "ProductVersion", "0.8.6\0"
END
END
BLOCK "VarFileInfo"
+8 -2
View File
@@ -18,7 +18,8 @@ LDFLAGS = -O2 -pthread
DLFLAGS = -shared
DLSUFFICS = .ld.so
# -lpthreads may be reuqired on some platforms instead of -pthreads
LIBS = -lcrypto -lssl -ldl
LIBSPREFIX = -l
LIBSSUFFIX =
LNOUT = -o
EXESUFFICS =
OBJSUFFICS = .o
@@ -28,7 +29,12 @@ REMOVECOMMAND = rm -f
TYPECOMMAND = cat
COMPATLIBS =
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
+2
View File
@@ -17,6 +17,8 @@ DCFLAGS = -fpic
DLFLAGS = -shared
DLSUFFICS = .ld.so
LIBS = -lpthread -lsocket -lnsl -lresolv -ldl
LIBSPREFIX = -l
LIBSSUFFIX =
LNOUT = -o ./
EXESUFFICS =
OBJSUFFICS = .o
+2
View File
@@ -18,6 +18,8 @@ DCFLAGS = -fpic
DLFLAGS = -shared
DLSUFFICS = .ld.so
LIBS = -lpthread -lsocket -lnsl -lresolv -ldl
LIBSPREFIX = -l
LIBSSUFFIX =
LNOUT = -o ./
EXESUFFICS =
OBJSUFFICS = .o
-34
View File
@@ -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
+36
View File
@@ -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 -c -pthread -static -DWITH_STD_MALLOC -DNOIPV6
COUT = -o
LN = clang
LDFLAGS = -O2 -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 ..\..)
+3 -1
View File
@@ -11,11 +11,13 @@ CC = cl
CFLAGS = /nologo /MT /W3 /Ox /GS /EHs- /GA /GF /D "MSVC" /D "WITH_STD_MALLOC" /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "_WIN32" /Fp"proxy.pch" /FD /c
COUT = /Fo
LN = link
LDFLAGS = /nologo /subsystem:console /incremental:no /machine:I386
LDFLAGS = /nologo /subsystem:console /incremental:no /machine:I386
DLFLAGS = /DLL
DLSUFFICS = .dll
LIBS = ws2_32.lib advapi32.lib odbc32.lib user32.lib kernel32.lib Gdi32.lib libeay32MT.lib ssleay32MT.lib
LIBSOLD = libeay32MT.lib ssleay32MT.lib
LIBSPREFIX =
LIBSSUFFIX = .lib
LIBEXT = .lib
LNOUT = /out:
EXESUFFICS = .exe
+2
View File
@@ -16,6 +16,8 @@ DLFLAGS = /DLL
DLSUFFICS = .dll
LIBS = ws2_32.lib advapi32.lib odbc32.lib user32.lib kernel32.lib Gdi32.lib libeay32MT.lib ssleay32MT.lib
LIBSOLD = libeay32MT.lib ssleay32MT.lib
LIBSPREFIX =
LIBSSUFFIX = .lib
LIBEXT = .lib
LNOUT = /out:
EXESUFFICS = .exe
+3 -1
View File
@@ -21,6 +21,8 @@ DCFLAGS = -fpic
DLFLAGS = -shared
DLSUFFICS = .ld.so
LIBS =
LIBSPREFIX = -l
LIBSSUFFIX =
LNOUT = -o
EXESUFFICS =
OBJSUFFICS = .o
@@ -30,7 +32,7 @@ REMOVECOMMAND = rm -f
TYPECOMMAND = cat
COMPATLIBS =
MAKEFILE = Makefile.unix
PLUGINS = StringsPlugin TrafficPlugin PCREPlugin
PLUGINS = StringsPlugin TrafficPlugin PCREPlugin PamAuth
include Makefile.inc
+3 -1
View File
@@ -13,10 +13,12 @@ CC = gcc
CFLAGS = -O2 -s -c -mthreads -DWITH_STD_MALLOC -DNOIPV6
COUT = -o
LN = gcc
LDFLAGS = -O2 -s -mthreads
LDFLAGS = -O2 -s -mthreads
DLFLAGS = -shared
DLSUFFICS = .dll
LIBS = -lws2_32 -lodbc32 -ladvapi32
LIBSPREFIX = -l
LIBSSUFFIX =
LNOUT = -o
EXESUFFICS = .exe
OBJSUFFICS = .o
+106 -3
View File
@@ -7,15 +7,118 @@
Please read doc/html/index.html and man pages.
Features:
1. General
+ HTTP/1.1 Proxy with keep-alive client and server support,
transparent proxy support.
+ Anonymous and random client emulation HTTP proxy mode
+ FTP over HTTP support.
+ DNS caching with built-in resolver
+ HTTPS (CONNECT) proxy
+ SOCKSv4/4.5 Proxy
+ SOCKSv5 Proxy
+ UDP and bind support for SOCKSv5 (fully compatible with
SocksCAP/FreeCAP for UDP)
+ Transparent SOCKS redirection for HTTP, POP3, FTP, SMTP, ICQ
+ POP3 Proxy
+ FTP proxy
+ DNS proxy
+ TCP port mapper
+ UDP port mapper
+ SMTP proxy
+ ICQ/AOL proxy
+ Threaded application (no child process).
+ Web administration and statistics
+ Plugins for functionality extension
+ Native 64 bit application for 64 bit OS, including 64-bit editions of
Windows.
+ IPv6 support
2. Proxy chaining and network connections
+ Connect back proxy support to bypass firewalls
+ Parent proxy support for any type of incoming connection
+ Username/password authentication for parent proxy(s).
+ HTTPS/SOCKS4/SOCKS5 and redirection parent support
+ Random parent selection
+ Chain building (multihop proxing)
+ Load balancing between few network connections by choosing network
interface
3. Logging
+ turnable log format compatible with any log parser
+ stdout logging
+ file logging
+ syslog logging (Unix)
+ ODBC logging
+ log file rotation (hourly, daily, weekly, monthly)
+ automatic log file comperssion with external archiver (for files)
+ automatic removal of older log files
+ Character filtering for log files
+ different log files for different servces are supported
4. Access control
+ ACL-driven (user/source/destination/protocol/weekday/daytime or
combined) bandwith limitation for incoming and (!)outgoing trafic.
+ ACL-driven (user/source/destination/protocol/weekday/daytime or
combined) traffic limitation per day, week or month for incoming and
(!) outgoing traffic
+ User authentication by DNS hostname
+ User authentication by username / password
+ Access control by username, source IP, destination IP, destination
port and destination action (POST, PUT, GET, etc), weekday and daytime.
+ Access control by username/password for SOCKSv5 and HTTP/HTTPS/FTP
+ Cleartext or encrypted (crypt/MD5 or NT) passwords.
+ Connection redirection
+ Access control by requested action (CONNECT/BIND,
HTTP GET/POST/PUT/HEAD/OTHER).
+ NTLM (v1 only) authentication for HTTP proxy access
+ All access control entries now support weekday and time limitations
+ Hostnames and * templates are supported instead of IP address
5. Extensions
+ Regular expression filtering (with PCRE) via PCREPlugin
currently HTTP traffic only for URLs, HTTP headers and HTTP data.
+ Authentication with Windows username/password (cleartext only!)
+ SSL/TLS decryptions with certificate spoofing
+ NAT support under Linux
6. Configuration
+ support for configuration files
+ support for includes in configuration files
+ interface binding
+ running as daemon process
+ utility for automated networks list building
+ configuration reload on any file change
Unix
+ support for chroot
+ support for setgid
+ support for setuid
+ support for signals
Windows
+ support --install as service
+ support --remove as service
+ support for service START, STOP, PAUSE and CONTINUE commands (on
PAUSE no new connection accepted, but active connections still in
progress, on CONTINUE configuration is reloaded)
Windows 95/98/ME
+ support --install as service
+ support --remove as service
6. Compilation
+ MSVC (static)
+ Intel Windows Compiler (msvcrt.dll)
+ Windows/gcc (msvcrt.dll)
+ Cygwin/gcc (cygwin.dll)
+ Unix/gcc
+ Unix/ccc
+ Solaris
+ Mac OS X, iPhone OS
+ Linux and derivered systems
+ Lite version for Windows 95/98/NT/2000/XP/2003
+ 32 bit and 64 bit versions for Windows Vista and above, Windows 2008 server and above
3proxy Combined proxy server may be used as
Windows 95/98/NT/2000/XP/2003/Vista
executable or service (supports installation and removal).
It uses config file to read it's configuration (see
3proxy.cfg.sample for details).
--install installs and starts proxy as NT/2000/XP service
--install installs and starts proxy as Windows service
(config file should be located in the same directory)
--remove removes the service (should be stopped before via
net stop 3proxy).
'net stop 3proxy').
3proxy.exe is all-in-one, it doesn't require all others .exe
to work.
See 3proxy.cfg.sample for examples, see man 3proxy.cfg
+53
View File
@@ -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
+56
View File
@@ -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.
-6
View File
@@ -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)
-15
View File
@@ -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
-15
View File
@@ -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
-191
View File
@@ -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;
}
-22
View File
@@ -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');
-63
View File
@@ -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 ------------------------------------
-129
View File
@@ -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
}
-185
View File
@@ -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}++;
}
+9 -1
View File
@@ -64,6 +64,14 @@ to automatically reload configuration on address change.
A: Check you use system DSN.
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.
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>
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.
@@ -114,7 +122,7 @@ parent 1000 http 0.0.0.0 0
allow * * $c:\3proxy\local.nets 80,8080-8088
#allow direct access to local.nets networks
allow * * * 80,8080-8088
parent 1000 http proxy.sandy.ru 3128
parent 1000 http proxy.3proxy.ru 3128
#use parent caching proxy for rest of the networks
allow *
+192 -184
View File
@@ -1,280 +1,288 @@
<meta http-equiv="Content-Type" content="text/html; charset=windows-1251">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
3APA3A 3proxy tiny proxy server Frequently Asked Questions (FAQ)
<ul>
<li><a href="#TROUBLE">Почему не работает...</a></li>
<li><a href="#TROUBLE">Почему не работает...</a></li>
<ul>
<li><a href="#NOTHING">Q: Почему ничего не работает?</a></li>
<li><a href="#LIMITS">Q: Почему не работают ограничения доступа (перенаправления, ограничения по скорости, трафику и т.д.)?</a></li>
<li><a href="#SERVICE">Q: Почему 3proxy не запускается как служба?</a></li>
<li><a href="#INTEXT">Q: Почему не получается указать internal и external?</a></li>
<li><a href="#ODBC">Q: Почему не работает ведение журналов в ODBC?</a></li>
<li><a href="#CHAP">Q: Почему не поддерживаются APOP и CRAM-MD5 в POP3 прокси?</a></li>
<li><a href="#NOTHING">Q: Почему ничего не работает?</a></li>
<li><a href="#LIMITS">Q: Почему не работают ограничения доступа (перенаправления, ограничения по скорости, трафику и т.д.)?</a></li>
<li><a href="#SERVICE">Q: Почему 3proxy не запускается как служба?</a></li>
<li><a href="#INTEXT">Q: Почему не получается указать internal и external?</a></li>
<li><a href="#ODBC">Q: Почему не работает ведение журналов в ODBC?</a></li>
<li><a href="#CHAP">Q: Почему не поддерживаются APOP и CRAM-MD5 в POP3 прокси?</a></li>
<li><a href="#CRASH">Q: Почему прокси крэшится при обработке запроса?</a></li>
</ul>
<li><a href="#SOCKSREDIR">Перенаправление socks соединений в локальный прокси</a></li>
<li><a href="#SOCKSREDIR">Перенаправление socks соединений в локальный прокси</a></li>
<ul>
<li><a href="#REDIR">Q: Для чего это надо?</a></li>
<li><a href="#REDIRLIMIT">Q: Какие недостатки?</a></li>
<li><a href="#REDIRADV">Q: Какие преимущества?</a></li>
<li><a href="#REDIRHOW">Q: Как настраивается?</a></li>
<li><a href="#REDIINTER">Q: Как взаимодействует с другими правилами в ACL?</a></li>
<li><a href="#REDIR">Q: Для чего это надо?</a></li>
<li><a href="#REDIRLIMIT">Q: Какие недостатки?</a></li>
<li><a href="#REDIRADV">Q: Какие преимущества?</a></li>
<li><a href="#REDIRHOW">Q: Как настраивается?</a></li>
<li><a href="#REDIINTER">Q: Как взаимодействует с другими правилами в ACL?</a></li>
</ul>
<li><a href="#ISIT">А есть ли...</a></li>
<li><a href="#ISIT">А есть ли...</a></li>
<ul>
<li><a href="#NAMES">Можно ли разрешать имена на родительском прокси?</a></li>
<li><a href="#ISFTP">Существует ли сейчас поддержка FTP прокси в продукте?</a></li>
<li><a href="#PORT">Каким образом можно прибиндить сервисы на свой порт, к примеру, HTTP прокси к 8080, а не 3128 как по-умолчанию?</a></li>
<li><a href="#BANDLIM">Как ограничить ширину канала?</a></li>
<li><a href="#NAMES">Можно ли разрешать имена на родительском прокси?</a></li>
<li><a href="#ISFTP">Существует ли сейчас поддержка FTP прокси в продукте?</a></li>
<li><a href="#PORT">Каким образом можно прибиндить сервисы на свой порт, к примеру, HTTP прокси к 8080, а не 3128 как по-умолчанию?</a></li>
<li><a href="#BANDLIM">Как ограничить ширину канала?</a></li>
</ul>
<li><a href="#BRRR">Почему так криво...</a></li>
<li><a href="#BRRR">Почему так криво...</a></li>
<ul>
<li><a href="#TRAF">Почему так криво считается трафик? Не совпадает с ...</a></li>
<li><a href="#CONFIG">Почему такая кривая конфигурация и ничерта не понятно?</a></li>
<li><a href="#CODE">Почему так криво написан код?</a>
<li><a href="#UNSAFE">Почему так много strcpy, sprintf и т.д., это ж дыры!</a>
<li><a href="#TRAF">Почему так криво считается трафик? Не совпадает с ...</a></li>
<li><a href="#CONFIG">Почему такая кривая конфигурация и ничерта не понятно?</a></li>
<li><a href="#CODE">Почему так криво написан код?</a>
<li><a href="#UNSAFE">Почему так много strcpy, sprintf и т.д., это ж дыры!</a>
</ul>
</ul>
<hr>
<li><b><a name="TROUBLE">Почему не работает...<a></b></li>
<li><b><a name="TROUBLE">Почему не работает...<a></b></li>
<ul>
<li><a name="NOTHING"><i>Q: Почему ничего не работает?</i></a></li>
<li><a name="NOTHING"><i>Q: Почему ничего не работает?</i></a></li>
<p>
<i>A:</i> Потому что для работы нужен правильный файл конфигурации.
<i>A:</i> Потому что для работы нужен правильный файл конфигурации.
</p>
<li><a name="LIMITS"><i>Q: Почему не работают ограничения доступа (перенаправления, ограничения по скорости,
трафику и т.д.)?</i></a></li>
<li><a name="LIMITS"><i>Q: Почему не работают ограничения доступа (перенаправления, ограничения по скорости,
трафику и т.д.)?</i></a></li>
<p>
<i>A:</i> Обычные ошибки - использование auth none (для работы любых
функций, основанных на ACL, требуется auth iponly, nbname или strong),
нарушение порядка ввода команд (команды выполняются последовательно,
запуск сервиса proxy, socks, tcppm и т.д. должен осуществляться после
того, как указана его конфигурация), неправильный порядок записей в ACL
(записи просматриваются последовательно до первой, удовлетворяющей
критериям). Если в ACL имеется хотя бы одна запись, то считается, что
последняя запись в ACL - это неявная deny *.
<i>A:</i> Обычные ошибки - использование auth none (для работы любых
функций, основанных на ACL, требуется auth iponly, nbname или strong),
нарушение порядка ввода команд (команды выполняются последовательно,
запуск сервиса proxy, socks, tcppm и т.д. должен осуществляться после
того, как указана его конфигурация), неправильный порядок записей в ACL
(записи просматриваются последовательно до первой, удовлетворяющей
критериям). Если в ACL имеется хотя бы одна запись, то считается, что
последняя запись в ACL - это неявная deny *.
</p>
<li><a name="SERVICE"><i>Q: Почему 3proxy не запускается как служба?</i></a></li>
<li><a name="SERVICE"><i>Q: Почему 3proxy не запускается как служба?</i></a></li>
<p>
<i>A:</i> Наиболее вероятные причины:
<i>A:</i> Наиболее вероятные причины:
<ul>
<li>Отсутствие команды service в файле конфигурации - команда необходима в 3proxy 0.5.2 и более ранних, чтобы 3proxy вел себя как системная служба Windows
<li>Использование относительных (неполных) путей файлов в файле конфигурации
При использовании файлов журналов, файлов вставок ($filename) используйте
полные пути, например, $"c:\3proxy\include files\networks.local". Тоже самое
относится к файлам журналов и любым другим.
Для отладки лучше запускать 3proxy с ведением журнала на стандартный вывод.
Не забудьте в таком случае отключить daemon и service в файле конфигурации.
Для чистоты эксперимента запускать 3proxy из коммандной строки в таком случае
следует, находясь в другой папке.
<li>Отсутствие у системной записи прав на доступ к исполняемому файлу, каким-либо файлам конфигурации, журнала и т.п.
<li>Отсутствие файла конфигурации по стандартному расположению -
3proxy.cfg в одном каталоге с исполняемым файлом. Если файл расположен по
другому пути, необходимо использовать команду
<li>Отсутствие команды service в файле конфигурации - команда необходима в 3proxy 0.5.2 и более ранних, чтобы 3proxy вел себя как системная служба Windows
<li>Использование относительных (неполных) путей файлов в файле конфигурации
При использовании файлов журналов, файлов вставок ($filename) используйте
полные пути, например, $"c:\3proxy\include files\networks.local". Тоже самое
относится к файлам журналов и любым другим.
Для отладки лучше запускать 3proxy с ведением журнала на стандартный вывод.
Не забудьте в таком случае отключить daemon и service в файле конфигурации.
Для чистоты эксперимента запускать 3proxy из коммандной строки в таком случае
следует, находясь в другой папке.
<li>Отсутствие у системной записи прав на доступ к исполняемому файлу, каким-либо файлам конфигурации, журнала и т.п.
<li>Отсутствие файла конфигурации по стандартному расположению -
3proxy.cfg в одном каталоге с исполняемым файлом. Если файл расположен по
другому пути, необходимо использовать команду
<pre>
3proxy --install path_to_configuration_file</pre>
<li>Отсутствие у пользователя прав на установку или запуск службы
<li>Служба уже установлена или запущена
<li>Отсутствие у пользователя прав на установку или запуск службы
<li>Служба уже установлена или запущена
</ul>
</p>
<li><a name="INTEXT"><i>Q: Почему не получается указать internal и external?</i></a></li></li>
<li><a name="INTEXT"><i>Q: Почему не получается указать internal и external?</i></a></li></li>
<p>
<i>A:</i> Убедитесь, что выправильно понимаете что такое internal и external адреса.
Оба адреса - это адреса, принадлежищие хосту, на котором установлен 3proxy.
Эта опция конфигурации необходима в классической ситуации, когда 3proxy
установлен на граничном компьютере с двумя (или более) подключениями:
<i>A:</i> Убедитесь, что выправильно понимаете что такое internal и external адреса.
Оба адреса - это адреса, принадлежищие хосту, на котором установлен 3proxy.
Эта опция конфигурации необходима в классической ситуации, когда 3proxy
установлен на граничном компьютере с двумя (или более) подключениями:
<pre>
LAN connection +-------------+ Internet connection
LAN <-------------->| 3proxy host |<-------------------> INTERNET
^+-------------+^
| |
Internal IP External IP</pre>
Если 3proxy работает на хосте с одним интерфейсом, то его адрес будет и
internal и external.
<br>Интерфейс с адресом internal должен существовать и быть рабочим на момент
запуска 3proxy, и не должен отключаться. Если internal интерфейс
периодически отключается, то не следует его указывать, или можно указать адрес
0.0.0.0. При этом прокси будет принимать запросы на всех интерфейсах, поэтому
при наличии нескольких интерфейсов для ограничения доступа следует использовать
фаервол или хотя бы ACL.
Если 3proxy работает на хосте с одним интерфейсом, то его адрес будет и
internal и external.
<br>Интерфейс с адресом internal должен существовать и быть рабочим на момент
запуска 3proxy, и не должен отключаться. Если internal интерфейс
периодически отключается, то не следует его указывать, или можно указать адрес
0.0.0.0. При этом прокси будет принимать запросы на всех интерфейсах, поэтому
при наличии нескольких интерфейсов для ограничения доступа следует использовать
фаервол или хотя бы ACL.
</p>
<p>
Интерфейс с адресом external, если он указан, должен быть рабочим на момент
получения запроса клиента. При отсутствии external или адресе 0.0.0.0 внешний
адрес будет выбираться системой при установке соединения. При этом, может быть
возможность доступа через прокси к ресурсам локальной сети, поэтому для
предотвращения несанкционированного доступа следует использовать ACL. Кроме
того, могут быть проблемы с приемом входящих соединений через SOCKSv5
(SOCKSv5 используется в клиентах исключительно редко).
В случае, если адрес динамический, можно либо не
указывать external, либо использовать адрес 0.0.0.0, либо, если необходима
поддержка входящих соединений в SOCKSv5, использовать скрипт,
который будет получать текущий адрес и сохранять его в файл, который будет
отслуживаться через команду monitor.
Интерфейс с адресом external, если он указан, должен быть рабочим на момент
получения запроса клиента. При отсутствии external или адресе 0.0.0.0 внешний
адрес будет выбираться системой при установке соединения. При этом, может быть
возможность доступа через прокси к ресурсам локальной сети, поэтому для
предотвращения несанкционированного доступа следует использовать ACL. Кроме
того, могут быть проблемы с приемом входящих соединений через SOCKSv5
(SOCKSv5 используется в клиентах исключительно редко).
В случае, если адрес динамический, можно либо не
указывать external, либо использовать адрес 0.0.0.0, либо, если необходима
поддержка входящих соединений в SOCKSv5, использовать скрипт,
который будет получать текущий адрес и сохранять его в файл, который будет
отслуживаться через команду monitor.
</p>
<li><a name="ODBC"><i>Q: Почему не работает ведение журналов в ODBC?</i></a></li>
<li><a name="ODBC"><i>Q: Почему не работает ведение журналов в ODBC?</i></a></li>
<p>
<i>A:</i> Убедитесь, что используется системный, а не
пользовательский DSN. Убедитесь, что выполняется правильный SQL запрос. Наиболее
распространенная проблема связана с отсутствием кавычек или неправильным
форматом данных. Самый простой способ - сделать ведение журнала в файл или
на стандартный вывод, просмотреть выдаваемые SQL запросы и попробовать
дать такой запрос вручную.
<i>A:</i> Убедитесь, что используется системный, а не
пользовательский DSN. Убедитесь, что выполняется правильный SQL запрос. Наиболее
распространенная проблема связана с отсутствием кавычек или неправильным
форматом данных. Самый простой способ - сделать ведение журнала в файл или
на стандартный вывод, просмотреть выдаваемые SQL запросы и попробовать
дать такой запрос вручную.
</p>
<li><a name="CHAP"><i>Q: Почему не поддерживаются APOP и CRAM-MD5 в POP3 прокси?</i></a></li>
<li><a name="CHAP"><i>Q: Почему не поддерживаются APOP и CRAM-MD5 в POP3 прокси?</i></a></li>
<p>
<i>A:</i> Любая challenge-response аутентификация, к которым относятся APOP
и CRAM-MD5, требует, чтобы со стороны сервера был передан уникальный challenge.
До начала аутентификации POP3 прокси не знает, к какому серверу следует
подключаться для получения Challenge, поэтому challenge-response в принципе
невозможен. Защитить соединение можно с помощью TLS (например, stunnel) или
<i>A:</i> Любая challenge-response аутентификация, к которым относятся APOP
и CRAM-MD5, требует, чтобы со стороны сервера был передан уникальный challenge.
До начала аутентификации POP3 прокси не знает, к какому серверу следует
подключаться для получения Challenge, поэтому challenge-response в принципе
невозможен. Защитить соединение можно с помощью TLS (например, stunnel) или
IPSec.
</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>
<hr>
<li><b><a name="SOCKSREDIR">Перенаправление socks соединений в локальный прокси</a></b></li>
<li><b><a name="SOCKSREDIR">Перенаправление socks соединений в локальный прокси</a></b></li>
<ul>
<li><a name="REDIR"><i>Q: Для чего это надо?</i></a></li>
<li><a name="REDIR"><i>Q: Для чего это надо?</i></a></li>
<p>
<i>A:</i> Чтобы иметь в логах URL запросов, если пользователь SOCKS пользуется
Web, FTP или POP3.
<i>A:</i> Чтобы иметь в логах URL запросов, если пользователь SOCKS пользуется
Web, FTP или POP3.
</p>
<li><a name="REDIRLIMIT"><i>Q: Какие недостатки?</i></a></li>
<li><a name="REDIRLIMIT"><i>Q: Какие недостатки?</i></a></li>
<p>
<i>A:</i> Перенапраление невозможно для web-серверов или FTP, висящих на
нестандартных портах, для SOCKSv4 не поддрживается авторизация с
паролем (IE поддерживает только SOCKSv4), но при этом IE передает
имя пользователя по SOCKSv4 (имя, с которым пользователь вошел в систему).
Для SOCKSv5 не поддерживается NTLM авторизация, пароли передаются в открытом
тексте.
<i>A:</i> Перенапраление невозможно для web-серверов или FTP, висящих на
нестандартных портах, для SOCKSv4 не поддрживается авторизация с
паролем (IE поддерживает только SOCKSv4), но при этом IE передает
имя пользователя по SOCKSv4 (имя, с которым пользователь вошел в систему).
Для SOCKSv5 не поддерживается NTLM авторизация, пароли передаются в открытом
тексте.
</p>
<li><a name="REDIRADV"><i>Q: Какие преимущества?</i></a></li>
<li><a name="REDIRADV"><i>Q: Какие преимущества?</i></a></li>
<p>
<i>A:</i> Достаточно в настройках IE только указать адрес SOCKS прокси. В
больших сетях можно для этого использовать WPAD (автоматическое
обнаружение прокси). В 3proxy достаточно запускать только одну службу
(socks). Если используется только Internet Explorer, то можно
автоматически получать имя пользователя в логах, не запрашивая
логин/пароль.
<i>A:</i> Достаточно в настройках IE только указать адрес SOCKS прокси. В
больших сетях можно для этого использовать WPAD (автоматическое
обнаружение прокси). В 3proxy достаточно запускать только одну службу
(socks). Если используется только Internet Explorer, то можно
автоматически получать имя пользователя в логах, не запрашивая
логин/пароль.
</p>
<li><a name="REDIRHOW"><i>Q: Как настраивается?</i></a></li>
<li><a name="REDIRHOW"><i>Q: Как настраивается?</i></a></li>
<p>
<i>A:</i> Указывается parent http proxy со специальным адресом 0.0.0.0 и портом
0. Пример:
<i>A:</i> Указывается parent http proxy со специальным адресом 0.0.0.0 и портом
0. Пример:
<pre>
allow * * * 80,8080-8088
parent 1000 http 0.0.0.0 0
allow * * * 80,8080-8088
#перенаправить соединения по портам 80 и 8080-8088 в локальный
#http прокси. Вторая команда allow необходима, т.к. контроль доступа
#осуществляется 2 раза - на уровне socks и на уровне HTTP прокси
#перенаправить соединения по портам 80 и 8080-8088 в локальный
#http прокси. Вторая команда allow необходима, т.к. контроль доступа
#осуществляется 2 раза - на уровне socks и на уровне HTTP прокси
allow * * * 21,2121
parent 1000 ftp 0.0.0.0 0
allow * * * 21,2121
#перенаправить соединения по портам 21 и 2121 в локальный
#ftp прокси
#перенаправить соединения по портам 21 и 2121 в локальный
#ftp прокси
allow *
#пустить все соединения напрямую
#пустить все соединения напрямую
socks</pre>
</p>
<li><a name="REDIINTER"><i>Q: Как взаимодействует с другими правилами в ACL?</i></a></li>
<li><a name="REDIINTER"><i>Q: Как взаимодействует с другими правилами в ACL?</i></a></li>
<p>
<i>A:</i> После внутреннего перенаправления правила рассматриваются еще раз за
исключением самого правила с перенаправлением (т.е. обработка правил не
прекращается). Это позволяет сделать дальнейшие перенаправления на
внешний прокси. По этой же причине локальное перенаправление не должно
быть последним правилом (т.е. должно быть еще хотя бы правило allow,
чтобы разрешить внешние соединения через HTTP прокси).
Например,
<i>A:</i> После внутреннего перенаправления правила рассматриваются еще раз за
исключением самого правила с перенаправлением (т.е. обработка правил не
прекращается). Это позволяет сделать дальнейшие перенаправления на
внешний прокси. По этой же причине локальное перенаправление не должно
быть последним правилом (т.е. должно быть еще хотя бы правило allow,
чтобы разрешить внешние соединения через HTTP прокси).
Например,
<pre>
allow * * * 80,8080-8088
parent 1000 http 0.0.0.0 0
#перенаправить во внутренний прокси
#перенаправить во внутренний прокси
allow * * $c:\3proxy\local.nets 80,8080-8088
#разрешить прямой web-доступ к сетям из local.nets
#разрешить прямой web-доступ к сетям из local.nets
allow * * * 80,8080-8088
parent 1000 http proxy.sandy.ru 3128
#все остальные веб-запросы перенаправить на внешний прокси-сервер
parent 1000 http proxy.3proxy.ru 3128
#все остальные веб-запросы перенаправить на внешний прокси-сервер
allow *
#разрешить socks-запросы по другим портам</pre>
#разрешить socks-запросы по другим портам</pre>
</p>
</ul>
<hr>
<li><b><a name="ISIT">А есть ли...</a></b></li>
<li><b><a name="ISIT">А есть ли...</a></b></li>
<ul>
<li><a name="NAMES"><i>Q: Можно ли разрешать имена на родительском прокси?</i></a></li>
<li><a name="NAMES"><i>Q: Можно ли разрешать имена на родительском прокси?</i></a></li>
<p>
<i>A:</i> Можно. Для этого надо использовать тип родительского прокси http,
connect+, socks4+ и socks5+. Однако, при это надо помнить, что самому 3proxy
требуется разрешение имени для управления ACL. Поэтому, если с прокси-хоста
не работают разрешения имени, необходимо в конфигурации дать команду
<i>A:</i> Можно. Для этого надо использовать тип родительского прокси http,
connect+, socks4+ и socks5+. Однако, при это надо помнить, что самому 3proxy
требуется разрешение имени для управления ACL. Поэтому, если с прокси-хоста
не работают разрешения имени, необходимо в конфигурации дать команду
<pre>
fakeresolve</pre>
которая разрешает любое имя в адрес 127.0.0.2.
которая разрешает любое имя в адрес 127.0.0.2.
</p>
<li><a name="ISFTP"><i>Q: Существует ли сейчас поддержка FTP прокси в продукте?</i></a></li>
<li><a name="ISFTP"><i>Q: Существует ли сейчас поддержка FTP прокси в продукте?</i></a></li>
<p>
Есть поддержка как FTP через HTTP (то, что называется FTP прокси в Internet
Explorer, Netscape, Opera) так и настоящего FTP прокси (то, что называется
FTP proxy в FAR и FTP клиентах).
Есть поддержка как FTP через HTTP (то, что называется FTP прокси в Internet
Explorer, Netscape, Opera) так и настоящего FTP прокси (то, что называется
FTP proxy в FAR и FTP клиентах).
</p>
<li><a name="PORT"><i>Q: Каким образом можно прибиндить сервисы на свой порт, к примеру, HTTP прокси к 8080, а не 3128 как по-умолчанию?</i></a></li>
<li><a name="PORT"><i>Q: Каким образом можно прибиндить сервисы на свой порт, к примеру, HTTP прокси к 8080, а не 3128 как по-умолчанию?</i></a></li>
<p>
А:
А:
<pre>
proxy -p8080</pre>
</p>
<li><a name="BANDLIM"><i>Q: Как ограничить ширину канала?</i></a></li>
<li><a name="BANDLIM"><i>Q: Как ограничить ширину канала?</i></a></li>
<p>
<i>A:</i> Читайте HowTo <a href="http://3proxy.ru/howtor.asp#BANDLIM">http://3proxy.ru/howtor.asp#BANDLIM</a>
<i>A:</i> Читайте HowTo <a href="http://3proxy.ru/howtor.asp#BANDLIM">http://3proxy.ru/howtor.asp#BANDLIM</a>
</p>
</ul>
<hr>
<li><b><a name="BRRR">Почему так криво...</a></b></li>
<li><b><a name="BRRR">Почему так криво...</a></b></li>
<ul>
<li><a name="TRAF"><i>Q: Почему так криво считается трафик? Не совпадает с ...</i></a></li>
<li><a name="TRAF"><i>Q: Почему так криво считается трафик? Не совпадает с ...</i></a></li>
<p>
<i>A:</i> Следует учитывать, что 3proxy считает трафик только на прикладном уровне и
только проходящий через прокси-сервер. Провайдеры и другие средства учета
трафика считают трафик на сетевом уровне, что уже дает расхождение порядка 10%
за счет информации из заголовков пакетов. Кроме того, часть трафика, как
минимум DNS-разрешения, различный флудовый трафик и т.д. идут мимо прокси.
Уровень "шумового" трафика в Internet сейчас составляет порядка 50KB/день на
каждый реальный IP адрес, но может сильно варьироваться в зависимости от сети,
наличия открытых портов, реакции на ping-запросы и текущего уровня вирусной
активности. По этим причинам, если 3proxy используется чтобы не "выжрать"
трафик, выделенный провайдером, всегда следует делать некий запас порядка
<i>A:</i> Следует учитывать, что 3proxy считает трафик только на прикладном уровне и
только проходящий через прокси-сервер. Провайдеры и другие средства учета
трафика считают трафик на сетевом уровне, что уже дает расхождение порядка 10%
за счет информации из заголовков пакетов. Кроме того, часть трафика, как
минимум DNS-разрешения, различный флудовый трафик и т.д. идут мимо прокси.
Уровень "шумового" трафика в Internet сейчас составляет порядка 50KB/день на
каждый реальный IP адрес, но может сильно варьироваться в зависимости от сети,
наличия открытых портов, реакции на ping-запросы и текущего уровня вирусной
активности. По этим причинам, если 3proxy используется чтобы не "выжрать"
трафик, выделенный провайдером, всегда следует делать некий запас порядка
15%.
</p>
<p>
Если на одной с 3proxy машине имеются какие-либо сервисы или
работает пользователь, то их трафик не проходит через proxy-сервер и так же
не будет учтен. Если где-то есть NAT, то клиенты, выходящие через NAT мимо
прокси, так же останутся неучтенными. Если расхождение с провайдером превышает
10% - нужно искать причину именно в этом.
Если на одной с 3proxy машине имеются какие-либо сервисы или
работает пользователь, то их трафик не проходит через proxy-сервер и так же
не будет учтен. Если где-то есть NAT, то клиенты, выходящие через NAT мимо
прокси, так же останутся неучтенными. Если расхождение с провайдером превышает
10% - нужно искать причину именно в этом.
</p>
<li><a name="CONFIG"><i>Q: Почему такая кривая конфигурация и ничерта не понятно?</i></a></li>
<li><a name="CONFIG"><i>Q: Почему такая кривая конфигурация и ничерта не понятно?</i></a></li>
<p>
<i>A:</i> Есть несколько причин. Во-первых, до выхода релиза (т.е. версии 1.0) я буду изо
всех сил добиваться совместимости конфигурации между версиями. Во-вторых,
конфигурация сделана так, чтобы ее можно было легко разбирать программно.
В-третьих, все там понятно. При желании. Если знать как все работает.
<i>A:</i> Есть несколько причин. Во-первых, до выхода релиза (т.е. версии 1.0) я буду изо
всех сил добиваться совместимости конфигурации между версиями. Во-вторых,
конфигурация сделана так, чтобы ее можно было легко разбирать программно.
В-третьих, все там понятно. При желании. Если знать как все работает.
</p>
<li><a name="CODE"><i>Q: Почему так криво написан код?</i></a></li>
<li><a name="CODE"><i>Q: Почему так криво написан код?</i></a></li>
<p>
<i>A:</i> Есть несколько причин. Во-первых, я не программист. Во-вторых, 3proxy изначально
писался на коленке (в отет на &quot;слабо&quot; в одной из конференций). Никто
не мог предположить, что им кто-то реально будет пользоваться. В-третьих, у многих
возникает желание разобраться в коде 3proxy чтобы внедрить его в какой-нибудь
троян. Очень не хочется облегчать эту задачу. В-четвертых, мне надо добиться
компиляции кода в как можно большем числе систем. Замечено, что чем кривее код в
C, тем он лучше переносится.
<i>A:</i> Есть несколько причин. Во-первых, я не программист. Во-вторых, 3proxy изначально
писался на коленке (в отет на &quot;слабо&quot; в одной из конференций). Никто
не мог предположить, что им кто-то реально будет пользоваться. В-третьих, у многих
возникает желание разобраться в коде 3proxy чтобы внедрить его в какой-нибудь
троян. Очень не хочется облегчать эту задачу. В-четвертых, мне надо добиться
компиляции кода в как можно большем числе систем. Замечено, что чем кривее код в
C, тем он лучше переносится.
</p>
<li><a name="UNSAFE"><i>Q: Почему так много strcpy, sprintf и т.д., это ж дыры!</i></a><li>
<li><a name="UNSAFE"><i>Q: Почему так много strcpy, sprintf и т.д., это ж дыры!</i></a><li>
<p>
<i>A:</i> Есть несколько причин. Во-первых, несмотря на дурной тон использования этих
функций, они наиболее совместимы между разными системами и компиляторами.
Во-вторых, само по себе их использование не означает присутствие дыры, если их
параметры должным образом контролируются. Найдете дыру - обязательно сообщите.
В третьих, может быть я уберу их перед конечным релизом, чтобы никого не
пугать.
<i>A:</i> Есть несколько причин. Во-первых, несмотря на дурной тон использования этих
функций, они наиболее совместимы между разными системами и компиляторами.
Во-вторых, само по себе их использование не означает присутствие дыры, если их
параметры должным образом контролируются. Найдете дыру - обязательно сообщите.
В третьих, может быть я уберу их перед конечным релизом, чтобы никого не
пугать.
</p>
</ul>
+65 -3
View File
@@ -33,6 +33,9 @@
<li><A HREF="#BANDLIM">How to limit bandwidth</A>
<li><A HREF="#TRAFLIM">How to limit traffic amount</A>
<li><A HREF="#NETLIST">How to build network lists</A>
<li><a href="#NSCACHING">How to configure name resolution and DNS caching</a>
<li><a href="#IPV6">How to use IPv6</a>
<li><a href="#CONNBACK">How to use connect back</a>
</ul>
<li><A HREF="#CLIENT">Client configuration</A>
<li><A HREF="#ADMIN">Administering and information analisys</A>
@@ -284,10 +287,10 @@ logformat "L%t.%. %N.%p %E %U %C:%c %R:%r %O %I %h %T"
<p>
If ODBC used, logformat should specify SQL command,
to insert record into log, for example
<p><font face="courier">
logformat "GINSERT INTO proxystat VALUES (%t, '%c', '%U', %I)"
</font>
<p><pre>
logformat "-\'+_GINSERT INTO proxystat VALUES (%t, '%c', '%U', %I)"</pre>
<br>(no line breaks)
<br>-\'+_ instructs to replace characters \ and ' with _
</p>
<li><A NAME="LOGANALIZERS">How to use log analizers with 3proxy</A>
<p>
@@ -738,6 +741,65 @@ In this example we obtain list of local networks from provider's page to
local.networks file, allow direct access to these networks and redirect all
connection to external networks to provider's proxy.
</p>
<li><a name="NSCACHING"><i>How to configure name resolution and DNS caching</i></a>
<p>
For name resolution and caching use commands nserver, nscache / nscache6 and nsrecord.
<pre>
nserver 192.168.1.2
nserver 192.168.1.3:5353/tcp</pre>
sets DNS resolvers. 192.168.1.3 will be used via TCP/5353 (instead of default UDP/53)
only if 192.168.1.2 fails. Up to 5 nservers may be specified.
If no nserver is configured, default system name resolution functions are used.
<pre>
nscache 65535
nscache6 65535</pre>
sets name cache size for IPv4 and IPv6. Name cache must be large enouth, if presents.
name cache is only used if nserver is configured.
<pre>
nsrecord server.mycompany.example.com 192.168.1.1
nsrecord www.porno.com 127.0.0.2
...
deny * * 127.0.0.2</pre>
adds static nsrecords. Also, static nsrecords are used for dnspr, unless -s option is specified.
Since 0.8 version, parent proxy may be configured for dnspr.
</p>
<li><a name="IPV6"><i>How to use IPv6</i></a>
<p>
IPv6 is supported since 0.8. Please note, some proxy protolos, e.g. SOCKSv4,
do not support IPv6. SOCKSv5 supports IPv6 with special request type (must be
implemented by client).
<br>
3proxy supports proxying from IPv4 and IPv6 networks to IPv4,
IPv6 and mixed networks. IPv6 address may be used in
internal, external, parent commands, ACLs, -i and -e options,etc.
external command and -e options may be given twice for each service - once with IPv4
and once with IPv6 address. internal can be given only once, to bind to all IPv4 and
IPv6 addresses use [0:0:0:0:0:0:0:0] or [::].
<br>
Any service may be configured with -4, -46, -64, -6 options to specify decied
priority for name to IPv4/IPv6 address resolution (IPv4 only, IPv4 priority,
IPv6 priority, IPv6 only).
</p>
<li><a name="CONNBACK"><i>How to use connect back</i></a>
<p>
In example, users needs access from external network to proxy server located
on the host 192.168.1.2. This host can not be accessed from external network,
but it has access to external network with with external address 1.1.1.1.
Also, user has access to the host 2.2.2.2 (IP address may be dynamic) with
hostname host.dyndns.example.org via external network. User needs 2 instances
of 3proxy, first one on the host 192.168.1.2 with config
<pre>
users user:CL:password
auth strong
allow user
proxy -rhost.dyndns.example.org:1234</pre>
second one on the host.dyndns.example.org (2.2.2.2) with config
<pre>
auth iponly
allow * * 1.1.1.1
tcppm -R0.0.0.0:1234 3128 1.1.1.1 3128</pre>
For browser settings proxy is host.dyndns.example.org:3128.
</p>
</ul>
<hr>
+719 -679
View File
File diff suppressed because it is too large. Load diff
+18
View File
@@ -0,0 +1,18 @@
<html><title>3proxy documentation</title><body><h2>3proxy documentation</h2>
<a href="securityen.html">Security recommendations</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>
+94
View File
@@ -0,0 +1,94 @@
<h3>3proxy Perl Compatible Regular Expressions (PCRE) plugin</h3>
This filtering plugin can be used to create matching and replace
rules with regular expressions for client's request, client and
servers header and client and server data. It adds 3 additional
configuration commands:
<pre>
pcre TYPE FILTER_ACTION REGEXP [ACE]
pcre_rewrite TYPE FILTER_ACTION REGEXP REWRITE_EXPRESSION [ACE]
pcre_extend FILTER_ACTION [ACE]
pcre_options OPTION1 [...]
</pre>
pcre - allows to apply some rule for matching
<br>pcre_rewrite - in addition to 'pcre' allows to substitute substrings
<br>pcre_extend - extends ACL of the last pcre or pcre_rewrite comand by
adding additional ACE (like with allow/deny configuration commands).
<br>pcre_options - allows to set matching options. Awailable options are:
PCRE_CASELESS,
PCRE_MULTILINE,
PCRE_DOTALL,
PCRE_EXTENDED,
PCRE_ANCHORED,
PCRE_DOLLAR_ENDONLY,
PCRE_EXTRA,
PCRE_NOTBOL,
PCRE_NOTEOL,
PCRE_UNGREEDY,
PCRE_NOTEMPTY,
PCRE_UTF8,
PCRE_NO_AUTO_CAPTURE,
PCRE_NO_UTF8_CHECK,
PCRE_AUTO_CALLOUT,
PCRE_PARTIAL,
PCRE_DFA_SHORTEST,
PCRE_DFA_RESTART,
PCRE_FIRSTLINE,
PCRE_DUPNAMES,
PCRE_NEWLINE_CR,
PCRE_NEWLINE_LF,
PCRE_NEWLINE_CRLF,
PCRE_NEWLINE_ANY,
PCRE_NEWLINE_ANYCRLF,
PCRE_BSR_ANYCRLF,
PCRE_BSR_UNICODE
<ul>
<li>TYPE - type of filtered data. May contain one or more
(comma delimited list) values:
<ul>
<li>request - content of client's request e.g. HTTP GET request string.
(known problem: changing request string doesn't change IP of the host to connect)
<li>cliheader - content of client request headers, e.g. HTTP request header.
<li>srvheader - content of server's reply headers, e.g. HTTP status and headers.
<li>clidata - data received from client, e.g. HTTP POST request data
<li>srvdata - data received from server, e.g. HTML page
</ul>
<li>FILTER_ACTION - action on match
<ul>allow - allow this request without checking rest of the given type
of the rules
<li>deny - deny this request without checking rest of the rules
<li>dunno - continue with the rest of rules (useful with pcre_rewrite)
</ul>
<li>REGEXP - PCRE (perl) regular expression. Use * if no regexp matching
required.
<li>REWRITE_EXPRESSION - substitution string. May contain perl-style
substrings
(not tested) $1, $2. $0 - means whole matched string. \r and \n may be used
to insert new strings, string may be empty ("").
<li>ACE - access control entry (user names, source IPs, destination IPs,
ports, etc), absolutely identical to allow/deny/bandlimin commands.
Regular expression is only matched if ACL matches connection data.
Warning:
reqular expression doesn't require authentication and can not replace
authentication and/or allow/deny ACLs.
</ul>
<h4>Example:</h4>
<pre>
plugin PCREPlugin.dll pcre_plugin
pcre request deny "porn|sex" user1,user2,user3 192.168.0.0/16
pcre srvheader deny "Content-type: application"
pcre_rewrite clidata,srvdata dunno "porn|sex|pussy" "***" baduser
pcre_extend deny * 192.168.0.1/16
</pre>
<h4>Download:</h4>
<ul>
<li>Plugin is included into 3proxy 0.6 binary and source distribution
<li>Example configuration (by Dennis Garber): <A HREF="NoPornLitest.cfg.txt">NoPornLitest.cfg</A>
</ul>
+90
View File
@@ -0,0 +1,90 @@
<h3>Плагин регулярных выражений совместимых с Perl (PCRE) для 3proxy</h3>
Фильтрующий плагин используется для создания правил поиска и замены
регулярных выражений в запросе, заголовков запроса и ответа и данных.
Добавляет поддержку 3х новых команд в файле конфигурации:
<pre>
pcre TYPE FILTER_ACTION REGEXP [ACE]
pcre_rewrite TYPE FILTER_ACTION REGEXP REWRITE_EXPRESSION [ACE]
pcre_extend FILTER_ACTION [ACE]
pcre_options OPTION1 [...]
</pre>
pcre - позволяет искать совпадения
<br>pcre_rewrite - дополнительно позволяет производить замену подстрок
<br>pcre_extend - расширяет ACL последней команды pcre или pcre_rewrite путем
добавления еще одной ACE (аналогично списку правил allow/deny).
<br>pcre_options - позволяет устанавливать опции поиска, доступны следующие опции:
PCRE_CASELESS,
PCRE_MULTILINE,
PCRE_DOTALL,
PCRE_EXTENDED,
PCRE_ANCHORED,
PCRE_DOLLAR_ENDONLY,
PCRE_EXTRA,
PCRE_NOTBOL,
PCRE_NOTEOL,
PCRE_UNGREEDY,
PCRE_NOTEMPTY,
PCRE_UTF8,
PCRE_NO_AUTO_CAPTURE,
PCRE_NO_UTF8_CHECK,
PCRE_AUTO_CALLOUT,
PCRE_PARTIAL,
PCRE_DFA_SHORTEST,
PCRE_DFA_RESTART,
PCRE_FIRSTLINE,
PCRE_DUPNAMES,
PCRE_NEWLINE_CR,
PCRE_NEWLINE_LF,
PCRE_NEWLINE_CRLF,
PCRE_NEWLINE_ANY,
PCRE_NEWLINE_ANYCRLF,
PCRE_BSR_ANYCRLF,
PCRE_BSR_UNICODE
<ul>
<li>TYPE - тип фильтруемых данных. Может содержать одно или
несколько (список через запятую) значений:
<ul>
<li>request - содержимое запроса клиента (например строка HTTP GET-запроса).
(в настоящий момент изменение запроса не приводит к изменению адреса запрашиваемого хоста)
<li>cliheader - содержимое заголовков запроса клиента, например заголовки HTTP
<li>srvheader - содержимое заголовков ответа сервера, например заголовки HTTP
<li>clidata - данные полученные от клиента, например данные POST-запроса
<li>srvdata - данные полученные от сервера, например содержимое HTML-страницы
</ul>
<li>FILTER_ACTION - действие при совпадении. Может принимать значение
<ul>allow - разрешить данный запрос без просмотра дальнейших правил
<li>deny - запретить данный запрос без просмотра дальнейших правил
<li>dunno - продолжить анализ правил (полезно для pcre_rewrite)
</ul>
<li>REGEXP - регулярное выражение в формате PCRE (perl). Используйте * если не
требуется проерка регулярного выражения.
<li>REWRITE_EXPRESSION - строка замены. Может содержать макроподстановки
(не тестировалось) $1, $2 и т.д. аналогично perl. $0 - полная найденная
подстрока. В строке замены можно использовать сочетания \r, \n для вставки
новых строк. Строка может быть пустой ("").
<li>ACE - Список контроля доступа (имя пользователя, IP источника, IP назначения, порт и т.д.),
полностью аналогичный ACE в командах allow, deny, bandlimin и т.п. Регулярное
выражение проверяется только при совпадении ACE с запросом. ВНИМАНИЕ:
использование регулярных выражений не требует авторизации и не заменяет ее.
Авторизацию необходимо конфигурировать отдельно.
</ul>
<h4>Пример:</h4>
<pre>
plugin PCREPlugin.dll pcre_plugin
pcre request deny "porn|sex" user1,user2,user3 192.168.0.0/16
pcre srvheader deny "Content-type: application"
pcre_rewrite clidata,srvdata dunno "porn|sex|pussy" "***" baduser
pcre_extend deny * 192.168.0.1/16
</pre>
<h4>Загрузить:</h4>
<ul>
<li>Плагин включен в дистрибутив 3proxy 0.6
<li>Пример конфигурации (by Dennis Garber): <A HREF="NoPornLitest.cfg.txt">NoPornLitest.cfg</A>
</ul>
+34
View File
@@ -0,0 +1,34 @@
<h3>3proxy SSL/TLS plugin</h3>
Plugin can be used to transparently decypher SSL/TLS data. Plugin should never be used in production environment due to
potential securiy reasons.
<pre>
ssl_certcache PATH_TO_CACHE
ssl_mitm
ssl_nomitm
</pre>
ssl_certcache - path to certificates cache. For transparent spoofing cache must contain 3 files: 3proxy.pem - public
self-signed certificates, 3proxy.key - key for public certificates, server.key - this key will be used to generates
spoofed certificates.
Generated certificates will be placed to the same path.
<br>ssl_mitm - spoof certificates for services started below
<br>ssl_nomitm - do not spoof certificates for services started below
<h4>Example:</h4>
<pre>
plugin /path/to/SslPlugin.dll ssl_plugin
ssl_certcache /path/to/cache/
ssl_mitm
proxy -p3128
ssl_nomitm
proxy -p3129
</pre>
<h4>Download:</h4>
<ul>
<li>Plugin included into 3proxy 0.8
</ul>
&copy; Vladimir Dubrovin, License: BSD style
+32
View File
@@ -0,0 +1,32 @@
<h3>Плагин SSL/TLS для 3proxy</h3>
Плагин используется для транспарентной дешифровки SSL-трафика с подменой сертификата.
Плагин не должен использоваться в рабочем окружении, т.к. его использование дает возможность обхода проверок SSL.
<pre>
ssl_certcache PATH_TO_CACHE
ssl_mitm
ssl_nomitm
</pre>
ssl_certcache - путь к кэшу сертификатов. Для транспорентной подмены сертификатов в кэше должно находиться 3 файла: 3proxy.pem - публичный
самоподписанный сертификат, 3proxy.key - ключ от этого сертификата, server.key - ключ с которым будут генерироваться подменные сертификаты.
Сгенерированные сертификаты будут помещаться в этот же каталог.
<br>ssl_mitm - подменять сертитфикаты для запущенных ниже сервисов
<br>ssl_nomitm - не подменять сертитфикаты для запущенных ниже сервисов
<h4>Пример:</h4>
<pre>
plugin /path/to/SslPlugin.dll ssl_plugin
ssl_certcache /path/to/cache/
ssl_mitm
proxy -p3128
ssl_nomitm
proxy -p3129
</pre>
<h4>Загрузить:</h4>
<ul>
<li>Плагин включен в дистрибутив 3proxy 0.8
</ul>
+16
View File
@@ -0,0 +1,16 @@
<h3>3proxy strings substitution plugin</h3>
May be used to make interface more pretty or to translate proxy server
messages to different language. All messages are taken from proxy.c and
moved to external text file (e.g. rus.3ps). On the moment of
writing there are 15 sections. Sections are delimited with "[end]".
<h4>Example:</h4>
<pre>plugin "StringsPlugin.dll" start c:\3proxy\bin\rus.3ps
</pre>
<h4>Download:</h4>
<ul>
<li>Plugin is included into 3proxy 0.6 binary and source distribution
</li></ul>
©Kirill Lopuchov
+18
View File
@@ -0,0 +1,18 @@
<h3>Плагин подмены строк 3proxy</h3>
Используется, в частности, для руссификации сообщений выдаваемых 3proxy.
Для корректной работы требуется 0.6 версия 3proxy.
Все сообщения были взяты из proxy.c
и вынесенны в отдельный файл. Пример файла rus-win1251.3ps.
Всего 15 секций на момент написания плагина в файле rus-win1251.3ps каждая секция отделяется строкой "[end]"
новая строка определяется строкой "\n"
<h4>Пример:</h4>
<pre>
plugin "StringsPlugin.dll" start c:\3proxy\bin\rus-win1251.3ps
</pre>
<h4>Загрузить:</h4>
<ul>
<li>Плагин включен в дистрибутив 3proxy 0.6
</ul>
+52
View File
@@ -0,0 +1,52 @@
<h3>3proxy traffic correction plugin</h3>
3proxy logs and counts traffic on application level, while provider usually does
it on network or link level. It's significant if you use 3proxy for billing,
especially in case where network packets are small, e.g. network games.
<p>
This plugin attempts to correct 3proxy computations to approximate network or
link level traffic by using either fixed coefficients by port number or
attempting to predict number and sizes of network packets.
</p><h4>Usage:</h4>
<ol>
<li>Extract TrafficPlugin.dll to the same folder with 3proxy executable.
</li><li>Start plugin in 3proxy.cfg with
<pre>plugin TrafficPlugin.dll start
</pre>
</li><li>Add correction rules:
<br>
FOR FIXED COEFFICIENTS MODE:
<pre>trafcorrect m &lt;service&gt; &lt;target port&gt; &lt;coefficient&gt;
</pre>
where &lt;service&gt; - one of proxy, socks4, socks45, socks5, tcppm, udppm, pop3p, * matches "any".
<br> &lt;target port&gt; - target port, * matches any
<br> &lt;coefficient&gt; - coefficient to multiply traffic for this port.
<br>
FOR PACKET HEADER PREDICTION MODE
<pre>trafcorrect p &lt;service&gt; &lt;tcp/udp&gt; &lt;target port&gt; [empty packet size]
</pre>
tcp ot udp - transport level protocol to apply rule
<br>
empty packet size - average size of "empty" packet, that is sum of average network/transport headers.
You can use network sniffer, such is Ethereal to discover it. Usually packet size
is 42 for UDP and
<br>Modes can be mixed.
<br>Plugin creates a list of rules, first matching rule will be applied.
</li></ol>
For any mode plugin approximates traffic, logged or counted amount is not exact.
<h4>Example:</h4>
<pre>plugin "TrafficPlugin.dll" start
trafcorrect m socks5 6112 4.5
trafcorrect m socks5 * 1.1
</pre>
wrong usage:
<pre>trafcorrect m socks5 * 1.1
trafcorrect m socks5 6112 4.5
</pre>
second rule will never be applied.
<h4>Download:</h4>
<ul>
<li>Plugin is included into 3proxy 0.6 binary and source distribution
</li></ul>
©Maslov Michael aka Flexx(rus)
+69
View File
@@ -0,0 +1,69 @@
<h3>Плагин коррекции траффика 3proxy</h3>
Как известно, 3proxy считает траффик не сетевой, а прикладной.
Обычно прикладной траффик немного меньше (примерно на 10%) чем сетевой,
однако в некоторых случаях, например когда пользователи сети играют в
игры, сетевой траффик может превысить прикладной в 4-5 раз. Это довольно неприятно,
так как получается, что они за это не платят.
<p>
Происходит это потому, что в каждом посланом пакете есть заголовок+данные. Заголовок
весит порядка 50-60 байт а количество данных может меняться от 15-20 байт (что характерно для игр)
до 800-900 байт (у IE). Также количество данных в пакете зависит от загрузки сети,
удалённости сервера и прочих причин.
<p>
Данный плагин может исправить такую ситуацию. Он может умножать счётчик траффика
при окончании соединения на некоторый коэффициент либо добавлять к данным размеры заголовков пакетов,
которые прошли по сети.
<h4>Использование</h4>
<ol>
<li>Извлечь TrafficPlugin.dll в каталог с 3proxy.exe
<li>Стартовать плагин в 3proxy.cfg
<pre>
plugin TrafficPlugin.dll start
</pre>
<li>Добавить правила:
<br>
ДЛЯ РЕЖИМА ДОМНОЖЕНИЯ ТРАФФИКА НА ЧИСЛО:
<pre>
trafcorrect m &lt;сервис&gt; &lt;исходящий порт&gt; &lt;коэффициент&gt;
</pre>
где: &lt;сервис&gt; может быть proxy, socks4, socks45, socks5, tcppm, udppm, pop3p
если сервис указан неверно то считается, что это может быть любой сервис.
можно использовать *, тогда правило будет считаться для любого сервиса.
<br> &lt;исходящий порт&gt; - порт, к которому подключается прокси сервер. * - любой
&lt;коэффициент&gt; - число на каоторое домнажается траффик. Обязательный параметр.
Должен быть от больше 0 и меньше 100
<br>
ДЛЯ РЕЖИМА С УЧЁТОМ РАЗМЕРА ЗАГОЛОВКОВ ПАКЕТОВ:
<pre>
trafcorrect p &lt;сервис&gt; &lt;tcp/udp&gt; &lt;исходящий порт&gt; [размер пустого пакета]
</pre>
&lt;tcp/udp&gt; - протокол, по которому осуществляется соединение.
[размер пакета] - средний размер пустого пакета. Можно определить захватив
данные при помощи такой утилиты как Ethereal. Параметр необязателен. Если отсутствует,
то размер пакета будет считаться равным 66 байт.
<br>Режимы можно смешивать.
Следует учитывать, что плугин создаёт список всех правил изменения траффика.
Когда происходит окончание соединения выполняется первое подходящее правило.
</ol>
Подсчет трафика в любом режиме не является точным, это некоторая аппроксимация
позволяющаяподсчитать трафик с точностью до нескольких процентов.
<h4>Пример:</h4>
<pre>
plugin "TrafficPlugin.dll" start
trafcorrect m socks5 6112 4.5
trafcorrect m socks5 * 1.1
</pre>
следующее неверно:
<pre>
plugin "TrafficPlugin.dll" start
trafcorrect m socks5 * 1.1
trafcorrect m socks5 6112 4.5
</pre>
Вторая строчка выполнена никогда не будет, т.к. правило 1 содержит *.
<h4>Загрузить:</h4>
<ul>
<li>Плагин включен в дистрибутив 3proxy 0.6
</ul>
+28
View File
@@ -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>
&copy; 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>
&copy; Vladimir Dubrovin, License: BSD style
@@ -0,0 +1,33 @@
<h3>3proxy Windows Authentication plugin</h3>
Support for cleartext authentication against Windows domain or local Windows account.
<h4>Usage:</h4>
<ol>
<li>Extract WindowsAuthentication.dll to the same folder with 3proxy executable.
<li>Create 3ProxyAllowedGroup - Windows system group allowed to use proxy.
You can choose different group name. Group can be either local or
Active Directory. Every account allowed to use 3proxy must be included in this
group either directly or through group nesting.
<li>Configure plugin with 'plugin' command in 3proxy.cfg, e.g.:
<pre><code>
plugin &quot;WindowsAuthentication.dll&quot; WindowsAuthentication &quot;3ProxyAllowedGroup&quot;
</code></pre>
<br>WindowsAuthentication.dll - location of DLL, if DLL is located in different folder
from 3proxy.exe you must specify complete path to DLL here. 3ProxyAllowedGroup - Windows
system group allowed to use 3proxy.
After plugin is loaded, 'windows' authentication type is supported.
<li>Configure 'auth windows' for services that require Windows authentication.
<li>It's recommended you also configure authentication caching (see 'authcache'),
to prevent excessive workload for domain controller. Example:
<pre>
authcache user,pass 900
auth cache windows
</pre>
<li>NTLM authentication is not currently supported for plugins, you should use proxy -n key to disable it.
</ol>
<h4>Download:</h4>
<ul>
<li>Plugin is included into 3proxy 0.6 binary and source distribution
</ul>
@@ -0,0 +1,35 @@
<h3>Плагин аутентификации Windows для 3proxy</h3>
Поддерживается только аутентификация открытым текстом в домене или на локальной машине Windows.
<h4>Использование</h4>
<ol>
<li>Извлечь WindowsAuthentication.dll в каталог с 3proxy.exe
<li>Создать 3ProxyAllowedGroup - системная группа Windows, которой разрешено использование прокси. Ее необходимо создать (можно
использовать группу с другим именем, см. ниже). Учетные записи пользователей, которым разрешен доступ к прокси
должны быть включены в группу непосредственно или посредством включения их групп. Группа может быть как локальной, так и в
ActiveDirectory.
<li>В файле конфигурации загрузить dll с помощью команды plugin:
<br>plugin &quot;WindowsAuthentication.dll&quot; WindowsAuthentication &quot;3ProxyAllowedGroup&quot;
<br>Если DLL находится в другом каталоге, то вместо &quot;WindowsAuthentication.dll&quot;
необходимо указать полный путь к DLL. 3ProxyAllowedGroup - название системной группы,
которой разрешен доступ к прокси.
<li>Плагин добавляет новый тип аутентификации - windows. Т.е. для использования
Windows-аутентификации надо дать команду
<pre>
auth windows
</pre>
<li>Не рекомендуется использовать данный плагин без кэширования
аутентификации (authcache), т.к. это приведет к увеличению нагрузки на
сервер/контроллер домена. Пример:
<pre>
authcache user,pass 900
auth cache windows
</pre>
<li>В настоящее время не поддерживается NTLM-аутентификация для плагинов,
поэтому необходимо запускать proxy с ключиком -n.
</ol>
<h4>Загрузить:</h4>
<ul>
<li>Плагин включен в дистрибутив 3proxy 0.6
</ul>
+4 -6
View File
@@ -1,4 +1,4 @@
.TH 3proxy "8" "July 2009" "3proxy 0.7" "Universal proxy server"
.TH 3proxy "8" "January 2016" "3proxy 0.8" "Universal proxy server"
.SH NAME
.B 3proxy
\- 3[APA3A] tiny proxy server, or trivial proxy server, or free proxy
@@ -138,7 +138,7 @@ wget to automate this task.
configuration file
.SH BUGS
Report all bugs to
.BR 3proxy@security.nnov.ru
.BR 3proxy@3proxy.ru
.SH SEE ALSO
3proxy.cfg(3), proxy(8), ftppr(8), socks(8), pop3p(8), tcppm(8), udppm(8),
kill(1), syslogd(8),
@@ -147,7 +147,5 @@ http://3proxy.ru/
.SH TRIVIA
3APA3A is pronounced as \`\`zaraza\'\'.
.SH AUTHORS
3proxy is designed by 3APA3A
.RI ( 3APA3A@security.nnov.ru ),
Vladimir Dubrovin
.RI ( vlad@sandy.ru )
3proxy is designed by Vladimir 3APA3A Dubrovin
.RI ( 3proxy@3proxy.ru )
+207 -175
View File
@@ -1,35 +1,37 @@
.TH 3proxy.cfg "3" "July 2009" "3proxy 0.7" "Universal proxy server"
.TH 3proxy.cfg "3" "January 2016" "3proxy 0.8" "Universal proxy server"
.SH NAME
.B 3proxy.cfg
\- 3proxy configuration file
.SH DESCRIPTION
Common structure:
.br
Configuration file is a text file 3proxy reads configuration from. Each line
Configuration file is a text file 3proxy reads configuration from. Each line
of the file is a command executed immediately, as it was given from
console. Sequence of commands is important. Configuration file as actually a
script for 3proxy executable.
Each line of the file is treated as a blank (space or tab) separated
command line. Additional space characters are ignored.
Think about 3proxy as "application level router" with console interface.
.br
Comments:
.br
Any string beginning with space character or \'#\' character is comment. It\'s
Any string beginning with space character or \'#\' character is comment. It\'s
ignored. <LF>s are ignored. <CR> is end of command.
.br
Quotation:
.br
Quotation character is " (double quote). Quotation must be used to quote
Quotation character is " (double quote). Quotation must be used to quote
spaces or another special characters. To use quotation character inside
quotation character must be dubbed (BASIC convention). For example to use
HELLO "WORLD" as an argument you should use it as "HELLO ""WORLD"""\.
Good practice is to quote any argument you use.
.br
File inclusion:
.br
You can include file by using $FILENAME macro (replace FILENAME with a path
You can include file by using $FILENAME macro (replace FILENAME with a path
to file, for example $/usr/local/etc/3proxy/conf.incl or
$"c:\\Program Files\\3proxy\\include.cfg" Quotation is
required in last example because path contains space character.
@@ -39,9 +41,12 @@ Thus, include files are only useful to store long signle-line commands
(like userlist, network lists, etc).
To use dollar sign somewhere in argument it must be quoted.
Recursion is not allowed.
.br
Next commands start gateway services:
.br
.br
.B proxy
[options]
.br
@@ -113,19 +118,39 @@ view without ability to reset).
(for dnspr) - simple, do not use 'resolver' and 3proxy cache, always use external DNS server.
.br
(for udppm) - singlepacket, expect only one packet from both client and server
.br
.B -u
Never ask for username/password
.br
.B -u2
(socks) require username/password in authentication methods
.br
.B -a
(for proxy) - anonymous proxy (no information about client reported)
.br
.B -a1
(for proxy) - anonymous proxy (random client information reported)
.br
.B -a2
(for proxy) - generate Via: and X-Forwared-For: instead of Forwarded:
.br
.B -6
Only resolve IPv6 addresses
Only resolve IPv6 addresses. IPv4 addresses are packed in IPv6 in IPV6_V6ONLY compatible way.
.br
.B -4
Only resolve IPv4 addresses
.br
.B -46
Resolve IPv6 addresses if IPv4 address is not resolvable
.br
.B -64
Resolve IPv4 addresses if IPv6 address is not resolvable
.br
.B -RHOST:port
listen on given local HOST:port for incoming connections instead of making remote outgoing connection. Can be used with another 3proxy service running -r option for connect back functionality. Most commonly used with tcppm. HOST can be given as IP or hostname, useful in case of dynamic DNS.
.br
.B -rHOST:port
connect to given remote HOST:port instead of listening local connection on -p or default port. Can be used with another 3proxy service running -R option for connect back functionality. Most commonly used with proxy or socks. HOST can be given as IP or hostname, useful in case of dynamic DNS.
.br
Also, all options mentioned for
.BR proxy (8)
@@ -157,28 +182,24 @@ proxy on a client with FTP proxy support. Username format is one of
.br
proxyuser:proxypassword:FTPuser:FTPpassword@FTPserver
.br
Please note, if you use FTP client interface for FTP proxy
do not add FTPpassword and FTPServer to username, because
FTP client does it for you. That is, if you use 3proxy with
authentication use
proxyuser:proxypassword:FTPuser
as FTP username, otherwise do not change original FTP user name
Please note, if you use FTP client interface for FTP proxy do not add FTPpassword and FTPServer to username, because FTP client does it for you. That is, if you use 3proxy with authentication use proxyuser:proxypassword:FTPuser as FTP username, otherwise do not change original FTP user name
.br
.B include
<path>
.br
Include config file
Include config file
.br
.B config
<path>
.br
Path to configuration file to use on 3proxy restart or to save configuration.
Path to configuration file to use on 3proxy restart or to save configuration.
.br
.B writable
.br
ReOpens configuration file for write access via Web interface,
ReOpens configuration file for write access via Web interface,
and re-reads it. Usually should be first command on config file
but in combination with "config" it can be used anywhere to open
alternate config file. Think twice before using it.
@@ -186,13 +207,13 @@ alternate config file. Think twice before using it.
.br
.B end
.br
End of configuration
End of configuration
.br
.B log
[[@|&]logfile] [<LOGTYPE>]
.br
sets logfile for all gateways
sets logfile for all gateways
.br
@ - (for Unix) use syslog, filename is used as ident name
.br
@@ -208,10 +229,10 @@ sets logfile for all gateways
.br
H - Hourly
.br
if logfile is not specified logging goes to stdout. You can specify individual logging options for gateway by using
if logfile is not specified logging goes to stdout. You can specify individual logging options for gateway by using
-l option in gateway configuration.
.br
"log" command supports same format specifications for filename template
"log" command supports same format specifications for filename template
as "logformat" (if filename contains '%' sign it's believed to be template).
As with "logformat" filename must begin with 'L' or 'G' to specify Local or
Grinwitch time zone for all time-based format specificators.
@@ -219,13 +240,13 @@ Grinwitch time zone for all time-based format specificators.
.br
.B rotate
<n>
how many archived log files to keep
how many archived log files to keep
.br
.B logformat
<format>
Format for log record. First symbol in format must be L (local time)
.br
Format for log record. First symbol in format must be L (local time)
or G (absolute Grinwitch time).
It can be preceeded with -XXX+Y where XXX is list of characters to be
filtered in user input (any non-printable characters are filtered too
@@ -233,72 +254,72 @@ in this case) and Y is replacement character. For example, "-,%+ L" in
the beginning of logformat means comma and percent are replaced
with space and all time based elemnts are in local time zone.
.br
You can use:
You can use:
.br
%y - Year in 2 digit format
%y - Year in 2 digit format
.br
%Y - Year in 4 digit format
%Y - Year in 4 digit format
.br
%m - Month number
%m - Month number
.br
%o - Month abbriviature
%o - Month abbriviature
.br
%d - Day
%d - Day
.br
%H - Hour
%H - Hour
.br
%M - Minute
%M - Minute
.br
%S - Second
%S - Second
.br
%t - Timstamp (in seconds since 01-Jan-1970)
%t - Timstamp (in seconds since 01-Jan-1970)
.br
%. - milliseconds
%. - milliseconds
.br
%z - timeZone (from Grinvitch)
%z - timeZone (from Grinvitch)
.br
%D - request duration (in milliseconds)
%D - request duration (in milliseconds)
.br
%b - average send rate per request (in Bytes per second) this speed is typically below connection speed shown by download manager.
%b - average send rate per request (in Bytes per second) this speed is typically below connection speed shown by download manager.
.br
%B - average receive rate per request (in Bytes per second) this speed is typically below connection speed shown by download manager.
%B - average receive rate per request (in Bytes per second) this speed is typically below connection speed shown by download manager.
.br
%U - Username
%U - Username
.br
%N - service Name
%N - service Name
.br
%p - service Port
%p - service Port
.br
%E - Error code
%E - Error code
.br
%C - Client IP
%C - Client IP
.br
%c - Client port
%c - Client port
.br
%R - Remote IP
%R - Remote IP
.br
%r - Remote port
%r - Remote port
.br
%e - External IP used to establish connection
%e - External IP used to establish connection
.br
%Q - Requested IP
%Q - Requested IP
.br
%q - Requested port
%q - Requested port
.br
%n - requested hostname
%n - requested hostname
.br
%I - bytes In
%I - bytes In
.br
%O - bytes Out
%O - bytes Out
.br
%h - Hops (redirections) count
%h - Hops (redirections) count
.br
%T - service specific Text
%T - service specific Text
.br
%N1-N2T - (N1 and N2 are positive numbers) - log only fields from N1 thorugh N2 of service specific text
%N1-N2T - (N1 and N2 are positive numbers) - log only fields from N1 thorugh N2 of service specific text
.br
in case of ODBC logging logformat specifies SQL statement, for exmample:
in case of ODBC logging logformat specifies SQL statement, for exmample:
.br
logformat "-'+_Linsert into log (l_date, l_user, l_service, l_in, l_out, l_descr) values ('%d-%m-%Y %H:%M:%S', '%U', '%N', %I, %O, '%T')"
@@ -306,7 +327,7 @@ in case of ODBC logging logformat specifies SQL statement, for exmample:
.B logdump
<in_traffic_limit> <out_traffic_limit>
.br
Immediately creates additional log records if given amount of incoming/outgoing
Immediately creates additional log records if given amount of incoming/outgoing
traffic is achieved for connection, without waiting for connection to finish.
It may be useful to prevent information about long-lasting downloads on server
shutdown.
@@ -315,7 +336,7 @@ shutdown.
.B archiver
<ext> <commandline>
.br
Archiver to use for log files. <ext> is file extension produced by
Archiver to use for log files. <ext> is file extension produced by
archiver. Filename will be last argument to archiver, optionally you
can use %A as produced archive name and %F as filename.
@@ -323,28 +344,28 @@ can use %A as produced archive name and %F as filename.
.B timeouts
<BYTE_SHORT> <BYTE_LONG> <STRING_SHORT> <STRING_LONG> <CONNECTION_SHORT> <CONNECTION_LONG> <DNS> <CHAIN>
.br
Sets timeout values
Sets timeout values
.br
BYTE_SHORT - short timeout for single byte, is usually used for receiving single byte from stream.
BYTE_SHORT - short timeout for single byte, is usually used for receiving single byte from stream.
.br
BYTE_LONG - long timeout for single byte, is usually used for receiving first byte in frame (for example first byte in socks request).
BYTE_LONG - long timeout for single byte, is usually used for receiving first byte in frame (for example first byte in socks request).
.br
STRING_SHORT - short timeout, for character string within stream (for example to wait between 2 HTTP headers)
STRING_SHORT - short timeout, for character string within stream (for example to wait between 2 HTTP headers)
.br
STRING_LONG - long timeout, for first string in stream (for example to wait for HTTP request).
STRING_LONG - long timeout, for first string in stream (for example to wait for HTTP request).
.br
CONNECTION_SHORT - inactivity timeout for short connections (HTTP, POP3, etc).
CONNECTION_SHORT - inactivity timeout for short connections (HTTP, POP3, etc).
.br
CONNECTION_LONG - inactivity timeout for long connection (SOCKS, portmappers, etc).
CONNECTION_LONG - inactivity timeout for long connection (SOCKS, portmappers, etc).
.br
DNS - timeout for DNS request before requesting next server
DNS - timeout for DNS request before requesting next server
.br
CHAIN - timeout for reading data from chained connection
CHAIN - timeout for reading data from chained connection
.br
.br
.B nserver
<ipaddr>[:port][/tcp]
<ipaddr>[:port][/tcp]
.br
Nameserver to use for name resolutions. If none specified
or name server fails system routines for name resolution will be
@@ -359,16 +380,15 @@ performed over TCP.
.B nscache6
<cachesize>
.br
Cache <cachesize> records for name resolution (nscache for IPv4,
Cache <cachesize> records for name resolution (nscache for IPv4,
nscache6 for IPv6). Cachesize usually should be large enougth
(for example 65536).
.br
.B nsrecord
<hostname> <hostaddr>
.BR
Adds static record to nscache. nscache must be enabled. If 0.0.0.0
.br
Adds static record to nscache. nscache must be enabled. If 0.0.0.0
is used as a hostaddr host will never resolve, it can be used to
blacklist something or together with
.B dialer
@@ -376,15 +396,15 @@ command to set up UDL for dialing.
.br
.B fakeresolve
.BR
All names are resolved to 127.0.0.2 address. Usefull if all requests are
.br
All names are resolved to 127.0.0.2 address. Usefull if all requests are
redirected to parent proxy with http, socks4+, connect+ or socks5+.
.br
.B dialer
<progname>
.br
Execute progname if external name can't be resolved.
Execute progname if external name can't be resolved.
Hint: if you use nscache, dialer may not work, because names will
be resolved through cache. In this case you can use something like
http://dial.right.now/ from browser to set up connection.
@@ -394,7 +414,7 @@ http://dial.right.now/ from browser to set up connection.
.B internal
<ipaddr>
.br
sets ip address of internal interface. This IP address will be used
sets ip address of internal interface. This IP address will be used
to bind gateways. Alternatively you can use -i option for individual
gateways. Since 0.8 version, IPv6 address may be used.
@@ -402,7 +422,7 @@ gateways. Since 0.8 version, IPv6 address may be used.
.B external
<ipaddr>
.br
sets ip address of external interface. This IP address will be source
sets ip address of external interface. This IP address will be source
address for all connections made by proxy. Alternatively you can use
-e option to specify individual address for gateway. Since 0.8 version
External or -e can be given twice: once with IPv4 and once with IPv6 address.
@@ -411,13 +431,13 @@ External or -e can be given twice: once with IPv4 and once with IPv6 address.
.B maxconn
<number>
.br
sets maximum number of simulationeous connections to each services
sets maximum number of simulationeous connections to each services
started after this command. Default is 100.
.br
.B service
.br
(depricated). Indicates 3proxy to behave as Windows 95/98/NT/2000/XP
(depricated). Indicates 3proxy to behave as Windows 95/98/NT/2000/XP
service, no effect for Unix. Not required for 3proxy 0.6 and above. If
you upgraded from previous version of 3proxy use --remove and --install
to reinstall service.
@@ -425,7 +445,7 @@ to reinstall service.
.br
.B daemon
.br
Should be specified to close console. Do not use 'daemon' with 'service'.
Should be specified to close console. Do not use 'daemon' with 'service'.
At least under FreeBSD 'daemon' should preceed any proxy service
and log commands to avoid sockets problem. Always place it in the beginning
of the configuration file.
@@ -434,68 +454,64 @@ of the configuration file.
.B auth
<authtype> [...]
.br
Type of user authorization. Currently supported:
Type of user authorization. Currently supported:
.br
none - no authentication or authorization required.
.br
none - no authentication or authorization required.
Note: is auth is none any ip based limitation, redirection, etc will not work.
This is default authentication type
This is default authentication type
.br
iponly - authentication by access control list with username ignored.
iponly - authentication by access control list with username ignored.
Appropriate for most cases
.br
useronly - authentication by username without checking for any password with
useronly - authentication by username without checking for any password with
authorization by ACLs. Useful for e.g. SOCKSv4 proxy and icqpr (icqpr set UIN /
AOL screen name as a username)
.br
dnsname - authentication by DNS hostnname with authorization by ACLs.
dnsname - authentication by DNS hostnname with authorization by ACLs.
DNS hostname is resolved via PTR (reverse) record and validated (resolved
name must resolve to same IP address). It's recommended to use authcache by
ip for this authentication.
NB: there is no any password check, name may be spoofed.
.br
nbname - authentication by NetBIOS name with authorization by ACLs.
Messanger service should be started on user's machine. Note, that
Windows 95/98 hosts do not have messanger service by default,
WinPopup program need to be started. It's recommended to use authcache by
ip for this authentication.
NB: there is no any password check, name may be spoofed.
.br
strong - username/password authentication required. It will work with
strong - username/password authentication required. It will work with
SOCKSv5, FTP, POP3 and HTTP proxy.
.br
cache - cached authentication, may be used with 'authcache'.
cache - cached authentication, may be used with 'authcache'.
.br
Plugins may add additional authentication types.
Plugins may add additional authentication types.
.br
It's possible to use few authentication types in the same commands. E.g.
.br
auth iponly strong
.br
In this case 'strong' authentication will be used only in case resource
In this case 'strong' authentication will be used only in case resource
access can not be performed with 'iponly' authentication, that is username is
required in ACL. It's usefull to protect access to some resources with
password allowing passwordless access to another resources, or to use
IP-based authentication for dedicated laptops and request username/password for
shared ones.
.br
.B authcache
<cachtype> <cachtime>
.br
Cache authentication information to given amount of time (cachetime) in seconds.
Cache authentication information to given amount of time (cachetime) in seconds.
Cahtype is one of:
.br
ip - after successful authentication all connections during caching time
ip - after successful authentication all connections during caching time
from same IP are assigned to the same user, username is not requested.
.br
ip,user username is requested and all connections from the same IP are
ip,user username is requested and all connections from the same IP are
assigned to the same user without actual authentication.
.br
user - same as above, but IP is not checked.
user - same as above, but IP is not checked.
.br
user,password - both username and password are checked against cached ones.
user,password - both username and password are checked against cached ones.
.br
Use auth type 'cache' for cached authentication
.br
.B allow
<userlist> <sourcelist> <targetlist> <targetportlist> <operationlist>
@@ -505,7 +521,7 @@ Use auth type 'cache' for cached authentication
<userlist> <sourcelist> <targetlist> <targetportlist> <operationlist>
<weekdayslist> <timeperiodslist>
.br
Access control entries. All lists are comma-separated, no spaces are
Access control entries. All lists are comma-separated, no spaces are
allowed. Usernames are case sensitive (if used with authtype nbname
username must be in uppercase). Source and target lists may contain
IP addresses (W.X.Y.Z), ranges A.B.C.D - W.X.Y.Z (since 0.8) or CIDRs
@@ -532,55 +548,51 @@ to appropriate interface only or to use ip filters.
Operation is one of:
.br
CONNECT - establish outgoing TCP connection
CONNECT - establish outgoing TCP connection
.br
BIND - bind TCP port for listening
BIND - bind TCP port for listening
.br
UDPASSOC - make UDP association
UDPASSOC - make UDP association
.br
ICMPASSOC - make ICMP association (for future use)
ICMPASSOC - make ICMP association (for future use)
.br
HTTP_GET - HTTP GET request
HTTP_GET - HTTP GET request
.br
HTTP_PUT - HTTP PUT request
HTTP_PUT - HTTP PUT request
.br
HTTP_POST - HTTP POST request
HTTP_POST - HTTP POST request
.br
HTTP_HEAD - HTTP HEAD request
HTTP_HEAD - HTTP HEAD request
.br
HTTP_CONNECT - HTTP CONNECT request
HTTP_CONNECT - HTTP CONNECT request
.br
HTTP_OTHER - over HTTP request
HTTP_OTHER - over HTTP request
.br
HTTP - matches any HTTP request except HTTP_CONNECT
HTTP - matches any HTTP request except HTTP_CONNECT
.br
HTTPS - same as HTTP_CONNECT
HTTPS - same as HTTP_CONNECT
.br
FTP_GET - FTP get request
FTP_GET - FTP get request
.br
FTP_PUT - FTP put request
FTP_PUT - FTP put request
.br
FTP_LIST - FTP list request
FTP_LIST - FTP list request
.br
FTP_DATA - FTP data connection. Note: FTP_DATA requires access to dynamic
non-ptivileged (1024-65535) ports on remote side.
FTP_DATA - FTP data connection. Note: FTP_DATA requires access to dynamic
non-ptivileged (1024-65535) ports on remote side.
.br
FTP - matches any FTP/FTP Data request
FTP - matches any FTP/FTP Data request
.br
ADMIN - access to administration interface
ADMIN - access to administration interface
.br
Weeksdays are week days numbers or periods (0 or 7 means Sunday, 1 is Monday,
1-5 means Monday through Friday). Timeperiodlists is a list of time
periods in HH:MM:SS-HH:MM:SS format. For example,
00:00:00-08:00:00,17:00:00-24:00:00
lists non-working hours.
Weeksdays are week days numbers or periods, 0 or 7 means Sunday, 1 is Monday, 1-5 means Monday through Friday. Timeperiodlists is a list of time
periods in HH:MM:SS-HH:MM:SS format. For example, 00:00:00-08:00:00,17:00:00-24:00:00 lists non-working hours.
.br
.B parent
<weight> <type> <ip> <port> <username> <password>
.br
this command must follow "allow" rule. It extends last allow rule to
this command must follow "allow" rule. It extends last allow rule to
build proxy chain. Proxies may be grouped. Proxy inside the
group is selected randomly. If few groups are specified one proxy
is randomly picked from each group and chain of proxies is created
@@ -615,38 +627,38 @@ with probability of 0.7) for outgoing web connections.
.br
type is one of:
.br
tcp - simply redirect connection. TCP is always last in chain.
tcp - simply redirect connection. TCP is always last in chain.
.br
http - redirect to HTTP proxy. HTTP is always last chain.
http - redirect to HTTP proxy. HTTP is always last chain.
.br
pop3 - redirect to POP3 proxy (only local redirection is supported, can not be
pop3 - redirect to POP3 proxy (only local redirection is supported, can not be
used for chaining)
.br
ftp - redirect to FTP proxy (only local redirection is supported, can not be
ftp - redirect to FTP proxy (only local redirection is supported, can not be
used for chaining)
.br
connect - parent is HTTP CONNECT method proxy
connect - parent is HTTP CONNECT method proxy
.br
connect+ - parent is HTTP CONNECT proxy with name resolution
connect+ - parent is HTTP CONNECT proxy with name resolution
.br
socks4 - parent is SOCKSv4 proxy
socks4 - parent is SOCKSv4 proxy
.br
socks4+ - parent is SOCKSv4 proxy with name resolution (SOCKSv4a)
socks4+ - parent is SOCKSv4 proxy with name resolution (SOCKSv4a)
.br
socks5 - parent is SOCKSv5 proxy
socks5 - parent is SOCKSv5 proxy
.br
socks5+ - parent is SOCKSv5 proxy with name resolution
socks5+ - parent is SOCKSv5 proxy with name resolution
.br
socks4b - parent is SOCKS4b (broken SOCKSv4 implementation with shortened
socks4b - parent is SOCKS4b (broken SOCKSv4 implementation with shortened
server reply. I never saw this kind ofservers byt they say there are).
Normally you should not use this option. Do not mess this option with
SOCKSv4a (socks4+).
.br
socks5b - parent is SOCKS5b (broken SOCKSv5 implementation with shortened
socks5b - parent is SOCKS5b (broken SOCKSv5 implementation with shortened
server reply. I think you will never find it useful). Never use this option
unless you know exactly you need it.
.br
admin - redirect request to local 'admin' service (with -s parameter).
admin - redirect request to local 'admin' service (with -s parameter).
.br
Use "+" proxy only with "fakeresolve" option
.br
@@ -687,14 +699,14 @@ example:
.br
socks
.br
redirects all SOCKS requests with target port 80 to local HTTP proxy,
redirects all SOCKS requests with target port 80 to local HTTP proxy,
local HTTP proxy parses requests and allows only GET and POST requests.
.br
parent 1000 http 1.2.3.4 0
.br
Changes external address for given connection to 1.2.3.4
Changes external address for given connection to 1.2.3.4
(an equivalent to -e1.2.3.4)
.br
Optional username and password are used to authenticate on parent
proxy. Username of '*' means username must be supplied by user.
@@ -702,7 +714,8 @@ proxy. Username of '*' means username must be supplied by user.
.br
.B nolog
<n>
extends last allow or deny command to prevent logging, e.g.
.br
extends last allow or deny command to prevent logging, e.g.
.br
allow * * 192.168.1.1
.br
@@ -712,13 +725,14 @@ nolog
.br
.B weight
<n>
extends last allow or deny command to set weight for this request
.br
allow * * 192.168.1.1
extends last allow or deny command to set weight for this request
.br
weight 100
allow * * 192.168.1.1
.br
Weight may be used for different purposes.
weight 100
.br
Weight may be used for different purposes.
.br
.B bandlimin
@@ -726,6 +740,7 @@ Weight may be used for different purposes.
.br
.B nobandlimin
<userlist> <sourcelist> <targetlist> <targetportlist> <operationlist>
.br
.B bandlimout
<rate> <userlist> <sourcelist> <targetlist> <targetportlist> <operationlist>
.br
@@ -750,7 +765,7 @@ addresses) to 57600 bps you have to specify 4 rules like
.br
bandlimin 57600 * 192.168.10.19
.br
and every of you clients will have 56K channel. if you specify
and every of you clients will have 56K channel. If you specify
.br
bandlimin 57600 * 192.168.10.16/30
.br
@@ -787,6 +802,8 @@ no traffic information on this counter is saved in file (that is
if proxy restarted all information is loosed) overwise it should be
unique sequential number.
Type specifies a type of counter. Type is one of:
.br
H - counter is resetted hourly
.br
D - counter is resetted daily
.br
@@ -799,7 +816,7 @@ Reporttype is one of D,W,M,H(hourly) and repotname specifies filename
template for reports. Report is text file with counter values in
format:
.br
<COUNTERNUMBER> <TRAF*4GB> <TRAF>
<COUNTERNUMBER> <TRAF>
.br
The rest of parameters is identical to bandlim/nobandlim.
@@ -807,28 +824,28 @@ format:
.B users
username[:pwtype:password] ...
.br
pwtype is one of:
pwtype is one of:
.br
none (empty) - use system authentication
none (empty) - use system authentication
.br
CL - password is cleartext
CL - password is cleartext
.br
CR - password is crypt-style password
CR - password is crypt-style password
.br
NT - password is NT password (in hex)
NT - password is NT password (in hex)
.br
example:
example:
.br
users test1:CL:password1 "test2:CR:$1$lFDGlder$pLRb4cU2D7GAT58YQvY49."
.br
users test3:NT:BD7DFBF29A93F93C63CB84790DA00E63
.br
(note: double quotes are requiered because password contains $ sign).
Note: double quotes are requiered because password contains $ sign.
.br
.B flush
.br
empty active access list. Access list must be flushed avery time you creating
empty active access list. Access list must be flushed avery time you creating
new access list for new service. For example:
.br
allow *
@@ -841,35 +858,36 @@ new access list for new service. For example:
.br
socks
.br
sets different ACLs for
sets different ACLs for
.B pop3p
and
.B socks
.br
.B system
<command>
.br
execute system command
execute system command
.br
.B pidfile
<filename>
.br
write pid of current process to file. It can be used to manipulate
write pid of current process to file. It can be used to manipulate
3proxy with signals under Unix. Currently next signals are available:
.br
.B monitor
<filename>
.br
If file monitored changes in modification time or size, 3proxy reloads
If file monitored changes in modification time or size, 3proxy reloads
configuration within one minute. Any number of files may be monitored.
.br
.B setuid
<uid>
.br
calls setuid(uid), uid must be numeric. Unix only. Warning: under some Linux
calls setuid(uid), uid must be numeric. Unix only. Warning: under some Linux
kernels setuid() works onle for current thread. It makes it impossible to suid
for all threads.
@@ -877,35 +895,51 @@ for all threads.
.B setgid
<gid>
.br
calls setgid(gid), gid must be numeric. Unix only.
calls setgid(gid), gid must be numeric. Unix only.
.br
.B chroot
<path>
.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
.br
.B plugin
<path_to_shared_library> <function_to_call> [<arg1> ...]
.br
Loads specified library and calls given export function with given arguments,
Loads specified library and calls given export function with given arguments,
as
.br
int functions_to_call(struct pluginlink * pl, int argc, char * argv[]);
int functions_to_call(struct pluginlink * pl, int argc, char * argv[]);
.br
function_to_call must return 0 in case of success, value > 0 to indicate error.
function_to_call must return 0 in case of success, value > 0 to indicate error.
.br
.B filtermaxsize
<max_size_of_data_to_filter>
.br
If Content-length (or another data length) is greater than given value, no
If Content-length (or another data length) is greater than given value, no
data filtering will be performed thorugh filtering plugins to avoid data
corruption and/or Content-Length chaging. Default is 1MB (1048576).
.SH BUGS
Report all bugs to
.BR 3proxy@3proxy.ru
.SH SEE ALSO
3proxy(8), proxy(8), ftppr(8), socks(8), pop3p(8), tcppm(8), udppm(8), syslogd(8),
.br
@@ -913,7 +947,5 @@ http://3proxy.ru/
.SH TRIVIA
3APA3A is pronounced as \`\`zaraza\'\'.
.SH AUTHORS
3proxy is designed by 3APA3A
.RI ( 3APA3A@security.nnov.ru ),
Vladimir Dubrovin
.RI ( vlad@sandy.ru )
3proxy is designed by Vladimir 3APA3A Dubrovin
.RI ( 3proxy@3proxy.ru )
+8 -6
View File
@@ -1,4 +1,4 @@
.TH ftppr "8" "July 2009" "3proxy 0.7" "Universal proxy server"
.TH ftppr "8" "January 2016" "3proxy 0.8" "Universal proxy server"
.SH NAME
.B ftppr
\- FTP proxy gateway service
@@ -51,6 +51,10 @@ is specified logging is to file. Under Unix, if
preceeds
.IR logfile ,
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
You can use any FTP client, regardless of FTP proxy support. For client with
FTP proxy support configure
@@ -73,13 +77,11 @@ is user\'s login on this FTP server. Login itself may contain \'@\' sign.
Only cleartext authentication is currently supported.
.SH BUGS
Report all bugs to
.BR 3proxy@security.nnov.ru
.BR 3proxy@3proxy.ru
.SH SEE ALSO
3proxy(8), proxy(8), pop3p(8), socks(8), tcppm(8), udppm(8), syslogd(8),
.br
http://3proxy.ru/
.SH AUTHORS
3proxy is designed by 3APA3A
.RI ( 3APA3A@security.nnov.ru ),
Vladimir Dubrovin
.RI ( vlad@sandy.ru )
3proxy is designed by Vladimir 3APA3A Dubrovin
.RI ( 3proxy@3proxy.ru )
+8 -6
View File
@@ -1,4 +1,4 @@
.TH icqpr "8" "July 2009" "3proxy 0.7" "Universal proxy server"
.TH icqpr "8" "January 2016" "3proxy 0.8" "Universal proxy server"
.SH NAME
.B icqpr
\- ICQ (AOL OSCAR) proxy
@@ -45,6 +45,10 @@ is specified logging is to file. Under Unix, if
preceeds
.IR logfile ,
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
.TP
.I local_port
@@ -66,13 +70,11 @@ as a destination in client application. Connection is forwarded to
.IR remote_host : remote_port
.SH BUGS
Report all bugs to
.BR 3proxy@security.nnov.ru
.BR 3proxy@3proxy.ru
.SH SEE ALSO
3proxy(8), proxy(8), ftppr(8), socks(8), pop3p(8), udppm(8), syslogd(8),
.br
http://3proxy.ru/
.SH AUTHORS
3proxy is designed by 3APA3A
.RI ( 3APA3A@security.nnov.ru ),
Vladimir Dubrovin
.RI ( vlad@sandy.ru )
3proxy is designed by Vladimir 3APA3A Dubrovin
.RI ( 3proxy@3proxy.ru )
+8 -6
View File
@@ -1,4 +1,4 @@
.TH pop3p "8" "July 2009" "3proxy 0.7" "Universal proxy server"
.TH pop3p "8" "January 2016" "3proxy 0.8" "Universal proxy server"
.SH NAME
.B pop3p
\- POP3 proxy gateway service
@@ -51,6 +51,10 @@ is specified logging is to file. Under Unix, if
preceeds
.IR logfile ,
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
You can use any MUA (Mail User Agent) with POP3 support. Set client to use
.I internal_ip
@@ -69,13 +73,11 @@ authentication (APOP, CRAM-MD5, etc) requires challenge from server before
we know which server to connect.
.SH BUGS
Report all bugs to
.BR 3proxy@security.nnov.ru
.BR 3proxy@3proxy.ru
.SH SEE ALSO
3proxy(8), ftppr(8), proxy(8), socks(8), tcppm(8), udppm(8), syslogd(8),
.br
http://3proxy.ru/
.SH AUTHORS
3proxy is designed by 3APA3A
.RI ( 3APA3A@security.nnov.ru ),
Vladimir Dubrovin
.RI ( vlad@sandy.ru )
3proxy is designed by Vladimir 3APA3A Dubrovin
.RI ( 3proxy@3proxy.ru )
+8 -6
View File
@@ -1,4 +1,4 @@
.TH proxy "8" "July 2009" "3proxy 0.7" "Universal proxy server"
.TH proxy "8" "January 2016" "3proxy 0.8" "Universal proxy server"
.SH NAME
.B proxy
\- HTTP proxy gateway service
@@ -52,6 +52,10 @@ is specified logging is to file. Under Unix, if
preceeds
.IR logfile ,
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
You should use client with HTTP proxy support or configure router to redirect
HTTP traffic to proxy (transparent proxy). Configure client to connect to
@@ -64,13 +68,11 @@ limit clients, use
instead.
.SH BUGS
Report all bugs to
.BR 3proxy@security.nnov.ru
.BR 3proxy@3proxy.ru
.SH SEE ALSO
3proxy(8), ftppr(8), socks(8), pop3p(8), tcppm(8), udppm(8), syslogd(8),
.br
http://3proxy.ru/
.SH AUTHORS
3proxy is designed by 3APA3A
.RI ( 3APA3A@security.nnov.ru ),
Vladimir Dubrovin
.RI ( vlad@sandy.ru )
3proxy is designed by Vladimir 3APA3A Dubrovin
.RI ( 3proxy@3proxy.ru )
+8 -6
View File
@@ -1,4 +1,4 @@
.TH smtpp "8" "July 2009" "3proxy 0.7" "Universal proxy server"
.TH smtpp "8" "January 2016" "3proxy 0.8" "Universal proxy server"
.SH NAME
.B smtpp
\- SMTP proxy gateway service
@@ -51,6 +51,10 @@ is specified logging is to file. Under Unix, if
preceeds
.IR logfile ,
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
You can use any MUA (Mail User Agent) with SMTP authentication support.
Set client to use
@@ -70,13 +74,11 @@ authentication (CRAM-MD5, SPA, etc) requires challenge from server before
we know which server to connect.
.SH BUGS
Report all bugs to
.BR 3proxy@security.nnov.ru
.BR 3proxy@3proxy.ru
.SH SEE ALSO
3proxy(8), ftppr(8), proxy(8), socks(8), tcppm(8), udppm(8), syslogd(8),
.br
http://3proxy.ru/
.SH AUTHORS
3proxy is designed by 3APA3A
.RI ( 3APA3A@security.nnov.ru ),
Vladimir Dubrovin
.RI ( vlad@sandy.ru )
3proxy is designed by Vladimir 3APA3A Dubrovin
.RI ( 3proxy@3proxy.ru )
+8 -6
View File
@@ -1,4 +1,4 @@
.TH socks "8" "July 2009" "3proxy 0.7" "Universal proxy server"
.TH socks "8" "January 2016" "3proxy 0.8" "Universal proxy server"
.SH NAME
.B socks
\- SOCKS 4/4.5/5 gateway service
@@ -48,6 +48,10 @@ is specified logging is to file. Under Unix, if
preceeds
.IR logfile ,
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
You should use client with SOCKS support or use some socksification support
(for example
@@ -65,13 +69,11 @@ sufficient privileges). If you need to control access use
instead.
.SH BUGS
Report all bugs to
.BR 3proxy@security.nnov.ru
.BR 3proxy@3proxy.ru
.SH SEE ALSO
3proxy(8), proxy(8), ftppr(8), pop3p(8), tcppm(8), udppm(8), syslogd(8),
.br
http://3proxy.ru/
.SH AUTHORS
3proxy is designed by 3APA3A
.RI ( 3APA3A@security.nnov.ru ),
Vladimir Dubrovin
.RI ( vlad@sandy.ru )
3proxy is designed by Vladimir 3APA3A Dubrovin
.RI ( 3proxy@3proxy.ru )
+8 -6
View File
@@ -1,4 +1,4 @@
.TH tcppm "8" "July 2009" "3proxy 0.7" "Universal proxy server"
.TH tcppm "8" "January 2016" "3proxy 0.8" "Universal proxy server"
.SH NAME
.B tcppm
\- TCP port mapper
@@ -40,6 +40,10 @@ is specified logging is to file. Under Unix, if
preceeds
.IR logfile ,
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
.TP
.I local_port
@@ -59,13 +63,11 @@ as a destination in client application. Connection is forwarded to
.IR remote_host : remote_port
.SH BUGS
Report all bugs to
.BR 3proxy@security.nnov.ru
.BR 3proxy@3proxy.ru
.SH SEE ALSO
3proxy(8), proxy(8), ftppr(8), socks(8), pop3p(8), udppm(8), syslogd(8),
.br
http://3proxy.ru/
.SH AUTHORS
3proxy is designed by 3APA3A
.RI ( 3APA3A@security.nnov.ru ),
Vladimir Dubrovin
.RI ( vlad@sandy.ru )
3proxy is designed by Vladimir 3APA3A Dubrovin
.RI ( 3proxy@3proxy.ru )
+8 -6
View File
@@ -1,4 +1,4 @@
.TH udppm "8" "July 2009" "3proxy 0.7" "Universal proxy server"
.TH udppm "8" "January 2016" "3proxy 0.8" "Universal proxy server"
.SH NAME
.B udppm
\- UDP port mapper
@@ -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.
It allows to share service between multiple clients for single packet services
(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
.TP
.I local_port
@@ -65,13 +69,11 @@ as a destination in client application. All datagrams are forwarded to
.IR remote_host : remote_port
.SH BUGS
Report all bugs to
.BR 3proxy@security.nnov.ru
.BR 3proxy@3proxy.ru
.SH SEE ALSO
3proxy(8), proxy(8), ftppr(8), socks(8), pop3p(8), udppm(8), syslogd(8),
.br
http://3proxy.ru/
.SH AUTHORS
3proxy is designed by 3APA3A
.RI ( 3APA3A@security.nnov.ru ),
Vladimir Dubrovin
.RI ( vlad@sandy.ru )
3proxy is designed by Vladimir 3APA3A Dubrovin
.RI ( 3proxy@3proxy.ru )
+256
View File
@@ -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>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</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--]
+10 -12
View File
@@ -87,7 +87,7 @@ void __stdcall CommandHandler( DWORD dwCommand )
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;
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 *tm;
tm = localtime(&oldtime);
memcpy(&tmold, tm, sizeof(tmold));
tmold = *tm;
tm = localtime(&newtime);
switch(lt){
case MINUTELY:
@@ -394,7 +394,7 @@ int WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int
"By clicking Yes you confirm you read and accepted License Agreement.\n"
"You can use Administration/Services to control %s service.",
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 = '\"';
@@ -415,7 +415,7 @@ int WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int
perror("Failed to open Service Manager");
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");
RETURN(103);
}
@@ -436,10 +436,10 @@ int WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int
RETURN(104);
}
if(RegSetValueEx( runsrv,
conf.stringtable[1],
(LPCSTR)conf.stringtable[1],
0,
REG_EXPAND_SZ,
(char *)tmpbuf,
(BYTE *)tmpbuf,
(int)strlen((char *)tmpbuf)+1)!=ERROR_SUCCESS){
perror("Failed to set registry value");
RETURN(105);
@@ -457,7 +457,7 @@ int WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int
perror("Failed to open Service Manager\n");
RETURN(106);
}
if (!(sch = OpenService(sch, conf.stringtable[1], DELETE))){
if (!(sch = OpenService(sch, (LPCSTR)conf.stringtable[1], DELETE))){
perror("Failed to open service");
RETURN(107);
}
@@ -476,7 +476,7 @@ int WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int
perror("Failed to open registry");
RETURN(109);
}
if(RegDeleteValue(runsrv, conf.stringtable[1]) != ERROR_SUCCESS){
if(RegDeleteValue(runsrv, (LPCSTR)conf.stringtable[1]) != ERROR_SUCCESS){
perror("Failed to clear registry");
RETURN(110);
}
@@ -510,14 +510,12 @@ int WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int
return 1;
}
pthread_mutex_init(&log_mutex, NULL);
logmutexinit = 1;
pthread_mutex_init(&config_mutex, NULL);
pthread_mutex_init(&bandlim_mutex, NULL);
pthread_mutex_init(&hash_mutex, NULL);
pthread_mutex_init(&tc_mutex, NULL);
pthread_mutex_init(&pwl_mutex, NULL);
pthread_mutex_init(&log_mutex, NULL);
freeconf(&conf);
res = readconfig(fp);
@@ -531,7 +529,7 @@ int WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int
if(service){
SERVICE_TABLE_ENTRY ste[] =
{
{ conf.stringtable[1], (LPSERVICE_MAIN_FUNCTION)ServiceMain},
{ (LPSTR)conf.stringtable[1], (LPSERVICE_MAIN_FUNCTION)ServiceMain},
{ NULL, NULL }
};
if(!StartServiceCtrlDispatcher( ste ))cyclestep();
+11 -16
View File
@@ -2,12 +2,7 @@
# 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
pre:
-cd .. && $(TYPECOMMAND) copying
$(PREMAKE)
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
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
$(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)
$(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)
$(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)
$(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)
$(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)
$(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)
$(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)
$(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
$(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
$(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
$(CC) $(COUT)mycryptmain$(OBJSUFFICS) $(CFLAGS) $(DEFINEOPTION)WITHMAIN mycrypt.c
$(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
+51 -45
View File
@@ -43,9 +43,9 @@ int clientnegotiate(struct chain * redir, struct clientparam * param, struct soc
len = sprintf((char *)buf, "CONNECT ");
if(redir->type == R_CONNECTP && param->hostname) {
char * needreplace;
needreplace = strchr(param->hostname, ':');
needreplace = strchr((char *)param->hostname, ':');
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++] = ']';
}
else {
@@ -241,7 +241,12 @@ int handleredirect(struct clientparam * param, struct ace * acentry){
r2 = (myrand(param, sizeof(struct clientparam))%1000);
}
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(param->extusername)
myfree(param->extusername);
@@ -266,11 +271,9 @@ int handleredirect(struct clientparam * param, struct ace * acentry){
case R_ICQ:
param->redirectfunc = icqprchild;
break;
/*
case R_MSN:
param->redirectfunc = msnprchild;
case R_SMTP:
param->redirectfunc = smtppchild;
break;
*/
default:
param->redirectfunc = proxychild;
}
@@ -279,12 +282,12 @@ int handleredirect(struct clientparam * param, struct ace * acentry){
}
else if(!*SAPORT(&cur->addr) && !SAISNULL(&cur->addr)) {
unsigned short port = *SAPORT(&param->sinsr);
memcpy(&param->sinsr, &cur->addr, SASIZE(&cur->addr));
param->sinsr = cur->addr;
*SAPORT(&param->sinsr) = port;
}
else if(SAISNULL(&cur->addr) && *SAPORT(&cur->addr)) *SAPORT(&param->sinsr) = *SAPORT(&cur->addr);
else {
memcpy(&param->sinsr, &cur->addr, SASIZE(&cur->addr));
param->sinsr = cur->addr;
}
if((res = alwaysauth(param))){
@@ -323,11 +326,13 @@ int IPInentry(struct sockaddr *sa, struct iplist *ipentry){
unsigned char *ip, *ipf, *ipt;
if(!sa || ! ipentry || *SAFAMILY(sa) != ipentry->family) return 0;
ip = (unsigned char *)SAADDR(sa);
ipf = (unsigned char *)&ipentry->ip_from;
ipt = (unsigned char *)&ipentry->ip_to;
if(!sa || ! ipentry || *SAFAMILY(sa) != ipentry->family) return 0;
addrlen = SAADDRLEN(sa);
if(memcmp(ip,ipf,addrlen) < 0 || memcmp(ip,ipt,addrlen) > 0) return 0;
@@ -353,7 +358,7 @@ int ACLmatches(struct ace* acentry, struct clientparam * param){
}
if(!ipentry) return 0;
}
if((acentry->dst && SAISNULL(&param->req)) || (acentry->dstnames && param->hostname)) {
if((acentry->dst && !SAISNULL(&param->req)) || (acentry->dstnames && param->hostname)) {
for(ipentry = acentry->dst; ipentry; ipentry = ipentry->next)
if(IPInentry((struct sockaddr *)&param->req, ipentry)) {
break;
@@ -367,19 +372,19 @@ int ACLmatches(struct ace* acentry, struct clientparam * param){
for(hstentry = acentry->dstnames; hstentry; hstentry = hstentry->next){
switch(hstentry->matchtype){
case 0:
if(strstr(param->hostname, hstentry->name)) match = 1;
if(strstr((char *)param->hostname, (char *)hstentry->name)) match = 1;
break;
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;
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;
default:
if(!strcmp(param->hostname, hstentry->name)) match = 1;
if(!strcmp((char *)param->hostname, (char *)hstentry->name)) match = 1;
break;
}
if(match) break;
@@ -606,7 +611,7 @@ int checkACL(struct clientparam * param){
if(param->redirected && acentry->chains && SAISNULL(&acentry->chains->addr) && !*SAPORT(&acentry->chains->addr)) {
continue;
}
memcpy(&dup, acentry, sizeof(struct ace));
dup = *acentry;
return handleredirect(param, &dup);
}
return acentry->action;
@@ -649,13 +654,13 @@ int cacheauth(struct clientparam * param){
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(&param->sincr) && !memcmp(SAADDR(&ac->sa), &param->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){
myfree(param->username);
}
param->username = mystrdup(ac->username);
param->username = (unsigned char *)mystrdup(ac->username);
pthread_mutex_unlock(&hash_mutex);
return 0;
}
@@ -683,21 +688,21 @@ int doauth(struct clientparam * param){
if(conf.authcachetype && authfuncs->authenticate && authfuncs->authenticate != cacheauth && param->username && (!(conf.authcachetype&4) || (!param->pwtype && param->password))){
pthread_mutex_lock(&hash_mutex);
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(&param->sincr) && !memcmp(SAADDR(&ac->sa), &param->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;
if(strcmp(ac->username, param->username)){
if(strcmp(ac->username, (char *)param->username)){
tmp = ac->username;
ac->username = mystrdup(param->username);
ac->username = mystrdup((char *)param->username);
myfree(tmp);
}
if((conf.authcachetype&4)){
tmp = ac->password;
ac->password = mystrdup(param->password);
ac->password = mystrdup((char *)param->password);
myfree(tmp);
}
memcpy(&ac->sa, &param->sincr, SASIZE(&param->sincr));
ac->sa = param->sincr;
break;
}
}
@@ -705,10 +710,10 @@ int doauth(struct clientparam * param){
ac = myalloc(sizeof(struct authcache));
if(ac){
ac->expires = conf.time + conf.authcachetime;
ac->username = mystrdup(param->username);
memcpy(&ac->sa, &param->sincr, SASIZE(&param->sincr));
ac->username = mystrdup((char *)param->username);
ac->sa = param->sincr;
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;
authc = ac;
@@ -770,7 +775,7 @@ int dnsauth(struct clientparam * param){
((u&0xFF000000)>>24));
}
if(!udpresolve(*SAFAMILY(&param->sincr), buf, addr, NULL, param, 1)) return 6;
if(!udpresolve(*SAFAMILY(&param->sincr), (unsigned char *)buf, (unsigned char *)addr, NULL, param, 1)) return 6;
if(!memcmp(SAADDR(&param->sincr), addr, SAADDRLEN(&param->sincr))) return 6;
return param->username? 0:4;
@@ -1035,17 +1040,18 @@ unsigned long udpresolve(int af, unsigned char * name, unsigned char * value, un
unsigned ttl;
#ifndef NOIPV6
struct sockaddr_in6 addr;
struct sockaddr_in6 *sinsr, *sinsl;
#else
struct sockaddr_in addr;
struct sockaddr_in *sinsr, *sinsl;
#endif
struct sockaddr *sinsr, *sinsl;
int usetcp = 0;
unsigned short serial = 1;
buf = b+2;
sinsl = (param && !makeauth)? (struct sockaddr *)&param->sinsl : (struct sockaddr *)&addr;
sinsr = (param && !makeauth)? (struct sockaddr *)&param->sinsr : (struct sockaddr *)&addr;
sinsl = (param && !makeauth)? &param->sinsl : &addr;
sinsr = (param && !makeauth)? &param->sinsr : &addr;
memset(sinsl, 0, sizeof(addr));
memset(sinsr, 0, sizeof(addr));
@@ -1059,19 +1065,19 @@ unsigned long udpresolve(int af, unsigned char * name, unsigned char * value, un
*SAFAMILY(sinsl) = *SAFAMILY(&nservers[i].addr);
}
if((sock=so._socket(SASOCK(sinsl), usetcp?SOCK_STREAM:SOCK_DGRAM, usetcp?IPPROTO_TCP:IPPROTO_UDP)) == INVALID_SOCKET) break;
if(so._bind(sock,sinsl,sizeof(addr))){
if(so._bind(sock,(struct sockaddr *)sinsl,SASIZE(sinsl))){
so._shutdown(sock, SHUT_RDWR);
so._closesocket(sock);
break;
}
if(makeauth && !SAISNULL(&authnserver.addr)){
memcpy(sinsr, &authnserver.addr, sizeof(addr));
*sinsr = authnserver.addr;
}
else {
memcpy(sinsr, &nservers[i].addr, sizeof(addr));
*sinsr = nservers[i].addr;
}
if(usetcp){
if(so._connect(sock,sinsr,sizeof(addr))) {
if(so._connect(sock,(struct sockaddr *)sinsr,SASIZE(sinsr))) {
so._shutdown(sock, SHUT_RDWR);
so._closesocket(sock);
break;
@@ -1107,13 +1113,13 @@ unsigned long udpresolve(int af, unsigned char * name, unsigned char * value, un
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._closesocket(sock);
continue;
}
if(param) param->statscli64 += len;
len = sockrecvfrom(sock, sinsr, buf, 4096, 15000);
len = sockrecvfrom(sock, (struct sockaddr *)sinsr, buf, 4096, conf.timeouts[DNS_TO]*1000);
so._shutdown(sock, SHUT_RDWR);
so._closesocket(sock);
if(len <= 13) {
@@ -1125,7 +1131,7 @@ unsigned long udpresolve(int af, unsigned char * name, unsigned char * value, un
us = ntohs(*(unsigned short*)buf);
len-=2;
buf+=2;
if(us > 4096 || us < len || (us > len && sockrecvfrom(sock, sinsr, buf+len, us-len, 15000) != 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;
}
}
@@ -1181,7 +1187,7 @@ unsigned long udpresolve(int af, unsigned char * name, unsigned char * value, un
}
*s2 = 0;
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);
}
@@ -1318,20 +1324,20 @@ void logsql(struct clientparam * param, const unsigned char *s) {
if(param->nolog) return;
pthread_mutex_lock(&log_mutex);
len = dobuf(param, tmpbuf, s, "\'");
len = dobuf(param, tmpbuf, s, (unsigned char *)"\'");
if(attempt > 5){
time_t t;
t = time(0);
if (t - attempt_time < 180){
sqlerr(tmpbuf);
sqlerr((char *)tmpbuf);
return;
}
}
if(!hstmt){
if(!init_sql(sqlstring)) {
sqlerr(tmpbuf);
sqlerr((char *)tmpbuf);
return;
}
}
@@ -1340,13 +1346,13 @@ void logsql(struct clientparam * param, const unsigned char *s) {
if(ret != SQL_SUCCESS && ret != SQL_SUCCESS_WITH_INFO){
close_sql();
if(!init_sql(sqlstring)){
sqlerr(tmpbuf);
sqlerr((char *)tmpbuf);
return;
}
if(hstmt) {
ret = SQLExecDirect(hstmt, (SQLCHAR *)tmpbuf, (SQLINTEGER)len);
if(ret != SQL_SUCCESS && ret != SQL_SUCCESS_WITH_INFO){
sqlerr(tmpbuf);
sqlerr((char *)tmpbuf);
return;
}
attempt = 0;
+43 -37
View File
@@ -58,6 +58,11 @@ struct extparam conf = {
NULL, NULL,
NULL,
NULL,
#ifdef __FreeBSD__
8192,
#else
0,
#endif
0, -1, 0, 0, 0, 0, 0, 500, 0, 0, 0,
6, 600,
1048576,
@@ -84,7 +89,7 @@ struct extparam conf = {
NULL,
(time_t)0, (time_t)0,
0,0,
'@'
'@',
};
int numservers=0;
@@ -157,10 +162,10 @@ struct sockfuncs so = {
#else
mypoll,
#endif
send,
sendto,
recv,
recvfrom,
(void *)send,
(void *)sendto,
(void *)recv,
(void *)recvfrom,
shutdown,
#ifdef _WIN32
closesocket
@@ -216,12 +221,12 @@ int ceparseargs(const char *str){
#endif
void parsehost(int family, char *host, struct sockaddr *sa){
void parsehost(int family, unsigned char *host, struct sockaddr *sa){
char *sp=NULL,*se=NULL;
unsigned short port;
if(*host == '[') se=strchr(host, ']');
if ( (sp = strchr(se?se:host, ':')) ) *sp = 0;
if(*host == '[') se=strchr((char *)host, ']');
if ( (sp = strchr(se?se:(char *)host, ':')) ) *sp = 0;
if(se){
*se = 0;
}
@@ -262,7 +267,7 @@ int parseusername(char *username, struct clientparam *param, int extpasswd){
char *sb = NULL, *se = NULL, *sp = NULL;
if(!username || !*username) return 1;
if(!param->srv->nouser && (sb = strchr(username, ':')) && (se = strchr(sb + 1, ':')) && (!extpasswd || (sp = strchr(se + 1, ':')))){
if(param->srv->needuser && (sb = strchr(username, ':')) && (se = strchr(sb + 1, ':')) && (!extpasswd || (sp = strchr(se + 1, ':')))){
*sb = 0;
*se = 0;
if(sp) *sp = 0;
@@ -297,7 +302,7 @@ int parseconnusername(char *username, struct clientparam *param, int extpasswd,
if(!username || !*username) return 1;
if ((sb=strchr(username, conf.delimchar)) == NULL){
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);
}
while ((se=strchr(sb+1, conf.delimchar)))sb=se;
@@ -466,7 +471,7 @@ int dobuf2(struct clientparam * param, unsigned char * buf, const unsigned char
break;
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;
if(len > 20) len = 20;
memcpy(buf+i, (len)?conf.stringtable[SERVICES + param->service]:(unsigned char*)"-", (len)?len:1);
@@ -601,17 +606,11 @@ void lognone(struct clientparam * param, const unsigned char *s) {
if(param->trafcountfunc)(*param->trafcountfunc)(param);
clearstat(param);
}
pthread_mutex_t log_mutex;
int logmutexinit = 0;
unsigned char tmpbuf[8192];
void logstdout(struct clientparam * param, const unsigned char *s) {
FILE *log;
if(!logmutexinit){
pthread_mutex_init(&log_mutex, NULL);
logmutexinit = 1;
}
pthread_mutex_lock(&log_mutex);
log = param->srv->stdlog?param->srv->stdlog:conf.stdlog?conf.stdlog:stdout;
dobuf(param, tmpbuf, s, NULL);
@@ -624,10 +623,6 @@ void logstdout(struct clientparam * param, const unsigned char *s) {
#ifndef _WIN32
void logsyslog(struct clientparam * param, const unsigned char *s) {
if(!logmutexinit){
pthread_mutex_init(&log_mutex, NULL);
logmutexinit = 1;
}
pthread_mutex_lock(&log_mutex);
dobuf(param, tmpbuf, s, NULL);
if(!param->nolog)syslog(LOG_INFO, "%s", tmpbuf);
@@ -648,7 +643,6 @@ int doconnect(struct clientparam * param){
}
else {
struct linger lg = {1,conf.timeouts[SINGLEBYTE_S]};
int opt = 1;
if(SAISNULL(&param->sinsr)){
if(SAISNULL(&param->req)) {
@@ -659,27 +653,39 @@ int doconnect(struct clientparam * param){
}
if(!*SAPORT(&param->sinsr))*SAPORT(&param->sinsr) = *SAPORT(&param->req);
if ((param->remsock=so._socket(SASOCK(&param->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_REUSEADDR, (unsigned char *)&opt, sizeof(int));
so._setsockopt(param->remsock, SOL_SOCKET, SO_LINGER, (char *)&lg, sizeof(lg));
#ifdef REUSE
{
int opt;
#ifdef SO_REUSEADDR
opt = 1;
so._setsockopt(param->remsock, SOL_SOCKET, SO_REUSEADDR, (char *)&opt, sizeof(int));
#endif
#ifdef SO_REUSEPORT
opt = 1;
so._setsockopt(param->remsock, SOL_SOCKET, SO_REUSEPORT, (unsigned char *)&opt, sizeof(int));
#endif
}
#endif
#ifndef NOIPV6
if(*SAFAMILY(&param->sinsr) == AF_INET6) memcpy(&param->sinsl, &param->srv->extsa6, sizeof(param->srv->extsa6));
if(*SAFAMILY(&param->sinsr) == AF_INET6) param->sinsl = param->srv->extsa6;
else
#endif
memcpy(&param->sinsl, &param->srv->extsa, sizeof(param->srv->extsa));
if (param->srv->targetport && !*SAPORT(&param->sinsl) && ntohs(*SAPORT(&param->sincr)) > 1023) *SAPORT(&param->sinsl) = *SAPORT(&param->sincr);
if(so._bind(param->remsock, (struct sockaddr*)&param->sinsl, sizeof(param->sinsl))==-1) {
*SAPORT(&param->sinsl) = 0;
if(so._bind(param->remsock, (struct sockaddr*)&param->sinsl, sizeof(param->sinsl))==-1) {
return 12;
}
param->sinsl = param->srv->extsa;
*SAPORT(&param->sinsl) = 0;
if(so._bind(param->remsock, (struct sockaddr*)&param->sinsl, SASIZE(&param->sinsl))==-1) {
return 12;
}
if(param->operation >= 256 || (param->operation & CONNECT)){
#ifdef _WIN32
unsigned long ul = 1;
#endif
if(so._connect(param->remsock,(struct sockaddr *)&param->sinsr,sizeof(param->sinsr))) {return (13);}
if(so._connect(param->remsock,(struct sockaddr *)&param->sinsr,SASIZE(&param->sinsr))) {
return (13);
}
param->nconnects++;
#ifdef _WIN32
ioctlsocket(param->remsock, FIONBIO, &ul);
@@ -817,11 +823,11 @@ unsigned long getip46(int family, unsigned char *name, struct sockaddr *sa){
if(!name[i]){
if(ndots == 3 && ncols == 0 && nhex == 0){
*SAFAMILY(sa)=(family == 6)?AF_INET6 : AF_INET;
return inet_pton(*SAFAMILY(sa), name, SAADDR(sa))? *SAFAMILY(sa) : 0;
return inet_pton(*SAFAMILY(sa), (char *)name, SAADDR(sa))? *SAFAMILY(sa) : 0;
}
if(ncols >= 2) {
*SAFAMILY(sa)=AF_INET6;
return inet_pton(AF_INET6, name, SAADDR(sa))?(family==4? 0:AF_INET6) : 0;
return inet_pton(AF_INET6, (char *)name, SAADDR(sa))?(family==4? 0:AF_INET6) : 0;
}
}
if((tmpresolv = resolvfunc)){
@@ -836,10 +842,10 @@ unsigned long getip46(int family, unsigned char *name, struct sockaddr *sa){
}
memset(&hint, 0, sizeof(hint));
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){
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;
}
+21 -11
View File
@@ -32,6 +32,7 @@ struct proxydef childdef = {NULL, 0, 0, S_NOSERVICE, ""};
#ifndef _WIN32
char *chrootp = NULL;
static pthread_attr_t pa;
#endif
char * curconf = NULL;
@@ -142,14 +143,14 @@ int start_proxy_thread(struct child * chp){
conf.threadinit = 1;
#ifdef _WIN32
#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
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
if(h)CloseHandle(h);
#else
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_create(&thread, &pa, startsrv, (void *)chp);
#endif
@@ -271,9 +272,11 @@ static int h_external(int argc, unsigned char ** argv){
int res;
#ifndef NOIPV6
struct sockaddr_in6 sa6;
memset(&sa6, 0, sizeof(sa6));
res = getip46(46, argv[1], (struct sockaddr *)&sa6);
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
res = getip46(46, argv[1], (struct sockaddr *)&conf.extsa);
if(!res) return 1;
@@ -332,6 +335,11 @@ static int h_log(int argc, unsigned char ** argv){
return 0;
}
static int h_stacksize(int argc, unsigned char **argv){
conf.stacksize = atoi((char *)argv[1]);
return 0;
}
static int h_service(int argc, unsigned char **argv){
return 0;
}
@@ -704,7 +712,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], "admin"))chains->type = R_ADMIN;
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 {
fprintf(stderr, "Chaining error: bad chain type (%s)\n", argv[2]);
return(4);
@@ -726,7 +735,7 @@ static int h_nolog(int argc, unsigned char **argv){
return(1);
}
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]);
return 0;
}
@@ -739,14 +748,14 @@ int scanipl(unsigned char *arg, struct iplist *dst){
#endif
char * slash, *dash;
int masklen, addrlen;
if((slash = strchr(arg, '/'))) *slash = 0;
if((dash = strchr(arg,'-'))) *dash = 0;
if((slash = strchr((char *)arg, '/'))) *slash = 0;
if((dash = strchr((char *)arg,'-'))) *dash = 0;
if(!getip46(46, arg, (struct sockaddr *)&sa)) return 1;
memcpy(&dst->ip_from, SAADDR(&sa), SAADDRLEN(&sa));
dst->family = *SAFAMILY(&sa);
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));
if(*SAFAMILY(&sa) != dst->family || memcmp(&dst->ip_to, &dst->ip_from, SAADDRLEN(&sa)) < 0) return 3;
return 0;
@@ -1253,7 +1262,7 @@ static int h_plugin(int argc, unsigned char **argv){
#ifdef _WINCE
hi = LoadLibraryW((LPCWSTR)CEToUnicode(argv[1]));
#else
hi = LoadLibrary(argv[1]);
hi = LoadLibrary((char *)argv[1]);
#endif
if(!hi) {
fprintf(stderr, "Failed to load %s, code %d\n", argv[1], (int)GetLastError());
@@ -1262,7 +1271,7 @@ static int h_plugin(int argc, unsigned char **argv){
#ifdef _WINCE
fp = GetProcAddressW(hi, (LPCWSTR)CEToUnicode(argv[2]));
#else
fp = GetProcAddress(hi, argv[2]);
fp = GetProcAddress(hi, (char *)argv[2]);
#endif
if(!fp) {
printf("%s not found in %s, code: %d\n", argv[2], argv[1], (int)GetLastError());
@@ -1389,6 +1398,7 @@ struct commands commandhandlers[]={
{commandhandlers+55, "msnpr", h_proxy, 4, 0},
{commandhandlers+56, "delimchar",h_delimchar, 2, 2},
{commandhandlers+57, "authnserver", h_authnserver, 2, 2},
{commandhandlers+58, "stacksize", h_stacksize, 2, 2},
{specificcommands, "", h_noop, 1, 0}
};
+1 -1
View File
@@ -74,7 +74,7 @@ static void pr_sa(struct node *node, CBFUNC cbf, void*cb){
buf[0] = '[';
buf[1] = 0;
inet_ntop(*SAFAMILY(node->value), node->value, buf+1, sizeof(buf)-10);
sprintf(buf + strlen(buf), "]:hu", (unsigned short)*SAPORT(node->value));
sprintf(buf + strlen(buf), "]:%hu", (unsigned short)*SAPORT(node->value));
if(node->value)(*cbf)(cb, buf, strlen(buf));
#endif
}
+3 -2
View File
@@ -6,6 +6,7 @@
*/
#include "proxy.h"
pthread_mutex_t log_mutex;
int sockgetchar(SOCKET sock, int timeosec, int timeousec){
@@ -18,7 +19,7 @@ int sockgetchar(SOCKET sock, int timeosec, int timeousec){
FD_ZERO(&fds);
FD_SET(sock, &fds);
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);
}
@@ -94,7 +95,7 @@ int main(int argc, char *argv[]){
fprintf(stderr, "Unable to connect: %s\n", host);
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);
if(i<1) return 9;
if(!(fp = fopen(argv[argc-1], "w"))) {
+9 -9
View File
@@ -39,7 +39,7 @@ void * dnsprchild(struct clientparam* param) {
}
buf = bbuf+2;
size = sizeof(param->sincr);
i = so._recvfrom(param->srv->srvsock, buf, BUFSIZE, 0, (struct sockaddr *)&param->sincr, &size);
i = so._recvfrom(param->srv->srvsock, (char *)buf, BUFSIZE, 0, (struct sockaddr *)&param->sincr, &size);
size = sizeof(param->sinsl);
getsockname(param->srv->srvsock, (struct sockaddr *)&param->sincl, &size);
#ifdef _WIN32
@@ -47,8 +47,8 @@ void * dnsprchild(struct clientparam* param) {
RETURN(818);
}
ioctlsocket(param->clisock, FIONBIO, &ul);
if(so._setsockopt(param->clisock, SOL_SOCKET, SO_REUSEADDR, (unsigned char *)&ul, sizeof(int))) {RETURN(820);};
if(so._bind(param->clisock,(struct sockaddr *)&param->sincl,sizeof(param->sincl))) {
if(so._setsockopt(param->clisock, SOL_SOCKET, SO_REUSEADDR, (char *)&ul, sizeof(int))) {RETURN(820);};
if(so._bind(param->clisock,(struct sockaddr *)&param->sincl,SASIZE(&param->sincl))) {
RETURN(822);
}
@@ -135,12 +135,12 @@ void * dnsprchild(struct clientparam* param) {
}
memset(&param->sinsl, 0, sizeof(param->sinsl));
*SAFAMILY(&param->sinsl) = *SAFAMILY(&nservers[0].addr);
if(so._bind(param->remsock,(struct sockaddr *)&param->sinsl,sizeof(param->sinsl))) {
if(so._bind(param->remsock,(struct sockaddr *)&param->sinsl,SASIZE(&param->sinsl))) {
RETURN(819);
}
memcpy(&param->sinsr, &nservers[0].addr, sizeof(param->sinsr));
param->sinsr = nservers[0].addr;
if(nservers[0].usetcp) {
if(so._connect(param->remsock,(struct sockaddr *)&param->sinsr,sizeof(param->sinsr))) RETURN(830);
if(so._connect(param->remsock,(struct sockaddr *)&param->sinsr,SASIZE(&param->sinsr))) RETURN(830);
buf-=2;
*(unsigned short*)buf = htons(i);
i+=2;
@@ -158,7 +158,7 @@ void * dnsprchild(struct clientparam* param) {
}
param->statscli64 += i;
param->nwrites++;
len = sockrecvfrom(param->remsock, (struct sockaddr *)&param->sinsr, buf, BUFSIZE, 15000);
len = sockrecvfrom(param->remsock, (struct sockaddr *)&param->sinsr, buf, BUFSIZE, conf.timeouts[DNS_TO]*1000);
if(len <= 13) {
RETURN(821);
}
@@ -195,8 +195,8 @@ CLEANRET:
sprintf((char *)buf, "%04x/%s/",
(unsigned)type,
host?host:"");
if(ip && type == 0x01 || type == 0x1c){
myinet_ntop(type == 0x01? AF_INET:AF_INET6, addr, buf+strlen(buf), 64);
if((ip && type == 0x01) || type == 0x1c){
myinet_ntop(type == 0x01? AF_INET:AF_INET6, addr, (char *)buf+strlen((char *)buf), 64);
}
(*param->srv->logfunc)(param, buf);
}
+1 -1
View File
@@ -189,7 +189,7 @@ SOCKET ftpdata(struct clientparam *param){
if(sscanf(sb+1, "%lu,%lu,%lu,%lu,%hu,%hu", &b1, &b2, &b3, &b4, &b5, &b6)!=6) return INVALID_SOCKET;
rem = param->remsock;
param->remsock = INVALID_SOCKET;
memcpy(&param->req,&param->sinsr,sizeof(param->req));
param->req = param->sinsr;
*SAPORT(&param->req) = *SAPORT(&param->sinsr) = htons((unsigned short)((b5<<8)^b6));
i = param->operation;
param->operation = FTP_DATA;
+10 -11
View File
@@ -76,7 +76,7 @@ void * ftpprchild(struct clientparam* param) {
{
int action, reqbufsize, reqsize;
reqbufsize = BUFSIZE;
reqsize = (int)strlen(buf) + 1;
reqsize = (int)strlen((char *)buf) + 1;
action = handlereqfilters(param, &buf, &reqbufsize, 0, &reqsize);
if(action == HANDLED){
@@ -94,7 +94,7 @@ void * ftpprchild(struct clientparam* param) {
{
int action, reqbufsize, reqsize;
reqbufsize = BUFSIZE;
reqsize = (int)strlen(buf) + 1;
reqsize = (int)strlen((char *)buf) + 1;
action = handlehdrfilterscli(param, &buf, &reqbufsize, 0, &reqsize);
if(action == HANDLED){
@@ -119,11 +119,11 @@ void * ftpprchild(struct clientparam* param) {
clidatasock = INVALID_SOCKET;
}
if ((clidatasock=socket(SASOCK(&param->sincl), SOCK_STREAM, IPPROTO_TCP)) == INVALID_SOCKET) {RETURN(821);}
sasize = sizeof(param->sincl);
*SAPORT(&param->sincl) = 0;
if(so._bind(clidatasock, (struct sockaddr *)&param->sincl, sasize)){RETURN(822);}
if(so._bind(clidatasock, (struct sockaddr *)&param->sincl, SASIZE(&param->sincl))){RETURN(822);}
if (pasv) {
if(so._listen(clidatasock, 1)) {RETURN(823);}
sasize = sizeof(param->sincl);
if(so._getsockname(clidatasock, (struct sockaddr *)&param->sincl, &sasize)){RETURN(824);}
if(*SAFAMILY(&param->sincl) == AF_INET)
sprintf((char *)buf, "227 OK (%u,%u,%u,%u,%u,%u)\r\n",
@@ -145,19 +145,18 @@ void * ftpprchild(struct clientparam* param) {
if(sscanf((char *)buf+5, "%lu,%lu,%lu,%lu,%hu,%hu", &b1, &b2, &b3, &b4, &b5, &b6)!=6) {RETURN(828);}
*SAPORT(&param->sincr) = htons((unsigned short)((b5<<8)^b6));
sasize = sizeof(param->sincr);
if(so._connect(clidatasock, (struct sockaddr *)&param->sincr, sasize)) {
if(so._connect(clidatasock, (struct sockaddr *)&param->sincr, SASIZE(&param->sincr))) {
so._closesocket(clidatasock);
clidatasock = INVALID_SOCKET;
RETURN(826);
}
sprintf(buf, "200 OK\r\n");
sprintf((char *)buf, "200 OK\r\n");
}
#ifndef WITHMAIN
{
int action, reqbufsize, reqsize;
reqbufsize = BUFSIZE;
reqsize = (int)strlen(buf) + 1;
reqsize = (int)strlen((char *)buf) + 1;
action = handlehdrfilterssrv(param, &buf, &reqbufsize, 0, &reqsize);
if(action == HANDLED){
@@ -185,7 +184,7 @@ void * ftpprchild(struct clientparam* param) {
{
int action, reqbufsize, reqsize;
reqbufsize = BUFSIZE;
reqsize = (int)strlen(buf) + 1;
reqsize = (int)strlen((char *)buf) + 1;
action = handlehdrfilterscli(param, &buf, &reqbufsize, 0, &reqsize);
if(action == HANDLED){
@@ -240,8 +239,8 @@ void * ftpprchild(struct clientparam* param) {
}
sc = param->remsock;
param->remsock = ss;
so._setsockopt(param->remsock, SOL_SOCKET, SO_LINGER, (unsigned char *)&lg, sizeof(lg));
so._setsockopt(clidatasock, 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, (char *)&lg, sizeof(lg));
param->clisock = clidatasock;
res = sockmap(param, conf.timeouts[CONNECTION_S]);
if(param->remsock != INVALID_SOCKET) {
+10 -10
View File
@@ -128,11 +128,11 @@ static int searchcookie(struct clientparam *param, struct flap_header * flap, in
icq_cookie_mutex_init = 1;
}
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){
ic = myalloc(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;
icq_cookies = ic;
}
@@ -202,10 +202,10 @@ static FILTER_ACTION icq_srv(void *fc, struct clientparam * param, unsigned char
state->state = ONCHAN;
}
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++;
if(state->leftinstate > 65535){
param->srv->logfunc(param, "Out of Sync");
param->srv->logfunc(param, (unsigned char *)"Out of Sync");
return REJECT;
}
}
@@ -214,7 +214,7 @@ static FILTER_ACTION icq_srv(void *fc, struct clientparam * param, unsigned char
break;
case ONCHAN:
if (*start >= 10){
param->srv->logfunc(param, "Warning: Wrong channel");
param->srv->logfunc(param, (unsigned char *)"Warning: Wrong channel");
state->state = ONBEGIN;
}
else {
@@ -234,15 +234,15 @@ static FILTER_ACTION icq_srv(void *fc, struct clientparam * param, unsigned char
case ONSEQ2:
state->gotseq += *start;
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)){
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);
state->state = ONBEGIN;
state->resyncseq = state->gotseq;
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);
state->srvseq = state->gotseq;
*(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;
len = ntohs(flap->size);
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;
return 0;
@@ -418,7 +418,7 @@ void * icqprchild(struct clientparam* param) {
for(ic = icq_cookies; ic; ic=ic->next){
if(ic->size && ic->size == tlv->size && !memcmp(ic->cookie, tlv->data, ntohs(tlv->size))){
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;
}
}
+7
View File
@@ -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)ladp$(LIBSSUFFIX) ldapauth$(OBJSUFFICS)
+15 -15
View File
@@ -144,7 +144,7 @@ static FILTER_ACTION pcre_filter_buffer(void *fc, struct clientparam *param, uns
if(!pcrefd->re) return pcrefd->action;
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(!(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]);
(*pl->myfree)(*buf_p);
*buf_p = newbuf;
*buf_p = (unsigned char *)newbuf;
*bufsize_p = ovector[0] + replen + 1;
}
memcpy(*buf_p + ovector[0], tmpbuf, replen);
@@ -229,15 +229,15 @@ static int h_pcre(int argc, unsigned char **argv){
struct filter *newf;
char *replace = NULL;
if(!strncmp(argv[2], "allow",5)) action = PASS;
else if(!strncmp(argv[2], "deny",4)) action = REJECT;
else if(!strncmp(argv[2], "remove",6)) action = REMOVE;
else if(!strncmp(argv[2], "dunno",5)) action = CONTINUE;
if(!strncmp((char *)argv[2], "allow",5)) action = PASS;
else if(!strncmp((char *)argv[2], "deny",4)) action = REJECT;
else if(!strncmp((char *)argv[2], "remove",6)) action = REMOVE;
else if(!strncmp((char *)argv[2], "dunno",5)) action = CONTINUE;
else return 1;
if(!strncmp(argv[0], "pcre_rewrite", 12)) {
if(!strncmp((char *)argv[0], "pcre_rewrite", 12)) {
int i,j;
offset = 5;
replace = pl->mystrdup(argv[4]);
replace = pl->mystrdup((char *)argv[4]);
if(!replace) return 9;
for(i=0, j=0; replace[i]; i++, j++){
if(replace[i] == '\\'){
@@ -266,7 +266,7 @@ static int h_pcre(int argc, unsigned char **argv){
replace[j] = 0;
}
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]) ){
re = pcre_compile((char *)argv[3], pcre_options, &errptr, &offset, NULL);
if(!re) {
@@ -296,11 +296,11 @@ static int h_pcre(int argc, unsigned char **argv){
newf->data = flt;
newf->filter_open = pcre_filter_open;
newf->filter_client = pcre_filter_client;
if(strstr(argv[1], "request"))newf->filter_request = pcre_filter_buffer;
if(strstr(argv[1], "cliheader"))newf->filter_header_cli = pcre_filter_buffer;
if(strstr(argv[1], "clidata"))newf->filter_data_cli = pcre_filter_buffer;
if(strstr(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], "request"))newf->filter_request = pcre_filter_buffer;
if(strstr((char *)argv[1], "cliheader"))newf->filter_header_cli = pcre_filter_buffer;
if(strstr((char *)argv[1], "clidata"))newf->filter_data_cli = pcre_filter_buffer;
if(strstr((char *)argv[1], "srvheader"))newf->filter_header_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_close = pcre_filter_close;
@@ -334,7 +334,7 @@ static int h_pcre_options(int argc, unsigned char **argv){
pcre_options = 0;
for(j=1; j<argc; j++)
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;
return 0;
+1 -1
View File
@@ -4,4 +4,4 @@ pamauth$(OBJSUFFICS): pamauth.c
$(CC) $(DCFLAGS) $(CFLAGS) pamauth.c
$(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)
+1 -1
View File
@@ -124,7 +124,7 @@ int start(struct pluginlink * pluginlink, int argc, unsigned char** argv)
if(argc < 2) return 1;
pl = pluginlink;
if(service) pl->myfree(service);
service=pl->mystrdup(argv[1]);
service=(unsigned char *)pl->mystrdup((char *)argv[1]);
if (already_loaded) { return (0); }
+6 -1
View File
@@ -326,8 +326,13 @@ static struct filter ssl_filter = {
};
int mitm = 0;
int ssl_inited = 0;
static int h_mitm(int argc, unsigned char **argv){
if(!ssl_inited) {
ssl_init();
ssl_inited = 1;
}
if((mitm&1)) return 1;
if(mitm) usleep(100*SLEEPTIME);
ssl_filter.next = pl->conf->filters;
@@ -389,9 +394,9 @@ __declspec(dllexport)
}
else {
ssl_release();
ssl_inited = 0;
}
ssl_init();
tcppmfunc = (PROXYFUNC)pl->findbyname("tcppm");
if(!tcppmfunc){return 13;}
proxyfunc = (PROXYFUNC)pl->findbyname("proxy");
@@ -47,7 +47,6 @@ static FILTER_ACTION transparent_filter_client(void *fo, struct clientparam * pa
len = sizeof(addr);
if(getsockopt(param->clisock, SOL_IP, SO_ORIGINAL_DST,(struct sockaddr *) &addr, &len) || !addr.sin_addr.s_addr){
perror("getsockopt()");
return PASS;
}
u = ntohl(addr.sin_addr.s_addr);
@@ -59,8 +58,6 @@ perror("getsockopt()");
((u&0x000000FF)),
p);
param->srv->logfunc(param, (unsigned char *)"transparent_filter_client() Success");
param->srv->logfunc(param, (unsigned char *)addrbuf);
pl->parsehostname(addrbuf, param, 0);
return PASS;
#else
@@ -41,7 +41,7 @@ extern "C" {
if(dom)*dom++=0;
if(!LogonUser( dom?dom:(char *)param->username,
dom?(char *)param->username:NULL,
param->password,
(char *)param->password,
LOGON32_LOGON_NETWORK,
LOGON32_PROVIDER_DEFAULT,
&h))return 5;
@@ -54,7 +54,7 @@ extern "C" {
if(GetLengthSid(ptg->Groups[i].Sid)==sidlen){
if(!memcmp((void *)ptg->Groups[i].Sid, (void *)psid, sidlen)) {
setlocale(LC_CTYPE, ".ACP");
_strlwr(param->username);
_strlwr((char *)param->username);
return 0;
}
}
+1 -1
View File
@@ -26,7 +26,7 @@ extern "C" {
#endif
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 c1, new_c1, new_c2, new_i;
for(i = 0; i < n; i++){
+36 -30
View File
@@ -14,49 +14,49 @@
char * proxy_stringtable[] = {
/* 0 */ "HTTP/1.0 400 Bad Request\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"
"<html><head><title>400 Bad Request</title></head>\r\n"
"<body><h2>400 Bad Request</h2></body></html>\r\n",
/* 1 */ "HTTP/1.0 502 Bad Gateway\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"
"<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",
/* 2 */ "HTTP/1.0 503 Service Unavailable\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"
"<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",
/* 3 */ "HTTP/1.0 503 Service Unavailable\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"
"<html><head><title>503 Service Unavailable</title></head>\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"
"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"
"<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",
/* 5 */ "HTTP/1.0 502 Bad Gateway\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"
"<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",
/* 6 */ "HTTP/1.0 500 Internal Error\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"
"<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",
@@ -64,7 +64,7 @@ char * proxy_stringtable[] = {
/* 7 */ "HTTP/1.0 407 Proxy Authentication Required\r\n"
"Proxy-Authenticate: Basic realm=\"proxy\"\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"
"<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",
@@ -76,14 +76,14 @@ char * proxy_stringtable[] = {
/* 10*/ "HTTP/1.0 404 Not Found\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"
"<html><head><title>404 Not Found</title></head>\r\n"
"<body><h2>404 Not Found</h2><h3>File not found</body></html>\r\n",
/* 11*/ "HTTP/1.0 403 Forbidden\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"
"<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",
@@ -94,7 +94,7 @@ char * proxy_stringtable[] = {
#endif
"Proxy-Authenticate: basic realm=\"proxy\"\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"
"<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",
@@ -106,13 +106,13 @@ char * proxy_stringtable[] = {
/* 14*/ "HTTP/1.0 403 Forbidden\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"
"<pre>",
/* 15*/ "HTTP/1.0 503 Service Unavailable\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"
"<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",
@@ -120,7 +120,7 @@ char * proxy_stringtable[] = {
/* 16*/ "HTTP/1.0 401 Authentication Required\r\n"
"WWW-Authenticate: basic realm=\"FTP Server\"\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"
"<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",
@@ -293,6 +293,7 @@ for(;;){
RETURN(511);
}
if(buf[i-3] == '1') keepalive = 2;
param->transparent = 0;
if((isconnect = !strncasecmp((char *)buf, "CONNECT", 7))) keepalive = 2;
if ((sb=(unsigned char *)(unsigned char *)strchr((char *)buf, ' ')) == NULL) {RETURN(512);}
@@ -327,7 +328,7 @@ for(;;){
prefix = (int)(se - buf);
su = (unsigned char*)strrchr((char *)sb, '@');
if(su) {
su = mystrdup(sb);
su = (unsigned char *)mystrdup((char *)sb);
decodeurl(su, 0);
parseconnusername((char *)su, (struct clientparam *)param, 1, (unsigned short)((ftp)?21:80));
myfree(su);
@@ -442,12 +443,16 @@ for(;;){
continue;
}
if(param->transparent && i > 6 && !strncasecmp((char *)buf + inbuf, "Host:", 5)){
unsigned char c;
sb = (unsigned char *)strchr((char *)(buf+inbuf), ':');
if(!sb)continue;
++sb;
while(isspace(*sb))sb++;
se = (unsigned char *)strchr((char *)sb, '\r');
if(se) *se = 0;
(se = (unsigned char *)strchr((char *)sb, '\r')) || (se = (unsigned char *)strchr((char *)sb, '\n'));
if(se) {
c = *se;
*se = 0;
}
if(!param->hostname){
parsehostname((char *)sb, param, 80);
}
@@ -459,7 +464,7 @@ for(;;){
myfree(req);
req = newbuf;
}
if(se)*se = '\r';
if(se)*se = c;
}
if(ftp && i > 13 && (!strncasecmp((char *)(buf+inbuf), "authorization", 13))){
sb = (unsigned char *)strchr((char *)(buf+inbuf), ':');
@@ -489,7 +494,7 @@ for(;;){
if(!sb)continue;
++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)){
RETURN(10);
}
@@ -509,7 +514,7 @@ for(;;){
buf[inbuf] = 0;
reqsize = (int)strlen(req);
reqsize = (int)strlen((char *)req);
reqbufsize = reqsize + 1;
#ifndef WITHMAIN
@@ -528,7 +533,7 @@ for(;;){
uint64_t newlen64;
newlen64 = sockfillbuffcli(param, (unsigned long)contentlength64, CONNECTION_S);
if(newlen64 == contentlength64) {
action = handledatfltcli(param, &param->clibuf, &param->clibufsize, 0, &param->cliinbuf);
action = handledatfltcli(param, &param->clibuf, (int *)&param->clibufsize, 0, (int *)&param->cliinbuf);
if(action == HANDLED){
RETURN(0);
}
@@ -802,7 +807,8 @@ for(;;){
else {
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);
}
param->statscli64 += res;
@@ -892,7 +898,7 @@ for(;;){
if(!sb)continue;
++sb;
while(isspace(*sb))sb++;
sscanf(sb, "%"PRINTF_INT64_MODIFIER"u", &contentlength64);
sscanf((char *)sb, "%"PRINTF_INT64_MODIFIER"u", &contentlength64);
hascontent = 1;
if(param->unsafefilter && param->ndatfilterssrv > 0) {
hascontent = 2;
@@ -908,7 +914,7 @@ for(;;){
if(!sb)continue;
++sb;
while(isspace(*sb))sb++;
if(!strncasecmp(sb, "chunked", 7)){
if(!strncasecmp((char *)sb, "chunked", 7)){
param->chunked = 1;
}
}
@@ -958,7 +964,7 @@ for(;;){
uint64_t newlen;
newlen = (uint64_t)sockfillbuffsrv(param, (unsigned long) contentlength64, CONNECTION_S);
if(newlen == contentlength64) {
action = handledatfltsrv(param, &param->srvbuf, &param->srvbufsize, 0, &param->srvinbuf);
action = handledatfltsrv(param, &param->srvbuf, (int *)&param->srvbufsize, 0, (int *)&param->srvinbuf);
param->nolongdatfilter = 1;
if(action == HANDLED){
RETURN(0);
@@ -991,7 +997,7 @@ for(;;){
if((param->chunked || contentlength64 > 0) && param->operation != HTTP_HEAD && res != 204 && res != 304) {
do {
if(param->chunked){
char smallbuf[32];
unsigned char smallbuf[32];
while ((i = sockgetlinebuf(param, SERVER, smallbuf, 30, '\n', conf.timeouts[STRING_S])) == 2) {
if (socksend(param->clisock, smallbuf, i, conf.timeouts[STRING_S]) != i){
RETURN(533);
@@ -1014,7 +1020,7 @@ for(;;){
}
smallbuf[i] = 0;
contentlength64 = 0;
sscanf(smallbuf, "%"PRINTF_INT64_MODIFIER"x", &contentlength64);
sscanf((char *)smallbuf, "%"PRINTF_INT64_MODIFIER"x", &contentlength64);
if(contentlength64 == 0) {
param->chunked = 2;
}
@@ -1047,7 +1053,7 @@ REQUESTEND:
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;
}
@@ -1072,7 +1078,7 @@ CLEANRET:
else if(param->res >=30 && param->res < 80) {
socksend(param->clisock, (unsigned char *)proxy_stringtable[5], (int)strlen(proxy_stringtable[5]), conf.timeouts[STRING_S]);
}
else if(param->res == 1 || (param->srv->nouser && param->res < 10)) {
else if(param->res == 1 || (!param->srv->needuser && param->res < 10)) {
socksend(param->clisock, (unsigned char *)proxy_stringtable[11], (int)strlen(proxy_stringtable[11]), conf.timeouts[STRING_S]);
}
else if(param->res < 10) {
@@ -1094,7 +1100,7 @@ CLEANRET:
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(buf)myfree(buf);
if(ftpbase)myfree(ftpbase);
+3 -7
View File
@@ -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"\
"Please read license agreement in \'copying\' file.\n"\
"You may not use this program without accepting license agreement"
@@ -104,7 +104,7 @@
#define PTHREAD_STACK_MIN 32768
#define sockerror strerror
#endif
#define daemonize() daemon(1,1)
#define daemonize() {if(fork())exit(0); else setsid();}
#define SLEEPTIME 1000
#ifndef O_BINARY
#define O_BINARY 0
@@ -122,8 +122,6 @@
#ifdef _WIN32
#define strcasecmp stricmp
#define strncasecmp strnicmp
#else
extern pthread_attr_t pa;
#endif
#ifndef SOCKET_ERROR
@@ -235,7 +233,7 @@ void mschap(const unsigned char *win_password,
struct hashtable;
void hashadd(struct hashtable *ht, const unsigned char* name, unsigned char* value, time_t expires);
void parsehost(int family, char *host, struct sockaddr *sa);
void parsehost(int family, unsigned char *host, struct sockaddr *sa);
int parsehostname(char *hostname, struct clientparam *param, unsigned short port);
int parseusername(char *username, struct clientparam *param, int extpasswd);
int parseconnusername(char *username, struct clientparam *param, int extpasswd, unsigned short port);
@@ -316,8 +314,6 @@ extern pthread_mutex_t hash_mutex;
extern pthread_mutex_t tc_mutex;
extern pthread_mutex_t pwl_mutex;
extern pthread_mutex_t log_mutex;
extern int logmutexinit;
extern struct datatype datatypes[64];
extern struct commands commandhandlers[];
+111 -56
View File
@@ -8,6 +8,7 @@
#include "proxy.h"
pthread_mutex_t log_mutex;
#define param ((struct clientparam *) p)
#ifdef _WIN32
@@ -22,21 +23,21 @@ void * threadfunc (void *p) {
param->remsock = so._accept(param->srv->cbsock, (struct sockaddr*)&param->sinsr, &size);
if(param->remsock == INVALID_SOCKET) {
param->res = 13;
param->srv->logfunc(param, "Connect back accept() failed");
param->srv->logfunc(param, (unsigned char *)"Connect back accept() failed");
continue;
}
#ifndef WITHMAIN
memcpy(&param->req, &param->sinsr, size);
param->req = param->sinsr;
if(param->srv->acl) param->res = checkACL(param);
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);
param->remsock = INVALID_SOCKET;
continue;
}
#endif
if(so._sendto(param->remsock, "C", 1, 0, (struct sockaddr*)&param->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);
param->remsock = INVALID_SOCKET;
continue;
@@ -119,16 +120,18 @@ int MODULEMAINFUNC (int argc, char** argv){
" -d go to background (daemon)\n"
#else
" -u never ask for username\n"
" -u2 always ask for username\n"
#endif
" -fFORMAT logging format (see documentation)\n"
" -l log to stderr\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"
" -iIP ip address or internal interface (clients are expected to connect)\n"
" -eIP ip address or external interface (outgoing connection will have this)\n"
" -rIP:PORT Use IP:port for connect back proxy instead of listen port\n"
" -RPORT Use PORT to listen connect back proxy connection to pass data to\n"
" -rHOST:PORT Use IP:port for connect back proxy instead of listen port\n"
" -RHOST:PORT Use PORT to listen connect back proxy connection to pass data to\n"
" -4 Use IPv4 for outgoing connections\n"
" -6 Use IPv6 for outgoing connections\n"
" -46 Prefer IPv4 for outgoing connections, use both IPv4 and IPv6\n"
@@ -137,6 +140,7 @@ int MODULEMAINFUNC (int argc, char** argv){
#ifdef _WIN32
unsigned long ul = 1;
#else
pthread_attr_t pa;
#ifdef STDMAIN
int inetd = 0;
#endif
@@ -172,13 +176,9 @@ int MODULEMAINFUNC (int argc, char** argv){
#else
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
srvinit(&srv, &defparam);
srv.pf = childdef.pf;
isudp = childdef.isudp;
@@ -195,7 +195,8 @@ int MODULEMAINFUNC (int argc, char** argv){
conf.services = conf.services->prev = &srv;
}
#else
srv.nouser = 1;
srv.needuser = 0;
pthread_mutex_init(&log_mutex, NULL);
#endif
for (i=1; i<argc; i++) {
@@ -208,7 +209,7 @@ int MODULEMAINFUNC (int argc, char** argv){
case 'l':
srv.logfunc = logstdout;
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]=='@'){
@@ -231,16 +232,20 @@ int MODULEMAINFUNC (int argc, char** argv){
}
break;
case 'i':
getip46(46, argv[i]+2, (struct sockaddr *)&srv.intsa);
getip46(46, (unsigned char *)argv[i]+2, (struct sockaddr *)&srv.intsa);
break;
case 'e':
{
#ifndef NOIPV6
struct sockaddr_in6 sa6;
error = !getip46(46, argv[i]+2, (struct sockaddr *)&sa6);
if(!error) memcpy((*SAFAMILY(&sa6)==AF_INET)?(void *)&srv.extsa:(void *)&srv.extsa6, &sa6, SASIZE(&sa6));
memset(&sa6, 0, sizeof(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
error = !getip46(46, argv[i]+2, (struct sockaddr *)&srv.extsa);
error = !getip46(46, (unsigned char *)argv[i]+2, (struct sockaddr *)&srv.extsa);
#endif
}
break;
@@ -262,7 +267,7 @@ int MODULEMAINFUNC (int argc, char** argv){
case 'I':
size = sizeof(defparam.sincl);
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;
break;
@@ -270,7 +275,7 @@ int MODULEMAINFUNC (int argc, char** argv){
#endif
case 'f':
if(srv.logformat)myfree(srv.logformat);
srv.logformat = mystrdup((unsigned char *)argv[i] + 2);
srv.logformat = (unsigned char *)mystrdup(argv[i] + 2);
break;
case 't':
srv.silent = 1;
@@ -279,19 +284,23 @@ int MODULEMAINFUNC (int argc, char** argv){
hostname = argv[i] + 2;
break;
case 'r':
cbc_string = mystrdup(argv[i] + 2);
cbc_string = (unsigned char *)mystrdup(argv[i] + 2);
iscbc = 1;
break;
case 'R':
cbl_string = mystrdup(argv[i] + 2);
cbl_string = (unsigned char *)mystrdup(argv[i] + 2);
iscbl = 1;
break;
case 'u':
srv.nouser = 1;
srv.needuser = 0;
if(*(argv[i] + 2)) srv.needuser = atoi(argv[i] + 2);
break;
case 'T':
srv.transparent = 1;
break;
case 'S':
srv.stacksize = atoi(argv[i]+2);
break;
case 's':
case 'a':
srv.singlepacket = 1 + atoi(argv[i]+2);
@@ -383,7 +392,7 @@ int MODULEMAINFUNC (int argc, char** argv){
if(! (newparam = myalloc (sizeof(defparam)))){
return 2;
};
memcpy(newparam, &defparam, sizeof(defparam));
*newparam = defparam;
return((*srv.pf)((void *)newparam)? 1:0);
}
@@ -435,14 +444,14 @@ int MODULEMAINFUNC (int argc, char** argv){
#endif
srv.srvsock = sock;
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
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
}
size = sizeof(srv.intsa);
for(sleeptime = SLEEPTIME * 100; so._bind(sock, (struct sockaddr*)&srv.intsa, size)==-1; usleep(sleeptime)) {
for(sleeptime = SLEEPTIME * 100; so._bind(sock, (struct sockaddr*)&srv.intsa, SASIZE(&srv.intsa))==-1; usleep(sleeptime)) {
sprintf((char *)buf, "bind(): %s", strerror(errno));
if(!srv.silent)(*srv.logfunc)(&defparam, buf);
sleeptime = (sleeptime<<1);
@@ -469,22 +478,22 @@ int MODULEMAINFUNC (int argc, char** argv){
if(iscbl){
parsehost(srv.family, cbl_string, (struct sockaddr *)&cbsa);
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;
}
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
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
if(so._bind(srv.cbsock, (struct sockaddr*)&cbsa, sizeof(cbsa))==-1) {
(*srv.logfunc)(&defparam, "Failed to bind connect back socket");
if(so._bind(srv.cbsock, (struct sockaddr*)&cbsa, SASIZE(&cbsa))==-1) {
(*srv.logfunc)(&defparam, (unsigned char *)"Failed to bind connect back socket");
return -7;
}
if(so._listen(srv.cbsock, 1 + (srv.maxchild>>4))==-1) {
(*srv.logfunc)(&defparam, "Failed to listen connect back socket");
(*srv.logfunc)(&defparam, (unsigned char *)"Failed to listen connect back socket");
return -8;
}
}
@@ -492,14 +501,19 @@ int MODULEMAINFUNC (int argc, char** argv){
srv.fds.fd = sock;
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(;;){
while((conf.paused == srv.version && srv.childcount >= srv.maxchild)){
nlog++;
if(nlog > 5000) {
if(!srv.silent && nlog > 5000) {
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;
}
usleep(SLEEPTIME);
@@ -522,19 +536,20 @@ int MODULEMAINFUNC (int argc, char** argv){
}
}
if((conf.paused != srv.version) || (error < 0)) break;
error = 0;
if(!isudp){
size = sizeof(defparam.sincr);
if(iscbc){
new_sock=so._socket(SASOCK(&defparam.sincr), SOCK_STREAM, IPPROTO_TCP);
if(new_sock != INVALID_SOCKET){
parsehost(srv.family, cbc_string, (struct sockaddr *)&defparam.sincr);
if(so._connect(new_sock,(struct sockaddr *)&defparam.sincr,sizeof(defparam.sincr))) {
if(so._connect(new_sock,(struct sockaddr *)&defparam.sincr,SASIZE(&defparam.sincr))) {
so._closesocket(new_sock);
new_sock = INVALID_SOCKET;
usleep(SLEEPTIME);
continue;
}
if(so._recvfrom(new_sock,buf,1,0,(struct sockaddr*)&defparam.sincr, &size) != 1) {
if(so._recvfrom(new_sock,(char *)buf,1,0,(struct sockaddr*)&defparam.sincr, &size) != 1) {
so._closesocket(new_sock);
new_sock = INVALID_SOCKET;
usleep(SLEEPTIME);
@@ -549,8 +564,47 @@ int MODULEMAINFUNC (int argc, char** argv){
else {
new_sock = so._accept(sock, (struct sockaddr*)&defparam.sincr, &size);
if(new_sock == INVALID_SOCKET){
sprintf((char *)buf, "accept(): %s", strerror(errno));
if(!srv.silent)(*srv.logfunc)(&defparam, buf);
#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));
(*srv.logfunc)(&defparam, buf);
nlog = 0;
}
continue;
}
}
@@ -565,8 +619,8 @@ int MODULEMAINFUNC (int argc, char** argv){
#else
fcntl(new_sock,F_SETFL,O_NONBLOCK);
#endif
so._setsockopt(new_sock, SOL_SOCKET, SO_LINGER, (unsigned char *)&lg, sizeof(lg));
so._setsockopt(new_sock, SOL_SOCKET, SO_OOBINLINE, (unsigned char *)&opt, sizeof(int));
so._setsockopt(new_sock, SOL_SOCKET, SO_LINGER, (char *)&lg, sizeof(lg));
so._setsockopt(new_sock, SOL_SOCKET, SO_OOBINLINE, (char *)&opt, sizeof(int));
}
else {
srv.fds.events = 0;
@@ -578,8 +632,8 @@ int MODULEMAINFUNC (int argc, char** argv){
usleep(SLEEPTIME);
continue;
};
memcpy(newparam, &defparam, sizeof(defparam));
if(defparam.hostname)newparam->hostname=strdup(defparam.hostname);
*newparam = defparam;
if(defparam.hostname)newparam->hostname=(unsigned char *)strdup((char *)defparam.hostname);
clearstat(newparam);
if(!isudp) newparam->clisock = new_sock;
#ifndef STDMAIN
@@ -599,9 +653,9 @@ int MODULEMAINFUNC (int argc, char** argv){
}
#ifdef _WIN32
#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
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
srv.childcount++;
if (h) {
@@ -659,28 +713,30 @@ void srvinit(struct srvparam * srv, struct clientparam *param){
srv->version = conf.paused;
srv->logfunc = conf.logfunc;
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->usentlm = 0;
srv->maxchild = conf.maxchild;
srv->stacksize = conf.stacksize;
srv->time_start = time(NULL);
if(conf.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->logdumpsrv = conf.logdumpsrv;
srv->logdumpcli = conf.logdumpcli;
srv->cbsock = INVALID_SOCKET;
srv->needuser = 1;
memset(param, 0, sizeof(struct clientparam));
param->srv = srv;
param->remsock = param->clisock = param->ctrlsock = param->ctrlsocksrv = INVALID_SOCKET;
*SAFAMILY(&param->req) = *SAFAMILY(&param->sinsl) = *SAFAMILY(&param->sinsr) = *SAFAMILY(&param->sincr) = *SAFAMILY(&param->sincl) = AF_INET;
pthread_mutex_init(&srv->counter_mutex, NULL);
memcpy(&srv->intsa, &conf.intsa, sizeof(srv->intsa));
memcpy(&srv->extsa, &conf.extsa, sizeof(srv->extsa));
srv->intsa = conf.intsa;
srv->extsa = conf.extsa;
#ifndef NOIPV6
memcpy(&srv->extsa6, &conf.extsa6, sizeof(srv->extsa6));
srv->extsa6 = conf.extsa6;
#endif
}
@@ -688,7 +744,7 @@ void srvinit2(struct srvparam * srv, struct clientparam *param){
if(srv->logformat){
char *s;
if(*srv->logformat == '-' && (s = strchr((char *)srv->logformat + 1, '+')) && s[1]){
char* logformat = srv->logformat;
unsigned char* logformat = srv->logformat;
*s = 0;
srv->nonprintable = (unsigned char *)mystrdup((char *)srv->logformat + 1);
@@ -704,13 +760,12 @@ void srvinit2(struct srvparam * srv, struct clientparam *param){
*SAFAMILY(&param->sinsl) = AF_INET;
*SAFAMILY(&param->sinsr) = AF_INET;
*SAFAMILY(&param->req) = AF_INET;
memcpy(&param->sincr, &srv->intsa, sizeof(param->sincr));
memcpy(&param->sincl, &srv->intsa, sizeof(param->sincl));
param->sincr = param->sincl = srv->intsa;
#ifndef NOIPV6
memcpy(&param->sinsr, (srv->family == 6 || srv->family == 64)? (void *)&srv->extsa6: (void *)&srv->extsa, sizeof(param->sinsl));
#else
memcpy(&param->sinsr, &srv->extsa, sizeof(param->sinsl));
if (srv->family == 6 || srv->family == 64) param->sinsr = srv->extsa6;
else
#endif
param->sinsr = srv->extsa;
}
void srvfree(struct srvparam * srv){
@@ -867,7 +922,7 @@ void copyfilter (struct filter *filter, struct srvparam *srv){
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;
if(srv->nfilters>0)srv->filter[srv->nfilters - 1].next = srv->filter + srv->nfilters;
srv->nfilters++;
+30 -30
View File
@@ -37,7 +37,7 @@ int readreply (struct clientparam* param) {
return 0;
}
buf[i] = 0;
res = atoi(buf);
res = atoi((char *)buf);
myfree(buf);
return res;
}
@@ -51,7 +51,7 @@ int readcommand (struct clientparam* param) {
i = sockgetlinebuf(param, CLIENT, buf, bufsize-1, '\n', conf.timeouts[STRING_L]);
if(i < 4) return 0;
#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);
if(res != PASS) {
myfree(buf);
@@ -62,7 +62,7 @@ int readcommand (struct clientparam* param) {
#endif
socksend(param->remsock, buf, i, conf.timeouts[STRING_S]);
myfree(buf);
if(!strncasecmp(buf, "STARTTLS", 8) || !strncasecmp(buf, "TURN", 4)){
if(!strncasecmp((char *)buf, "STARTTLS", 8) || !strncasecmp((char *)buf, "TURN", 4)){
ret = 22;
}
return ret;
@@ -118,22 +118,22 @@ void * smtppchild(struct clientparam* param) {
else {
login = -1;
buf[i] = 0;
command = mystrdup(buf);
command = mystrdup((char *)buf);
break;
}
i = sockgetlinebuf(param, CLIENT, buf, sizeof(buf) - 10, '\n', conf.timeouts[STRING_S]);
}
if(!login) {RETURN(662);}
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]);
if(i < 3) {RETURN(663);}
buf[i-2] = 0;
i = de64(buf,username,255);
if(i < 1) {RETURN(664);}
username[i] = 0;
parseconnusername(username, param, 0, 25);
socksend(param->clisock, "334 UGFzc3dvcmQ6\r\n", 18,conf.timeouts[STRING_S]);
parseconnusername((char *)username, param, 0, 25);
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]);
if(i < 2) {RETURN(665);}
buf[i-2] = 0;
@@ -141,7 +141,7 @@ void * smtppchild(struct clientparam* param) {
if(i < 0) {RETURN(666);}
username[i] = 0;
if(param->extpassword) myfree(param->extpassword);
param->extpassword = mystrdup(username);
param->extpassword = (unsigned char *)mystrdup((char *)username);
}
else if(login == 2){
if(i > 13) {
@@ -149,7 +149,7 @@ void * smtppchild(struct clientparam* param) {
i = de64(buf+11,username,255);
}
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]);
if(i < 3) {RETURN(667);}
buf[i-2] = 0;
@@ -157,18 +157,18 @@ void * smtppchild(struct clientparam* param) {
}
if(i < 3 || *username) {RETURN(668);}
username[i] = 0;
parseconnusername(username+1, param, 0, 25);
res = (int)strlen(username+1) + 2;
parseconnusername((char *)username+1, param, 0, 25);
res = (int)strlen((char *)username+1) + 2;
if(res < i){
if(param->extpassword) myfree(param->extpassword);
param->extpassword = mystrdup(username + res);
param->extpassword = (unsigned char *)mystrdup((char *)username + res);
}
}
#ifndef WITHMAIN
{
int action, reqbufsize, reqsize;
reqbufsize = reqsize = (int)strlen(param->hostname) + 1;
reqbufsize = reqsize = (int)strlen((char *)param->hostname) + 1;
action = handlereqfilters(param, &param->hostname, &reqbufsize, 0, &reqsize);
if(action == HANDLED){
RETURN(0);
@@ -186,9 +186,9 @@ void * smtppchild(struct clientparam* param) {
if( i < 3 ) {RETURN(671);}
buf[i] = 0;
if(strncasecmp((char *)buf, "220", 3)||!strncasecmp((char *)buf+4, "PROXY", 5)){RETURN(672);}
i = sprintf(buf, "EHLO [");
i += myinet_ntop(*SAFAMILY(&param->sinsl), SAADDR(&param->sinsl), buf+strlen(buf), 64);
i += sprintf(buf+strlen(buf), "]\r\n");
i = sprintf((char *)buf, "EHLO [");
i += myinet_ntop(*SAFAMILY(&param->sinsl), SAADDR(&param->sinsl), (char *)buf+strlen((char *)buf), 64);
i += sprintf((char *)buf+strlen((char *)buf), "]\r\n");
if(socksend(param->remsock, buf, i, conf.timeouts[STRING_S])!= i) {RETURN(673);}
param->statscli64+=i;
param->nwrites++;
@@ -204,44 +204,44 @@ void * smtppchild(struct clientparam* param) {
if(i<3) {RETURN(672);}
if(!command || (param->extusername && param->extpassword)){
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)) {
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->nwrites++;
i = sockgetlinebuf(param, SERVER, buf, sizeof(buf) - 1, '\n', conf.timeouts[STRING_L]);
if(i<4 || strncasecmp((char *)buf, "334", 3)) {RETURN(680);}
en64(param->extusername, buf, (int)strlen(param->extusername));
socksend(param->remsock, buf, (int)strlen(buf), conf.timeouts[STRING_S]);
socksend(param->remsock, "\r\n", 2, conf.timeouts[STRING_S]);
en64(param->extusername, buf, (int)strlen((char *)param->extusername));
socksend(param->remsock, buf, (int)strlen((char *)buf), conf.timeouts[STRING_S]);
socksend(param->remsock, (unsigned char *)"\r\n", 2, conf.timeouts[STRING_S]);
param->statscli64+=(i+2);
param->nwrites+=2;
i = sockgetlinebuf(param, SERVER, buf, sizeof(buf) - 1, '\n', conf.timeouts[STRING_L]);
if(i<4 || strncasecmp((char *)buf, "334", 3)) {RETURN(681);}
en64(param->extpassword, buf, (int)strlen(param->extpassword));
socksend(param->remsock, buf, (int)strlen(buf), conf.timeouts[STRING_S]);
socksend(param->remsock, "\r\n", 2, conf.timeouts[STRING_S]);
en64(param->extpassword, buf, (int)strlen((char *)param->extpassword));
socksend(param->remsock, buf, (int)strlen((char *)buf), conf.timeouts[STRING_S]);
socksend(param->remsock, (unsigned char *)"\r\n", 2, conf.timeouts[STRING_S]);
param->statscli64+=(i+2);
param->nwrites+=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->nwrites++;
i = sockgetlinebuf(param, SERVER, buf, sizeof(buf) - 1, '\n', conf.timeouts[STRING_L]);
if(i<4 || strncasecmp((char *)buf, "334", 3)) {RETURN(682);}
*username = 0;
i = (int)strlen(param->extusername) + 1;
i = (int)strlen((char *)param->extusername) + 1;
memcpy(username+1, param->extusername, i);
i++;
res = (int)strlen(param->extpassword);
res = (int)strlen((char *)param->extpassword);
memcpy(username + i, param->extpassword, res);
i+=res;
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, "\r\n", 2, conf.timeouts[STRING_S]);
socksend(param->remsock, (unsigned char *)"\r\n", 2, conf.timeouts[STRING_S]);
param->statscli64+=(i+2);
param->nwrites+=2;
}
@@ -266,7 +266,7 @@ void * smtppchild(struct clientparam* param) {
}
#endif
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
+3 -3
View File
@@ -22,7 +22,7 @@ int socksend(SOCKET sock, unsigned char * buf, int bufsize, int to){
res = so._poll(&fds, 1, to*1000);
if(res < 0 && (errno == EAGAIN || errno == EINTR)) continue;
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(errno == EAGAIN || errno == EINTR) continue;
break;
@@ -45,7 +45,7 @@ int socksendto(SOCKET sock, struct sockaddr * sin, unsigned char * buf, int bufs
res = so._poll(&fds, 1, to);
if(res < 0 && (errno == EAGAIN || errno == EINTR)) continue;
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(errno != EAGAIN && errno != EINTR) break;
continue;
@@ -66,7 +66,7 @@ int sockrecvfrom(SOCKET sock, struct sockaddr * sin, unsigned char * buf, int bu
if (so._poll(&fds, 1, to)<1) return 0;
sasize = SASIZE(sin);
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));
return res;
}
+8 -8
View File
@@ -49,14 +49,14 @@ int sockmap(struct clientparam * param, int timeo){
if(action != PASS) return 19;
if(!param->nolongdatfilter){
if(param->cliinbuf > param->clioffset){
action = handledatfltcli(param, &param->clibuf, &param->clibufsize, param->clioffset, &param->cliinbuf);
action = handledatfltcli(param, &param->clibuf, (int *)&param->clibufsize, param->clioffset, (int *)&param->cliinbuf);
if(action == HANDLED){
return 0;
}
if(action != PASS) return 19;
}
if(param->srvinbuf > param->srvoffset){
action = handledatfltsrv(param, &param->srvbuf, &param->srvbufsize, param->srvoffset, &param->srvinbuf);
action = handledatfltsrv(param, &param->srvbuf, (int *)&param->srvbufsize, param->srvoffset, (int *)&param->srvinbuf);
if(action == HANDLED){
return 0;
}
@@ -127,7 +127,7 @@ int sockmap(struct clientparam * param, int timeo){
if(param->bandlimfunc) {
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*)&param->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*)&param->sincr, sasize);
if(res < 0) {
if(errno != EAGAIN && errno != EINTR) return 96;
if(errno == EINTR) usleep(SLEEPTIME);
@@ -153,7 +153,7 @@ int sockmap(struct clientparam * param, int timeo){
sl1 = (*param->bandlimfunc)(param, 0, param->cliinbuf - param->clioffset);
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*)&param->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*)&param->sinsr, sasize);
if(res < 0) {
if(errno != EAGAIN && errno != EINTR) return 97;
if(errno == EINTR) usleep(SLEEPTIME);
@@ -172,7 +172,7 @@ int sockmap(struct clientparam * param, int timeo){
#if DEBUGLEVEL > 2
(*param->srv->logfunc)(param, "recv from client");
#endif
res = so._recvfrom(param->clisock, param->clibuf + param->cliinbuf, param->clibufsize - param->cliinbuf, 0, (struct sockaddr *)&param->sincr, &sasize);
res = so._recvfrom(param->clisock, (char *)param->clibuf + param->cliinbuf, param->clibufsize - param->cliinbuf, 0, (struct sockaddr *)&param->sincr, &sasize);
if (res==0) {
so._shutdown(param->clisock, SHUT_RDWR);
so._closesocket(param->clisock);
@@ -187,7 +187,7 @@ int sockmap(struct clientparam * param, int timeo){
}
param->cliinbuf += res;
if(!param->nolongdatfilter){
action = handledatfltcli(param, &param->clibuf, &param->clibufsize, param->cliinbuf - res, &param->cliinbuf);
action = handledatfltcli(param, &param->clibuf, (int *)&param->clibufsize, param->cliinbuf - res, (int *)&param->cliinbuf);
if(action == HANDLED){
return 0;
}
@@ -203,7 +203,7 @@ int sockmap(struct clientparam * param, int timeo){
#endif
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) {
so._shutdown(param->remsock, SHUT_RDWR);
so._closesocket(param->remsock);
@@ -220,7 +220,7 @@ int sockmap(struct clientparam * param, int timeo){
param->nreads++;
param->statssrv64 += res;
if(!param->nolongdatfilter){
action = handledatfltsrv(param, &param->srvbuf, &param->srvbufsize, param->srvinbuf - res, &param->srvinbuf);
action = handledatfltsrv(param, &param->srvbuf, (int *)&param->srvbufsize, param->srvinbuf - res, (int *)&param->srvinbuf);
if(action == HANDLED){
return 0;
}
+27 -12
View File
@@ -48,13 +48,14 @@ void * sockschild(struct clientparam* param) {
if ((i = sockgetcharcli(param, conf.timeouts[SINGLEBYTE_S], 0)) == EOF) {RETURN(441);} /* nmethods */
for (; i; i--) {
if ((res = sockgetcharcli(param, conf.timeouts[SINGLEBYTE_S], 0)) == EOF) {RETURN(441);}
if (res == 2 && !param->srv->nouser) {
if (res == 2 && param->srv->needuser) {
havepass = res;
}
}
buf[0] = 5;
buf[1] = havepass;
buf[1] = (param->srv->needuser > 1 && !havepass)? 255 : havepass;
if(socksend(param->clisock, buf, 2, conf.timeouts[STRING_S])!=2){RETURN(401);}
if (param->srv->needuser > 1 && !havepass) RETURN(4);
if (havepass) {
if (((res = sockgetcharcli(param, conf.timeouts[SINGLEBYTE_L], 0))) != 1) {
RETURN(412);
@@ -132,7 +133,7 @@ void * sockschild(struct clientparam* param) {
}
buf[i] = 0;
if(!getip46(param->srv->family, buf, (struct sockaddr *) &param->req)) RETURN(100);
memcpy(&param->sinsr, &param->req, sizeof(param->req));
param->sinsr = param->req;
break;
default:
RETURN(997);
@@ -150,7 +151,7 @@ void * sockschild(struct clientparam* param) {
else {
sockgetlinebuf(param, CLIENT, buf, BUFSIZE - 1, 0, conf.timeouts[STRING_S]);
buf[127] = 0;
if(!param->srv->nouser && *buf && !param->username)param->username = (unsigned char *)mystrdup((char *)buf);
if(param->srv->needuser && *buf && !param->username)param->username = (unsigned char *)mystrdup((char *)buf);
if(!memcmp(SAADDR(&param->req), "\0\0\0", 3)){
param->service = S_SOCKS45;
sockgetlinebuf(param, CLIENT, buf, BUFSIZE - 1, 0, conf.timeouts[STRING_S]);
@@ -158,7 +159,7 @@ void * sockschild(struct clientparam* param) {
if(param->hostname)myfree(param->hostname);
param->hostname = (unsigned char *)mystrdup((char *)buf);
if(!getip46(param->srv->family, buf, (struct sockaddr *) &param->req)) RETURN(100);
memcpy(&param->sinsr, &param->req, sizeof(&param->req));
param->sinsr = param->req;
}
}
@@ -172,12 +173,26 @@ void * sockschild(struct clientparam* param) {
case 3:
#ifndef NOIPV6
memcpy(&param->sinsl, *SAFAMILY(&param->req)==AF_INET6? (struct sockaddr *)&param->srv->extsa6:(struct sockaddr *)&param->srv->extsa, SASIZE(&param->req));
param->sinsl = *SAFAMILY(&param->req)==AF_INET6? param->srv->extsa6 : param->srv->extsa;
#else
memcpy(&param->sinsl, &param->srv->extsa, SASIZE(&param->req));
param->sinsl = param->srv->extsa;
#endif
if ((param->remsock=so._socket(SASOCK(&param->req), command == 2? SOCK_STREAM:SOCK_DGRAM, command == 2?IPPROTO_TCP:IPPROTO_UDP)) == INVALID_SOCKET) {RETURN (11);}
param->operation = command == 2?BIND:UDPASSOC;
#ifdef REUSE
if (command == 2){
int opt;
#ifdef SO_REUSEADDR
opt = 1;
so._setsockopt(param->remsock, SOL_SOCKET, SO_REUSEADDR, (unsigned char *)&opt, sizeof(int));
#endif
#ifdef SO_REUSEPORT
opt = 1;
so._setsockopt(param->remsock, SOL_SOCKET, SO_REUSEPORT, (unsigned char *)&opt, sizeof(int));
#endif
}
#endif
break;
default:
@@ -203,9 +218,9 @@ fflush(stderr);
param->ctrlsock = param->clisock;
param->clisock = so._socket(SASOCK(&param->sincr), SOCK_DGRAM, IPPROTO_UDP);
if(param->clisock == INVALID_SOCKET) {RETURN(11);}
memcpy(&sin, &param->sincl, sizeof(&sin));
sin = param->sincl;
*SAPORT(&sin) = 0;
if(so._bind(param->clisock,(struct sockaddr *)&sin,sizeof(sin))) {RETURN (12);}
if(so._bind(param->clisock,(struct sockaddr *)&sin,SASIZE(&sin))) {RETURN (12);}
#if SOCKSTRACE > 0
fprintf(stderr, "%hu binded to communicate with client\n",
ntohs(*SAPORT(&sin))
@@ -313,7 +328,7 @@ fflush(stderr);
param->res = sockmap(param, conf.timeouts[CONNECTION_S]);
break;
case 3:
memcpy(&param->sinsr, &param->req, sizeof(param->sinsr));
param->sinsr = param->req;
myfree(buf);
if(!(buf = myalloc(LARGEBUFSIZE))) {RETURN(21);}
@@ -334,7 +349,7 @@ fflush(stderr);
}
if (fds[1].revents) {
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;
break;
}
@@ -398,7 +413,7 @@ fflush(stderr);
sasize = sizeof(param->sinsr);
buf[0]=buf[1]=buf[2]=0;
buf[3]=(*SAFAMILY(&param->sinsl) == AF_INET)?1:4;
if((len = so._recvfrom(param->remsock, buf+6+SAADDRLEN(&param->sinsl), 65535 - 10, 0, (struct sockaddr *)&param->sinsr, &sasize)) <= 0) {
if((len = so._recvfrom(param->remsock, (char *)buf+6+SAADDRLEN(&param->sinsl), 65535 - 10, 0, (struct sockaddr *)&param->sinsr, &sasize)) <= 0) {
param->res = 468;
break;
}
+14 -11
View File
@@ -217,6 +217,7 @@ typedef enum {
R_SOCKS5,
R_HTTP,
R_POP3,
R_SMTP,
R_FTP,
R_CONNECTP,
R_SOCKS4P,
@@ -225,7 +226,7 @@ typedef enum {
R_SOCKS5B,
R_ADMIN,
R_ICQ,
R_MSN
R_EXTIP
} REDIRTYPE;
struct chain {
@@ -366,11 +367,12 @@ struct srvparam {
int version;
int singlepacket;
int usentlm;
int nouser;
int needuser;
int silent;
int transparent;
int nfilters, nreqfilters, nhdrfilterscli, nhdrfilterssrv, npredatfilters, ndatfilterscli, ndatfilterssrv;
int family;
int stacksize;
unsigned bufsize;
unsigned logdumpsrv, logdumpcli;
#ifndef NOIPV6
@@ -421,6 +423,9 @@ struct clientparam {
REDIRTYPE redirtype;
uint64_t waitclient64,
waitserver64;
int redirected,
operation,
nfilters, nreqfilters, nhdrfilterscli, nhdrfilterssrv, npredatfilters, ndatfilterscli, ndatfilterssrv,
@@ -428,8 +433,6 @@ struct clientparam {
int res,
status;
uint64_t waitclient64,
waitserver64;
int pwtype,
threadid,
weight,
@@ -490,7 +493,7 @@ struct extparam {
struct bandlim * bandlimiter, *bandlimiterout;
struct trafcount * trafcounter;
struct srvparam *services;
int threadinit, counterd, haveerror, rotate, paused, archiverc,
int stacksize, threadinit, counterd, haveerror, rotate, paused, archiverc,
demon, maxchild, singlepacket, needreload, timetoexit;
int authcachetype, authcachetime;
int filtermaxsize;
@@ -610,13 +613,13 @@ struct sockfuncs {
int (WINAPI *_connect)(SOCKET s, const 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 *_getsockopt)(SOCKET s, int level, int optname, void * optval, int * optlen);
int (WINAPI *_setsockopt)(SOCKET s, int level, int optname, const 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 char *optval, int optlen);
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 *_sendto)(SOCKET s, const void *msg, int len, int flags, const struct sockaddr *to, int tolen);
int (WINAPI *_recv)(SOCKET s, void *buf, int len, int flags);
int (WINAPI *_recvfrom)(SOCKET s, void * buf, int len, int flags, struct sockaddr * from, int * fromlen);
int (WINAPI *_send)(SOCKET s, const char *msg, int len, int flags);
int (WINAPI *_sendto)(SOCKET s, const char *msg, int len, int flags, const struct sockaddr *to, int tolen);
int (WINAPI *_recv)(SOCKET s, char *buf, int len, int flags);
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 *_closesocket)(SOCKET s);
#else
+3 -3
View File
@@ -59,11 +59,11 @@ void * udppmchild(struct clientparam* param) {
if((param->clisock=so._socket(SASOCK(&param->sincr), SOCK_DGRAM, IPPROTO_UDP)) == INVALID_SOCKET) {
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);
size = sizeof(param->sinsl);
if(so._getsockname(param->srv->srvsock, (struct sockaddr *)&param->sinsl, &size)) {RETURN(21);};
if(so._bind(param->clisock,(struct sockaddr *)&param->sinsl,sizeof(struct sockaddr_in))) {
if(so._bind(param->clisock,(struct sockaddr *)&param->sinsl,SASIZE(&param->sinsl))) {
RETURN(822);
}
#else
@@ -77,7 +77,7 @@ void * udppmchild(struct clientparam* param) {
#endif
*SAPORT(&param->sinsl) = 0;
if ((param->remsock=so._socket(SASOCK(&param->sinsl), SOCK_DGRAM, IPPROTO_UDP)) == INVALID_SOCKET) {RETURN (11);}
if(so._bind(param->remsock,(struct sockaddr *)&param->sinsl,sizeof(param->sinsl))) {RETURN (12);}
if(so._bind(param->remsock,(struct sockaddr *)&param->sinsl,SASIZE(&param->sinsl))) {RETURN (12);}
#ifdef _WIN32
ioctlsocket(param->remsock, FIONBIO, &ul);
#else
+2 -2
View File
@@ -1,2 +1,2 @@
#define VERSION "3proxy-0.8b-devel"
#define BUILDDATE "160107200335"
#define VERSION "3proxy-0.8.6"
#define BUILDDATE "160307165135"
+1 -1
View File
@@ -473,7 +473,7 @@ void * adminchild(struct clientparam* param) {
"<td>MB%s</td>"
"<td>%"PRINTF_INT64_MODIFIER"u</td>"
"<td>%s</td>",
cp->traflim64,
cp->traflim64 / (1024 * 1024),
rotations[cp->type],
cp->traf64,
cp->cleared?ctime(&cp->cleared):"never"