Compare commits

...
94 Commits
Author SHA1 Message Date
z3APA3A e85b064b52 Commit as 0.8.13 2019-08-01 17:54:28 +03:00
z3APA3A 9f6c0b5b8d Fix: $ is ignored in the begginning of quoted line 2019-08-01 16:54:40 +03:00
z3APA3A 3b67dc8447 Fix: out-of-bounds write and few more bugs in 'admin' configuration upload 2019-08-01 16:49:26 +03:00
z3APA3A d07500687c Commit as 0.8.12 2018-04-18 22:48:45 +03:00
z3APA3A 439373abd3 Example corrected 2018-04-18 19:36:05 +03:00
z3APA3A 8afad700f8 force / noforce commands description added 2018-04-18 19:33:31 +03:00
z3APA3A a8b79d5df5 add hostname logging to tcppm 2018-04-18 19:28:37 +03:00
z3APA3A 10a8febb0d Fix IPv4/IPv6 addresses in webadmin 2018-04-18 19:27:14 +03:00
z3APA3A 747828d3ab Move sys/timeb.h to Win32 section. 2018-04-18 19:26:27 +03:00
z3APA3A 9b8e6b33c7 UDP portmap doesn't resolve hostname in UDP packet 2018-04-18 19:23:34 +03:00
z3APA3A 05b23a840e resolving conflicts 2018-04-18 19:23:07 +03:00
z3APA3A 5c9bb58a81 Clearing LdapPlugin compilation issues 2018-04-18 19:22:43 +03:00
z3APA3A f8557187cd Conflic resolve 2018-04-18 19:19:05 +03:00
z3APA3A 23623a22ff -fno-strict-aliasing added to gcc options 2018-04-18 19:18:02 +03:00
z3APA3A 215171ad46 Publish as 0.8.11 2017-10-19 18:08:41 +03:00
z3APA3A c20a04b752 change strdup to mystrdup 2017-10-19 17:54:31 +03:00
z3APA3A 3f859fdb11 Change log location in demo scripts 2017-10-19 17:53:32 +03:00
z3APA3A 556681a829 Change EPSV reply code to 229 2017-10-19 17:49:27 +03:00
z3APA3A ee0bb55c06 EPSV support for ftppr 2017-10-19 17:49:03 +03:00
z3APA3A 2c0bc19f75 Remove static to prevent race conditions 2017-10-19 17:38:28 +03:00
z3APA3A 286aa51e78 Fix: recursion detection was not working 2017-10-19 17:31:30 +03:00
z3APA3A 145eb580e4 Fix: %n terminated log string on IPv6 address 2017-10-19 17:31:12 +03:00
z3APA3A 46211c26d2 Prevent deadlock on thread creation error 2017-10-19 17:30:47 +03:00
z3APA3A e0262c23b0 pthread_attr_destroy added to prevent memory leak on config reload 2017-10-19 17:30:22 +03:00
z3APA3A 7f80f4f958 Fix: invalid reverse check for dnsresolve 2017-10-19 17:29:30 +03:00
z3APA3A 6a54b37181 fix: do not fail external with "0.0.0.0" with NOIPV6 (lite version) 2017-10-19 17:28:42 +03:00
z3APA3A c0bb608acc publish as 0.8.10 2017-06-25 19:12:56 +03:00
z3APA3A 4631335aca Fix - sometime request may go to parent proxy where it shouldn't 2017-06-25 18:42:39 +03:00
z3APA3A 94c58b3db4 banlimits for old connection may stop functioning on configuration reload 2017-06-25 18:42:17 +03:00
z3APA3A d75dcf0b54 Publish as 0.8.9 2017-02-02 01:19:10 +03:00
z3APA3A 28581b1738 FIX: tcppm may not work with parent proxy 2017-02-02 01:08:29 +03:00
z3APA3A d3395cf649 Commit as 0.8.8 2016-12-13 01:19:55 +03:00
z3APA3A 7b48714993 Merge remote-tracking branch 'refs/remotes/origin/devel' 2016-12-13 01:15:09 +03:00
z3APA3A 945c30c5ee Use pragma aux to export valid names from DLL in Watcom 2016-12-12 19:49:58 +03:00
z3APA3A a9fb0ea969 Correct previous resolver patch 2016-12-12 12:38:33 +03:00
z3APA3A afbc27eac4 Correct resolver to handle non-compressed answers 2016-12-11 03:25:18 +03:00
z3APA3A 953c7efafc Merge branch 'devel' of https://github.com/z3APA3A/3proxy into devel 2016-12-10 03:56:20 +03:00
z3APA3A c650d32206 Compatibility with Watcom's DLL exports for plugins 2016-12-10 03:56:11 +03:00
Vladimir Dubrovin 88af9d6050 handle IPv6/name bind reply from parent 2016-11-20 22:24:04 +03:00
Vladimir Dubrovin 9c8e18f0b5 Merge pull request #99 from alexndlm/patch-1
Update Makefile.Linux
2016-09-21 22:20:34 +04:00
alexndlm 0f695a4248 Update Makefile.Linux 2016-09-19 23:37:04 +03:00
z3APA3A 88263ebde9 Return valid error code for name resolution problem in 'proxy' 2016-09-07 18:50:21 +03:00
z3APA3A a8f8a4d624 'if' is not required 2016-09-07 18:35:01 +03:00
z3APA3A 0b2afa1ba7 switch to 0.8.7 2016-09-04 16:30:40 +03:00
z3APA3A 80b9e18588 Commit as 0.8.7 2016-09-04 16:19:53 +03:00
z3APA3A 63bafa5a62 Merge remote-tracking branch 'refs/remotes/origin/devel'
# Conflicts:
#	src/version.h
2016-09-04 16:16:29 +03:00
z3APA3A fd29e887c3 add optimization to watcom makefile 2016-09-04 15:49:04 +03:00
z3APA3A ec9d556707 Add makefile for OpenWatcom 2.0 2016-09-04 15:33:38 +03:00
z3APA3A 9890823664 fix signess warning 2016-09-04 15:33:20 +03:00
z3APA3A 880255093a minor compilers compatibility issues 2016-09-04 15:11:15 +03:00
z3APA3A 4e96a66093 fix authentication via reverse name 2016-09-04 15:10:45 +03:00
z3APA3A e2b406f27b Addition al fix for Linux (glibc?) specific daemon problem 2016-08-23 18:36:18 +03:00
z3APA3A b242d6df8c Fix daemonize in *nix 2016-08-23 14:19:27 +03:00
z3APA3A 4e4f71712d Fix: 'extip' may fail with 9 error code 2016-08-16 15:21:02 +03:00
z3APA3A 6426ed0c1a fix %i logging 2016-06-07 15:39:14 +03:00
z3APA3A cdc4210a0a Fix '%i' logging 2016-06-07 14:16:55 +03:00
z3APA3A 7742b08ec5 Revert "Delay service exit until new configuration is loaded"
This reverts commit 05f39246bf.
2016-06-07 14:16:17 +03:00
z3APA3A 05f39246bf Delay service exit until new configuration is loaded 2016-06-06 18:01:51 +03:00
z3APA3A 84664a203b support %i in loformat 2016-06-06 17:54:23 +03:00
z3APA3A cd35215532 support -u2 for proxy 2016-05-28 00:24:26 +03:00
z3APA3A f347b37770 support port number in 'nserver' / 'authnserver' 2016-05-18 00:05:23 +03:00
z3APA3A fbcdcf3d7b Correct IP matching in cache auth 2016-05-17 23:27:10 +03:00
z3APA3A 8cdf341d0e workaround for broken getsockname() in FTP proxy 2016-05-14 00:09:51 +03:00
z3APA3A ccbc94e06b Revert "pam_auth; lock only pam_start"
This reverts commit 556fea670e.
2016-05-11 22:05:45 +03:00
z3APA3A 556fea670e pam_auth; lock only pam_start 2016-05-11 20:51:14 +03:00
z3APA3A 32ff114787 Revert "pam_auth: Authenticate all users in single session"
This reverts commit 438a5bac9b.
2016-05-11 20:49:39 +03:00
z3APA3A 438a5bac9b pam_auth: Authenticate all users in single session 2016-05-11 19:56:40 +03:00
z3APA3A 4cb43b438f Use mutex with pam auth, because pam is not thread safe 2016-05-11 19:03:16 +03:00
z3APA3A 8e820b28c0 Documentation correction 2016-05-11 19:02:51 +03:00
z3APA3A cfa4d11027 Do not fail connection with 333 error on configuration reload 2016-04-26 18:50:57 +03:00
z3APA3A 8b1c12005f avoid type mismatch in ?: operator 2016-04-08 15:08:18 +03:00
z3APA3A 3c8c866ac1 Fix counters time check for different platforms 2016-04-08 14:53:15 +03:00
z3APA3A d3f9d80b65 Resolve races on log buffer without mutex 2016-04-05 19:12:18 +03:00
z3APA3A 1d162abec3 Merge branch 'devel' of https://github.com/z3APA3A/3proxy into devel 2016-04-04 13:43:30 +03:00
z3APA3A d6f72a51fe fix race condition on 'log' command processing 2016-04-04 13:43:08 +03:00
Vladimir Dubrovin e210f24194 fix for noforce 2016-04-02 12:00:53 +03:00
Vladimir Dubrovin 9bfae5faaa force / no force commands added 2016-04-02 11:43:25 +03:00
Vladimir Dubrovin 2fed299b9d warning fix 2016-04-02 11:22:33 +03:00
z3APA3A 6cac541e33 fix broken extip functionality 2016-03-30 19:16:12 +03:00
z3APA3A 938b1d1aab re-authenticate connection on configuration change 2016-03-28 17:57:37 +03:00
z3APA3A eeb2d78fb1 re-authenticate user on 2016-03-28 17:49:27 +03:00
z3APA3A dcec2cadaa support external username / password up to 128 octets 2016-03-10 17:05:56 +03:00
z3APA3A f67c9a39f1 Use setreuid/setregid instead of setuid / setgid 2016-03-09 18:28:52 +03:00
z3APA3A a44a32c484 Do not fail for zero address on SOCKSv5 BIND/UDPASSOC 2016-03-08 13:28:29 +03:00
z3APA3A b513584fdb More distinct error codes for SOCKS 2016-03-08 12:43:07 +03:00
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 1404c63e10 add index.html to repro 2016-02-28 13:40:25 +03:00
46 changed files with 6986 additions and 2027 deletions

No files matched your search

