mirror of
https://github.com/3proxy/3proxy.git
synced 2026-11-26 23:59:41 +08:00
traffic counters are changed to 64-bit
traffic counters are changed to 64-bit using pstdint.h
This commit is contained in:
1 parent
467650bbbf
commit
2890f06488
21 files changed
+569
-44
No files matched your search
+119
-1
@@ -217,7 +217,11 @@ void * proxychild(struct clientparam* param) {
|
||||
unsigned char *ftpbase=NULL;
|
||||
unsigned char username[1024];
|
||||
int keepalive = 0;
|
||||
#ifndef NOPSTDINT
|
||||
uint64_t contentlength64 = 0;
|
||||
#else
|
||||
unsigned long contentlength = 0;
|
||||
#endif
|
||||
int hascontent =0;
|
||||
int isconnect = 0;
|
||||
int redirect = 0;
|
||||
@@ -388,6 +392,16 @@ for(;;){
|
||||
while( (i = sockgetlinebuf(param, CLIENT, buf, BUFSIZE - 1, '\n', conf.timeouts[STRING_S])) > 2){
|
||||
if(i> 15 && (!strncasecmp((char *)(buf), "content-length", 14))){
|
||||
buf[i]=0;
|
||||
#ifndef NOPSTDINT
|
||||
sscanf((char *)buf + 15, "%"PRINTF_INT64_MODIFIER"u", &contentlength64);
|
||||
}
|
||||
}
|
||||
while( contentlength64 > 0 && (i = sockgetlinebuf(param, CLIENT, buf, (BUFSIZE < contentlength64)? BUFSIZE - 1:(int)contentlength64, '\n', conf.timeouts[STRING_S])) > 0){
|
||||
if ((uint64_t)i > contentlength64) break;
|
||||
contentlength64-=i;
|
||||
}
|
||||
contentlength64 = 0;
|
||||
#else
|
||||
sscanf((char *)buf + 15, "%lu", &contentlength);
|
||||
}
|
||||
}
|
||||
@@ -396,6 +410,7 @@ for(;;){
|
||||
contentlength-=i;
|
||||
}
|
||||
contentlength = 0;
|
||||
#endif
|
||||
if(param->password)myfree(param->password);
|
||||
param->password = myalloc(32);
|
||||
param->pwtype = 2;
|
||||
@@ -492,11 +507,19 @@ for(;;){
|
||||
if(!sb)continue;
|
||||
++sb;
|
||||
while(isspace(*sb))sb++;
|
||||
#ifndef NOPSTDINT
|
||||
sscanf(sb, "%"PRINTF_INT64_MODIFIER"u",&contentlength64);
|
||||
if(param->maxtrafout64 && (param->maxtrafout64 < param->statscli64 || contentlength64 > param->maxtrafout64 - param->statscli64)){
|
||||
RETURN(10);
|
||||
}
|
||||
if(param->ndatfilterscli > 0 && contentlength64 > 0) continue;
|
||||
#else
|
||||
sscanf(sb, "%lu",&contentlength);
|
||||
if(param->maxtrafout && (param->maxtrafout < param->statscli || (unsigned)contentlength > param->maxtrafout - param->statscli)){
|
||||
RETURN(10);
|
||||
}
|
||||
if(param->ndatfilterscli > 0 && contentlength > 0) continue;
|
||||
#endif
|
||||
}
|
||||
inbuf += i;
|
||||
if((bufsize - inbuf) < LINESIZE){
|
||||
@@ -527,19 +550,34 @@ for(;;){
|
||||
RETURN(0);
|
||||
}
|
||||
if(action != PASS) RETURN(517);
|
||||
#ifndef NOPSTDINT
|
||||
if(param->ndatfilterscli > 0 && contentlength64 > 0){
|
||||
uint64_t newlen64;
|
||||
newlen64 = sockfillbuffcli(param, (unsigned long)contentlength64, CONNECTION_S);
|
||||
if(newlen64 == contentlength64) {
|
||||
#else
|
||||
if(param->ndatfilterscli > 0 && contentlength > 0){
|
||||
unsigned long newlen;
|
||||
newlen = sockfillbuffcli(param, contentlength, CONNECTION_S);
|
||||
if(newlen == contentlength) {
|
||||
#endif
|
||||
action = handledatfltcli(param, ¶m->clibuf, ¶m->clibufsize, 0, ¶m->cliinbuf);
|
||||
if(action == HANDLED){
|
||||
RETURN(0);
|
||||
}
|
||||
if(action != PASS) RETURN(517);
|
||||
#ifndef NOPSTDINT
|
||||
contentlength64 = param->cliinbuf;
|
||||
#else
|
||||
contentlength = param->cliinbuf;
|
||||
#endif
|
||||
param->ndatfilterscli = 0;
|
||||
}
|
||||
#ifndef NOPSTDINT
|
||||
sprintf((char*)buf+strlen((char *)buf), "Content-Length: %"PRINTF_INT64_MODIFIER"u\r\n", contentlength64);
|
||||
#else
|
||||
sprintf((char*)buf+strlen((char *)buf), "Content-Length: %lu\r\n", contentlength);
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -619,7 +657,11 @@ for(;;){
|
||||
socksend(param->clisock, (unsigned char *)proxy_stringtable[8], (int)strlen(proxy_stringtable[8]), conf.timeouts[STRING_S]);
|
||||
s = param->remsock;
|
||||
param->remsock = ftps;
|
||||
#ifndef NOPSTDINT
|
||||
if((param->operation == FTP_PUT) && (contentlength64 > 0)) param->waitclient64 = contentlength64;
|
||||
#else
|
||||
if((param->operation == FTP_PUT) && (contentlength > 0)) param->waitclient = contentlength;
|
||||
#endif
|
||||
res = sockmap(param, conf.timeouts[CONNECTION_L]);
|
||||
if (res == 99) res = 0;
|
||||
so._closesocket(ftps);
|
||||
@@ -821,7 +863,11 @@ for(;;){
|
||||
if(socksend(param->remsock, req , (res = (int)strlen((char *)req)), conf.timeouts[STRING_L]) != res) {
|
||||
RETURN(518);
|
||||
}
|
||||
#ifndef NOPSTDINT
|
||||
param->statscli64 += res;
|
||||
#else
|
||||
param->statscli += res;
|
||||
#endif
|
||||
param->nwrites++;
|
||||
}
|
||||
inbuf = 0;
|
||||
@@ -853,11 +899,27 @@ for(;;){
|
||||
if ((res = socksend(param->remsock, buf+reqlen, (int)strlen((char *)buf+reqlen), conf.timeouts[STRING_S])) != (int)strlen((char *)buf+reqlen)) {
|
||||
RETURN(518);
|
||||
}
|
||||
#ifndef NOPSTDINT
|
||||
param->statscli64 += res;
|
||||
#else
|
||||
param->statscli += res;
|
||||
#endif
|
||||
param->nwrites++;
|
||||
if(param->bandlimfunc) {
|
||||
sleeptime = param->bandlimfunc(param, 0, (int)strlen((char *)buf));
|
||||
}
|
||||
#ifndef NOPSTDINT
|
||||
if(contentlength64 > 0){
|
||||
param->nolongdatfilter = 0;
|
||||
param->waitclient64 = contentlength64;
|
||||
res = sockmap(param, conf.timeouts[CONNECTION_S]);
|
||||
param->waitclient64 = 0;
|
||||
if(res != 99) {
|
||||
RETURN(res);
|
||||
}
|
||||
}
|
||||
contentlength64 = 0;
|
||||
#else
|
||||
if(contentlength > 0){
|
||||
param->nolongdatfilter = 0;
|
||||
param->waitclient = contentlength;
|
||||
@@ -868,6 +930,7 @@ for(;;){
|
||||
}
|
||||
}
|
||||
contentlength = 0;
|
||||
#endif
|
||||
inbuf = 0;
|
||||
ckeepalive = keepalive;
|
||||
res = 0;
|
||||
@@ -900,13 +963,21 @@ for(;;){
|
||||
if(!sb)continue;
|
||||
++sb;
|
||||
while(isspace(*sb))sb++;
|
||||
#ifndef NOPSTDINT
|
||||
sscanf(sb, "%"PRINTF_INT64_MODIFIER"u", &contentlength64);
|
||||
#else
|
||||
sscanf(sb, "%lu", &contentlength);
|
||||
#endif
|
||||
hascontent = 1;
|
||||
if(param->unsafefilter && param->ndatfilterssrv > 0) {
|
||||
hascontent = 2;
|
||||
continue;
|
||||
}
|
||||
#ifndef NOPSTDINT
|
||||
if(param->maxtrafin64 && (param->maxtrafin64 < param->statssrv64 || contentlength64 + param->statssrv64 > param->maxtrafin64)){
|
||||
#else
|
||||
if(param->maxtrafin && (param->maxtrafin < param->statssrv || (unsigned)contentlength > param->maxtrafin - param->statssrv)){
|
||||
#endif
|
||||
RETURN(10);
|
||||
}
|
||||
}
|
||||
@@ -935,7 +1006,11 @@ for(;;){
|
||||
}
|
||||
if((res == 304 || res == 204) && !hascontent){
|
||||
hascontent = 1;
|
||||
#ifndef NOPSTDINT
|
||||
contentlength64 = 0;
|
||||
#else
|
||||
contentlength = 0;
|
||||
#endif
|
||||
}
|
||||
if(param->bandlimfunc) {
|
||||
int st1;
|
||||
@@ -959,6 +1034,27 @@ for(;;){
|
||||
param->nolongdatfilter = 0;
|
||||
|
||||
|
||||
#ifndef NOPSTDINT
|
||||
if (conf.filtermaxsize && contentlength64 > (uint64_t)conf.filtermaxsize) {
|
||||
param->nolongdatfilter = 1;
|
||||
}
|
||||
else if(param->unsafefilter && param->ndatfilterssrv > 0 && contentlength64 > 0 && param->operation != HTTP_HEAD && res != 204 && res != 304){
|
||||
uint64_t newlen;
|
||||
newlen = (uint64_t)sockfillbuffsrv(param, (unsigned long) contentlength64, CONNECTION_S);
|
||||
if(newlen == contentlength64) {
|
||||
action = handledatfltsrv(param, ¶m->srvbuf, ¶m->srvbufsize, 0, ¶m->srvinbuf);
|
||||
param->nolongdatfilter = 1;
|
||||
if(action == HANDLED){
|
||||
RETURN(0);
|
||||
}
|
||||
if(action != PASS) RETURN(517);
|
||||
contentlength64 = param->srvinbuf;
|
||||
sprintf((char*)buf+strlen((char *)buf), "Content-Length: %"PRINTF_INT64_MODIFIER"u\r\n", contentlength64);
|
||||
hascontent = 1;
|
||||
}
|
||||
}
|
||||
if (contentlength64 > 0 && hascontent != 1) ckeepalive = 0;
|
||||
#else
|
||||
if (conf.filtermaxsize && contentlength > (unsigned long)conf.filtermaxsize) {
|
||||
param->nolongdatfilter = 1;
|
||||
}
|
||||
@@ -978,6 +1074,7 @@ for(;;){
|
||||
}
|
||||
}
|
||||
if (contentlength > 0 && hascontent != 1) ckeepalive = 0;
|
||||
#endif
|
||||
#else
|
||||
#endif
|
||||
if(!isconnect || param->operation){
|
||||
@@ -996,7 +1093,11 @@ for(;;){
|
||||
RETURN(521);
|
||||
}
|
||||
}
|
||||
#ifndef NOPSTDINT
|
||||
if((param->chunked || contentlength64 > 0) && param->operation != HTTP_HEAD && res != 204 && res != 304) {
|
||||
#else
|
||||
if((param->chunked || contentlength > 0) && param->operation != HTTP_HEAD && res != 204 && res != 304) {
|
||||
#endif
|
||||
do {
|
||||
if(param->chunked){
|
||||
char smallbuf[32];
|
||||
@@ -1021,18 +1122,32 @@ for(;;){
|
||||
break;
|
||||
}
|
||||
smallbuf[i] = 0;
|
||||
#ifndef NOPSTDINT
|
||||
contentlength64 = 0;
|
||||
sscanf(smallbuf, "%"PRINTF_INT64_MODIFIER"x", &contentlength64);
|
||||
if(contentlength64 == 0) {
|
||||
#else
|
||||
contentlength = 0;
|
||||
sscanf(smallbuf, "%lx", &contentlength);
|
||||
if(contentlength == 0) {
|
||||
#endif
|
||||
param->chunked = 2;
|
||||
}
|
||||
}
|
||||
if(param->chunked != 2){
|
||||
#ifndef NOPSTDINT
|
||||
param->waitserver64 = contentlength64;
|
||||
#else
|
||||
param->waitserver = contentlength;
|
||||
#endif
|
||||
if((res = sockmap(param, conf.timeouts[CONNECTION_S])) != 98){
|
||||
RETURN(res);
|
||||
}
|
||||
#ifndef NOPSTDINT
|
||||
param->waitserver64 = 0;
|
||||
#else
|
||||
param->waitserver = 0;
|
||||
#endif
|
||||
}
|
||||
} while(param->chunked);
|
||||
}
|
||||
@@ -1045,8 +1160,11 @@ for(;;){
|
||||
else if(!hascontent && !param->chunked) {
|
||||
RETURN(sockmap(param, conf.timeouts[CONNECTION_S]));
|
||||
}
|
||||
#ifndef NOPSTDINT
|
||||
contentlength64 = 0;
|
||||
#else
|
||||
contentlength = 0;
|
||||
|
||||
#endif
|
||||
REQUESTEND:
|
||||
|
||||
if((!ckeepalive || !keepalive) && param->remsock != INVALID_SOCKET){
|
||||
|
||||
Reference in new issue
Block a user