Compare commits

..
26 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
25 changed files with 6650 additions and 1860 deletions

No files matched your search

+5 -8
View File
@@ -1,9 +1,6 @@
#include "src/version.h"
1 VERSIONINFO
FILEVERSION 0,8,10,0
PRODUCTVERSION 0,8,10,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.10\0"
VALUE "FileVersion", "0.8.13\0"
VALUE "InternalName", "3proxy\0"
VALUE "LegalCopyright", "Copyright (C) 2002-2017 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.10\0"
VALUE "ProductVersion", "0.8.13\0"
END
END
BLOCK "VarFileInfo"
+2 -2
View File
@@ -10,11 +10,11 @@
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
+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
+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
+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
+11
View File
@@ -736,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
+7 -3
View File
@@ -789,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){
+3 -4
View File
@@ -468,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])) {
@@ -480,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;
@@ -651,8 +650,8 @@ int doconnect(struct clientparam * param){
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;
+9 -5
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,7 +280,6 @@ 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;
}
@@ -1425,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++){
@@ -1444,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;
}
@@ -1456,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){
@@ -1494,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++;
+19 -17
View File
@@ -75,7 +75,7 @@ static void pr_sa(struct node *node, CBFUNC cbf, void*cb){
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
@@ -743,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"}
};
@@ -776,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"},
+12 -4
View File
@@ -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;
+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)
+11 -23
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);
@@ -385,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]));
@@ -398,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);
@@ -565,7 +553,7 @@ PLUGINAPI int PLUGINCALL start(struct pluginlink * pluginlink,
/*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;
+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);
+1 -11
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,16 +29,6 @@
#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))
@@ -47,6 +36,7 @@
#ifdef _WIN32
#include <winsock2.h>
#include <sys/timeb.h>
#ifndef _WINCE
#include <io.h>
#else
+8 -3
View File
@@ -633,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
@@ -643,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;
@@ -665,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
@@ -674,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);
@@ -699,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);
+1 -1
View File
@@ -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);
+12
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
+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.10"
#define BUILDDATE "170625190910"
#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);