Compare commits

..
40 Commits
Author SHA1 Message Date
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
37 changed files with 6751 additions and 1914 deletions

No files matched your search

+5 -5
View File
@@ -2,8 +2,8 @@
1 VERSIONINFO 1 VERSIONINFO
FILEVERSION 0,8,7,0 FILEVERSION 0,8,12,0
PRODUCTVERSION 0,8,7,0 PRODUCTVERSION 0,8,12,0
FILETYPE 1 FILETYPE 1
FILESUBTYPE 0x0L FILESUBTYPE 0x0L
BEGIN BEGIN
@@ -14,12 +14,12 @@ BEGIN
VALUE "Comments", "3proxy - tiny proxy server, http://3proxy.ru/\0" VALUE "Comments", "3proxy - tiny proxy server, http://3proxy.ru/\0"
VALUE "CompanyName", "Vladimir Dubrovin\0" VALUE "CompanyName", "Vladimir Dubrovin\0"
VALUE "FileDescription", "3proxy - tiny proxy server\0" VALUE "FileDescription", "3proxy - tiny proxy server\0"
VALUE "FileVersion", "0.8.7\0" VALUE "FileVersion", "0.8.12\0"
VALUE "InternalName", "3proxy\0" VALUE "InternalName", "3proxy\0"
VALUE "LegalCopyright", "Copyright (C) 2002-2016 Vladimir Dubrovin\0" VALUE "LegalCopyright", "Copyright (C) 2002-2018 Vladimir Dubrovin\0"
VALUE "OriginalFilename", "3proxy.exe\0" VALUE "OriginalFilename", "3proxy.exe\0"
VALUE "ProductName", "3proxy\0" VALUE "ProductName", "3proxy\0"
VALUE "ProductVersion", "0.8.7\0" VALUE "ProductVersion", "0.8.12\0"
END END
END END
BLOCK "VarFileInfo" BLOCK "VarFileInfo"
+3 -3
View File
@@ -4,17 +4,17 @@
# You can try to remove -DWITH_STD_MALLOC to CFLAGS to use optimized malloc # You can try to remove -DWITH_STD_MALLOC to CFLAGS to use optimized malloc
# libraries # libraries
# #
# remove -DNOODBC from CFLAGS and add -lodbc to LDFLAGS to compile with ODBC # remove -DNOODBC from CFLAGS and add -lodbc to LIBS to compile with ODBC
# library support. Add -DSAFESQL for poorely written ODBC library / drivers. # library support. Add -DSAFESQL for poorely written ODBC library / drivers.
BUILDDIR = BUILDDIR =
CC = gcc CC = gcc
CFLAGS = -g -O2 -c -pthread -DGETHOSTBYNAME_R -D_THREAD_SAFE -D_REENTRANT -DNOODBC -DWITH_STD_MALLOC -DFD_SETSIZE=4096 -DWITH_POLL CFLAGS = -g -O2 -fno-strict-aliasing -c -pthread -DGETHOSTBYNAME_R -D_THREAD_SAFE -D_REENTRANT -DNOODBC -DWITH_STD_MALLOC -DFD_SETSIZE=4096 -DWITH_POLL
COUT = -o COUT = -o
LN = gcc LN = gcc
DCFLAGS = -fpic DCFLAGS = -fpic
LDFLAGS = -O2 -pthread LDFLAGS = -O2 -fno-strict-aliasing -pthread
DLFLAGS = -shared DLFLAGS = -shared
DLSUFFICS = .ld.so DLSUFFICS = .ld.so
# -lpthreads may be reuqired on some platforms instead of -pthreads # -lpthreads may be reuqired on some platforms instead of -pthreads
+1 -1
View File
@@ -10,7 +10,7 @@
BUILDDIR = BUILDDIR =
CC = gcc CC = gcc
CFLAGS = -O3 -c -D_SOLARIS -D_THREAD_SAFE -DGETHOSTBYNAME_R -D_REENTRANT -DNOODBC -DWITH_STD_MALLOC -DFD_SETSIZE=4096 -DWITH_POLL CFLAGS = -O2 -fno-strict-aliasing -c -D_SOLARIS -D_THREAD_SAFE -DGETHOSTBYNAME_R -D_REENTRANT -DNOODBC -DWITH_STD_MALLOC -DFD_SETSIZE=4096 -DWITH_POLL
COUT = -o ./ COUT = -o ./
LN = gcc LN = gcc
LDFLAGS = -O3 LDFLAGS = -O3
+2 -2
View File
@@ -10,10 +10,10 @@
BUILDDIR = ../bin/ BUILDDIR = ../bin/
CC = clang 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 COUT = -o
LN = clang LN = clang
LDFLAGS = -O2 -static -s LDFLAGS = -O2 -fno-strict-aliasing -static -s
DLFLAGS = -shared DLFLAGS = -shared
DLSUFFICS = .dll DLSUFFICS = .dll
LIBS = -lws2_32 -lodbc32 -ladvapi32 LIBS = -lws2_32 -lodbc32 -ladvapi32
+2 -2
View File
@@ -11,10 +11,10 @@ BUILDDIR =
CC = gcc CC = gcc
# you may need -L/usr/pkg/lib for older NetBSD versions # you may need -L/usr/pkg/lib for older NetBSD versions
CFLAGS = -g -O2 -c -pthread -D_THREAD_SAFE -D_REENTRANT -DNOODBC -DWITH_STD_MALLOC -DFD_SETSIZE=4096 -DWITH_POLL CFLAGS = -g -O2 -fno-strict-aliasing -c -pthread -D_THREAD_SAFE -D_REENTRANT -DNOODBC -DWITH_STD_MALLOC -DFD_SETSIZE=4096 -DWITH_POLL
COUT = -o COUT = -o
LN = gcc LN = gcc
LDFLAGS = -O2 -pthread LDFLAGS = -O2 -fno-strict-aliasing -pthread
# -lpthreads may be reuqired on some platforms instead of -pthreads # -lpthreads may be reuqired on some platforms instead of -pthreads
# -ldl or -lld may be required for some platforms # -ldl or -lld may be required for some platforms
DCFLAGS = -fpic DCFLAGS = -fpic
+1 -1
View File
@@ -8,7 +8,7 @@
BUILDDIR = ../bin/ BUILDDIR = ../bin/
CC = cl CC = cl
CFLAGS = /nologo /Ox /MT /D "NOIPV6" /D "NODEBUG" /D "NOODBC" /D "MSVC" /D "WITH_STD_MALLOC" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "_WIN32" /c 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 COUT = /Fo
LN = link LN = link
LDFLAGS = /nologo /subsystem:console /incremental:no LDFLAGS = /nologo /subsystem:console /incremental:no
+1 -1
View File
@@ -37,7 +37,7 @@ users 3APA3A:CL:3apa3a "test:CR:$1$qwer$CHFTUFGqkjue9HyhcMHEe1"
service service
# service is required under NT if you want 3proxy to start as service # service is required under NT if you want 3proxy to start as service
#log /usr/local/etc/3proxy/logs/3proxy.log D #log /var/log/3proxy/log D
log c:\3proxy\logs\3proxy.log D log c:\3proxy\logs\3proxy.log D
# log allows to specify log file location and rotation, D means logfile # log allows to specify log file location and rotation, D means logfile
# is created daily # is created daily
+6507 -1738
View File
File diff suppressed because it is too large. Load diff
+11
View File
@@ -736,6 +736,17 @@ nolog
.br .br
Weight may be used for different purposes. Weight may be used for different purposes.
.br
.B force
.br
.B noforce
.br
If force is specified for service, configuration reload will require all current
sessions of this service to be re-authenticated. If ACL is changed or user account
is removed, old connections which do not match current are closed.
noforce allows to keep previously authenticated connections.
.br .br
.B bandlimin .B bandlimin
<rate> <userlist> <sourcelist> <targetlist> <targetportlist> <operationlist> <rate> <userlist> <sourcelist> <targetlist> <targetportlist> <operationlist>
+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/passwd
monitor /usr/local/etc/3proxy/bandlimiters monitor /usr/local/etc/3proxy/bandlimiters
log /usr/local/etc/3proxy/log/log D log /var/log/3proxy/log D
rotate 60 rotate 60
counter /usr/local/etc/3proxy/3proxy.3cf counter /usr/local/etc/3proxy/3proxy.3cf
+36 -18
View File
@@ -19,10 +19,9 @@ int clientnegotiate(struct chain * redir, struct clientparam * param, struct soc
user = redir->extuser; user = redir->extuser;
pass = redir->extpass; pass = redir->extpass;
if (param->srvinbuf < 4096){ if (!param->srvbufsize){
if(param->srvbuf)myfree(param->srvbuf); param->srvbufsize = SRVBUFSIZE;
param->srvbuf = myalloc(4096); param->srvbuf = myalloc(param->srvbufsize);
param->srvbufsize = 4096;
} }
buf = param->srvbuf; buf = param->srvbuf;
username = buf + 2048; username = buf + 2048;
@@ -190,11 +189,21 @@ int clientnegotiate(struct chain * redir, struct clientparam * param, struct soc
if(buf[1] != 0) { if(buf[1] != 0) {
return 60 + (buf[1] % 10); return 60 + (buf[1] % 10);
} }
if(buf[3] != 1) { switch (buf[3]) {
return 58; case 1:
} if (redir->type == R_SOCKS5B || sockgetlinebuf(param, SERVER, buf, 6, EOF, conf.timeouts[CHAIN_TO]) == 6)
if (redir->type != R_SOCKS5B && sockgetlinebuf(param, SERVER, buf, 6, EOF, conf.timeouts[CHAIN_TO]) != 6){ break;
return 59; return 59;
case 3:
if (sockgetlinebuf(param, SERVER, buf, 256, 0, conf.timeouts[CHAIN_TO]) > 1)
break;
return 59;
case 4:
if (sockgetlinebuf(param, SERVER, buf, 18, EOF, conf.timeouts[CHAIN_TO]) == 18)
break;
return 59;
default:
return 58;
} }
return 0; return 0;
} }
@@ -476,8 +485,14 @@ unsigned bandlimitfunc(struct clientparam *param, unsigned nbytesin, unsigned nb
if(!nbytesin && !nbytesout) return 0; if(!nbytesin && !nbytesout) return 0;
pthread_mutex_lock(&bandlim_mutex); pthread_mutex_lock(&bandlim_mutex);
if(param->paused != conf.paused){ if(param->paused != conf.paused && param->bandlimver != conf.paused){
return (1); 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++){ for(i=0; nbytesin&& i<MAXBANDLIMS && param->bandlims[i]; i++){
if( !param->bandlims[i]->basetime || if( !param->bandlims[i]->basetime ||
@@ -774,10 +789,14 @@ int dnsauth(struct clientparam * param){
((u&0xFF000000)>>24)); ((u&0xFF000000)>>24));
} }
if(!udpresolve(*SAFAMILY(&param->sincr), (unsigned char *)buf, (unsigned char *)addr, NULL, param, 1)) return 6; if(!udpresolve(*SAFAMILY(&param->sincr), (unsigned char *)buf, (unsigned char *)addr, NULL, param, 1)) {
if(!memcmp(SAADDR(&param->sincr), addr, SAADDRLEN(&param->sincr))) return 6; 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){ int strongauth(struct clientparam * param){
@@ -1151,6 +1170,8 @@ unsigned long udpresolve(int af, unsigned char * name, unsigned char * value, un
k += 4; k += 4;
if(na > 255) na = 255; /* somebody is very evil */ if(na > 255) na = 255; /* somebody is very evil */
for (j = 0; j < na; j++) { /* now there should be answers */ for (j = 0; j < na; j++) { /* now there should be answers */
while(buf[k] < 192 && buf[k] !=0 && (k+buf[k]+14) < len) k+= (buf[k] + 1);
if(!buf[k]) k--;
if((k+(af == AF_INET6?28:16)) > len) { if((k+(af == AF_INET6?28:16)) > len) {
break; break;
} }
@@ -1166,10 +1187,7 @@ unsigned long udpresolve(int af, unsigned char * name, unsigned char * value, un
ttl = ntohl(*(unsigned long *)(buf + k + 6)); ttl = ntohl(*(unsigned long *)(buf + k + 6));
memcpy(value, buf + k + 12, af == AF_INET6? 16:4); memcpy(value, buf + k + 12, af == AF_INET6? 16:4);
if(ttl < 60 || ttl > (3600*12)) ttl = 300; if(ttl < 60 || ttl > (3600*12)) ttl = 300;
if(ttl){ hashadd(af == AF_INET6?&dns6_table:&dns_table, name, value, conf.time+ttl);
hashadd(af == AF_INET6?&dns6_table:&dns_table, name, value, conf.time+ttl);
}
if(retttl) *retttl = ttl; if(retttl) *retttl = ttl;
return 1; return 1;
} }
+3 -4
View File
@@ -468,7 +468,7 @@ int dobuf2(struct clientparam * param, unsigned char * buf, const unsigned char
break; break;
case 'n': case 'n':
len = param->hostname? (int)strlen((char *)param->hostname) : 0; len = param->hostname? (int)strlen((char *)param->hostname) : 0;
if (len > 0 && !strchr((char *)param->hostname, ':')) for(len = 0; param->hostname[len] && i < 4000; len++, i++){ if (len > 0 && !strchr((char *)param->hostname, ':')) for(len = 0; param->hostname[len] && i < 256; len++, i++){
buf[i] = param->hostname[len]; buf[i] = param->hostname[len];
if(param->srv->nonprintable && (buf[i] < 0x20 || strchr((char *)param->srv->nonprintable, buf[i]))) buf[i] = param->srv->replace; if(param->srv->nonprintable && (buf[i] < 0x20 || strchr((char *)param->srv->nonprintable, buf[i]))) buf[i] = param->srv->replace;
if(doublec && strchr((char *)doublec, buf[i])) { if(doublec && strchr((char *)doublec, buf[i])) {
@@ -480,7 +480,6 @@ int dobuf2(struct clientparam * param, unsigned char * buf, const unsigned char
buf[i++] = '['; buf[i++] = '[';
i += myinet_ntop(*SAFAMILY(&param->req), SAADDR(&param->req), (char *)buf + i, 64); i += myinet_ntop(*SAFAMILY(&param->req), SAADDR(&param->req), (char *)buf + i, 64);
buf[i++] = ']'; buf[i++] = ']';
buf[i++] = 0;
} }
break; break;
@@ -651,8 +650,8 @@ int doconnect(struct clientparam * param){
SASIZETYPE size; SASIZETYPE size;
if (*SAFAMILY(&param->sincr) == *SAFAMILY(&param->req) && !memcmp(SAADDR(&param->sincr), SAADDR(&param->req), SAADDRLEN(&param->req)) && if (*SAFAMILY(&param->sincl) == *SAFAMILY(&param->req) && !memcmp(SAADDR(&param->sincl), SAADDR(&param->req), SAADDRLEN(&param->req)) &&
*SAPORT(&param->sincr) == *SAPORT(&param->req)) return 519; *SAPORT(&param->sincl) == *SAPORT(&param->req)) return 519;
if (param->operation == ADMIN || param->operation == DNSRESOLVE || param->operation == BIND || param->operation == UDPASSOC) if (param->operation == ADMIN || param->operation == DNSRESOLVE || param->operation == BIND || param->operation == UDPASSOC)
return 0; return 0;
+1 -1
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_setstacksize(&pa,PTHREAD_STACK_MIN + (16384+conf.stacksize));
pthread_attr_setdetachstate(&pa,PTHREAD_CREATE_DETACHED); pthread_attr_setdetachstate(&pa,PTHREAD_CREATE_DETACHED);
pthread_create(&thread, &pa, startsrv, (void *)chp); pthread_create(&thread, &pa, startsrv, (void *)chp);
pthread_attr_destroy(&pa);
#endif #endif
while(conf.threadinit)usleep(SLEEPTIME); while(conf.threadinit)usleep(SLEEPTIME);
if(haveerror) { if(haveerror) {
@@ -279,7 +280,6 @@ static int h_external(int argc, unsigned char ** argv){
else conf.extsa6 = sa6; else conf.extsa6 = sa6;
#else #else
res = getip46(46, argv[1], (struct sockaddr *)&conf.extsa); res = getip46(46, argv[1], (struct sockaddr *)&conf.extsa);
if(!res) return 1;
#endif #endif
return 0; return 0;
} }
+19 -17
View File
@@ -75,7 +75,7 @@ static void pr_sa(struct node *node, CBFUNC cbf, void*cb){
char buf[64]; char buf[64];
buf[0] = '['; buf[0] = '[';
buf[1] = 0; buf[1] = 0;
inet_ntop(*SAFAMILY(node->value), node->value, buf+1, sizeof(buf)-10); inet_ntop(*SAFAMILY(node->value), SAADDR(node->value), buf+1, sizeof(buf)-10);
sprintf(buf + strlen(buf), "]:%hu", (unsigned short)*SAPORT(node->value)); sprintf(buf + strlen(buf), "]:%hu", (unsigned short)*SAPORT(node->value));
if(node->value)(*cbf)(cb, buf, strlen(buf)); if(node->value)(*cbf)(cb, buf, strlen(buf));
#endif #endif
@@ -743,21 +743,23 @@ static struct property prop_server[] = {
{prop_server + 2, "target", ef_server_target, TYPE_STRING, "portmapper target ip"}, {prop_server + 2, "target", ef_server_target, TYPE_STRING, "portmapper target ip"},
{prop_server + 3, "targetport", ef_server_targetport, TYPE_PORT, "portmapper target port"}, {prop_server + 3, "targetport", ef_server_targetport, TYPE_PORT, "portmapper target port"},
{prop_server + 4, "starttime", ef_server_starttime, TYPE_DATETIME, "service started seconds"}, {prop_server + 4, "starttime", ef_server_starttime, TYPE_DATETIME, "service started seconds"},
{prop_server + 5, "intsa", ef_server_intsa, TYPE_SA, "ip address of internal interface"}, {prop_server + 5, "auth", ef_server_auth, TYPE_STRING, "service authentication type"},
{prop_server + 6, "extsa", ef_server_extsa, TYPE_SA, "ip address of external interface"}, {prop_server + 6, "acl", ef_server_acl, TYPE_ACE, "access control list"},
{prop_server + 7, "auth", ef_server_auth, TYPE_STRING, "service authentication type"}, {prop_server + 7, "singlepacket", ef_server_singlepacket, TYPE_INTEGER, "is single packet redirection"},
{prop_server + 8, "acl", ef_server_acl, TYPE_ACE, "access control list"}, {prop_server + 8, "usentlm", ef_server_usentlm, TYPE_INTEGER, "allow NTLM authentication"},
{prop_server + 9, "singlepacket", ef_server_singlepacket, TYPE_INTEGER, "is single packet redirection"}, {prop_server + 9, "log", ef_server_log, TYPE_STRING, "type of logging"},
{prop_server + 10, "usentlm", ef_server_usentlm, TYPE_INTEGER, "allow NTLM authentication"}, {prop_server + 10, "logtarget", ef_server_logtarget, TYPE_STRING, "log target options"},
{prop_server + 11, "log", ef_server_log, TYPE_STRING, "type of logging"}, {prop_server + 11, "logformat", ef_server_logformat, TYPE_STRING, "logging format string"},
{prop_server + 12, "logtarget", ef_server_logtarget, TYPE_STRING, "log target options"}, {prop_server + 12, "nonprintable", ef_server_nonprintable, TYPE_STRING, "non printable characters"},
{prop_server + 13, "logformat", ef_server_logformat, TYPE_STRING, "logging format string"}, {prop_server + 13, "replacement", ef_server_replacement, TYPE_CHAR, "replacement character"},
{prop_server + 14, "nonprintable", ef_server_nonprintable, TYPE_STRING, "non printable characters"}, {prop_server + 14, "childcount", ef_server_childcount, TYPE_INTEGER, "number of servers connected"},
{prop_server + 15, "replacement", ef_server_replacement, TYPE_CHAR, "replacement character"}, {prop_server + 15, "intsa", ef_server_intsa, TYPE_SA, "ip address of internal interface"},
{prop_server + 16, "childcount", ef_server_childcount, TYPE_INTEGER, "number of servers connected"}, {prop_server + 16, "extsa", ef_server_extsa, TYPE_SA, "ip address of external interface"},
{prop_server + 17, "child", ef_server_child, TYPE_CLIENT, "connected clients"},
#ifndef NOIPV6 #ifndef NOIPV6
{prop_server + 18, "extsa6", ef_server_extsa6, TYPE_SA, "ipv6 address of external interface"}, {prop_server + 17, "extsa6", ef_server_extsa6, TYPE_SA, "ipv6 address of external interface"},
{prop_server + 18, "child", ef_server_child, TYPE_CLIENT, "connected clients"},
#else
{prop_server + 17, "child", ef_server_child, TYPE_CLIENT, "connected clients"},
#endif #endif
{NULL, "next", ef_server_next, TYPE_SERVER, "next"} {NULL, "next", ef_server_next, TYPE_SERVER, "next"}
}; };
@@ -776,8 +778,8 @@ static struct property prop_client[] = {
{prop_client + 10, "username", ef_client_username, TYPE_STRING, "client username"}, {prop_client + 10, "username", ef_client_username, TYPE_STRING, "client username"},
{prop_client + 11, "password", ef_client_password, TYPE_STRING, "client password"}, {prop_client + 11, "password", ef_client_password, TYPE_STRING, "client password"},
{prop_client + 12, "clisa", ef_client_clisa, TYPE_SA, "client sa"}, {prop_client + 12, "clisa", ef_client_clisa, TYPE_SA, "client sa"},
{prop_client + 13, "srvsa", ef_client_srvsa, TYPE_IP, "target server sa"}, {prop_client + 13, "srvsa", ef_client_srvsa, TYPE_SA, "target server sa"},
{prop_client + 14, "reqsa", ef_client_reqsa, TYPE_IP, "requested server sa"}, {prop_client + 14, "reqsa", ef_client_reqsa, TYPE_SA, "requested server sa"},
{prop_client + 15, "bytesin", ef_client_bytesin64, TYPE_UNSIGNED64, "bytes from server to client"}, {prop_client + 15, "bytesin", ef_client_bytesin64, TYPE_UNSIGNED64, "bytes from server to client"},
{prop_client + 16, "bytesout", ef_client_bytesout64, TYPE_UNSIGNED64, "bytes from client to server"}, {prop_client + 16, "bytesout", ef_client_bytesout64, TYPE_UNSIGNED64, "bytes from client to server"},
{prop_client + 17, "maxtrafin", ef_client_maxtrafin64, TYPE_UNSIGNED64, "maximum traffic allowed for download"}, {prop_client + 17, "maxtrafin", ef_client_maxtrafin64, TYPE_UNSIGNED64, "maximum traffic allowed for download"},
+11 -3
View File
@@ -88,6 +88,7 @@ void * ftpprchild(struct clientparam* param) {
} }
else if (status >= 3 && ( else if (status >= 3 && (
(!strncasecmp((char *)buf, "PASV", 4) && (pasv = 1)) || (!strncasecmp((char *)buf, "PASV", 4) && (pasv = 1)) ||
(!strncasecmp((char *)buf, "EPSV", 4) && (pasv = 2)) ||
(!strncasecmp((char *)buf, "PORT ", 5) && !(pasv = 0)) (!strncasecmp((char *)buf, "PORT ", 5) && !(pasv = 0))
)){ )){
#ifndef WITHMAIN #ifndef WITHMAIN
@@ -125,8 +126,9 @@ void * ftpprchild(struct clientparam* param) {
if(so._listen(clidatasock, 1)) {RETURN(823);} if(so._listen(clidatasock, 1)) {RETURN(823);}
sasize = sizeof(param->sincl); sasize = sizeof(param->sincl);
if(so._getsockname(clidatasock, (struct sockaddr *)&param->sincl, &sasize)){RETURN(824);} if(so._getsockname(clidatasock, (struct sockaddr *)&param->sincl, &sasize)){RETURN(824);}
if(*SAFAMILY(&param->sincl) == AF_INET) if(pasv == 1){
sprintf((char *)buf, "227 OK (%u,%u,%u,%u,%u,%u)\r\n", 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)))[0]),
(unsigned)(((unsigned char *)(SAADDR(&param->sincl)))[1]), (unsigned)(((unsigned char *)(SAADDR(&param->sincl)))[1]),
(unsigned)(((unsigned char *)(SAADDR(&param->sincl)))[2]), (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)))[0]),
(unsigned)(((unsigned char *)(SAPORT(&param->sincl)))[1]) (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)))[0]),
(unsigned)(((unsigned char *)(SAPORT(&param->sincl)))[1]) (unsigned)(((unsigned char *)(SAPORT(&param->sincl)))[1])
); );
}
else {
sprintf((char *)buf, "229 OK (|||%u|)\r\n",
(unsigned)ntohs(*SAPORT(&param->sincl))
);
}
} }
else { else {
unsigned long b1, b2, b3, b4; unsigned long b1, b2, b3, b4;
+5 -5
View File
@@ -878,13 +878,13 @@ static struct commands file_commandhandlers[] = {
static int file_loaded=0; static int file_loaded=0;
#ifdef WATCOM
#ifdef _WIN32 #pragma aux file_plugin "*" parm caller [ ] value struct float struct routine [eax] modify [eax ecx edx]
__declspec(dllexport) #undef PLUGINCALL
#define PLUGINCALL
#endif #endif
PLUGINAPI int PLUGINCALL file_plugin (struct pluginlink * pluginlink,
int file_plugin (struct pluginlink * pluginlink,
int argc, char** argv){ int argc, char** argv){
if(!file_loaded){ if(!file_loaded){
+8 -3
View File
@@ -677,13 +677,18 @@ static struct commands lfm_commandhandlers[] = {
{NULL, "lfm_format", h_lfm_format, 2, 2} {NULL, "lfm_format", h_lfm_format, 2, 2}
}; };
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
#ifdef _WIN32
__declspec(dllexport) #ifdef WATCOM
#pragma aux lfm_plugin "*" parm caller [ ] value struct float struct routine [eax] modify [eax ecx edx]
#undef PLUGINCALL
#define PLUGINCALL
#endif #endif
int lfm_plugin( struct pluginlink * pluginlink, int argc, char** argv )
PLUGINAPI int PLUGINCALL lfm_plugin( struct pluginlink * pluginlink, int argc, char** argv )
{ {
pl = pluginlink; pl = pluginlink;
myOutputDebugStringA1( "lfm_plugin" ); myOutputDebugStringA1( "lfm_plugin" );
+1 -1
View File
@@ -4,4 +4,4 @@ ldapauth$(OBJSUFFICS): ldapauth.c
$(CC) $(DCFLAGS) $(CFLAGS) ldapauth.c $(CC) $(DCFLAGS) $(CFLAGS) ldapauth.c
$(BUILDDIR)ldapauth$(DLSUFFICS): ldapauth$(OBJSUFFICS) $(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 <stdio.h>
#include <stdlib.h>
#include <string.h> #include <string.h>
#include <stdlib.h>
#include <time.h> #include <time.h>
#include <ldap.h>
#ifndef _WIN32 #ifndef _WIN32
#include <ctype.h> #include <ctype.h>
#endif #endif
#include "../../proxy.h"
#include "../../structures.h" #include "../../structures.h"
#define LDAP_DEPRECATED 1
struct counter_record #include <ldap.h>
{
unsigned long traf;
unsigned long trafgb;
time_t cleared;
time_t updated;
};
int already_loaded = 0; int already_loaded = 0;
@@ -62,7 +52,7 @@ void lower (char *string)
#endif #endif
/* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */
int savecouters(void) int savecounters(void)
{ {
struct trafcount *tc=mypluginlink->conf->trafcounter; struct trafcount *tc=mypluginlink->conf->trafcounter;
struct trafcount *tcd; struct trafcount *tcd;
@@ -82,8 +72,8 @@ int savecouters(void)
sprintf(tmpbuf,pat_file,ldap_dircount,tcd->ace->users->user); sprintf(tmpbuf,pat_file,ldap_dircount,tcd->ace->users->user);
f=fopen(tmpbuf,"w+b"); f=fopen(tmpbuf,"w+b");
fseek(f,0,SEEK_SET); fseek(f,0,SEEK_SET);
fprintf(f,"%10lu %10lu %lu %lu\n",tcd->trafgb,tcd->traf, fprintf(f,"%"PRINTF_INT64_MODIFIER"u %lu %lu\n",tcd->traf64,
tcd->cleared,tcd->updated); (unsigned long)tcd->cleared,(unsigned long)tcd->updated);
fclose(f); fclose(f);
mypluginlink->myfree(tmpbuf); mypluginlink->myfree(tmpbuf);
@@ -100,17 +90,7 @@ int savecouters(void)
return (0); return (0);
} }
/*--------------------------------------------------------------------------*/
#ifdef _WIN32
__declspec(dllexport) int start(struct pluginlink * pluginlink,
int argc, char** argv);
#else
int start(struct pluginlink * pluginlink,
int argc, char** argv);
#endif
/* --------------------------------------------------------------------------*/ /* --------------------------------------------------------------------------*/
static int ldapfunc(struct clientparam *param) static int ldapfunc(struct clientparam *param)
@@ -395,8 +375,7 @@ int h_trafgroup(int argc, unsigned char ** argv)
memset(newtrafcount, 0, sizeof(struct trafcount)); memset(newtrafcount, 0, sizeof(struct trafcount));
newtrafcount->ace = newace; newtrafcount->ace = newace;
newtrafcount->type=rtype; newtrafcount->type=rtype;
newtrafcount->traflimgb =(traflimit/(1024*4)); newtrafcount->traflim64 = traflimit;
newtrafcount->traflim = ((traflimit - (newtrafcount->traflimgb*(1024*4)))*(1024*1024));
newtrafcount->comment=(*mypluginlink->mystrdup)("ldapcounters"); newtrafcount->comment=(*mypluginlink->mystrdup)("ldapcounters");
newtrafcount->number=0; newtrafcount->number=0;
tmpbuf=(*mypluginlink->myalloc)(strlen(pat_file)+strlen(ldap_dircount)+strlen(vals[0])); tmpbuf=(*mypluginlink->myalloc)(strlen(pat_file)+strlen(ldap_dircount)+strlen(vals[0]));
@@ -408,12 +387,11 @@ int h_trafgroup(int argc, unsigned char ** argv)
fseek(f,0,SEEK_SET); fseek(f,0,SEEK_SET);
fgets(buf, 256, f); fgets(buf, 256, f);
sscanf(buf,"%10lu %10lu %lu %lu\n",&rcounter.trafgb, &rcounter.traf, sscanf(buf,"%"PRINTF_INT64_MODIFIER"u %lu %lu\n",&rcounter.traf64,
&rcounter.cleared, &rcounter.updated); &rcounter.cleared, &rcounter.updated);
newtrafcount->trafgb=rcounter.trafgb; newtrafcount->traf64=rcounter.traf64;
newtrafcount->traf=rcounter.traf;
newtrafcount->cleared=rcounter.cleared; newtrafcount->cleared=rcounter.cleared;
newtrafcount->updated=rcounter.updated; newtrafcount->updated=rcounter.updated;
fclose(f); fclose(f);
@@ -467,7 +445,16 @@ int h_dircount(int argc, unsigned char ** argv)
/*------------------------------- MAIN -------------------------------------- /*------------------------------- MAIN --------------------------------------
start plugin init */ start plugin init */
int start(struct pluginlink * pluginlink, int argc, char** argv)
#ifdef WATCOM
#pragma aux start "*" parm caller [ ] value struct float struct routine [eax] modify [eax ecx edx]
#undef PLUGINCALL
#define PLUGINCALL
#endif
PLUGINAPI int PLUGINCALL start(struct pluginlink * pluginlink,
int argc, char** argv)
{ {
@@ -566,7 +553,7 @@ int start(struct pluginlink * pluginlink, int argc, char** argv)
/*create job shedule for processing reload, save counters to file */ /*create job shedule for processing reload, save counters to file */
memset(&myschedule,0,sizeof(struct schedule)); memset(&myschedule,0,sizeof(struct schedule));
myschedule.type=MINUTELY; myschedule.type=MINUTELY;
myschedule.function=savecouters; myschedule.function=savecounters;
myschedule.next = *pluginlink->schedule; myschedule.next = *pluginlink->schedule;
*pluginlink->schedule=&myschedule; *pluginlink->schedule=&myschedule;
+6 -3
View File
@@ -358,12 +358,15 @@ static struct symbol regexp_symbols[] = {
{NULL, "pcre_free", NULL}, {NULL, "pcre_free", NULL},
}; };
#ifdef _WIN32 #ifdef WATCOM
__declspec(dllexport) #pragma aux pcre_plugin "*" parm caller [ ] value struct float struct routine [eax] modify [eax ecx edx]
#undef PLUGINCALL
#define PLUGINCALL
#endif #endif
int pcre_plugin (struct pluginlink * pluginlink, PLUGINAPI int PLUGINCALL pcre_plugin (struct pluginlink * pluginlink,
int argc, char** argv){ int argc, char** argv){
struct filter *flt, *tmpflt; struct filter *flt, *tmpflt;
pl = pluginlink; pl = pluginlink;
pcre_options = 0; pcre_options = 0;
+7 -1
View File
@@ -117,9 +117,15 @@ static int pamfunc(struct clientparam *param)
} }
#ifdef WATCOM
#pragma aux start "*" parm caller [ ] value struct float struct routine [eax] modify [eax ecx edx]
#undef PLUGINCALL
#define PLUGINCALL
#endif
/*------------------------------- MAIN -------------------------------------- /*------------------------------- MAIN --------------------------------------
start plugin init */ start plugin init */
int start(struct pluginlink * pluginlink, int argc, unsigned char** argv) PLUGINAPI int PLUGINCALL start(struct pluginlink * pluginlink, int argc, unsigned char** argv)
{ {
+2 -2
View File
@@ -112,8 +112,8 @@ SSL_CERT ssl_copy_cert(SSL_CERT cert)
unsigned char p2[] = "3proxy"; unsigned char p2[] = "3proxy";
unsigned char p3[] = "3proxy CA"; unsigned char p3[] = "3proxy CA";
static char hash_name[sizeof(src_cert->sha1_hash)*2 + 1]; char hash_name[sizeof(src_cert->sha1_hash)*2 + 1];
static char cache_name[200]; char cache_name[200];
bin2hex(src_cert->sha1_hash, sizeof(src_cert->sha1_hash), hash_name, sizeof(hash_name)); bin2hex(src_cert->sha1_hash, sizeof(src_cert->sha1_hash), hash_name, sizeof(hash_name));
sprintf(cache_name, "%s%s.pem", cert_path, hash_name); sprintf(cache_name, "%s%s.pem", cert_path, hash_name);
+6 -3
View File
@@ -372,12 +372,15 @@ static struct commands ssl_commandhandlers[] = {
}; };
#ifdef _WIN32 #ifdef WATCOM
__declspec(dllexport) #pragma aux ssl_plugin "*" parm caller [ ] value struct float struct routine [eax] modify [eax ecx edx]
#undef PLUGINCALL
#define PLUGINCALL
#endif #endif
int ssl_plugin (struct pluginlink * pluginlink, PLUGINAPI int PLUGINCALL ssl_plugin (struct pluginlink * pluginlink,
int argc, char** argv){ int argc, char** argv){
pl = pluginlink; pl = pluginlink;
if(!ssl_loaded){ if(!ssl_loaded){
ssl_loaded = 1; ssl_loaded = 1;
+7 -9
View File
@@ -151,8 +151,6 @@ static int restore_old_table(void * v)
/*-------------------------------------------------------------------*/ /*-------------------------------------------------------------------*/
#ifdef _WIN32 #ifdef _WIN32
__declspec(dllexport) int start(struct pluginlink * pluginlink,
int argc, char** argv);
BOOL WINAPI DllMain( HINSTANCE hModule, BOOL WINAPI DllMain( HINSTANCE hModule,
DWORD ul_reason_for_call, DWORD ul_reason_for_call,
LPVOID lpReserved LPVOID lpReserved
@@ -165,17 +163,17 @@ BOOL WINAPI DllMain( HINSTANCE hModule,
} }
return TRUE; return TRUE;
} }
#else
int start(struct pluginlink * pluginlink,
int argc, char** argv);
#endif #endif
#ifdef WATCOM
#pragma aux start "*" parm caller [ ] value struct float struct routine [eax] modify [eax ecx edx]
#undef PLUGINCALL
#define PLUGINCALL
#endif
PLUGINAPI int PLUGINCALL start(struct pluginlink * pluginlink,
/*---------------------- start plugin init ------------------------------ */ int argc, char** argv)
int start(struct pluginlink * pluginlink, int argc, char** argv)
{ {
FILE *f=NULL; FILE *f=NULL;
+8 -3
View File
@@ -266,11 +266,16 @@ BOOL WINAPI DllMain( HINSTANCE hModule,
return TRUE; return TRUE;
} }
__declspec(dllexport)
#endif #endif
int start(struct pluginlink * pluginlink, int argc, char** argv) { #ifdef WATCOM
#pragma aux start "*" parm caller [ ] value struct float struct routine [eax] modify [eax ecx edx]
#undef PLUGINCALL
#define PLUGINCALL
#endif
PLUGINAPI int PLUGINCALL start(struct pluginlink * pluginlink, int argc, char** argv) {
struct commands * starthandler; struct commands * starthandler;
conf = pluginlink->conf; conf = pluginlink->conf;
commandhandlers = pluginlink->commandhandlers; commandhandlers = pluginlink->commandhandlers;
@@ -89,11 +89,13 @@ static struct filter transparent_filter = {
}; };
#ifdef _WIN32 #ifdef WATCOM
__declspec(dllexport) #pragma aux transparent_plugin "*" parm caller [ ] value struct float struct routine [eax] modify [eax ecx edx]
#undef PLUGINCALL
#define PLUGINCALL
#endif #endif
int transparent_plugin (struct pluginlink * pluginlink, PLUGINAPI int PLUGINCALL transparent_plugin (struct pluginlink * pluginlink,
int argc, char** argv){ int argc, char** argv){
pl = pluginlink; pl = pluginlink;
if(!transparent_loaded){ if(!transparent_loaded){
@@ -15,10 +15,6 @@
extern "C" { extern "C" {
#endif #endif
__declspec(dllexport) int WindowsAuthentication(struct pluginlink * pluginlink,
int argc, char** argv);
static struct auth alwaysauth; static struct auth alwaysauth;
static char sidbuf[4096]; static char sidbuf[4096];
@@ -62,12 +58,13 @@ extern "C" {
return 7; return 7;
} }
#ifdef __cplusplus #ifdef WATCOM
} #pragma aux WindowsAuthentication "*" parm caller [ ] value struct float struct routine [eax] modify [eax ecx edx]
#undef PLUGINCALL
#define PLUGINCALL
#endif #endif
PLUGINAPI int PLUGINCALL WindowsAuthentication(struct pluginlink * pluginlink, int argc, char** argv){
int WindowsAuthentication(struct pluginlink * pluginlink, int argc, char** argv){
char tmpbuf[4096]; char tmpbuf[4096];
DWORD dlen, sidlen; DWORD dlen, sidlen;
SID_NAME_USE snu; SID_NAME_USE snu;
@@ -91,4 +88,7 @@ int WindowsAuthentication(struct pluginlink * pluginlink, int argc, char** argv)
return 0; return 0;
} }
#ifdef __cplusplus
}
#endif
+9 -7
View File
@@ -14,9 +14,6 @@
extern "C" { extern "C" {
#endif #endif
__declspec(dllexport) int utf8tocp1251(struct pluginlink * pluginlink,
int argc, char** argv);
static struct auth alwaysauth; static struct auth alwaysauth;
@@ -64,12 +61,14 @@ unsigned char * conv_utf8_to_cp1251(unsigned char *s){
return 4; return 4;
} }
#ifdef __cplusplus
} #ifdef WATCOM
#pragma aux utf8tocp1251 "*" parm caller [ ] value struct float struct routine [eax] modify [eax ecx edx]
#undef PLUGINCALL
#define PLUGINCALL
#endif #endif
PLUGINAPI int PLUGINCALL utf8tocp1251(struct pluginlink * pluginlink, int argc, char** argv){
int utf8tocp1251(struct pluginlink * pluginlink, int argc, char** argv){
static int loaded = 0; static int loaded = 0;
@@ -85,4 +84,7 @@ int utf8tocp1251(struct pluginlink * pluginlink, int argc, char** argv){
} }
#ifdef __cplusplus
}
#endif
+4 -4
View File
@@ -278,7 +278,7 @@ for(;;){
buf[i] = 0; buf[i] = 0;
if(req) { if(req) {
if(!param->transparent && !param->srv->transparent && param->redirtype != R_HTTP && (i<=prefix || strncasecmp((char *)buf, (char *)req, prefix))){ if(!param->transparent && !param->srv->transparent && (i<=prefix || strncasecmp((char *)buf, (char *)req, prefix))){
ckeepalive = 0; ckeepalive = 0;
if(param->remsock != INVALID_SOCKET){ if(param->remsock != INVALID_SOCKET){
so._shutdown(param->remsock, SHUT_RDWR); so._shutdown(param->remsock, SHUT_RDWR);
@@ -336,10 +336,10 @@ for(;;){
if(su) { if(su) {
su = (unsigned char *)mystrdup((char *)sb); su = (unsigned char *)mystrdup((char *)sb);
decodeurl(su, 0); decodeurl(su, 0);
parseconnusername((char *)su, (struct clientparam *)param, 1, (unsigned short)((ftp)?21:80)); if(parseconnusername((char *)su, (struct clientparam *)param, 1, (unsigned short)((ftp)?21:80))) RETURN (100);
myfree(su); myfree(su);
} }
else parsehostname((char *)sb, (struct clientparam *)param, (unsigned short)((ftp)? 21:80)); else if(parsehostname((char *)sb, (struct clientparam *)param, (unsigned short)((ftp)? 21:80))) RETURN(100);
if(!isconnect){ if(!isconnect){
if(se==sg)*se-- = ' '; if(se==sg)*se-- = ' ';
*se = '/'; *se = '/';
@@ -460,7 +460,7 @@ for(;;){
*se = 0; *se = 0;
} }
if(!param->hostname){ if(!param->hostname){
parsehostname((char *)sb, param, 80); if(parsehostname((char *)sb, param, 80)) RETURN(100);
} }
newbuf = myalloc(strlen((char *)req) + strlen((char *)(buf+inbuf)) + 8); newbuf = myalloc(strlen((char *)req) + strlen((char *)(buf+inbuf)) + 8);
if(newbuf){ if(newbuf){
+2 -11
View File
@@ -21,7 +21,6 @@
#include <ctype.h> #include <ctype.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <sys/timeb.h>
#include <fcntl.h> #include <fcntl.h>
#include <time.h> #include <time.h>
@@ -30,22 +29,14 @@
#define _PASSWORD_LEN 256 #define _PASSWORD_LEN 256
#define MAXNSERVERS 5 #define MAXNSERVERS 5
#define ALLOW 0
#define DENY 1
#define REDIRECT 2
#define BANDLIM 3
#define NOBANDLIM 4
#define COUNTIN 5
#define NOCOUNTIN 6
#define COUNTOUT 7
#define NOCOUNTOUT 8
#define UDPBUFSIZE 16384 #define UDPBUFSIZE 16384
#define TCPBUFSIZE 8192 #define TCPBUFSIZE 8192
#define SRVBUFSIZE (param->srv->bufsize?param->srv->bufsize:((param->service == S_UDPPM)?UDPBUFSIZE:TCPBUFSIZE))
#ifdef _WIN32 #ifdef _WIN32
#include <winsock2.h> #include <winsock2.h>
#include <sys/timeb.h>
#ifndef _WINCE #ifndef _WINCE
#include <io.h> #include <io.h>
#else #else
+8 -3
View File
@@ -633,7 +633,7 @@ int MODULEMAINFUNC (int argc, char** argv){
continue; continue;
}; };
*newparam = defparam; *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); clearstat(newparam);
if(!isudp) newparam->clisock = new_sock; if(!isudp) newparam->clisock = new_sock;
#ifndef STDMAIN #ifndef STDMAIN
@@ -643,6 +643,7 @@ int MODULEMAINFUNC (int argc, char** argv){
} }
#endif #endif
newparam->prev = newparam->next = NULL; newparam->prev = newparam->next = NULL;
error = 0;
pthread_mutex_lock(&srv.counter_mutex); pthread_mutex_lock(&srv.counter_mutex);
if(!srv.child){ if(!srv.child){
srv.child = newparam; srv.child = newparam;
@@ -665,7 +666,7 @@ int MODULEMAINFUNC (int argc, char** argv){
else { else {
sprintf((char *)buf, "_beginthreadex(): %s", _strerror(NULL)); sprintf((char *)buf, "_beginthreadex(): %s", _strerror(NULL));
if(!srv.silent)(*srv.logfunc)(&defparam, buf); if(!srv.silent)(*srv.logfunc)(&defparam, buf);
freeparam(newparam); error = 1;
} }
#else #else
@@ -674,13 +675,14 @@ int MODULEMAINFUNC (int argc, char** argv){
if(error){ if(error){
sprintf((char *)buf, "pthread_create(): %s", strerror(error)); sprintf((char *)buf, "pthread_create(): %s", strerror(error));
if(!srv.silent)(*srv.logfunc)(&defparam, buf); if(!srv.silent)(*srv.logfunc)(&defparam, buf);
freeparam(newparam);
} }
else { else {
newparam->threadid = (unsigned)thread; newparam->threadid = (unsigned)thread;
} }
#endif #endif
pthread_mutex_unlock(&srv.counter_mutex); pthread_mutex_unlock(&srv.counter_mutex);
if(error) freeparam(newparam);
memset(&defparam.sincl, 0, sizeof(defparam.sincl)); memset(&defparam.sincl, 0, sizeof(defparam.sincl));
memset(&defparam.sincr, 0, sizeof(defparam.sincr)); memset(&defparam.sincr, 0, sizeof(defparam.sincr));
if(isudp) while(!srv.fds.events)usleep(SLEEPTIME); if(isudp) while(!srv.fds.events)usleep(SLEEPTIME);
@@ -699,6 +701,9 @@ int MODULEMAINFUNC (int argc, char** argv){
pthread_mutex_unlock(&config_mutex); pthread_mutex_unlock(&config_mutex);
#endif #endif
#ifndef _WIN32
pthread_attr_destroy(&pa);
#endif
if(defparam.hostname)myfree(defparam.hostname); if(defparam.hostname)myfree(defparam.hostname);
if(cbc_string)myfree(cbc_string); if(cbc_string)myfree(cbc_string);
if(cbl_string)myfree(cbl_string); if(cbl_string)myfree(cbl_string);
+3 -6
View File
@@ -7,9 +7,6 @@
#include "proxy.h" #include "proxy.h"
#define BUFSIZE (param->srv->bufsize?param->srv->bufsize:((param->service == S_UDPPM)?UDPBUFSIZE:TCPBUFSIZE))
int socksend(SOCKET sock, unsigned char * buf, int bufsize, int to){ int socksend(SOCKET sock, unsigned char * buf, int bufsize, int to){
int sent = 0; int sent = 0;
int res; int res;
@@ -75,8 +72,8 @@ int sockgetcharcli(struct clientparam * param, int timeosec, int timeousec){
int len; int len;
if(!param->clibuf){ if(!param->clibuf){
if(!(param->clibuf = myalloc(BUFSIZE))) return 0; if(!(param->clibuf = myalloc(SRVBUFSIZE))) return 0;
param->clibufsize = BUFSIZE; param->clibufsize = SRVBUFSIZE;
param->clioffset = param->cliinbuf = 0; param->clioffset = param->cliinbuf = 0;
} }
if(param->cliinbuf && param->clioffset < param->cliinbuf){ if(param->cliinbuf && param->clioffset < param->cliinbuf){
@@ -137,7 +134,7 @@ int sockgetcharsrv(struct clientparam * param, int timeosec, int timeousec){
int bufsize; int bufsize;
if(!param->srvbuf){ if(!param->srvbuf){
bufsize = BUFSIZE; bufsize = SRVBUFSIZE;
if(param->ndatfilterssrv > 0 && bufsize < 32768) bufsize = 32768; if(param->ndatfilterssrv > 0 && bufsize < 32768) bufsize = 32768;
if(!(param->srvbuf = myalloc(bufsize))) return 0; if(!(param->srvbuf = myalloc(bufsize))) return 0;
param->srvbufsize = bufsize; param->srvbufsize = bufsize;
+4 -3
View File
@@ -8,8 +8,6 @@
#include "proxy.h" #include "proxy.h"
#define BUFSIZE (param->srv->bufsize?param->srv->bufsize:((param->service == S_UDPPM)?UDPBUFSIZE:TCPBUFSIZE))
int sockmap(struct clientparam * param, int timeo){ int sockmap(struct clientparam * param, int timeo){
int res=0; int res=0;
uint64_t sent=0, received=0; uint64_t sent=0, received=0;
@@ -21,13 +19,16 @@ int sockmap(struct clientparam * param, int timeo){
FILTER_ACTION action; FILTER_ACTION action;
int retcode = 0; int retcode = 0;
bufsize = BUFSIZE; bufsize = SRVBUFSIZE;
minsize = (param->service == S_UDPPM || param->service == S_TCPPM)? bufsize - 1 : (bufsize>>2); minsize = (param->service == S_UDPPM || param->service == S_TCPPM)? bufsize - 1 : (bufsize>>2);
fds[0].fd = param->clisock; fds[0].fd = param->clisock;
fds[1].fd = param->remsock; fds[1].fd = param->remsock;
if(param->cliinbuf == param->clioffset) param->cliinbuf = param->clioffset = 0;
if(param->srvinbuf == param->srvoffset) param->srvinbuf = param->srvoffset = 0;
#if DEBUGLEVEL > 2 #if DEBUGLEVEL > 2
(*param->srv->logfunc)(param, "Starting sockets mapping"); (*param->srv->logfunc)(param, "Starting sockets mapping");
#endif #endif
+1 -1
View File
@@ -376,7 +376,7 @@ fflush(stderr);
buf[i] = buf[i+1]; buf[i] = buf[i+1];
} }
buf[i++] = 0; buf[i++] = 0;
if(!getip46(param->srv->family, buf, (struct sockaddr *) &param->sinsr)) RETURN(100); if(!getip46(param->srv->family, buf+4, (struct sockaddr *) &param->sinsr)) RETURN(100);
break; break;
default: default:
RETURN(997); RETURN(997);
+29 -4
View File
@@ -76,6 +76,18 @@ int
#endif #endif
#define ALLOW 0
#define DENY 1
#define REDIRECT 2
#define BANDLIM 3
#define NOBANDLIM 4
#define COUNTIN 5
#define NOCOUNTIN 6
#define COUNTOUT 7
#define NOCOUNTOUT 8
#define CONNLIM 9
#define NOCONNLIM 10
#define CONNECT 0x00000001 #define CONNECT 0x00000001
#define BIND 0x00000002 #define BIND 0x00000002
#define UDPASSOC 0x00000004 #define UDPASSOC 0x00000004
@@ -162,7 +174,21 @@ typedef void (*TRAFCOUNTFUNC)(struct clientparam * param);
typedef void * (*EXTENDFUNC) (struct node *node); typedef void * (*EXTENDFUNC) (struct node *node);
typedef void (*CBFUNC)(void *cb, char * buf, int inbuf); typedef void (*CBFUNC)(void *cb, char * buf, int inbuf);
typedef void (*PRINTFUNC) (struct node *node, CBFUNC cbf, void*cb); typedef void (*PRINTFUNC) (struct node *node, CBFUNC cbf, void*cb);
typedef int (*PLUGINFUNC) (struct pluginlink *pluginlink, int argc, char** argv);
#ifdef WIN32
#define PLUGINAPI __declspec(dllexport)
typedef int (__cdecl *PLUGINFUNC) (struct pluginlink *pluginlink, int argc, char** argv);
#define PLUGINCALL __cdecl
#else
#define PLUGINCALL
#define PLUGINAPI
typedef int (*PLUGINFUNC)(struct pluginlink *pluginlink, int argc, char** argv);
#endif
struct auth { struct auth {
struct auth *next; struct auth *next;
@@ -430,7 +456,8 @@ struct clientparam {
int redirected, int redirected,
operation, operation,
nfilters, nreqfilters, nhdrfilterscli, nhdrfilterssrv, npredatfilters, ndatfilterscli, ndatfilterssrv, nfilters, nreqfilters, nhdrfilterscli, nhdrfilterssrv, npredatfilters, ndatfilterscli, ndatfilterssrv,
unsafefilter; unsafefilter,
bandlimver;
int res, int res,
status; status;
@@ -752,8 +779,6 @@ typedef enum {
TYPE_SERVER TYPE_SERVER
}DATA_TYPE; }DATA_TYPE;
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
+1 -1
View File
@@ -23,7 +23,7 @@ void * tcppmchild(struct clientparam* param) {
RETURN (sockmap(param, conf.timeouts[CONNECTION_L])); RETURN (sockmap(param, conf.timeouts[CONNECTION_L]));
CLEANRET: CLEANRET:
(*param->srv->logfunc)(param, NULL); (*param->srv->logfunc)(param, param->hostname);
freeparam(param); freeparam(param);
return (NULL); return (NULL);
} }
+2 -2
View File
@@ -1,2 +1,2 @@
#define VERSION "3proxy-0.8.7" #define VERSION "3proxy-0.8.12"
#define BUILDDATE "160904162014" #define BUILDDATE "180418205022"