+1
View File
@@ -15,6 +15,7 @@ tmp/
*.swp
*.o
*.idb
*.err
res
version.c
3proxy.res
+5 -8
View File
@@ -1,9 +1,6 @@
#include "src/version.h"
1 VERSIONINFO
FILEVERSION 0,8,4,0
PRODUCTVERSION 0,8,4,0
FILEVERSION 0,8,13,0
PRODUCTVERSION 0,8,13,0
FILETYPE 1
FILESUBTYPE 0x0L
BEGIN
@@ -14,12 +11,12 @@ BEGIN
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.4\0"
VALUE "FileVersion", "0.8.13\0"
VALUE "InternalName", "3proxy\0"
VALUE "LegalCopyright", "Copyright (C) 2002-2016 Vladimir Dubrovin\0"
VALUE "LegalCopyright", "Copyright (C) 2002-2019 Vladimir Dubrovin\0"
VALUE "OriginalFilename", "3proxy.exe\0"
VALUE "ProductName", "3proxy\0"
VALUE "ProductVersion", "0.8.4\0"
VALUE "ProductVersion", "0.8.13\0"
END
END
BLOCK "VarFileInfo"
+9 -5
View File
@@ -4,21 +4,20 @@
# 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
# remove -DNOODBC from CFLAGS and add -lodbc to LIBS to compile with ODBC
# library support. Add -DSAFESQL for poorely written ODBC library / drivers.
BUILDDIR =
CC = gcc
CFLAGS = -g -O2 -c -pthread -DGETHOSTBYNAME_R -D_THREAD_SAFE -D_REENTRANT -DNOODBC -DWITH_STD_MALLOC -DFD_SETSIZE=4096 -DWITH_POLL
CFLAGS = -g -O2 -fno-strict-aliasing -c -pthread -DGETHOSTBYNAME_R -D_THREAD_SAFE -D_REENTRANT -DNOODBC -DWITH_STD_MALLOC -DFD_SETSIZE=4096 -DWITH_POLL
COUT = -o
LN = gcc
DCFLAGS = -fpic
LDFLAGS = -O2 -pthread
LDFLAGS = -O2 -fno-strict-aliasing -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
@@ -30,7 +29,12 @@ REMOVECOMMAND = rm -f
TYPECOMMAND = cat
COMPATLIBS =
MAKEFILE = Makefile.Linux
PLUGINS = SSLPlugin StringsPlugin TrafficPlugin PCREPlugin TransparentPlugin PamAuth
# 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
+1 -1
View File
@@ -10,7 +10,7 @@
BUILDDIR =
CC = gcc
CFLAGS = -O3 -c -D_SOLARIS -D_THREAD_SAFE -DGETHOSTBYNAME_R -D_REENTRANT -DNOODBC -DWITH_STD_MALLOC -DFD_SETSIZE=4096 -DWITH_POLL
CFLAGS = -O2 -fno-strict-aliasing -c -D_SOLARIS -D_THREAD_SAFE -DGETHOSTBYNAME_R -D_REENTRANT -DNOODBC -DWITH_STD_MALLOC -DFD_SETSIZE=4096 -DWITH_POLL
COUT = -o ./
LN = gcc
LDFLAGS = -O3
+2 -2
View File
@@ -10,10 +10,10 @@
BUILDDIR = ../bin/
CC = clang
CFLAGS = -O2 -c -pthread -static -DWITH_STD_MALLOC -DNOIPV6
CFLAGS = -O2 -fno-strict-aliasing -c -pthread -static -DWITH_STD_MALLOC -DNOIPV6
COUT = -o
LN = clang
LDFLAGS = -O2 -static -s
LDFLAGS = -O2 -fno-strict-aliasing -static -s
DLFLAGS = -shared
DLSUFFICS = .dll
LIBS = -lws2_32 -lodbc32 -ladvapi32
+2 -2
View File
@@ -11,10 +11,10 @@ BUILDDIR =
CC = gcc
# you may need -L/usr/pkg/lib for older NetBSD versions
CFLAGS = -g -O2 -c -pthread -D_THREAD_SAFE -D_REENTRANT -DNOODBC -DWITH_STD_MALLOC -DFD_SETSIZE=4096 -DWITH_POLL
CFLAGS = -g -O2 -fno-strict-aliasing -c -pthread -D_THREAD_SAFE -D_REENTRANT -DNOODBC -DWITH_STD_MALLOC -DFD_SETSIZE=4096 -DWITH_POLL
COUT = -o
LN = gcc
LDFLAGS = -O2 -pthread
LDFLAGS = -O2 -fno-strict-aliasing -pthread
# -lpthreads may be reuqired on some platforms instead of -pthreads
# -ldl or -lld may be required for some platforms
DCFLAGS = -fpic
+43
View File
@@ -0,0 +1,43 @@
#
# 3 proxy Makefile for Open Watcom 2
#
# You can try to remove -DWITH_STD_MALLOC to CFLAGS to use optimized malloc
# libraries
#
# Add /DSAFESQL to CFLAGS if you are using poorely written/tested ODBC driver
BUILDDIR = ../bin/
CC = cl
CFLAGS = /nologo /Ox /MT /D "NOIPV6" /D "NODEBUG" /D "NOODBC" /D"WATCOM" /D "MSVC" /D "WITH_STD_MALLOC" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "_WIN32" /c
COUT = /Fo
LN = link
LDFLAGS = /nologo /subsystem:console /incremental:no
DLFLAGS = /DLL
DLSUFFICS = .dll
LIBS = ws2_32.lib advapi32.lib user32.lib kernel32.lib
LIBSOLD = libeay32MT.lib ssleay32MT.lib
LIBSPREFIX =
LIBSSUFFIX = .lib
LIBEXT = .lib
LNOUT = /out:
EXESUFFICS = .exe
OBJSUFFICS = .obj
DEFINEOPTION = /D
COMPFILES = *.pch *.idb *.err
REMOVECOMMAND = del 2>NUL >NUL
TYPECOMMAND = type
COMPATLIBS =
MAKEFILE = Makefile.watcom
PLUGINS = utf8tocp1251 WindowsAuthentication TrafficPlugin StringsPlugin PCREPlugin
VERFILE = $(VERFILE)
include Makefile.inc
../3proxy.res:
rc /fo../3proxy.res ../3proxy.rc
3proxyres.obj: ../3proxy.res
cvtres /out:3proxyres.obj ../3proxy.res
allplugins:
call ../makeplugins.bat
+1 -1
View File
@@ -37,7 +37,7 @@ users 3APA3A:CL:3apa3a "test:CR:$1$qwer$CHFTUFGqkjue9HyhcMHEe1"
service
# service is required under NT if you want 3proxy to start as service
#log /usr/local/etc/3proxy/logs/3proxy.log D
#log /var/log/3proxy/log D
log c:\3proxy\logs\3proxy.log D
# log allows to specify log file location and rotation, D means logfile
# is created daily
+1 -1
View File
@@ -129,7 +129,7 @@
невозможен. Защитить соединение можно с помощью TLS (например, stunnel) или
IPSec.
</p>
<li><a name="#CRASH"><i>Q: Почему прокси крэшится при обработке запроса?</a></i></li>
<li><a name="CRASH"><i>Q: Почему прокси крэшится при обработке запроса?</a></i></li>
<p>
<i>A:</i> Возможно, недостаточен размер стека потока по-умолчанию, это может
быть при использовани каких-либо сторонних плагинов (PAM, ODBC) или на
+19 -18
View File
@@ -1,18 +1,19 @@
<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>
<html><title>3proxy documentation</title><body><h2>3proxy documentation</h2>
<a href="securityen.html">Security recommendations</a><br>
<a href="highload.html">Optimizing 3proxy for high loads</a><br>
<a href="howtoe.html">How To (English, very incomplete)</a><br>
<a href="howtor.html">How To (Russian)</a><br>
<a href="faqe.html">FAQ (English)</a><br>
<a href="faqr.html">FAQ (Russian)</a>
<h3>Man pages:</h>
<br><A HREF="man8/3proxy.8.html">3proxy.8</A>
<br><A HREF="man8/ftppr.8.html">ftppr.8</A>
<br><A HREF="man8/icqpr.8.html">icqpr.8</A>
<br><A HREF="man8/pop3p.8.html">pop3p.8</A>
<br><A HREF="man8/proxy.8.html">proxy.8</A>
<br><A HREF="man8/smtpp.8.html">smtpp.8</A>
<br><A HREF="man8/socks.8.html">socks.8</A>
<br><A HREF="man8/tcppm.8.html">tcppm.8</A>
<br><A HREF="man8/udppm.8.html">udppm.8</A>
<br><A HREF="man3/3proxy.cfg.3.html">3proxy.cfg.3</A>
</body></html>
+6507 -1738
View File
File diff suppressed because it is too large. Load diff
+13
View File
@@ -300,6 +300,8 @@ with space and all time based elemnts are in local time zone.
%R - Remote IP
.br
%r - Remote port
.br
%i - Internal IP used to accept client connection
.br
%e - External IP used to establish connection
.br
@@ -734,6 +736,17 @@ nolog
.br
Weight may be used for different purposes.
.br
.B force
.br
.B noforce
.br
If force is specified for service, configuration reload will require all current
sessions of this service to be re-authenticated. If ACL is changed or user account
is removed, old connections which do not match current are closed.
noforce allows to keep previously authenticated connections.
.br
.B bandlimin
<rate> <userlist> <sourcelist> <targetlist> <targetportlist> <operationlist>
+1 -1
View File
@@ -10,7 +10,7 @@ monitor /usr/local/etc/3proxy/counters
monitor /usr/local/etc/3proxy/passwd
monitor /usr/local/etc/3proxy/bandlimiters
log /usr/local/etc/3proxy/log/log D
log /var/log/3proxy/log D
rotate 60
counter /usr/local/etc/3proxy/3proxy.3cf
+6 -1
View File
@@ -59,8 +59,8 @@ void __stdcall CommandHandler( DWORD dwCommand )
case SERVICE_CONTROL_STOP:
case SERVICE_CONTROL_SHUTDOWN:
SetStatus( SERVICE_STOP_PENDING, 0, 1 );
conf.paused++;
conf.timetoexit = 1;
conf.paused++;
Sleep(2000);
SetStatus( SERVICE_STOPPED, 0, 0 );
#ifndef NOODBC
@@ -192,6 +192,7 @@ void doschedule(void){
void dumpcounters(struct trafcount *tlin, int counterd){
unsigned char tmpbuf[8192];
struct trafcount *tl;
if(counterd >= 0 && tlin) {
@@ -234,6 +235,7 @@ void dumpcounters(struct trafcount *tlin, int counterd){
void cyclestep(void){
struct tm *tm;
time_t minutecounter;
unsigned char tmpbuf[8192];
minutecounter = time(0);
for(;;){
@@ -362,6 +364,7 @@ int WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int
#ifdef _WIN32
unsigned char * arg;
WSADATA wd;
unsigned char tmpbuf[8192];
WSAStartup(MAKEWORD( 1, 1 ), &wd);
osv.dwOSVersionInfoSize = sizeof(osv);
@@ -515,9 +518,11 @@ int WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int
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);
conf.version++;
if(res) RETURN(res);
if(!writable)fclose(fp);
+41 -24
View File
@@ -19,10 +19,9 @@ int clientnegotiate(struct chain * redir, struct clientparam * param, struct soc
user = redir->extuser;
pass = redir->extpass;
if (param->srvinbuf < 4096){
if(param->srvbuf)myfree(param->srvbuf);
param->srvbuf = myalloc(4096);
param->srvbufsize = 4096;
if (!param->srvbufsize){
param->srvbufsize = SRVBUFSIZE;
param->srvbuf = myalloc(param->srvbufsize);
}
buf = param->srvbuf;
username = buf + 2048;
@@ -57,7 +56,7 @@ int clientnegotiate(struct chain * redir, struct clientparam * param, struct soc
":%hu HTTP/1.0\r\nProxy-Connection: keep-alive\r\n", ntohs(*SAPORT(addr)));
if(user){
len += sprintf((char *)buf + len, "Proxy-authorization: basic ");
sprintf((char *)username, "%.128s:%.64s", user, pass?pass:(unsigned char *)"");
sprintf((char *)username, "%.128s:%.128s", user, pass?pass:(unsigned char *)"");
en64(username, buf+len, (int)strlen((char *)username));
len = (int)strlen((char *)buf);
len += sprintf((char *)buf + len, "\r\n");
@@ -190,11 +189,21 @@ int clientnegotiate(struct chain * redir, struct clientparam * param, struct soc
if(buf[1] != 0) {
return 60 + (buf[1] % 10);
}
if(buf[3] != 1) {
return 58;
}
if (redir->type != R_SOCKS5B && sockgetlinebuf(param, SERVER, buf, 6, EOF, conf.timeouts[CHAIN_TO]) != 6){
return 59;
switch (buf[3]) {
case 1:
if (redir->type == R_SOCKS5B || sockgetlinebuf(param, SERVER, buf, 6, EOF, conf.timeouts[CHAIN_TO]) == 6)
break;
return 59;
case 3:
if (sockgetlinebuf(param, SERVER, buf, 256, 0, conf.timeouts[CHAIN_TO]) > 1)
break;
return 59;
case 4:
if (sockgetlinebuf(param, SERVER, buf, 18, EOF, conf.timeouts[CHAIN_TO]) == 18)
break;
return 59;
default:
return 58;
}
return 0;
}
@@ -317,8 +326,8 @@ int handleredirect(struct clientparam * param, struct ace * acentry){
connected = 1;
}
if(!connected) return 9;
return (redir)?clientnegotiate(redir, param, (struct sockaddr *)&param->req):0;
if(!connected || !redir) return 0;
return clientnegotiate(redir, param, (struct sockaddr *)&param->req);
}
int IPInentry(struct sockaddr *sa, struct iplist *ipentry){
@@ -476,8 +485,14 @@ unsigned bandlimitfunc(struct clientparam *param, unsigned nbytesin, unsigned nb
if(!nbytesin && !nbytesout) return 0;
pthread_mutex_lock(&bandlim_mutex);
if(param->srv->version != conf.paused){
if(param->paused != conf.paused && param->bandlimver != conf.paused){
if(!conf.bandlimfunc){
param->bandlimfunc = NULL;
pthread_mutex_unlock(&bandlim_mutex);
return 0;
}
initbandlims(param);
param->bandlimver = conf.paused;
}
for(i=0; nbytesin&& i<MAXBANDLIMS && param->bandlims[i]; i++){
if( !param->bandlims[i]->basetime ||
@@ -558,7 +573,6 @@ int alwaysauth(struct clientparam * param){
res = doconnect(param);
if(!res){
if(param->srv->version != conf.paused) return 333;
initbandlims(param);
for(tc = conf.trafcounter; tc; tc = tc->next) {
if(tc->disabled) continue;
@@ -655,7 +669,7 @@ int cacheauth(struct clientparam * param){
}
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&1)) || (*SAFAMILY(&ac->sa) == *SAFAMILY(&param->sincr) && !memcmp(SAADDR(&ac->sa), SAADDR(&param->sincr), SAADDRLEN(&ac->sa)))) &&
(!(conf.authcachetype&4) || (ac->password && param->password && !strcmp(ac->password, (char *)param->password)))) {
if(param->username){
myfree(param->username);
@@ -689,7 +703,7 @@ int doauth(struct clientparam * param){
pthread_mutex_lock(&hash_mutex);
for(ac = authc; ac; ac = ac->next){
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&1) || (*SAFAMILY(&ac->sa) == *SAFAMILY(&param->sincr) && !memcmp(SAADDR(&ac->sa), SAADDR(&param->sincr), SAADDRLEN(&ac->sa)))) &&
(!(conf.authcachetype&4) || (ac->password && !strcmp(ac->password, (char *)param->password)))) {
ac->expires = conf.time + conf.authcachetime;
if(strcmp(ac->username, (char *)param->username)){
@@ -710,7 +724,7 @@ int doauth(struct clientparam * param){
ac = myalloc(sizeof(struct authcache));
if(ac){
ac->expires = conf.time + conf.authcachetime;
ac->username = mystrdup((char *)param->username);
ac->username = param->username?mystrdup((char *)param->username):NULL;
ac->sa = param->sincr;
ac->password = NULL;
if((conf.authcachetype&4) && param->password) ac->password = mystrdup((char *)param->password);
@@ -775,10 +789,14 @@ int dnsauth(struct clientparam * param){
((u&0xFF000000)>>24));
}
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;
if(!udpresolve(*SAFAMILY(&param->sincr), (unsigned char *)buf, (unsigned char *)addr, NULL, param, 1)) {
return 3;
}
if(memcmp(SAADDR(&param->sincr), addr, SAADDRLEN(&param->sincr))) {
return 3;
}
return param->username? 0:4;
return param->username? 0:3;
}
int strongauth(struct clientparam * param){
@@ -1152,6 +1170,8 @@ unsigned long udpresolve(int af, unsigned char * name, unsigned char * value, un
k += 4;
if(na > 255) na = 255; /* somebody is very evil */
for (j = 0; j < na; j++) { /* now there should be answers */
while(buf[k] < 192 && buf[k] !=0 && (k+buf[k]+14) < len) k+= (buf[k] + 1);
if(!buf[k]) k--;
if((k+(af == AF_INET6?28:16)) > len) {
break;
}
@@ -1167,10 +1187,7 @@ unsigned long udpresolve(int af, unsigned char * name, unsigned char * value, un
ttl = ntohl(*(unsigned long *)(buf + k + 6));
memcpy(value, buf + k + 12, af == AF_INET6? 16:4);
if(ttl < 60 || ttl > (3600*12)) ttl = 300;
if(ttl){
hashadd(af == AF_INET6?&dns6_table:&dns_table, name, value, conf.time+ttl);
}
hashadd(af == AF_INET6?&dns6_table:&dns_table, name, value, conf.time+ttl);
if(retttl) *retttl = ttl;
return 1;
}
+35 -17
View File
@@ -17,6 +17,16 @@ int randomizer = 1;
#ifndef _WIN32
pthread_attr_t pa;
void daemonize(void){
if(fork() > 0) {
usleep(SLEEPTIME);
_exit(0);
}
setsid();
}
#endif
unsigned char **stringtable = NULL;
@@ -63,7 +73,7 @@ struct extparam conf = {
#else
0,
#endif
0, -1, 0, 0, 0, 0, 0, 500, 0, 0, 0,
0, -1, 0, 0, 0, 0, 0, 500, 0, 0, 0, 0, 0,
6, 600,
1048576,
NULL, NULL,
@@ -221,30 +231,34 @@ int ceparseargs(const char *str){
#endif
void parsehost(int family, unsigned char *host, struct sockaddr *sa){
int parsehost(int family, unsigned char *host, struct sockaddr *sa){
char *sp=NULL,*se=NULL;
unsigned short port;
unsigned short port=0;
int ret = 0;
if(!host) return 2;
if(*host == '[') se=strchr((char *)host, ']');
if ( (sp = strchr(se?se:(char *)host, ':')) ) *sp = 0;
if ( (sp = strchr(se?se:(char *)host, ':')) && !strchr(sp+1, ':')) *sp = 0;
if(se){
*se = 0;
}
if(sp){
port = atoi(sp+1);
}
getip46(family, host + (se!=0), (struct sockaddr *)sa);
ret = !getip46(family, host + (se!=0), (struct sockaddr *)sa);
if(se) *se = ']';
if(sp) *sp = ':';
*SAPORT(sa) = htons(port);
if(port)*SAPORT(sa) = htons(port);
return ret;
}
int parsehostname(char *hostname, struct clientparam *param, unsigned short port){
char *sp=NULL,*se=NULL;
int ret = 0;
if(!hostname || !*hostname)return 1;
if(!hostname || !*hostname)return 2;
if(*hostname == '[') se=strchr(hostname, ']');
if ( (sp = strchr(se?se:hostname, ':')) ) *sp = 0;
if ( (sp = strchr(se?se:hostname, ':')) && !strchr(sp+1, ':')) *sp = 0;
if(se){
*se = 0;
}
@@ -255,12 +269,12 @@ int parsehostname(char *hostname, struct clientparam *param, unsigned short port
if(sp){
port = atoi(sp+1);
}
getip46(param->srv->family, param->hostname, (struct sockaddr *)&param->req);
ret = !getip46(param->srv->family, param->hostname, (struct sockaddr *)&param->req);
if(se) *se = ']';
if(sp) *sp = ':';
*SAPORT(&param->req) = htons(port);
memset(&param->sinsr, 0, sizeof(param->sinsr));
return 0;
return ret;
}
int parseusername(char *username, struct clientparam *param, int extpasswd){
@@ -454,7 +468,7 @@ int dobuf2(struct clientparam * param, unsigned char * buf, const unsigned char
break;
case 'n':
len = param->hostname? (int)strlen((char *)param->hostname) : 0;
if (len > 0 && !strchr((char *)param->hostname, ':')) for(len = 0; param->hostname[len] && i < 4000; len++, i++){
if (len > 0 && !strchr((char *)param->hostname, ':')) for(len = 0; param->hostname[len] && i < 256; len++, i++){
buf[i] = param->hostname[len];
if(param->srv->nonprintable && (buf[i] < 0x20 || strchr((char *)param->srv->nonprintable, buf[i]))) buf[i] = param->srv->replace;
if(doublec && strchr((char *)doublec, buf[i])) {
@@ -466,7 +480,6 @@ int dobuf2(struct clientparam * param, unsigned char * buf, const unsigned char
buf[i++] = '[';
i += myinet_ntop(*SAFAMILY(&param->req), SAADDR(&param->req), (char *)buf + i, 64);
buf[i++] = ']';
buf[i++] = 0;
}
break;
@@ -498,6 +511,9 @@ int dobuf2(struct clientparam * param, unsigned char * buf, const unsigned char
case 'e':
i += myinet_ntop(*SAFAMILY(&param->sinsl), SAADDR(&param->sinsl), (char *)buf + i, 64);
break;
case 'i':
i += myinet_ntop(*SAFAMILY(&param->sincl), SAADDR(&param->sincl), (char *)buf + i, 64);
break;
case 'C':
i += myinet_ntop(*SAFAMILY(&param->sincr), SAADDR(&param->sincr), (char *)buf + i, 64);
break;
@@ -631,14 +647,16 @@ void logsyslog(struct clientparam * param, const unsigned char *s) {
#endif
int doconnect(struct clientparam * param){
SASIZETYPE size = sizeof(param->sinsr);
SASIZETYPE size;
if (*SAFAMILY(&param->sincr) == *SAFAMILY(&param->req) && !memcmp(SAADDR(&param->sincr), SAADDR(&param->req), SAADDRLEN(&param->req)) &&
*SAPORT(&param->sincr) == *SAPORT(&param->req)) return 519;
if (*SAFAMILY(&param->sincl) == *SAFAMILY(&param->req) && !memcmp(SAADDR(&param->sincl), SAADDR(&param->req), SAADDRLEN(&param->req)) &&
*SAPORT(&param->sincl) == *SAPORT(&param->req)) return 519;
if (param->operation == ADMIN || param->operation == DNSRESOLVE || param->operation == BIND || param->operation == UDPASSOC)
return 0;
if (param->remsock != INVALID_SOCKET){
size = sizeof(param->sinsr);
if(so._getpeername(param->remsock, (struct sockaddr *)&param->sinsr, &size)==-1) {return (15);}
}
else {
@@ -675,8 +693,8 @@ int doconnect(struct clientparam * param){
else
#endif
param->sinsl = param->srv->extsa;
*SAPORT(&param->sinsl) = 0;
}
*SAPORT(&param->sinsl) = 0;
if(so._bind(param->remsock, (struct sockaddr*)&param->sinsl, SASIZE(&param->sinsl))==-1) {
return 12;
}
@@ -694,8 +712,8 @@ int doconnect(struct clientparam * param){
#else
fcntl(param->remsock,F_SETFL,O_NONBLOCK);
#endif
size = sizeof(param->sinsl);
}
size = sizeof(param->sinsl);
if(so._getsockname(param->remsock, (struct sockaddr *)&param->sinsl, &size)==-1) {return (15);}
}
return 0;
+41 -21
View File
@@ -153,6 +153,7 @@ int start_proxy_thread(struct child * chp){
pthread_attr_setstacksize(&pa,PTHREAD_STACK_MIN + (16384+conf.stacksize));
pthread_attr_setdetachstate(&pa,PTHREAD_CREATE_DETACHED);
pthread_create(&thread, &pa, startsrv, (void *)chp);
pthread_attr_destroy(&pa);
#endif
while(conf.threadinit)usleep(SLEEPTIME);
if(haveerror) {
@@ -279,12 +280,12 @@ static int h_external(int argc, unsigned char ** argv){
else conf.extsa6 = sa6;
#else
res = getip46(46, argv[1], (struct sockaddr *)&conf.extsa);
if(!res) return 1;
#endif
return 0;
}
static int h_log(int argc, unsigned char ** argv){
unsigned char tmpbuf[8192];
conf.logfunc = logstdout;
if(conf.logtarget){
myfree(conf.logtarget);
@@ -317,14 +318,12 @@ static int h_log(int argc, unsigned char ** argv){
conf.logname = (unsigned char *)mystrdup((char *)argv[1]);
fp = fopen((char *)dologname (tmpbuf, conf.logname, NULL, conf.logtype, conf.logtime), "a");
if(!fp){
perror("fopen()");
perror((char *)tmpbuf);
return 1;
}
else {
pthread_mutex_lock(&log_mutex);
if(conf.stdlog)fclose(conf.stdlog);
conf.stdlog = fp;
pthread_mutex_unlock(&log_mutex);
#ifdef _WINCE
freopen(tmpbuf, "w", stdout);
freopen(tmpbuf, "w", stderr);
@@ -340,6 +339,17 @@ static int h_stacksize(int argc, unsigned char **argv){
return 0;
}
static int h_force(int argc, unsigned char **argv){
conf.noforce = 0;
return 0;
}
static int h_noforce(int argc, unsigned char **argv){
conf.noforce = 1;
return 0;
}
static int h_service(int argc, unsigned char **argv){
return 0;
}
@@ -395,17 +405,22 @@ static int h_counter(int argc, unsigned char **argv){
fprintf(stderr, "Not a counter file %s, line %d\n", argv[1], linenum);
return 2;
}
#ifdef _MSC_VER
#ifdef _TIME64_T_DEFINED
#ifndef _MAX__TIME64_T
#define _MAX__TIME64_T 0x793406fffi64
#ifdef _MAX__TIME64_T
#define MAX_COUNTER_TIME (_MAX__TIME64_T)
#elif defined (MAX__TIME64_T)
#define MAX_COUNTER_TIME (MAX__TIME64_T)
#else
#define MAX_COUNTER_TIME (0x793406fff)
#endif
#else
#define MAX_COUNTER_TIME ((sizeof(time_t)>4)?(time_t)0x793406fff:(time_t)0x7fffffff)
#endif
if(ch1.updated >= _MAX__TIME64_T){
if(ch1.updated < 0 || ch1.updated >= MAX_COUNTER_TIME){
fprintf(stderr, "Invalid or corrupted counter file %s. Use countersutil utility to convert from older version\n", argv[1]);
return 3;
}
#endif
cheader.updated = ch1.updated;
}
if(argc >=4) {
@@ -548,8 +563,8 @@ static int h_nserver(int argc, unsigned char **argv){
if(numservers < MAXNSERVERS) {
if((str = strchr((char *)argv[1], '/')))
*str = 0;
if(!getip46(46, argv[1], (struct sockaddr *)&nservers[numservers].addr)) return 1;
*SAPORT(&nservers[numservers].addr) = htons(53);
if(parsehost(46, argv[1], (struct sockaddr *)&nservers[numservers].addr)) return 1;
if(str) {
nservers[numservers].usetcp = strstr(str + 1, "tcp")? 1:0;
*str = '/';
@@ -566,7 +581,7 @@ static int h_authnserver(int argc, unsigned char **argv){
if((str = strchr((char *)argv[1], '/')))
*str = 0;
if(!getip46(46, argv[1], (struct sockaddr *)&authnserver.addr)) return 1;
if(parsehost(46, argv[1], (struct sockaddr *)&authnserver.addr)) return 1;
*SAPORT(&authnserver.addr) = htons(53);
if(str) {
authnserver.usetcp = strstr(str + 1, "tcp")? 1:0;
@@ -1199,12 +1214,10 @@ static int h_ace(int argc, unsigned char **argv){
tl->traf64 = crecord.traf64;
tl->cleared = crecord.cleared;
tl->updated = crecord.updated;
#ifdef _MAX__TIME64_T
if(tl->cleared >= _MAX__TIME64_T || tl->updated >= _MAX__TIME64_T){
fprintf(stderr, "Invalid or corrupted counter file. Use countersutil utility to convert from older version\n");
if(tl->cleared < 0 || tl->cleared >= MAX_COUNTER_TIME || tl->updated < 0 || tl->updated >= MAX_COUNTER_TIME){
fprintf(stderr, "Invalid, incompatible or corrupted counter file.\n");
return(6);
}
#endif
}
}
pthread_mutex_lock(&tc_mutex);
@@ -1293,7 +1306,7 @@ static int h_plugin(int argc, unsigned char **argv){
static int h_setuid(int argc, unsigned char **argv){
int res;
res = atoi((char *)argv[1]);
if(!res || setuid(res)) {
if(!res || setreuid(res,res)) {
fprintf(stderr, "Unable to set uid %d", res);
return(1);
}
@@ -1304,7 +1317,7 @@ static int h_setgid(int argc, unsigned char **argv){
int res;
res = atoi((char *)argv[1]);
if(!res || setgid(res)) {
if(!res || setregid(res,res)) {
fprintf(stderr, "Unable to set gid %d", res);
return(1);
}
@@ -1399,6 +1412,8 @@ struct commands commandhandlers[]={
{commandhandlers+56, "delimchar",h_delimchar, 2, 2},
{commandhandlers+57, "authnserver", h_authnserver, 2, 2},
{commandhandlers+58, "stacksize", h_stacksize, 2, 2},
{commandhandlers+59, "force", h_force, 1, 1},
{commandhandlers+60, "noforce", h_noforce, 1, 1},
{specificcommands, "", h_noop, 1, 0}
};
@@ -1410,7 +1425,6 @@ int parsestr (unsigned char *str, unsigned char **argm, int nitems, unsigned cha
unsigned char * incbegin = 0;
int fd;
int res, len;
int i = 1;
unsigned char *str1;
for(;;str++){
@@ -1429,7 +1443,14 @@ int parsestr (unsigned char *str, unsigned char **argm, int nitems, unsigned cha
argm[argc] = 0;
return argc;
case '$':
if(!comment && !included){
if(comment){
if(space){
argm[argc++] = str;
if(argc >= nitems) return argc;
space = 0;
}
}
else if(!included){
incbegin = str;
*str = 0;
}
@@ -1441,7 +1462,6 @@ int parsestr (unsigned char *str, unsigned char **argm, int nitems, unsigned cha
if(!comment){
*str = 0;
space = 1;
i = 0;
if(incbegin){
argc--;
if((fd = open((char *)incbegin+1, O_RDONLY)) <= 0){
@@ -1479,7 +1499,6 @@ int parsestr (unsigned char *str, unsigned char **argm, int nitems, unsigned cha
break;
}
default:
i++;
if(space) {
if(comment && *str == '\"' && str[1] != '\"'){
str++;
@@ -1686,6 +1705,7 @@ int reload (void){
fp = confopen();
if(fp){
error = readconfig(fp);
conf.version++;
if(error) {
freeconf(&conf);
}
+22 -18
View File
@@ -61,19 +61,21 @@ static void pr_ip(struct node *node, CBFUNC cbf, void*cb){
if(node->value)(*cbf)(cb, buf, myinet_ntop(AF_INET, node -> value, buf, 4));
}
#ifndef NOIPV6
static void pr_ip6(struct node *node, CBFUNC cbf, void*cb){
char buf[64];
if(node->value)(*cbf)(cb, buf, myinet_ntop(AF_INET6, node -> value, buf, 16));
}
#endif
static void pr_sa(struct node *node, CBFUNC cbf, void*cb){
#ifdef NOIPV6
if(node->value)return pr_ip(node, cbf, cb);
if(node->value)pr_ip(node, cbf, cb);
#else
char buf[64];
buf[0] = '[';
buf[1] = 0;
inet_ntop(*SAFAMILY(node->value), node->value, buf+1, sizeof(buf)-10);
inet_ntop(*SAFAMILY(node->value), SAADDR(node->value), buf+1, sizeof(buf)-10);
sprintf(buf + strlen(buf), "]:%hu", (unsigned short)*SAPORT(node->value));
if(node->value)(*cbf)(cb, buf, strlen(buf));
#endif
@@ -741,21 +743,23 @@ static struct property prop_server[] = {
{prop_server + 2, "target", ef_server_target, TYPE_STRING, "portmapper target ip"},
{prop_server + 3, "targetport", ef_server_targetport, TYPE_PORT, "portmapper target port"},
{prop_server + 4, "starttime", ef_server_starttime, TYPE_DATETIME, "service started seconds"},
{prop_server + 5, "intsa", ef_server_intsa, TYPE_SA, "ip address of internal interface"},
{prop_server + 6, "extsa", ef_server_extsa, TYPE_SA, "ip address of external interface"},
{prop_server + 7, "auth", ef_server_auth, TYPE_STRING, "service authentication type"},
{prop_server + 8, "acl", ef_server_acl, TYPE_ACE, "access control list"},
{prop_server + 9, "singlepacket", ef_server_singlepacket, TYPE_INTEGER, "is single packet redirection"},
{prop_server + 10, "usentlm", ef_server_usentlm, TYPE_INTEGER, "allow NTLM authentication"},
{prop_server + 11, "log", ef_server_log, TYPE_STRING, "type of logging"},
{prop_server + 12, "logtarget", ef_server_logtarget, TYPE_STRING, "log target options"},
{prop_server + 13, "logformat", ef_server_logformat, TYPE_STRING, "logging format string"},
{prop_server + 14, "nonprintable", ef_server_nonprintable, TYPE_STRING, "non printable characters"},
{prop_server + 15, "replacement", ef_server_replacement, TYPE_CHAR, "replacement character"},
{prop_server + 16, "childcount", ef_server_childcount, TYPE_INTEGER, "number of servers connected"},
{prop_server + 17, "child", ef_server_child, TYPE_CLIENT, "connected clients"},
{prop_server + 5, "auth", ef_server_auth, TYPE_STRING, "service authentication type"},
{prop_server + 6, "acl", ef_server_acl, TYPE_ACE, "access control list"},
{prop_server + 7, "singlepacket", ef_server_singlepacket, TYPE_INTEGER, "is single packet redirection"},
{prop_server + 8, "usentlm", ef_server_usentlm, TYPE_INTEGER, "allow NTLM authentication"},
{prop_server + 9, "log", ef_server_log, TYPE_STRING, "type of logging"},
{prop_server + 10, "logtarget", ef_server_logtarget, TYPE_STRING, "log target options"},
{prop_server + 11, "logformat", ef_server_logformat, TYPE_STRING, "logging format string"},
{prop_server + 12, "nonprintable", ef_server_nonprintable, TYPE_STRING, "non printable characters"},
{prop_server + 13, "replacement", ef_server_replacement, TYPE_CHAR, "replacement character"},
{prop_server + 14, "childcount", ef_server_childcount, TYPE_INTEGER, "number of servers connected"},
{prop_server + 15, "intsa", ef_server_intsa, TYPE_SA, "ip address of internal interface"},
{prop_server + 16, "extsa", ef_server_extsa, TYPE_SA, "ip address of external interface"},
#ifndef NOIPV6
{prop_server + 18, "extsa6", ef_server_extsa6, TYPE_SA, "ipv6 address of external interface"},
{prop_server + 17, "extsa6", ef_server_extsa6, TYPE_SA, "ipv6 address of external interface"},
{prop_server + 18, "child", ef_server_child, TYPE_CLIENT, "connected clients"},
#else
{prop_server + 17, "child", ef_server_child, TYPE_CLIENT, "connected clients"},
#endif
{NULL, "next", ef_server_next, TYPE_SERVER, "next"}
};
@@ -774,8 +778,8 @@ static struct property prop_client[] = {
{prop_client + 10, "username", ef_client_username, TYPE_STRING, "client username"},
{prop_client + 11, "password", ef_client_password, TYPE_STRING, "client password"},
{prop_client + 12, "clisa", ef_client_clisa, TYPE_SA, "client sa"},
{prop_client + 13, "srvsa", ef_client_srvsa, TYPE_IP, "target server sa"},
{prop_client + 14, "reqsa", ef_client_reqsa, TYPE_IP, "requested server sa"},
{prop_client + 13, "srvsa", ef_client_srvsa, TYPE_SA, "target server sa"},
{prop_client + 14, "reqsa", ef_client_reqsa, TYPE_SA, "requested server sa"},
{prop_client + 15, "bytesin", ef_client_bytesin64, TYPE_UNSIGNED64, "bytes from server to client"},
{prop_client + 16, "bytesout", ef_client_bytesout64, TYPE_UNSIGNED64, "bytes from client to server"},
{prop_client + 17, "maxtrafin", ef_client_maxtrafin64, TYPE_UNSIGNED64, "maximum traffic allowed for download"},
+20 -7
View File
@@ -9,17 +9,17 @@
int ftplogin(struct clientparam *param, char *nbuf, int *innbuf) {
char tbuf[1024];
char tbuf[256];
int i;
char *buf;
int len;
int res;
buf = nbuf?nbuf:tbuf;
len = nbuf?*innbuf:1024;
len = nbuf?*innbuf:sizeof(tbuf);
if(innbuf)*innbuf = 0;
if(len < 48) return 707;
if(len < 140) return 707;
while((i = sockgetlinebuf(param, SERVER, (unsigned char *)buf, len - 1, '\n', conf.timeouts[STRING_L])) > 0 && (i < 3 || !isnumber(*buf) || buf[3] == '-')){
}
if(i < 3) return 706;
@@ -28,7 +28,7 @@ int ftplogin(struct clientparam *param, char *nbuf, int *innbuf) {
*innbuf = i;
return 702;
}
sprintf(buf, "USER %.32s\r\n", param->extusername?param->extusername:(unsigned char *)"anonymous");
sprintf(buf, "USER %.128s\r\n", param->extusername?param->extusername:(unsigned char *)"anonymous");
if((int)socksend(param->remsock, (unsigned char *)buf, (int)strlen(buf), conf.timeouts[STRING_S]) != (int)strlen(buf)){
return 703;
}
@@ -40,7 +40,7 @@ int ftplogin(struct clientparam *param, char *nbuf, int *innbuf) {
buf[i] = 0;
res = atoi(buf)/100;
if(res == 3){
sprintf(buf, "PASS %.32s\r\n",
sprintf(buf, "PASS %.128s\r\n",
param->extusername?
(param->extpassword?
param->extpassword:(unsigned char *)"")
@@ -174,6 +174,7 @@ SOCKET ftpdata(struct clientparam *param){
SOCKET s = INVALID_SOCKET, rem;
unsigned long b1, b2, b3, b4;
unsigned short b5, b6;
SASIZETYPE sasize;
if(socksend(param->remsock, (unsigned char *)"PASV\r\n", 6, conf.timeouts[STRING_S]) != 6){
return INVALID_SOCKET;
@@ -187,15 +188,27 @@ SOCKET ftpdata(struct clientparam *param){
buf[i-2] = 0;
if(!(sb = strchr(buf+4, '(')) || !(se= strchr(sb, ')'))) return INVALID_SOCKET;
if(sscanf(sb+1, "%lu,%lu,%lu,%lu,%hu,%hu", &b1, &b2, &b3, &b4, &b5, &b6)!=6) return INVALID_SOCKET;
sasize = sizeof(param->sinsl);
if(so._getsockname(param->remsock, (struct sockaddr *)&param->sinsl, &sasize)){return INVALID_SOCKET;}
sasize = sizeof(param->sinsr);
if(so._getpeername(param->remsock, (struct sockaddr *)&param->sinsr, &sasize)){return INVALID_SOCKET;}
rem = param->remsock;
param->remsock = INVALID_SOCKET;
param->req = param->sinsr;
*SAPORT(&param->req) = *SAPORT(&param->sinsr) = htons((unsigned short)((b5<<8)^b6));
*SAPORT(&param->sinsl) = 0;
i = param->operation;
param->operation = FTP_DATA;
if((param->res = (*param->srv->authfunc)(param))) {
param->remsock = rem;
return INVALID_SOCKET;
if(param->remsock != INVALID_SOCKET) {
so._closesocket(param->remsock);
param->remsock = INVALID_SOCKET;
}
memset(&param->sinsl, 0, sizeof(param->sinsl));
if((param->res = (*param->srv->authfunc)(param))) {
param->remsock = rem;
return INVALID_SOCKET;
}
}
param->operation = i;
s = param->remsock;
+13 -5
View File
@@ -70,7 +70,7 @@ void * ftpprchild(struct clientparam* param) {
param->res = res;
if(inbuf && inbuf != BUFSIZE && socksend(param->ctrlsock, buf, inbuf, conf.timeouts[STRING_S])!=inbuf) {RETURN (807);}
if(!res) status = 3;
sprintf((char *)buf, "%.64s@%.128s%c%hu", param->extusername, param->hostname, (ntohs(*SAPORT(&param->sinsr))==21)?0:':', ntohs(*SAPORT(&param->sinsr)));
sprintf((char *)buf, "%.128s@%.128s%c%hu", param->extusername, param->hostname, (ntohs(*SAPORT(&param->sinsr))==21)?0:':', ntohs(*SAPORT(&param->sinsr)));
req = mystrdup((char *)buf);
#ifndef WITHMAIN
{
@@ -88,6 +88,7 @@ void * ftpprchild(struct clientparam* param) {
}
else if (status >= 3 && (
(!strncasecmp((char *)buf, "PASV", 4) && (pasv = 1)) ||
(!strncasecmp((char *)buf, "EPSV", 4) && (pasv = 2)) ||
(!strncasecmp((char *)buf, "PORT ", 5) && !(pasv = 0))
)){
#ifndef WITHMAIN
@@ -125,8 +126,9 @@ void * ftpprchild(struct clientparam* param) {
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",
if(pasv == 1){
if(*SAFAMILY(&param->sincl) == AF_INET)
sprintf((char *)buf, "227 OK (%u,%u,%u,%u,%u,%u)\r\n",
(unsigned)(((unsigned char *)(SAADDR(&param->sincl)))[0]),
(unsigned)(((unsigned char *)(SAADDR(&param->sincl)))[1]),
(unsigned)(((unsigned char *)(SAADDR(&param->sincl)))[2]),
@@ -134,10 +136,16 @@ void * ftpprchild(struct clientparam* param) {
(unsigned)(((unsigned char *)(SAPORT(&param->sincl)))[0]),
(unsigned)(((unsigned char *)(SAPORT(&param->sincl)))[1])
);
else sprintf((char *)buf, "227 OK (127,0,0,1,%u,%u)\r\n",
else sprintf((char *)buf, "227 OK (127,0,0,1,%u,%u)\r\n",
(unsigned)(((unsigned char *)(SAPORT(&param->sincl)))[0]),
(unsigned)(((unsigned char *)(SAPORT(&param->sincl)))[1])
);
);
}
else {
sprintf((char *)buf, "229 OK (|||%u|)\r\n",
(unsigned)ntohs(*SAPORT(&param->sincl))
);
}
}
else {
unsigned long b1, b2, b3, b4;
+3 -3
View File
@@ -25,20 +25,20 @@ struct flap_header {
unsigned char chan;
unsigned short seq;
unsigned short size;
char data[0];
char data[1];
};
struct snack_header {
unsigned family;
unsigned short flags;
unsigned id;
char data[0];
char data[1];
};
struct tlv_header {
unsigned short type;
unsigned short size;
char data[0];
char data[1];
};
+5 -5
View File
@@ -878,13 +878,13 @@ static struct commands file_commandhandlers[] = {
static int file_loaded=0;
#ifdef _WIN32
__declspec(dllexport)
#ifdef WATCOM
#pragma aux file_plugin "*" parm caller [ ] value struct float struct routine [eax] modify [eax ecx edx]
#undef PLUGINCALL
#define PLUGINCALL
#endif
int file_plugin (struct pluginlink * pluginlink,
PLUGINAPI int PLUGINCALL file_plugin (struct pluginlink * pluginlink,
int argc, char** argv){
if(!file_loaded){
+8 -3
View File
@@ -677,13 +677,18 @@ static struct commands lfm_commandhandlers[] = {
{NULL, "lfm_format", h_lfm_format, 2, 2}
};
#ifdef __cplusplus
extern "C" {
#endif
#ifdef _WIN32
__declspec(dllexport)
#ifdef WATCOM
#pragma aux lfm_plugin "*" parm caller [ ] value struct float struct routine [eax] modify [eax ecx edx]
#undef PLUGINCALL
#define PLUGINCALL
#endif
int lfm_plugin( struct pluginlink * pluginlink, int argc, char** argv )
PLUGINAPI int PLUGINCALL lfm_plugin( struct pluginlink * pluginlink, int argc, char** argv )
{
pl = pluginlink;
myOutputDebugStringA1( "lfm_plugin" );
+1 -1
View File
@@ -4,4 +4,4 @@ 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)
$(LN) $(LNOUT)../../$(BUILDDIR)ldapauth$(DLSUFFICS) $(LDFLAGS) $(DLFLAGS) $(LIBSPREFIX)ldap$(LIBSSUFFIX) ldapauth$(OBJSUFFICS)
+21 -34
View File
@@ -1,25 +1,15 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdlib.h>
#include <time.h>
#include <ldap.h>
#ifndef _WIN32
#include <ctype.h>
#endif
#include "../../proxy.h"
#include "../../structures.h"
struct counter_record
{
unsigned long traf;
unsigned long trafgb;
time_t cleared;
time_t updated;
};
#define LDAP_DEPRECATED 1
#include <ldap.h>
int already_loaded = 0;
@@ -62,7 +52,7 @@ void lower (char *string)
#endif
/* -------------------------------------------------------------------------- */
int savecouters(void)
int savecounters(void)
{
struct trafcount *tc=mypluginlink->conf->trafcounter;
struct trafcount *tcd;
@@ -82,8 +72,8 @@ int savecouters(void)
sprintf(tmpbuf,pat_file,ldap_dircount,tcd->ace->users->user);
f=fopen(tmpbuf,"w+b");
fseek(f,0,SEEK_SET);
fprintf(f,"%10lu %10lu %lu %lu\n",tcd->trafgb,tcd->traf,
tcd->cleared,tcd->updated);
fprintf(f,"%"PRINTF_INT64_MODIFIER"u %lu %lu\n",tcd->traf64,
(unsigned long)tcd->cleared,(unsigned long)tcd->updated);
fclose(f);
mypluginlink->myfree(tmpbuf);
@@ -100,17 +90,7 @@ int savecouters(void)
return (0);
}
/*--------------------------------------------------------------------------*/
#ifdef _WIN32
__declspec(dllexport) int start(struct pluginlink * pluginlink,
int argc, char** argv);
#else
int start(struct pluginlink * pluginlink,
int argc, char** argv);
#endif
/* --------------------------------------------------------------------------*/
static int ldapfunc(struct clientparam *param)
@@ -395,8 +375,7 @@ int h_trafgroup(int argc, unsigned char ** argv)
memset(newtrafcount, 0, sizeof(struct trafcount));
newtrafcount->ace = newace;
newtrafcount->type=rtype;
newtrafcount->traflimgb =(traflimit/(1024*4));
newtrafcount->traflim = ((traflimit - (newtrafcount->traflimgb*(1024*4)))*(1024*1024));
newtrafcount->traflim64 = traflimit;
newtrafcount->comment=(*mypluginlink->mystrdup)("ldapcounters");
newtrafcount->number=0;
tmpbuf=(*mypluginlink->myalloc)(strlen(pat_file)+strlen(ldap_dircount)+strlen(vals[0]));
@@ -408,12 +387,11 @@ int h_trafgroup(int argc, unsigned char ** argv)
fseek(f,0,SEEK_SET);
fgets(buf, 256, f);
sscanf(buf,"%10lu %10lu %lu %lu\n",&rcounter.trafgb, &rcounter.traf,
sscanf(buf,"%"PRINTF_INT64_MODIFIER"u %lu %lu\n",&rcounter.traf64,
&rcounter.cleared, &rcounter.updated);
newtrafcount->trafgb=rcounter.trafgb;
newtrafcount->traf=rcounter.traf;
newtrafcount->traf64=rcounter.traf64;
newtrafcount->cleared=rcounter.cleared;
newtrafcount->updated=rcounter.updated;
fclose(f);
@@ -467,7 +445,16 @@ int h_dircount(int argc, unsigned char ** argv)
/*------------------------------- MAIN --------------------------------------
start plugin init */
int start(struct pluginlink * pluginlink, int argc, char** argv)
#ifdef WATCOM
#pragma aux start "*" parm caller [ ] value struct float struct routine [eax] modify [eax ecx edx]
#undef PLUGINCALL
#define PLUGINCALL
#endif
PLUGINAPI int PLUGINCALL start(struct pluginlink * pluginlink,
int argc, char** argv)
{
@@ -566,7 +553,7 @@ int start(struct pluginlink * pluginlink, int argc, char** argv)
/*create job shedule for processing reload, save counters to file */
memset(&myschedule,0,sizeof(struct schedule));
myschedule.type=MINUTELY;
myschedule.function=savecouters;
myschedule.function=savecounters;
myschedule.next = *pluginlink->schedule;
*pluginlink->schedule=&myschedule;
+6 -3
View File
@@ -358,12 +358,15 @@ static struct symbol regexp_symbols[] = {
{NULL, "pcre_free", NULL},
};
#ifdef _WIN32
__declspec(dllexport)
#ifdef WATCOM
#pragma aux pcre_plugin "*" parm caller [ ] value struct float struct routine [eax] modify [eax ecx edx]
#undef PLUGINCALL
#define PLUGINCALL
#endif
int pcre_plugin (struct pluginlink * pluginlink,
PLUGINAPI int PLUGINCALL pcre_plugin (struct pluginlink * pluginlink,
int argc, char** argv){
struct filter *flt, *tmpflt;
pl = pluginlink;
pcre_options = 0;
+12 -3
View File
@@ -12,7 +12,7 @@ Kirill Lopuchov <lopuchov@mail.ru>
#include <security/pam_appl.h>
pthread_mutex_t pam_mutex;
static int already_loaded = 0;
@@ -89,9 +89,10 @@ static int pamfunc(struct clientparam *param)
/*start process auth */
conv.appdata_ptr = (char *) param->password;
pthread_mutex_lock(&pam_mutex);
if (!pamh)
{
retval = pam_start ((char *)service, "3proxy@" , &conv, &pamh);
retval = pam_start ((char *)service, "3proxy@" , &conv, &pamh);
}
if (retval == PAM_SUCCESS)
retval = pam_set_item (pamh, PAM_USER, param->username);
@@ -110,14 +111,21 @@ static int pamfunc(struct clientparam *param)
retval = pam_end (pamh, retval);
if (retval != PAM_SUCCESS)
{ pamh = NULL; }
pthread_mutex_unlock(&pam_mutex);
return rc;
}
#ifdef WATCOM
#pragma aux start "*" parm caller [ ] value struct float struct routine [eax] modify [eax ecx edx]
#undef PLUGINCALL
#define PLUGINCALL
#endif
/*------------------------------- MAIN --------------------------------------
start plugin init */
int start(struct pluginlink * pluginlink, int argc, unsigned char** argv)
PLUGINAPI int PLUGINCALL start(struct pluginlink * pluginlink, int argc, unsigned char** argv)
{
@@ -130,6 +138,7 @@ int start(struct pluginlink * pluginlink, int argc, unsigned char** argv)
already_loaded = 1;
pthread_mutex_init(&pam_mutex, NULL);
pamauth.authenticate = pamfunc;
pamauth.authorize = pluginlink->checkACL;
pamauth.desc = "pam";
+2 -2
View File
@@ -112,8 +112,8 @@ SSL_CERT ssl_copy_cert(SSL_CERT cert)
unsigned char p2[] = "3proxy";
unsigned char p3[] = "3proxy CA";
static char hash_name[sizeof(src_cert->sha1_hash)*2 + 1];
static char cache_name[200];
char hash_name[sizeof(src_cert->sha1_hash)*2 + 1];
char cache_name[200];
bin2hex(src_cert->sha1_hash, sizeof(src_cert->sha1_hash), hash_name, sizeof(hash_name));
sprintf(cache_name, "%s%s.pem", cert_path, hash_name);
+6 -3
View File
@@ -372,12 +372,15 @@ static struct commands ssl_commandhandlers[] = {
};
#ifdef _WIN32
__declspec(dllexport)
#ifdef WATCOM
#pragma aux ssl_plugin "*" parm caller [ ] value struct float struct routine [eax] modify [eax ecx edx]
#undef PLUGINCALL
#define PLUGINCALL
#endif
int ssl_plugin (struct pluginlink * pluginlink,
PLUGINAPI int PLUGINCALL ssl_plugin (struct pluginlink * pluginlink,
int argc, char** argv){
pl = pluginlink;
if(!ssl_loaded){
ssl_loaded = 1;
+7 -9
View File
@@ -151,8 +151,6 @@ static int restore_old_table(void * v)
/*-------------------------------------------------------------------*/
#ifdef _WIN32
__declspec(dllexport) int start(struct pluginlink * pluginlink,
int argc, char** argv);
BOOL WINAPI DllMain( HINSTANCE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
@@ -165,17 +163,17 @@ BOOL WINAPI DllMain( HINSTANCE hModule,
}
return TRUE;
}
#else
int start(struct pluginlink * pluginlink,
int argc, char** argv);
#endif
#ifdef WATCOM
#pragma aux start "*" parm caller [ ] value struct float struct routine [eax] modify [eax ecx edx]
#undef PLUGINCALL
#define PLUGINCALL
#endif
/*---------------------- start plugin init ------------------------------ */
int start(struct pluginlink * pluginlink, int argc, char** argv)
PLUGINAPI int PLUGINCALL start(struct pluginlink * pluginlink,
int argc, char** argv)
{
FILE *f=NULL;
+8 -3
View File
@@ -266,11 +266,16 @@ BOOL WINAPI DllMain( HINSTANCE hModule,
return TRUE;
}
__declspec(dllexport)
#endif
int start(struct pluginlink * pluginlink, int argc, char** argv) {
#ifdef WATCOM
#pragma aux start "*" parm caller [ ] value struct float struct routine [eax] modify [eax ecx edx]
#undef PLUGINCALL
#define PLUGINCALL
#endif
PLUGINAPI int PLUGINCALL start(struct pluginlink * pluginlink, int argc, char** argv) {
struct commands * starthandler;
conf = pluginlink->conf;
commandhandlers = pluginlink->commandhandlers;
@@ -89,11 +89,13 @@ static struct filter transparent_filter = {
};
#ifdef _WIN32
__declspec(dllexport)
#ifdef WATCOM
#pragma aux transparent_plugin "*" parm caller [ ] value struct float struct routine [eax] modify [eax ecx edx]
#undef PLUGINCALL
#define PLUGINCALL
#endif
int transparent_plugin (struct pluginlink * pluginlink,
PLUGINAPI int PLUGINCALL transparent_plugin (struct pluginlink * pluginlink,
int argc, char** argv){
pl = pluginlink;
if(!transparent_loaded){
@@ -15,10 +15,6 @@
extern "C" {
#endif
__declspec(dllexport) int WindowsAuthentication(struct pluginlink * pluginlink,
int argc, char** argv);
static struct auth alwaysauth;
static char sidbuf[4096];
@@ -62,12 +58,13 @@ extern "C" {
return 7;
}
#ifdef __cplusplus
}
#ifdef WATCOM
#pragma aux WindowsAuthentication "*" parm caller [ ] value struct float struct routine [eax] modify [eax ecx edx]
#undef PLUGINCALL
#define PLUGINCALL
#endif
int WindowsAuthentication(struct pluginlink * pluginlink, int argc, char** argv){
PLUGINAPI int PLUGINCALL WindowsAuthentication(struct pluginlink * pluginlink, int argc, char** argv){
char tmpbuf[4096];
DWORD dlen, sidlen;
SID_NAME_USE snu;
@@ -91,4 +88,7 @@ int WindowsAuthentication(struct pluginlink * pluginlink, int argc, char** argv)
return 0;
}
#ifdef __cplusplus
}
#endif
+9 -7
View File
@@ -14,9 +14,6 @@
extern "C" {
#endif
__declspec(dllexport) int utf8tocp1251(struct pluginlink * pluginlink,
int argc, char** argv);
static struct auth alwaysauth;
@@ -64,12 +61,14 @@ unsigned char * conv_utf8_to_cp1251(unsigned char *s){
return 4;
}
#ifdef __cplusplus
}
#ifdef WATCOM
#pragma aux utf8tocp1251 "*" parm caller [ ] value struct float struct routine [eax] modify [eax ecx edx]
#undef PLUGINCALL
#define PLUGINCALL
#endif
int utf8tocp1251(struct pluginlink * pluginlink, int argc, char** argv){
PLUGINAPI int PLUGINCALL utf8tocp1251(struct pluginlink * pluginlink, int argc, char** argv){
static int loaded = 0;
@@ -85,4 +84,7 @@ int utf8tocp1251(struct pluginlink * pluginlink, int argc, char** argv){
}
#ifdef __cplusplus
}
#endif
+1 -1
View File
@@ -48,7 +48,7 @@ void * pop3pchild(struct clientparam* param) {
CLEANRET:
if(param->hostname&&param->extusername) {
sprintf((char *)buf, "%.64s@%.128s%c%hu", param->extusername, param->hostname, (*SAPORT(&param->sinsr)==110)?0:':', ntohs(*SAPORT(&param->sinsr)));
sprintf((char *)buf, "%.128s@%.128s%c%hu", param->extusername, param->hostname, (*SAPORT(&param->sinsr)==110)?0:':', ntohs(*SAPORT(&param->sinsr)));
(*param->srv->logfunc)(param, buf);
}
else (*param->srv->logfunc)(param, NULL);
+14 -7
View File
@@ -131,8 +131,8 @@ char * proxy_stringtable[] = {
NULL
};
#define BUFSIZE 8192
#define LINESIZE 4096
#define BUFSIZE (LINESIZE*2)
#define FTPBUFSIZE 1536
static void logurl(struct clientparam * param, char * buf, char * req, int ftp){
@@ -152,7 +152,7 @@ static void logurl(struct clientparam * param, char * buf, char * req, int ftp){
strcpy(se, sb);
}
}
if(param->res != 555)(*param->srv->logfunc)(param, (unsigned char *)(req?buf:NULL));
if(param->res != 555 && param->res != 508)(*param->srv->logfunc)(param, (unsigned char *)(req?buf:NULL));
}
void decodeurl(unsigned char *s, int allowcr){
@@ -264,6 +264,9 @@ for(;;){
param->remsock = INVALID_SOCKET;
param->redirected = 0;
param->redirtype = 0;
memset(&param->sinsl, 0, sizeof(param->sinsl));
memset(&param->sinsr, 0, sizeof(param->sinsr));
memset(&param->req, 0, sizeof(param->req));
}
}
@@ -275,7 +278,7 @@ for(;;){
buf[i] = 0;
if(req) {
if(!param->transparent && !param->srv->transparent && param->redirtype != R_HTTP && (i<=prefix || strncasecmp((char *)buf, (char *)req, prefix))){
if(!param->transparent && !param->srv->transparent && (i<=prefix || strncasecmp((char *)buf, (char *)req, prefix))){
ckeepalive = 0;
if(param->remsock != INVALID_SOCKET){
so._shutdown(param->remsock, SHUT_RDWR);
@@ -284,6 +287,9 @@ for(;;){
param->remsock = INVALID_SOCKET;
param->redirected = 0;
param->redirtype = 0;
memset(&param->sinsl, 0, sizeof(param->sinsl));
memset(&param->sinsr, 0, sizeof(param->sinsr));
memset(&param->req, 0, sizeof(param->req));
}
myfree(req);
}
@@ -330,10 +336,10 @@ for(;;){
if(su) {
su = (unsigned char *)mystrdup((char *)sb);
decodeurl(su, 0);
parseconnusername((char *)su, (struct clientparam *)param, 1, (unsigned short)((ftp)?21:80));
if(parseconnusername((char *)su, (struct clientparam *)param, 1, (unsigned short)((ftp)?21:80))) RETURN (100);
myfree(su);
}
else parsehostname((char *)sb, (struct clientparam *)param, (unsigned short)((ftp)? 21:80));
else if(parsehostname((char *)sb, (struct clientparam *)param, (unsigned short)((ftp)? 21:80))) RETURN(100);
if(!isconnect){
if(se==sg)*se-- = ' ';
*se = '/';
@@ -454,7 +460,7 @@ for(;;){
*se = 0;
}
if(!param->hostname){
parsehostname((char *)sb, param, 80);
if(parsehostname((char *)sb, param, 80)) RETURN(100);
}
newbuf = myalloc(strlen((char *)req) + strlen((char *)(buf+inbuf)) + 8);
if(newbuf){
@@ -546,6 +552,7 @@ for(;;){
#endif
if(param->srv->needuser > 1 && !param->username) {RETURN(4);}
if((res = (*param->srv->authfunc)(param))) {RETURN(res);}
if(ftp && param->redirtype != R_HTTP){
@@ -843,7 +850,7 @@ for(;;){
if(keepalive <= 1) sprintf((char*)buf+strlen((char *)buf), "%s: %s\r\n", (param->redirtype == R_HTTP)?"Proxy-Connection":"Connection", keepalive? "keep-alive":"close");
if(param->extusername){
sprintf((char*)buf + strlen((char *)buf), "%s: basic ", (redirect)?"Proxy-Authorization":"Authorization");
sprintf((char*)username, "%.128s:%.64s", param->extusername, param->extpassword?param->extpassword:(unsigned char*)"");
sprintf((char*)username, "%.128s:%.128s", param->extusername, param->extpassword?param->extpassword:(unsigned char*)"");
en64(username, buf+strlen((char *)buf), (int)strlen((char *)username));
sprintf((char*)buf + strlen((char *)buf), "\r\n");
}
+5 -15
View File
@@ -21,7 +21,6 @@
#include <ctype.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/timeb.h>
#include <fcntl.h>
#include <time.h>
@@ -30,22 +29,14 @@
#define _PASSWORD_LEN 256
#define MAXNSERVERS 5
#define ALLOW 0
#define DENY 1
#define REDIRECT 2
#define BANDLIM 3
#define NOBANDLIM 4
#define COUNTIN 5
#define NOCOUNTIN 6
#define COUNTOUT 7
#define NOCOUNTOUT 8
#define UDPBUFSIZE 16384
#define TCPBUFSIZE 8192
#define SRVBUFSIZE (param->srv->bufsize?param->srv->bufsize:((param->service == S_UDPPM)?UDPBUFSIZE:TCPBUFSIZE))
#ifdef _WIN32
#include <winsock2.h>
#include <sys/timeb.h>
#ifndef _WINCE
#include <io.h>
#else
@@ -104,7 +95,7 @@
#define PTHREAD_STACK_MIN 32768
#define sockerror strerror
#endif
#define daemonize() {if(fork())exit(0); else setsid();}
void daemonize(void);
#define SLEEPTIME 1000
#ifndef O_BINARY
#define O_BINARY 0
@@ -188,7 +179,7 @@ unsigned bandlimitfunc(struct clientparam *param, unsigned nbytesin, unsigned nb
int scanaddr(const unsigned char *s, unsigned long * ip, unsigned long * mask);
int myinet_ntop(int af, void *src, char *dst, socklen_t size);
extern struct nserver nservers[MAXNSERVERS];
struct nserver authnserver;
extern struct nserver authnserver;
unsigned long getip(unsigned char *name);
unsigned long getip46(int family, unsigned char *name, struct sockaddr *sa);
unsigned long myresolver(int, unsigned char *, unsigned char *);
@@ -233,7 +224,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, unsigned char *host, struct sockaddr *sa);
int parsehost(int family, unsigned char *host, struct sockaddr *sa);
int parsehostname(char *hostname, struct clientparam *param, unsigned short port);
int parseusername(char *username, struct clientparam *param, int extpasswd);
int parseconnusername(char *username, struct clientparam *param, int extpasswd, unsigned short port);
@@ -314,7 +305,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 struct datatype datatypes[64];
extern struct commands commandhandlers[];
+17 -13
View File
@@ -9,7 +9,6 @@
#include "proxy.h"
pthread_mutex_t log_mutex;
int logmutexinit = 0;
#define param ((struct clientparam *) p)
#ifdef _WIN32
@@ -180,11 +179,6 @@ int MODULEMAINFUNC (int argc, char** argv){
#endif
#endif
if(!logmutexinit){
pthread_mutex_init(&log_mutex, NULL);
logmutexinit = 1;
}
srvinit(&srv, &defparam);
srv.pf = childdef.pf;
isudp = childdef.isudp;
@@ -202,6 +196,7 @@ int MODULEMAINFUNC (int argc, char** argv){
}
#else
srv.needuser = 0;
pthread_mutex_init(&log_mutex, NULL);
#endif
for (i=1; i<argc; i++) {
@@ -514,7 +509,7 @@ int MODULEMAINFUNC (int argc, char** argv){
for (;;) {
for(;;){
while((conf.paused == srv.version && srv.childcount >= srv.maxchild)){
while((conf.paused == srv.paused && srv.childcount >= srv.maxchild)){
nlog++;
if(!srv.silent && nlog > 5000) {
sprintf((char *)buf, "Warning: too many connected clients (%d/%d)", srv.childcount, srv.maxchild);
@@ -524,7 +519,7 @@ int MODULEMAINFUNC (int argc, char** argv){
usleep(SLEEPTIME);
}
if (iscbc) break;
if (conf.paused != srv.version) break;
if (conf.paused != srv.paused) break;
if (srv.fds.events & POLLIN) {
error = so._poll(&srv.fds, 1, 1000);
}
@@ -540,7 +535,7 @@ int MODULEMAINFUNC (int argc, char** argv){
break;
}
}
if((conf.paused != srv.version) || (error < 0)) break;
if((conf.paused != srv.paused) || (error < 0)) break;
error = 0;
if(!isudp){
size = sizeof(defparam.sincr);
@@ -638,7 +633,7 @@ int MODULEMAINFUNC (int argc, char** argv){
continue;
};
*newparam = defparam;
if(defparam.hostname)newparam->hostname=(unsigned char *)strdup((char *)defparam.hostname);
if(defparam.hostname)newparam->hostname=(unsigned char *)mystrdup((char *)defparam.hostname);
clearstat(newparam);
if(!isudp) newparam->clisock = new_sock;
#ifndef STDMAIN
@@ -648,6 +643,7 @@ int MODULEMAINFUNC (int argc, char** argv){
}
#endif
newparam->prev = newparam->next = NULL;
error = 0;
pthread_mutex_lock(&srv.counter_mutex);
if(!srv.child){
srv.child = newparam;
@@ -670,7 +666,7 @@ int MODULEMAINFUNC (int argc, char** argv){
else {
sprintf((char *)buf, "_beginthreadex(): %s", _strerror(NULL));
if(!srv.silent)(*srv.logfunc)(&defparam, buf);
freeparam(newparam);
error = 1;
}
#else
@@ -679,13 +675,14 @@ int MODULEMAINFUNC (int argc, char** argv){
if(error){
sprintf((char *)buf, "pthread_create(): %s", strerror(error));
if(!srv.silent)(*srv.logfunc)(&defparam, buf);
freeparam(newparam);
}
else {
newparam->threadid = (unsigned)thread;
}
#endif
pthread_mutex_unlock(&srv.counter_mutex);
if(error) freeparam(newparam);
memset(&defparam.sincl, 0, sizeof(defparam.sincl));
memset(&defparam.sincr, 0, sizeof(defparam.sincr));
if(isudp) while(!srv.fds.events)usleep(SLEEPTIME);
@@ -704,6 +701,9 @@ int MODULEMAINFUNC (int argc, char** argv){
pthread_mutex_unlock(&config_mutex);
#endif
#ifndef _WIN32
pthread_attr_destroy(&pa);
#endif
if(defparam.hostname)myfree(defparam.hostname);
if(cbc_string)myfree(cbc_string);
if(cbl_string)myfree(cbl_string);
@@ -715,8 +715,10 @@ int MODULEMAINFUNC (int argc, char** argv){
void srvinit(struct srvparam * srv, struct clientparam *param){
memset(srv, 0, sizeof(struct srvparam));
srv->version = conf.paused;
srv->version = conf.version + 1;
srv->paused = conf.paused;
srv->logfunc = conf.logfunc;
srv->noforce = conf.noforce;
if(srv->logformat)myfree(srv->logformat);
srv->logformat = conf.logformat? (unsigned char *)mystrdup((char *)conf.logformat) : NULL;
srv->authfunc = conf.authfunc;
@@ -735,6 +737,8 @@ void srvinit(struct srvparam * srv, struct clientparam *param){
srv->needuser = 1;
memset(param, 0, sizeof(struct clientparam));
param->srv = srv;
param->version = srv->version;
param->paused = srv->paused;
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);
+1 -1
View File
@@ -291,7 +291,7 @@ void * smtppchild(struct clientparam* param) {
CLEANRET:
if(param->hostname&&param->extusername) {
sprintf((char *)buf, "%.64s@%.128s%c%hu", param->extusername, param->hostname, *SAPORT(&param->sinsr)==25?0:':',ntohs(*SAPORT(&param->sinsr)));
sprintf((char *)buf, "%.128s@%.128s%c%hu", param->extusername, param->hostname, *SAPORT(&param->sinsr)==25?0:':',ntohs(*SAPORT(&param->sinsr)));
(*param->srv->logfunc)(param, buf);
}
else (*param->srv->logfunc)(param, NULL);
+3 -6
View File
@@ -7,9 +7,6 @@
#include "proxy.h"
#define BUFSIZE (param->srv->bufsize?param->srv->bufsize:((param->service == S_UDPPM)?UDPBUFSIZE:TCPBUFSIZE))
int socksend(SOCKET sock, unsigned char * buf, int bufsize, int to){
int sent = 0;
int res;
@@ -75,8 +72,8 @@ int sockgetcharcli(struct clientparam * param, int timeosec, int timeousec){
int len;
if(!param->clibuf){
if(!(param->clibuf = myalloc(BUFSIZE))) return 0;
param->clibufsize = BUFSIZE;
if(!(param->clibuf = myalloc(SRVBUFSIZE))) return 0;
param->clibufsize = SRVBUFSIZE;
param->clioffset = param->cliinbuf = 0;
}
if(param->cliinbuf && param->clioffset < param->cliinbuf){
@@ -137,7 +134,7 @@ int sockgetcharsrv(struct clientparam * param, int timeosec, int timeousec){
int bufsize;
if(!param->srvbuf){
bufsize = BUFSIZE;
bufsize = SRVBUFSIZE;
if(param->ndatfilterssrv > 0 && bufsize < 32768) bufsize = 32768;
if(!(param->srvbuf = myalloc(bufsize))) return 0;
param->srvbufsize = bufsize;
+9 -3
View File
@@ -8,8 +8,6 @@
#include "proxy.h"
#define BUFSIZE (param->srv->bufsize?param->srv->bufsize:((param->service == S_UDPPM)?UDPBUFSIZE:TCPBUFSIZE))
int sockmap(struct clientparam * param, int timeo){
int res=0;
uint64_t sent=0, received=0;
@@ -21,13 +19,16 @@ int sockmap(struct clientparam * param, int timeo){
FILTER_ACTION action;
int retcode = 0;
bufsize = BUFSIZE;
bufsize = SRVBUFSIZE;
minsize = (param->service == S_UDPPM || param->service == S_TCPPM)? bufsize - 1 : (bufsize>>2);
fds[0].fd = param->clisock;
fds[1].fd = param->remsock;
if(param->cliinbuf == param->clioffset) param->cliinbuf = param->clioffset = 0;
if(param->srvinbuf == param->srvoffset) param->srvinbuf = param->srvoffset = 0;
#if DEBUGLEVEL > 2
(*param->srv->logfunc)(param, "Starting sockets mapping");
#endif
@@ -68,6 +69,11 @@ int sockmap(struct clientparam * param, int timeo){
while (!stop&&!conf.timetoexit){
sasize = sizeof(struct sockaddr_in);
if(param->version < conf.version){
if((res = (*param->srv->authfunc)(param)) && res != 2 && !param->srv->noforce) {return(res);}
param->paused = conf.paused;
param->version = conf.version;
}
if((param->maxtrafin64 && param->statssrv64 >= param->maxtrafin64) || (param->maxtrafout64 && param->statscli64 >= param->maxtrafout64)){
return (10);
}
+4 -4
View File
@@ -120,8 +120,8 @@ void * sockschild(struct clientparam* param) {
#ifndef NOIPV6
}
#endif
if(SAISNULL(&param->req)) {
RETURN(421);
if(command == 1 && SAISNULL(&param->req)) {
RETURN(431);
}
myinet_ntop(*SAFAMILY(&param->sinsr), SAADDR(&param->sinsr), (char *)buf, 64);
break;
@@ -164,7 +164,7 @@ void * sockschild(struct clientparam* param) {
}
*SAPORT(&param->sinsr) = *SAPORT(&param->req) = port;
if(command == 1 && !*SAPORT(&param->sinsr)) {RETURN(421);}
if(command == 1 && !*SAPORT(&param->sinsr)) {RETURN(461);}
switch(command) {
case 1:
param->operation = CONNECT;
@@ -376,7 +376,7 @@ fflush(stderr);
buf[i] = buf[i+1];
}
buf[i++] = 0;
if(!getip46(param->srv->family, buf, (struct sockaddr *) &param->sinsr)) RETURN(100);
if(!getip46(param->srv->family, buf+4, (struct sockaddr *) &param->sinsr)) RETURN(100);
break;
default:
RETURN(997);
+35 -7
View File
@@ -76,6 +76,18 @@ int
#endif
#define ALLOW 0
#define DENY 1
#define REDIRECT 2
#define BANDLIM 3
#define NOBANDLIM 4
#define COUNTIN 5
#define NOCOUNTIN 6
#define COUNTOUT 7
#define NOCOUNTOUT 8
#define CONNLIM 9
#define NOCONNLIM 10
#define CONNECT 0x00000001
#define BIND 0x00000002
#define UDPASSOC 0x00000004
@@ -162,7 +174,21 @@ typedef void (*TRAFCOUNTFUNC)(struct clientparam * param);
typedef void * (*EXTENDFUNC) (struct node *node);
typedef void (*CBFUNC)(void *cb, char * buf, int inbuf);
typedef void (*PRINTFUNC) (struct node *node, CBFUNC cbf, void*cb);
typedef int (*PLUGINFUNC) (struct pluginlink *pluginlink, int argc, char** argv);
#ifdef WIN32
#define PLUGINAPI __declspec(dllexport)
typedef int (__cdecl *PLUGINFUNC) (struct pluginlink *pluginlink, int argc, char** argv);
#define PLUGINCALL __cdecl
#else
#define PLUGINCALL
#define PLUGINAPI
typedef int (*PLUGINFUNC)(struct pluginlink *pluginlink, int argc, char** argv);
#endif
struct auth {
struct auth *next;
@@ -364,7 +390,7 @@ struct srvparam {
SOCKET srvsock, cbsock;
int childcount;
int maxchild;
int version;
int paused, version;
int singlepacket;
int usentlm;
int needuser;
@@ -373,6 +399,7 @@ struct srvparam {
int nfilters, nreqfilters, nhdrfilterscli, nhdrfilterssrv, npredatfilters, ndatfilterscli, ndatfilterssrv;
int family;
int stacksize;
int noforce;
unsigned bufsize;
unsigned logdumpsrv, logdumpcli;
#ifndef NOIPV6
@@ -429,7 +456,8 @@ struct clientparam {
int redirected,
operation,
nfilters, nreqfilters, nhdrfilterscli, nhdrfilterssrv, npredatfilters, ndatfilterscli, ndatfilterssrv,
unsafefilter;
unsafefilter,
bandlimver;
int res,
status;
@@ -440,7 +468,9 @@ struct clientparam {
nolongdatfilter,
nooverwritefilter,
transparent,
chunked;
chunked,
paused,
version;
unsigned char *hostname,
*username,
@@ -494,7 +524,7 @@ struct extparam {
struct trafcount * trafcounter;
struct srvparam *services;
int stacksize, threadinit, counterd, haveerror, rotate, paused, archiverc,
demon, maxchild, singlepacket, needreload, timetoexit;
demon, maxchild, singlepacket, needreload, timetoexit, version, noforce;
int authcachetype, authcachetime;
int filtermaxsize;
unsigned char *logname, **archiver;
@@ -749,8 +779,6 @@ typedef enum {
TYPE_SERVER
}DATA_TYPE;
#ifdef __cplusplus
}
#endif
+1 -1
View File
@@ -23,7 +23,7 @@ void * tcppmchild(struct clientparam* param) {
RETURN (sockmap(param, conf.timeouts[CONNECTION_L]));
CLEANRET:
(*param->srv->logfunc)(param, NULL);
(*param->srv->logfunc)(param, param->hostname);
freeparam(param);
return (NULL);
}
+2 -2
View File
@@ -1,2 +1,2 @@
#define VERSION "3proxy-0.8.4"
#define BUILDDATE "160228134701"
#define VERSION "3proxy-0.8.13"
#define BUILDDATE "190801174904"
+10 -10
View File
@@ -10,7 +10,7 @@
#define RETURN(xxx) { param->res = xxx; goto CLEANRET; }
#define LINESIZE 2048
#define LINESIZE 65536
extern FILE *writable;
FILE * confopen();
@@ -341,7 +341,7 @@ void * adminchild(struct clientparam* param) {
char *sb;
char *req = NULL;
struct printparam pp;
int contentlen = 0;
unsigned contentlen = 0;
int isform = 0;
pp.inbuf = 0;
@@ -390,7 +390,8 @@ void * adminchild(struct clientparam* param) {
else if(i > 15 && (!strncasecmp(buf, "content-length:", 15))){
sb = buf + 15;
while(isspace(*sb))sb++;
contentlen = atoi(sb);
sscanf(sb, "%u", &contentlen);
if(contentlen > LINESIZE*1024) contentlen = 0;
}
else if(i > 13 && (!strncasecmp(buf, "content-type:", 13))){
sb = buf + 13;
@@ -520,7 +521,7 @@ void * adminchild(struct clientparam* param) {
break;
}
printstr(&pp, "<h3>Please be careful editing config file remotely</h3>");
printstr(&pp, "<form method=\"POST\" action=\"/U\"><textarea cols=\"80\" rows=\"30\" name=\"conffile\">");
printstr(&pp, "<form method=\"POST\" action=\"/U\" enctype=\"application/x-www-form-urlencoded\"><textarea cols=\"80\" rows=\"30\" name=\"conffile\">");
while(fgets(buf, 256, fp)){
printstr(&pp, buf);
}
@@ -530,24 +531,23 @@ void * adminchild(struct clientparam* param) {
}
case 'U':
{
int l=0;
unsigned l=0;
int error = 0;
if(!writable || fseek(writable, 0, 0)){
if(!writable || !contentlen || fseek(writable, 0, 0)){
error = 1;
}
while((i = sockgetlinebuf(param, CLIENT, (unsigned char *)buf, LINESIZE - 1, '+', conf.timeouts[STRING_S])) > 0){
while(l < contentlen && (i = sockgetlinebuf(param, CLIENT, (unsigned char *)buf, (contentlen - l) > LINESIZE - 1?LINESIZE - 1:contentlen - l, '+', conf.timeouts[STRING_S])) > 0){
if(i > (contentlen - l)) i = (contentlen - l);
buf[i] = 0;
if(!l){
if(strncasecmp(buf, "conffile=", 9)) error = 1;
if(i<9 || strncasecmp(buf, "conffile=", 9)) error = 1;
}
if(!error){
buf[i] = 0;
decodeurl((unsigned char *)buf, 1);
fprintf(writable, "%s", l? buf : buf + 9);
}
l += i;
if(l >= contentlen) break;
}
if(writable && !error){
fflush(writable);