legacy counters code removed

This commit is contained in:
z3APA3A 2014-04-14 02:14:34 +04:00
parent 5543b3052d
commit f4c6c9d962
16 changed files with 3 additions and 483 deletions

View File

@ -45,12 +45,7 @@ struct counter_header {
} cheader = {"3CF", (time_t)0}; } cheader = {"3CF", (time_t)0};
struct counter_record { struct counter_record {
#ifndef NOPSTDINT
uint64_t traf64; uint64_t traf64;
#else
unsigned long traf;
unsigned long trafgb;
#endif
time_t cleared; time_t cleared;
time_t updated; time_t updated;
} crecord; } crecord;
@ -469,11 +464,7 @@ void dumpcounters(struct trafcount *tlin, int counterd){
if(cfp){ if(cfp){
for(tl = tlin; cfp && tl; tl = tl->next){ for(tl = tlin; cfp && tl; tl = tl->next){
if(tl->type >= conf.countertype) if(tl->type >= conf.countertype)
#ifndef NOPSTDINT
fprintf(cfp, "%05d %020"PRINTF_INT64_MODIFIER"u%s%s\n", tl->number, tl->traf64, tl->comment?" #" : "", tl->comment? tl->comment : ""); fprintf(cfp, "%05d %020"PRINTF_INT64_MODIFIER"u%s%s\n", tl->number, tl->traf64, tl->comment?" #" : "", tl->comment? tl->comment : "");
#else
fprintf(cfp, "%05d %010lu %010lu%s%s\n", tl->number, tl->trafgb, tl->traf, tl->comment?" #" : "", tl->comment? tl->comment : "");
#endif
} }
fclose(cfp); fclose(cfp);
} }
@ -488,24 +479,14 @@ void dumpcounters(struct trafcount *tlin, int counterd){
lseek(counterd, lseek(counterd,
sizeof(struct counter_header) + (tl->number - 1) * sizeof(struct counter_record), sizeof(struct counter_header) + (tl->number - 1) * sizeof(struct counter_record),
SEEK_SET); SEEK_SET);
#ifndef NOPSTDINT
crecord.traf64 = tl->traf64; crecord.traf64 = tl->traf64;
#else
crecord.traf = tl->traf;
crecord.trafgb = tl->trafgb;
#endif
crecord.cleared = tl->cleared; crecord.cleared = tl->cleared;
crecord.updated = tl->updated; crecord.updated = tl->updated;
write(counterd, &crecord, sizeof(struct counter_record)); write(counterd, &crecord, sizeof(struct counter_record));
} }
if(tl->type!=NEVER && timechanged(tl->cleared, conf.time, tl->type)){ if(tl->type!=NEVER && timechanged(tl->cleared, conf.time, tl->type)){
tl->cleared = conf.time; tl->cleared = conf.time;
#ifndef NOPSTDINT
tl->traf64 = 0; tl->traf64 = 0;
#else
tl->traf = 0;
tl->trafgb = 0;
#endif
} }
} }
} }
@ -1551,14 +1532,8 @@ static int h_ace(int argc, unsigned char **argv){
sscanf((char *)argv[1], "%u", &tl->number); sscanf((char *)argv[1], "%u", &tl->number);
sscanf((char *)argv[3], "%lu", &lim); sscanf((char *)argv[3], "%lu", &lim);
tl->type = getrotate(*argv[2]); tl->type = getrotate(*argv[2]);
#ifndef NOPSTDINT
tl->traflim64 = ((uint64_t)lim)*(1024*1024); tl->traflim64 = ((uint64_t)lim)*(1024*1024);
if(!tl->traflim64) { if(!tl->traflim64) {
#else
tl->traflimgb = (lim/(1024*4));
tl->traflim = ((lim - (tl->traflimgb*(1024*4)))*(1024*1024));
if(!tl->traflim && !tl->traflimgb) {
#endif
fprintf(stderr, "Wrong traffic limit specified, line %d\n", linenum); fprintf(stderr, "Wrong traffic limit specified, line %d\n", linenum);
return(6); return(6);
} }
@ -1568,12 +1543,7 @@ static int h_ace(int argc, unsigned char **argv){
SEEK_SET); SEEK_SET);
memset(&crecord, 0, sizeof(struct counter_record)); memset(&crecord, 0, sizeof(struct counter_record));
read(conf.counterd, &crecord, sizeof(struct counter_record)); read(conf.counterd, &crecord, sizeof(struct counter_record));
#ifndef NOPSTDINT
tl->traf64 = crecord.traf64; tl->traf64 = crecord.traf64;
#else
tl->traf = crecord.traf;
tl->trafgb = crecord.trafgb;
#endif
tl->cleared = crecord.cleared; tl->cleared = crecord.cleared;
tl->updated = crecord.updated; tl->updated = crecord.updated;
#ifdef _MAX__TIME64_T #ifdef _MAX__TIME64_T

View File

@ -115,11 +115,7 @@ int clientnegotiate(struct chain * redir, struct clientparam * param, unsigned l
len += sprintf((char *)buf + len, "\r\n"); len += sprintf((char *)buf + len, "\r\n");
if(socksend(param->remsock, buf, len, conf.timeouts[CHAIN_TO]) != (int)strlen((char *)buf)) if(socksend(param->remsock, buf, len, conf.timeouts[CHAIN_TO]) != (int)strlen((char *)buf))
return 31; return 31;
#ifndef NOPSTDINT
param->statssrv64+=len; param->statssrv64+=len;
#else
param->statssrv+=len;
#endif
param->nwrites++; param->nwrites++;
if((res = sockgetlinebuf(param, SERVER,buf,13,'\n',conf.timeouts[CHAIN_TO])) < 13) if((res = sockgetlinebuf(param, SERVER,buf,13,'\n',conf.timeouts[CHAIN_TO])) < 13)
return 32; return 32;
@ -156,11 +152,7 @@ int clientnegotiate(struct chain * redir, struct clientparam * param, unsigned l
if(socksend(param->remsock, buf, len, conf.timeouts[CHAIN_TO]) < len){ if(socksend(param->remsock, buf, len, conf.timeouts[CHAIN_TO]) < len){
return 41; return 41;
} }
#ifndef NOPSTDINT
param->statssrv64+=len; param->statssrv64+=len;
#else
param->statssrv+=len;
#endif
param->nwrites++; param->nwrites++;
if((len = sockgetlinebuf(param, SERVER, buf, (redir->type == R_SOCKS4B)? 3:8, EOF, conf.timeouts[CHAIN_TO])) != ((redir->type == R_SOCKS4B)? 3:8)){ if((len = sockgetlinebuf(param, SERVER, buf, (redir->type == R_SOCKS4B)? 3:8, EOF, conf.timeouts[CHAIN_TO])) != ((redir->type == R_SOCKS4B)? 3:8)){
return 42; return 42;
@ -183,11 +175,7 @@ int clientnegotiate(struct chain * redir, struct clientparam * param, unsigned l
if(socksend(param->remsock, buf, 3, conf.timeouts[CHAIN_TO]) != 3){ if(socksend(param->remsock, buf, 3, conf.timeouts[CHAIN_TO]) != 3){
return 51; return 51;
} }
#ifndef NOPSTDINT
param->statssrv64+=len; param->statssrv64+=len;
#else
param->statssrv+=len;
#endif
param->nwrites++; param->nwrites++;
if(sockgetlinebuf(param, SERVER, buf, 2, EOF, conf.timeouts[CHAIN_TO]) != 2){ if(sockgetlinebuf(param, SERVER, buf, 2, EOF, conf.timeouts[CHAIN_TO]) != 2){
return 52; return 52;
@ -209,11 +197,7 @@ int clientnegotiate(struct chain * redir, struct clientparam * param, unsigned l
if(socksend(param->remsock, buf, inbuf, conf.timeouts[CHAIN_TO]) != inbuf){ if(socksend(param->remsock, buf, inbuf, conf.timeouts[CHAIN_TO]) != inbuf){
return 51; return 51;
} }
#ifndef NOPSTDINT
param->statssrv64+=inbuf; param->statssrv64+=inbuf;
#else
param->statssrv+=inbuf;
#endif
param->nwrites++; param->nwrites++;
if(sockgetlinebuf(param, SERVER, buf, 2, EOF, 60) != 2){ if(sockgetlinebuf(param, SERVER, buf, 2, EOF, 60) != 2){
return 55; return 55;
@ -243,11 +227,7 @@ int clientnegotiate(struct chain * redir, struct clientparam * param, unsigned l
if(socksend(param->remsock, buf, len, conf.timeouts[CHAIN_TO]) != len){ if(socksend(param->remsock, buf, len, conf.timeouts[CHAIN_TO]) != len){
return 51; return 51;
} }
#ifndef NOPSTDINT
param->statssrv64+=len; param->statssrv64+=len;
#else
param->statssrv+=len;
#endif
param->nwrites++; param->nwrites++;
if(sockgetlinebuf(param, SERVER, buf, 4, EOF, conf.timeouts[CHAIN_TO]) != 4){ if(sockgetlinebuf(param, SERVER, buf, 4, EOF, conf.timeouts[CHAIN_TO]) != 4){
return 57; return 57;
@ -561,7 +541,6 @@ unsigned bandlimitfunc(struct clientparam *param, unsigned nbytesin, unsigned nb
void trafcountfunc(struct clientparam *param){ void trafcountfunc(struct clientparam *param){
struct trafcount * tc; struct trafcount * tc;
unsigned long val;
int countout = 0; int countout = 0;
pthread_mutex_lock(&tc_mutex); pthread_mutex_lock(&tc_mutex);
@ -573,13 +552,7 @@ void trafcountfunc(struct clientparam *param){
countout = 1; countout = 1;
continue; continue;
} }
#ifndef NOPSTDINT
tc->traf64 += param->statssrv64; tc->traf64 += param->statssrv64;
#else
val = tc->traf + param->statssrv;
if(val < tc->traf) tc->trafgb++;
tc->traf = val;
#endif
time(&t); time(&t);
tc->updated = t; tc->updated = t;
} }
@ -591,13 +564,7 @@ void trafcountfunc(struct clientparam *param){
if(tc->ace->action != COUNTOUT) { if(tc->ace->action != COUNTOUT) {
continue; continue;
} }
#ifndef NOPSTDINT
tc->traf64 += param->statscli64; tc->traf64 += param->statscli64;
#else
val = tc->traf + param->statscli;
if(val < tc->traf) tc->trafgb++;
tc->traf = val;
#endif
time(&t); time(&t);
tc->updated = t; tc->updated = t;
} }
@ -624,21 +591,9 @@ int alwaysauth(struct clientparam * param){
continue; continue;
} }
#ifndef NOPSTDINT
if(tc->traflim64 <= tc->traf64) return 10; if(tc->traflim64 <= tc->traf64) return 10;
param->trafcountfunc = conf.trafcountfunc; param->trafcountfunc = conf.trafcountfunc;
param->maxtrafin64 = tc->traflim64 - tc->traf64; param->maxtrafin64 = tc->traflim64 - tc->traf64;
#else
if((tc->traflimgb < tc->trafgb) ||
((tc->traflimgb == tc->trafgb) && (tc->traflim < tc->traf))
) return 10;
param->trafcountfunc = conf.trafcountfunc;
if(tc->traflimgb - tc->trafgb < 1 || ((tc->traflimgb - tc->trafgb) == 1 && tc->traf > tc->traflim)){
unsigned maxtraf = tc->traflim - tc->traf;
if(!param->maxtrafin || param->maxtrafin > maxtraf) param->maxtrafin = maxtraf;
}
if((tc->trafgb > tc->traflimgb) || (tc->trafgb == tc->traflimgb && tc->traf >= tc->traflim)) param->maxtrafin = 1;
#endif
} }
} }
if(countout)for(tc = conf.trafcounter; tc; tc = tc->next) { if(countout)for(tc = conf.trafcounter; tc; tc = tc->next) {
@ -649,21 +604,9 @@ int alwaysauth(struct clientparam * param){
continue; continue;
} }
#ifndef NOPSTDINT
if(tc->traflim64 <= tc->traf64) return 10; if(tc->traflim64 <= tc->traf64) return 10;
param->trafcountfunc = conf.trafcountfunc; param->trafcountfunc = conf.trafcountfunc;
param->maxtrafout64 = tc->traflim64 - tc->traf64; param->maxtrafout64 = tc->traflim64 - tc->traf64;
#else
if((tc->traflimgb < tc->trafgb) ||
((tc->traflimgb == tc->trafgb) && (tc->traflim < tc->traf))
) return 10;
param->trafcountfunc = conf.trafcountfunc;
if(tc->traflimgb - tc->trafgb < 1 || ((tc->traflimgb - tc->trafgb) == 1 && tc->traf > tc->traflim)){
unsigned maxtraf = tc->traflim - tc->traf;
if(!param->maxtrafout || param->maxtrafout > maxtraf) param->maxtrafout = maxtraf;
}
if((tc->trafgb > tc->traflimgb) || (tc->trafgb == tc->traflimgb && tc->traf >= tc->traflim)) param->maxtrafout = 1;
#endif
} }
} }
@ -1129,20 +1072,12 @@ unsigned long udpresolve(unsigned char * name, unsigned *retttl, struct clientpa
so._closesocket(sock); so._closesocket(sock);
continue; continue;
} }
#ifndef NOPSTDINT
if(param) param->statscli64 += len; if(param) param->statscli64 += len;
#else
if(param) param->statscli += len;
#endif
len = sockrecvfrom(sock, sinsp, buf, 4096, 15000); len = sockrecvfrom(sock, sinsp, buf, 4096, 15000);
so._shutdown(sock, SHUT_RDWR); so._shutdown(sock, SHUT_RDWR);
so._closesocket(sock); so._closesocket(sock);
if(len <= 13) continue; if(len <= 13) continue;
#ifndef NOPSTDINT
if(param) param->statssrv64 += len; if(param) param->statssrv64 += len;
#else
if(param) param->statssrv += len;
#endif
if(*(unsigned short *)buf != nquery)continue; if(*(unsigned short *)buf != nquery)continue;
if((na = buf[7] + (((unsigned short)buf[6])<<8)) < 1) { if((na = buf[7] + (((unsigned short)buf[6])<<8)) < 1) {
return 0; return 0;

View File

@ -287,11 +287,7 @@ void clearstat(struct clientparam * param) {
param->time_start = (time_t)tv.tv_sec; param->time_start = (time_t)tv.tv_sec;
param->msec_start = (tv.tv_usec / 1000); param->msec_start = (tv.tv_usec / 1000);
#endif #endif
#ifndef NOPSTDINT
param->statscli64 = param->statssrv64 = param->nreads = param->nwrites = param->statscli64 = param->statssrv64 = param->nreads = param->nwrites =
#else
param->statscli = param->statssrv = param->nreads = param->nwrites =
#endif
param->nconnects = 0; param->nconnects = 0;
} }
@ -382,17 +378,10 @@ int dobuf2(struct clientparam * param, unsigned char * buf, const unsigned char
i+=10; i+=10;
break; break;
case 'b': case 'b':
#ifndef NOPSTDINT
i+=sprintf((char *)buf+i, "%u", delay?(unsigned)(param->statscli64 * 1000./delay):0); i+=sprintf((char *)buf+i, "%u", delay?(unsigned)(param->statscli64 * 1000./delay):0);
break; break;
case 'B': case 'B':
i+=sprintf((char *)buf+i, "%u", delay?(unsigned)(param->statssrv64 * 1000./delay):0); i+=sprintf((char *)buf+i, "%u", delay?(unsigned)(param->statssrv64 * 1000./delay):0);
#else
i+=sprintf((char *)buf+i, "%u", delay?(unsigned)(param->statscli * 1000./delay):0);
break;
case 'B':
i+=sprintf((char *)buf+i, "%u", delay?(unsigned)(param->statssrv * 1000./delay):0);
#endif
break; break;
case 'D': case 'D':
i+=sprintf((char *)buf+i, "%u", delay); i+=sprintf((char *)buf+i, "%u", delay);
@ -489,19 +478,11 @@ int dobuf2(struct clientparam * param, unsigned char * buf, const unsigned char
i += (int)strlen((char *)buf+i); i += (int)strlen((char *)buf+i);
break; break;
case 'I': case 'I':
#ifndef NOPSTDINT
sprintf((char *)buf+i, "%"PRINTF_INT64_MODIFIER"u", param->statssrv64); sprintf((char *)buf+i, "%"PRINTF_INT64_MODIFIER"u", param->statssrv64);
i += (int)strlen((char *)buf+i); i += (int)strlen((char *)buf+i);
break; break;
case 'O': case 'O':
sprintf((char *)buf+i, "%"PRINTF_INT64_MODIFIER"u", param->statscli64); sprintf((char *)buf+i, "%"PRINTF_INT64_MODIFIER"u", param->statscli64);
#else
sprintf((char *)buf+i, "%lu", param->statssrv);
i += (int)strlen((char *)buf+i);
break;
case 'O':
sprintf((char *)buf+i, "%lu", param->statscli);
#endif
i += (int)strlen((char *)buf+i); i += (int)strlen((char *)buf+i);
break; break;
case 'h': case 'h':

View File

@ -8,12 +8,10 @@
#include "proxy.h" #include "proxy.h"
#ifndef NOPSTDINT
static void pr_unsigned64(struct node *node, CBFUNC cbf, void*cb){ static void pr_unsigned64(struct node *node, CBFUNC cbf, void*cb){
char buf[32]; char buf[32];
if(node->value)(*cbf)(cb, buf, sprintf(buf, "%"PRINTF_INT64_MODIFIER"u", *(uint64_t *)node->value)); if(node->value)(*cbf)(cb, buf, sprintf(buf, "%"PRINTF_INT64_MODIFIER"u", *(uint64_t *)node->value));
} }
#endif
static void pr_integer(struct node *node, CBFUNC cbf, void*cb){ static void pr_integer(struct node *node, CBFUNC cbf, void*cb){
char buf[16]; char buf[16];
@ -453,7 +451,6 @@ static void * ef_trafcounter_type(struct node * node){
return &((struct trafcount *)node->value) -> type; return &((struct trafcount *)node->value) -> type;
} }
#ifndef NOPSTDINT
static void * ef_trafcounter_traffic64(struct node * node){ static void * ef_trafcounter_traffic64(struct node * node){
return &((struct trafcount *)node->value) -> traf64; return &((struct trafcount *)node->value) -> traf64;
} }
@ -476,33 +473,6 @@ static void * ef_client_bytesout64(struct node * node){
return &((struct clientparam *)node->value) -> statscli64; return &((struct clientparam *)node->value) -> statscli64;
} }
#else
static void * ef_trafcounter_traffic(struct node * node){
return &((struct trafcount *)node->value) -> traf;
}
static void * ef_trafcounter_limit(struct node * node){
return &((struct trafcount *)node->value) -> traflim;
}
static void * ef_client_maxtrafin(struct node * node){
return &((struct clientparam *)node->value) -> maxtrafin;
}
static void * ef_client_maxtrafout(struct node * node){
return &((struct clientparam *)node->value) -> maxtrafout;
}
static void * ef_client_bytesin(struct node * node){
return &((struct clientparam *)node->value) -> statssrv;
}
static void * ef_client_bytesout(struct node * node){
return &((struct clientparam *)node->value) -> statscli;
}
#endif
static void * ef_trafcounter_cleared(struct node * node){ static void * ef_trafcounter_cleared(struct node * node){
return &((struct trafcount *)node->value) -> cleared; return &((struct trafcount *)node->value) -> cleared;
} }
@ -777,13 +747,8 @@ static struct property prop_trafcounter[] = {
{prop_trafcounter + 4, "type", ef_trafcounter_type, TYPE_ROTATION, "rotation type"}, {prop_trafcounter + 4, "type", ef_trafcounter_type, TYPE_ROTATION, "rotation type"},
#ifndef NOPSTDINT
{prop_trafcounter + 5, "traffic", ef_trafcounter_traffic64, TYPE_UNSIGNED64, "counter value"}, {prop_trafcounter + 5, "traffic", ef_trafcounter_traffic64, TYPE_UNSIGNED64, "counter value"},
{prop_trafcounter + 6, "limit", ef_trafcounter_limit64, TYPE_UNSIGNED64, "counter limit"}, {prop_trafcounter + 6, "limit", ef_trafcounter_limit64, TYPE_UNSIGNED64, "counter limit"},
#else
{prop_trafcounter + 5, "traffic", ef_trafcounter_traffic, TYPE_TRAFFIC, "counter value"},
{prop_trafcounter + 6, "limit", ef_trafcounter_limit, TYPE_TRAFFIC, "counter limit"},
#endif
{prop_trafcounter + 7, "cleared", ef_trafcounter_cleared, TYPE_DATETIME, "last rotated"}, {prop_trafcounter + 7, "cleared", ef_trafcounter_cleared, TYPE_DATETIME, "last rotated"},
{prop_trafcounter + 8, "updated", ef_trafcounter_updated, TYPE_DATETIME, "last updated"}, {prop_trafcounter + 8, "updated", ef_trafcounter_updated, TYPE_DATETIME, "last updated"},
{prop_trafcounter + 9, "comment", ef_trafcounter_comment, TYPE_STRING, "counter comment"}, {prop_trafcounter + 9, "comment", ef_trafcounter_comment, TYPE_STRING, "counter comment"},
@ -835,17 +800,10 @@ static struct property prop_client[] = {
{prop_client + 15, "srvport", ef_client_srvport, TYPE_PORT, "target server port"}, {prop_client + 15, "srvport", ef_client_srvport, TYPE_PORT, "target server port"},
{prop_client + 16, "reqip", ef_client_reqip, TYPE_IP, "requested server ip"}, {prop_client + 16, "reqip", ef_client_reqip, TYPE_IP, "requested server ip"},
{prop_client + 17, "reqport", ef_client_reqport, TYPE_PORT, "requested server port"}, {prop_client + 17, "reqport", ef_client_reqport, TYPE_PORT, "requested server port"},
#ifndef NOPSTDINT
{prop_client + 18, "bytesin", ef_client_bytesin64, TYPE_UNSIGNED64, "bytes from server to client"}, {prop_client + 18, "bytesin", ef_client_bytesin64, TYPE_UNSIGNED64, "bytes from server to client"},
{prop_client + 19, "bytesout", ef_client_bytesout64, TYPE_UNSIGNED64, "bytes from client to server"}, {prop_client + 19, "bytesout", ef_client_bytesout64, TYPE_UNSIGNED64, "bytes from client to server"},
{prop_client + 20, "maxtrafin", ef_client_maxtrafin64, TYPE_UNSIGNED64, "maximum traffic allowed for download"}, {prop_client + 20, "maxtrafin", ef_client_maxtrafin64, TYPE_UNSIGNED64, "maximum traffic allowed for download"},
{prop_client + 21, "maxtrafout", ef_client_maxtrafout64, TYPE_UNSIGNED64, "maximum traffic allowed for upload"}, {prop_client + 21, "maxtrafout", ef_client_maxtrafout64, TYPE_UNSIGNED64, "maximum traffic allowed for upload"},
#else
{prop_client + 18, "bytesin", ef_client_bytesin, TYPE_UNSIGNED, "bytes from server to client"},
{prop_client + 19, "bytesout", ef_client_bytesout, TYPE_UNSIGNED, "bytes from client to server"},
{prop_client + 20, "maxtrafin", ef_client_maxtrafin, TYPE_UNSIGNED, "maximum traffic allowed for download"},
{prop_client + 21, "maxtrafout", ef_client_maxtrafout, TYPE_UNSIGNED, "maximum traffic allowed for upload"},
#endif
{prop_client + 22, "pwtype", ef_client_pwtype, TYPE_INTEGER, "type of client password"}, {prop_client + 22, "pwtype", ef_client_pwtype, TYPE_INTEGER, "type of client password"},
{NULL, "next", ef_client_next, TYPE_CLIENT, "next"} {NULL, "next", ef_client_next, TYPE_CLIENT, "next"}

View File

@ -147,21 +147,13 @@ void * dnsprchild(struct clientparam* param) {
if(socksendto(param->remsock, &param->sins, buf, i, conf.timeouts[SINGLEBYTE_L]*1000) != i){ if(socksendto(param->remsock, &param->sins, buf, i, conf.timeouts[SINGLEBYTE_L]*1000) != i){
RETURN(820); RETURN(820);
} }
#ifndef NOPSTDINT
param->statscli64 += i; param->statscli64 += i;
#else
param->statscli += i;
#endif
param->nwrites++; param->nwrites++;
len = sockrecvfrom(param->remsock, &param->sins, buf, BUFSIZE, 15000); len = sockrecvfrom(param->remsock, &param->sins, buf, BUFSIZE, 15000);
if(len <= 13) { if(len <= 13) {
RETURN(821); RETURN(821);
} }
#ifndef NOPSTDINT
param->statssrv64 += len; param->statssrv64 += len;
#else
param->statssrv += len;
#endif
param->nreads++; param->nreads++;
if(buf[6] || buf[7]){ if(buf[6] || buf[7]){
if(socksendto(param->clisock, &param->sinc, buf, len, conf.timeouts[SINGLEBYTE_L]*1000) != len){ if(socksendto(param->clisock, &param->sinc, buf, len, conf.timeouts[SINGLEBYTE_L]*1000) != len){

View File

@ -276,11 +276,7 @@ param->srv->logfunc(param,buf);
buf[i++] = '\r'; buf[i++] = '\r';
buf[i++] = '\n'; buf[i++] = '\n';
if(socksend(param->remsock, buf, i, conf.timeouts[STRING_S])!=i) {RETURN (811);} if(socksend(param->remsock, buf, i, conf.timeouts[STRING_S])!=i) {RETURN (811);}
#ifndef NOPSTDINT
param->statscli64+=(i); param->statscli64+=(i);
#else
param->statscli+=(i);
#endif
param->nwrites++; param->nwrites++;
while((i = sockgetlinebuf(param, SERVER, buf, BUFSIZE, '\n', conf.timeouts[STRING_L])) > 0){ while((i = sockgetlinebuf(param, SERVER, buf, BUFSIZE, '\n', conf.timeouts[STRING_L])) > 0){
if(socksend(param->ctrlsock, buf, i, conf.timeouts[STRING_S])!=i) {RETURN (812);} if(socksend(param->ctrlsock, buf, i, conf.timeouts[STRING_S])!=i) {RETURN (812);}
@ -291,15 +287,9 @@ param->srv->logfunc(param,buf);
} }
sasize = sizeof(struct sockaddr_in); sasize = sizeof(struct sockaddr_in);
if(so._getpeername(param->ctrlsock, (struct sockaddr *)&param->sinc, &sasize)){RETURN(819);} if(so._getpeername(param->ctrlsock, (struct sockaddr *)&param->sinc, &sasize)){RETURN(819);}
#ifndef NOPSTDINT
if(req && (param->statscli64 || param->statssrv64)){ if(req && (param->statscli64 || param->statssrv64)){
(*param->srv->logfunc)(param, (unsigned char *)req); (*param->srv->logfunc)(param, (unsigned char *)req);
} }
#else
if(req && (param->statscli || param->statssrv)){
(*param->srv->logfunc)(param, (unsigned char *)req);
}
#endif
} }
CLEANRET: CLEANRET:
@ -318,11 +308,7 @@ CLEANRET:
} }
sasize = sizeof(struct sockaddr_in); sasize = sizeof(struct sockaddr_in);
so._getpeername(param->ctrlsock, (struct sockaddr *)&param->sinc, &sasize); so._getpeername(param->ctrlsock, (struct sockaddr *)&param->sinc, &sasize);
#ifndef NOPSTDINT
if(param->res != 0 || param->statscli64 || param->statssrv64 ){ if(param->res != 0 || param->statscli64 || param->statssrv64 ){
#else
if(param->res != 0 || param->statscli || param->statssrv ){
#endif
(*param->srv->logfunc)(param, (unsigned char *)((req && (param->res > 802))? req:NULL)); (*param->srv->logfunc)(param, (unsigned char *)((req && (param->res > 802))? req:NULL));
} }
if(req) myfree(req); if(req) myfree(req);

View File

@ -109,11 +109,7 @@ static void addbuffer(int increment, struct clientparam * param, unsigned char *
if(len > 0) { if(len > 0) {
*length_p += len; *length_p += len;
param->nreads++; param->nreads++;
#ifndef NOPSTDINT
param->statssrv64 += len; param->statssrv64 += len;
#else
param->statssrv += len;
#endif
} }
return; return;
} }
@ -441,31 +437,17 @@ void * icqprchild(struct clientparam* param) {
if(greet){ if(greet){
if(socksend(param->remsock, tmpsend, 10, conf.timeouts[STRING_S])!=10) {RETURN (1105);} if(socksend(param->remsock, tmpsend, 10, conf.timeouts[STRING_S])!=10) {RETURN (1105);}
#ifndef NOPSTDINT
param->statscli64 += 10; param->statscli64 += 10;
#else
param->statscli += 10;
#endif
} }
if(readflap(param, SERVER, tmpsend, 1024)) {RETURN (1111);} if(readflap(param, SERVER, tmpsend, 1024)) {RETURN (1111);}
#ifndef NOPSTDINT
param->statssrv64 += (ntohs(((struct flap_header *)tmpsend)->size) + 6); param->statssrv64 += (ntohs(((struct flap_header *)tmpsend)->size) + 6);
#else
param->statssrv += (ntohs(((struct flap_header *)tmpsend)->size) + 6);
#endif
mystate.srvseq = ntohs(((struct flap_header *)tmpsend)->seq) + 1; mystate.srvseq = ntohs(((struct flap_header *)tmpsend)->seq) + 1;
mystate.seq = 1; mystate.seq = 1;
len = ntohs(flap->size) + 6; len = ntohs(flap->size) + 6;
if((res=handledatfltcli(param, &buf, &buflen, offset, &len))!=PASS) RETURN(res); if((res=handledatfltcli(param, &buf, &buflen, offset, &len))!=PASS) RETURN(res);
if(socksend(param->remsock, buf+offset, len, conf.timeouts[STRING_S])!=(ntohs(flap->size)+6)) {RETURN (1106);} if(socksend(param->remsock, buf+offset, len, conf.timeouts[STRING_S])!=(ntohs(flap->size)+6)) {RETURN (1106);}
offset = 0; offset = 0;
#ifndef NOPSTDINT
param->statscli64 += len; param->statscli64 += len;
#else
param->statscli += len;
#endif
if(logintype == ICQMD5) { if(logintype == ICQMD5) {
if(readflap(param, SERVER, buf, 65550)) {RETURN (1112);} if(readflap(param, SERVER, buf, 65550)) {RETURN (1112);}
@ -481,11 +463,7 @@ void * icqprchild(struct clientparam* param) {
len = ntohs(flap->size) + 6; len = ntohs(flap->size) + 6;
if((res=handledatfltcli(param, &buf, &buflen, offset, &len))!=PASS) RETURN(res); if((res=handledatfltcli(param, &buf, &buflen, offset, &len))!=PASS) RETURN(res);
if(socksend(param->remsock, buf+offset, len, conf.timeouts[STRING_S])!=len) {RETURN (1115);} if(socksend(param->remsock, buf+offset, len, conf.timeouts[STRING_S])!=len) {RETURN (1115);}
#ifndef NOPSTDINT
param->statscli64 += len; param->statscli64 += len;
#else
param->statscli += len;
#endif
offset = 0; offset = 0;
} }
if(logintype != ICQCOOKIE) { if(logintype != ICQCOOKIE) {

View File

@ -173,22 +173,14 @@ void * msnprchild(struct clientparam* param) {
if(!sec){ if(!sec){
len = (int)strlen(verstr); len = (int)strlen(verstr);
if(socksend(param->remsock, verstr, len, conf.timeouts[STRING_S])!= len) {RETURN (1207);} if(socksend(param->remsock, verstr, len, conf.timeouts[STRING_S])!= len) {RETURN (1207);}
#ifndef NOPSTDINT
param->statscli64 += len; param->statscli64 += len;
#else
param->statscli += len;
#endif
myfree(verstr); myfree(verstr);
verstr = mystrdup(buf); verstr = mystrdup(buf);
len = sockgetlinebuf(param, SERVER, buf, 240, '\n', conf.timeouts[STRING_S]); len = sockgetlinebuf(param, SERVER, buf, 240, '\n', conf.timeouts[STRING_S]);
if(len < 10) RETURN(1208); if(len < 10) RETURN(1208);
#ifndef NOPSTDINT
param->statssrv64 += len; param->statssrv64 += len;
#else
param->statssrv += len;
#endif
strcpy(buf, verstr); strcpy(buf, verstr);
} }
@ -198,11 +190,7 @@ void * msnprchild(struct clientparam* param) {
if(socksend(param->remsock, buf, len, conf.timeouts[STRING_S])!= len) {RETURN (1207);} if(socksend(param->remsock, buf, len, conf.timeouts[STRING_S])!= len) {RETURN (1207);}
#ifndef NOPSTDINT
param->statscli64 += len; param->statscli64 += len;
#else
param->statscli += len;
#endif
if(sec){ if(sec){
RETURN(sockmap(param, conf.timeouts[CONNECTION_L])); RETURN(sockmap(param, conf.timeouts[CONNECTION_L]));

View File

@ -43,11 +43,7 @@ void * pop3pchild(struct clientparam* param) {
socksend(param->remsock, param->extusername, (int)strlen((char *)param->extusername), conf.timeouts[STRING_S]) <= 0 || socksend(param->remsock, param->extusername, (int)strlen((char *)param->extusername), conf.timeouts[STRING_S]) <= 0 ||
socksend(param->remsock, (unsigned char *)"\r\n", 2, conf.timeouts[STRING_S])!=2) socksend(param->remsock, (unsigned char *)"\r\n", 2, conf.timeouts[STRING_S])!=2)
{RETURN(623);} {RETURN(623);}
#ifndef NOPSTDINT
param->statscli64 += (uint64_t)(strlen((char *)param->extusername) + 7); param->statscli64 += (uint64_t)(strlen((char *)param->extusername) + 7);
#else
param->statscli += (int)(strlen((char *)param->extusername) + 7);
#endif
param->nwrites++; param->nwrites++;
RETURN (sockmap(param, 180)); RETURN (sockmap(param, 180));
CLEANRET: CLEANRET:

View File

@ -217,11 +217,7 @@ void * proxychild(struct clientparam* param) {
unsigned char *ftpbase=NULL; unsigned char *ftpbase=NULL;
unsigned char username[1024]; unsigned char username[1024];
int keepalive = 0; int keepalive = 0;
#ifndef NOPSTDINT
uint64_t contentlength64 = 0; uint64_t contentlength64 = 0;
#else
unsigned long contentlength = 0;
#endif
int hascontent =0; int hascontent =0;
int isconnect = 0; int isconnect = 0;
int redirect = 0; int redirect = 0;
@ -392,7 +388,6 @@ for(;;){
while( (i = sockgetlinebuf(param, CLIENT, buf, BUFSIZE - 1, '\n', conf.timeouts[STRING_S])) > 2){ while( (i = sockgetlinebuf(param, CLIENT, buf, BUFSIZE - 1, '\n', conf.timeouts[STRING_S])) > 2){
if(i> 15 && (!strncasecmp((char *)(buf), "content-length", 14))){ if(i> 15 && (!strncasecmp((char *)(buf), "content-length", 14))){
buf[i]=0; buf[i]=0;
#ifndef NOPSTDINT
sscanf((char *)buf + 15, "%"PRINTF_INT64_MODIFIER"u", &contentlength64); sscanf((char *)buf + 15, "%"PRINTF_INT64_MODIFIER"u", &contentlength64);
} }
} }
@ -401,16 +396,6 @@ for(;;){
contentlength64-=i; contentlength64-=i;
} }
contentlength64 = 0; contentlength64 = 0;
#else
sscanf((char *)buf + 15, "%lu", &contentlength);
}
}
while( contentlength > 0 && (i = sockgetlinebuf(param, CLIENT, buf, (BUFSIZE < contentlength)? BUFSIZE - 1:contentlength, '\n', conf.timeouts[STRING_S])) > 0){
if ((unsigned long)i > contentlength) break;
contentlength-=i;
}
contentlength = 0;
#endif
if(param->password)myfree(param->password); if(param->password)myfree(param->password);
param->password = myalloc(32); param->password = myalloc(32);
param->pwtype = 2; param->pwtype = 2;
@ -507,19 +492,11 @@ for(;;){
if(!sb)continue; if(!sb)continue;
++sb; ++sb;
while(isspace(*sb))sb++; while(isspace(*sb))sb++;
#ifndef NOPSTDINT
sscanf(sb, "%"PRINTF_INT64_MODIFIER"u",&contentlength64); sscanf(sb, "%"PRINTF_INT64_MODIFIER"u",&contentlength64);
if(param->maxtrafout64 && (param->maxtrafout64 < param->statscli64 || contentlength64 > param->maxtrafout64 - param->statscli64)){ if(param->maxtrafout64 && (param->maxtrafout64 < param->statscli64 || contentlength64 > param->maxtrafout64 - param->statscli64)){
RETURN(10); RETURN(10);
} }
if(param->ndatfilterscli > 0 && contentlength64 > 0) continue; 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; inbuf += i;
if((bufsize - inbuf) < LINESIZE){ if((bufsize - inbuf) < LINESIZE){
@ -550,34 +527,19 @@ for(;;){
RETURN(0); RETURN(0);
} }
if(action != PASS) RETURN(517); if(action != PASS) RETURN(517);
#ifndef NOPSTDINT
if(param->ndatfilterscli > 0 && contentlength64 > 0){ if(param->ndatfilterscli > 0 && contentlength64 > 0){
uint64_t newlen64; uint64_t newlen64;
newlen64 = sockfillbuffcli(param, (unsigned long)contentlength64, CONNECTION_S); newlen64 = sockfillbuffcli(param, (unsigned long)contentlength64, CONNECTION_S);
if(newlen64 == contentlength64) { 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, &param->clibuf, &param->clibufsize, 0, &param->cliinbuf); action = handledatfltcli(param, &param->clibuf, &param->clibufsize, 0, &param->cliinbuf);
if(action == HANDLED){ if(action == HANDLED){
RETURN(0); RETURN(0);
} }
if(action != PASS) RETURN(517); if(action != PASS) RETURN(517);
#ifndef NOPSTDINT
contentlength64 = param->cliinbuf; contentlength64 = param->cliinbuf;
#else
contentlength = param->cliinbuf;
#endif
param->ndatfilterscli = 0; param->ndatfilterscli = 0;
} }
#ifndef NOPSTDINT
sprintf((char*)buf+strlen((char *)buf), "Content-Length: %"PRINTF_INT64_MODIFIER"u\r\n", contentlength64); 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 #endif
@ -657,11 +619,7 @@ for(;;){
socksend(param->clisock, (unsigned char *)proxy_stringtable[8], (int)strlen(proxy_stringtable[8]), conf.timeouts[STRING_S]); socksend(param->clisock, (unsigned char *)proxy_stringtable[8], (int)strlen(proxy_stringtable[8]), conf.timeouts[STRING_S]);
s = param->remsock; s = param->remsock;
param->remsock = ftps; param->remsock = ftps;
#ifndef NOPSTDINT
if((param->operation == FTP_PUT) && (contentlength64 > 0)) param->waitclient64 = contentlength64; 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]); res = sockmap(param, conf.timeouts[CONNECTION_L]);
if (res == 99) res = 0; if (res == 99) res = 0;
so._closesocket(ftps); so._closesocket(ftps);
@ -863,11 +821,7 @@ for(;;){
if(socksend(param->remsock, req , (res = (int)strlen((char *)req)), conf.timeouts[STRING_L]) != res) { if(socksend(param->remsock, req , (res = (int)strlen((char *)req)), conf.timeouts[STRING_L]) != res) {
RETURN(518); RETURN(518);
} }
#ifndef NOPSTDINT
param->statscli64 += res; param->statscli64 += res;
#else
param->statscli += res;
#endif
param->nwrites++; param->nwrites++;
} }
inbuf = 0; inbuf = 0;
@ -899,16 +853,11 @@ for(;;){
if ((res = socksend(param->remsock, buf+reqlen, (int)strlen((char *)buf+reqlen), conf.timeouts[STRING_S])) != (int)strlen((char *)buf+reqlen)) { if ((res = socksend(param->remsock, buf+reqlen, (int)strlen((char *)buf+reqlen), conf.timeouts[STRING_S])) != (int)strlen((char *)buf+reqlen)) {
RETURN(518); RETURN(518);
} }
#ifndef NOPSTDINT
param->statscli64 += res; param->statscli64 += res;
#else
param->statscli += res;
#endif
param->nwrites++; param->nwrites++;
if(param->bandlimfunc) { if(param->bandlimfunc) {
sleeptime = param->bandlimfunc(param, 0, (int)strlen((char *)buf)); sleeptime = param->bandlimfunc(param, 0, (int)strlen((char *)buf));
} }
#ifndef NOPSTDINT
if(contentlength64 > 0){ if(contentlength64 > 0){
param->nolongdatfilter = 0; param->nolongdatfilter = 0;
param->waitclient64 = contentlength64; param->waitclient64 = contentlength64;
@ -919,18 +868,6 @@ for(;;){
} }
} }
contentlength64 = 0; contentlength64 = 0;
#else
if(contentlength > 0){
param->nolongdatfilter = 0;
param->waitclient = contentlength;
res = sockmap(param, conf.timeouts[CONNECTION_S]);
param->waitclient = 0;
if(res != 99) {
RETURN(res);
}
}
contentlength = 0;
#endif
inbuf = 0; inbuf = 0;
ckeepalive = keepalive; ckeepalive = keepalive;
res = 0; res = 0;
@ -963,21 +900,13 @@ for(;;){
if(!sb)continue; if(!sb)continue;
++sb; ++sb;
while(isspace(*sb))sb++; while(isspace(*sb))sb++;
#ifndef NOPSTDINT
sscanf(sb, "%"PRINTF_INT64_MODIFIER"u", &contentlength64); sscanf(sb, "%"PRINTF_INT64_MODIFIER"u", &contentlength64);
#else
sscanf(sb, "%lu", &contentlength);
#endif
hascontent = 1; hascontent = 1;
if(param->unsafefilter && param->ndatfilterssrv > 0) { if(param->unsafefilter && param->ndatfilterssrv > 0) {
hascontent = 2; hascontent = 2;
continue; continue;
} }
#ifndef NOPSTDINT
if(param->maxtrafin64 && (param->maxtrafin64 < param->statssrv64 || contentlength64 + param->statssrv64 > param->maxtrafin64)){ 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); RETURN(10);
} }
} }
@ -1006,11 +935,7 @@ for(;;){
} }
if((res == 304 || res == 204) && !hascontent){ if((res == 304 || res == 204) && !hascontent){
hascontent = 1; hascontent = 1;
#ifndef NOPSTDINT
contentlength64 = 0; contentlength64 = 0;
#else
contentlength = 0;
#endif
} }
if(param->bandlimfunc) { if(param->bandlimfunc) {
int st1; int st1;
@ -1034,7 +959,6 @@ for(;;){
param->nolongdatfilter = 0; param->nolongdatfilter = 0;
#ifndef NOPSTDINT
if (conf.filtermaxsize && contentlength64 > (uint64_t)conf.filtermaxsize) { if (conf.filtermaxsize && contentlength64 > (uint64_t)conf.filtermaxsize) {
param->nolongdatfilter = 1; param->nolongdatfilter = 1;
} }
@ -1054,27 +978,6 @@ for(;;){
} }
} }
if (contentlength64 > 0 && hascontent != 1) ckeepalive = 0; if (contentlength64 > 0 && hascontent != 1) ckeepalive = 0;
#else
if (conf.filtermaxsize && contentlength > (unsigned long)conf.filtermaxsize) {
param->nolongdatfilter = 1;
}
else if(param->unsafefilter && param->ndatfilterssrv > 0 && contentlength > 0 && param->operation != HTTP_HEAD && res != 204 && res != 304){
unsigned long newlen;
newlen = sockfillbuffsrv(param, (unsigned long) contentlength, CONNECTION_S);
if(newlen == contentlength) {
action = handledatfltsrv(param, &param->srvbuf, &param->srvbufsize, 0, &param->srvinbuf);
param->nolongdatfilter = 1;
if(action == HANDLED){
RETURN(0);
}
if(action != PASS) RETURN(517);
contentlength = param->srvinbuf;
sprintf((char*)buf+strlen((char *)buf), "Content-Length: %lu\r\n", contentlength);
hascontent = 1;
}
}
if (contentlength > 0 && hascontent != 1) ckeepalive = 0;
#endif
#else #else
#endif #endif
if(!isconnect || param->operation){ if(!isconnect || param->operation){
@ -1093,11 +996,7 @@ for(;;){
RETURN(521); RETURN(521);
} }
} }
#ifndef NOPSTDINT
if((param->chunked || contentlength64 > 0) && param->operation != HTTP_HEAD && res != 204 && res != 304) { 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 { do {
if(param->chunked){ if(param->chunked){
char smallbuf[32]; char smallbuf[32];
@ -1122,32 +1021,18 @@ for(;;){
break; break;
} }
smallbuf[i] = 0; smallbuf[i] = 0;
#ifndef NOPSTDINT
contentlength64 = 0; contentlength64 = 0;
sscanf(smallbuf, "%"PRINTF_INT64_MODIFIER"x", &contentlength64); sscanf(smallbuf, "%"PRINTF_INT64_MODIFIER"x", &contentlength64);
if(contentlength64 == 0) { if(contentlength64 == 0) {
#else
contentlength = 0;
sscanf(smallbuf, "%lx", &contentlength);
if(contentlength == 0) {
#endif
param->chunked = 2; param->chunked = 2;
} }
} }
if(param->chunked != 2){ if(param->chunked != 2){
#ifndef NOPSTDINT
param->waitserver64 = contentlength64; param->waitserver64 = contentlength64;
#else
param->waitserver = contentlength;
#endif
if((res = sockmap(param, conf.timeouts[CONNECTION_S])) != 98){ if((res = sockmap(param, conf.timeouts[CONNECTION_S])) != 98){
RETURN(res); RETURN(res);
} }
#ifndef NOPSTDINT
param->waitserver64 = 0; param->waitserver64 = 0;
#else
param->waitserver = 0;
#endif
} }
} while(param->chunked); } while(param->chunked);
} }
@ -1160,11 +1045,7 @@ for(;;){
else if(!hascontent && !param->chunked) { else if(!hascontent && !param->chunked) {
RETURN(sockmap(param, conf.timeouts[CONNECTION_S])); RETURN(sockmap(param, conf.timeouts[CONNECTION_S]));
} }
#ifndef NOPSTDINT
contentlength64 = 0; contentlength64 = 0;
#else
contentlength = 0;
#endif
REQUESTEND: REQUESTEND:
if((!ckeepalive || !keepalive) && param->remsock != INVALID_SOCKET){ if((!ckeepalive || !keepalive) && param->remsock != INVALID_SOCKET){

View File

@ -191,11 +191,7 @@ void * smtppchild(struct clientparam* param) {
ul = param->extip; ul = param->extip;
i = sprintf(buf, "EHLO [%lu.%lu.%lu.%lu]\r\n", ((ul&0xFF000000)>>24), ((ul&0x00FF0000)>>16), ((ul&0x0000FF00)>>8), ((ul&0x000000FF))); i = sprintf(buf, "EHLO [%lu.%lu.%lu.%lu]\r\n", ((ul&0xFF000000)>>24), ((ul&0x00FF0000)>>16), ((ul&0x0000FF00)>>8), ((ul&0x000000FF)));
if(socksend(param->remsock, buf, i, conf.timeouts[STRING_S])!= i) {RETURN(673);} if(socksend(param->remsock, buf, i, conf.timeouts[STRING_S])!= i) {RETURN(673);}
#ifndef NOPSTDINT
param->statscli64+=i; param->statscli64+=i;
#else
param->statscli+=i;
#endif
param->nwrites++; param->nwrites++;
login = 0; login = 0;
do { do {
@ -213,42 +209,26 @@ void * smtppchild(struct clientparam* param) {
} }
if ((login & 1)) { if ((login & 1)) {
socksend(param->remsock, "AUTH LOGIN\r\n", 12, conf.timeouts[STRING_S]); socksend(param->remsock, "AUTH LOGIN\r\n", 12, conf.timeouts[STRING_S]);
#ifndef NOPSTDINT
param->statscli64+=12; param->statscli64+=12;
#else
param->statscli+=12;
#endif
param->nwrites++; param->nwrites++;
i = sockgetlinebuf(param, SERVER, buf, sizeof(buf) - 1, '\n', conf.timeouts[STRING_L]); i = sockgetlinebuf(param, SERVER, buf, sizeof(buf) - 1, '\n', conf.timeouts[STRING_L]);
if(i<4 || strncasecmp((char *)buf, "334", 3)) {RETURN(680);} if(i<4 || strncasecmp((char *)buf, "334", 3)) {RETURN(680);}
en64(param->extusername, buf, (int)strlen(param->extusername)); en64(param->extusername, buf, (int)strlen(param->extusername));
socksend(param->remsock, buf, (int)strlen(buf), conf.timeouts[STRING_S]); socksend(param->remsock, buf, (int)strlen(buf), conf.timeouts[STRING_S]);
socksend(param->remsock, "\r\n", 2, conf.timeouts[STRING_S]); socksend(param->remsock, "\r\n", 2, conf.timeouts[STRING_S]);
#ifndef NOPSTDINT
param->statscli64+=(i+2); param->statscli64+=(i+2);
#else
param->statscli+=(i+2);
#endif
param->nwrites+=2; param->nwrites+=2;
i = sockgetlinebuf(param, SERVER, buf, sizeof(buf) - 1, '\n', conf.timeouts[STRING_L]); i = sockgetlinebuf(param, SERVER, buf, sizeof(buf) - 1, '\n', conf.timeouts[STRING_L]);
if(i<4 || strncasecmp((char *)buf, "334", 3)) {RETURN(681);} if(i<4 || strncasecmp((char *)buf, "334", 3)) {RETURN(681);}
en64(param->extpassword, buf, (int)strlen(param->extpassword)); en64(param->extpassword, buf, (int)strlen(param->extpassword));
socksend(param->remsock, buf, (int)strlen(buf), conf.timeouts[STRING_S]); socksend(param->remsock, buf, (int)strlen(buf), conf.timeouts[STRING_S]);
socksend(param->remsock, "\r\n", 2, conf.timeouts[STRING_S]); socksend(param->remsock, "\r\n", 2, conf.timeouts[STRING_S]);
#ifndef NOPSTDINT
param->statscli64+=(i+2); param->statscli64+=(i+2);
#else
param->statscli+=(i+2);
#endif
param->nwrites+=2; param->nwrites+=2;
} }
else if((login & 2)){ else if((login & 2)){
socksend(param->remsock, "AUTH PLAIN\r\n", 12, conf.timeouts[STRING_S]); socksend(param->remsock, "AUTH PLAIN\r\n", 12, conf.timeouts[STRING_S]);
#ifndef NOPSTDINT
param->statscli64+=(12); param->statscli64+=(12);
#else
param->statscli+=(12);
#endif
param->nwrites++; param->nwrites++;
i = sockgetlinebuf(param, SERVER, buf, sizeof(buf) - 1, '\n', conf.timeouts[STRING_L]); i = sockgetlinebuf(param, SERVER, buf, sizeof(buf) - 1, '\n', conf.timeouts[STRING_L]);
if(i<4 || strncasecmp((char *)buf, "334", 3)) {RETURN(682);} if(i<4 || strncasecmp((char *)buf, "334", 3)) {RETURN(682);}
@ -263,11 +243,7 @@ void * smtppchild(struct clientparam* param) {
i = (int)strlen(buf); i = (int)strlen(buf);
socksend(param->remsock, buf, i, conf.timeouts[STRING_S]); socksend(param->remsock, buf, i, conf.timeouts[STRING_S]);
socksend(param->remsock, "\r\n", 2, conf.timeouts[STRING_S]); socksend(param->remsock, "\r\n", 2, conf.timeouts[STRING_S]);
#ifndef NOPSTDINT
param->statscli64+=(i+2); param->statscli64+=(i+2);
#else
param->statscli+=(i+2);
#endif
param->nwrites+=2; param->nwrites+=2;
} }
if(command) { if(command) {

View File

@ -126,11 +126,7 @@ int sockfillbuffsrv(struct clientparam * param, unsigned long size, int timeosec
if((len = sockrecvfrom(param->remsock, &param->sinc, param->srvbuf + param->srvinbuf, (param->srvbufsize - param->srvinbuf) < size? param->srvbufsize - param->srvinbuf:size, timeosec*1000)) > 0){ if((len = sockrecvfrom(param->remsock, &param->sinc, param->srvbuf + param->srvinbuf, (param->srvbufsize - param->srvinbuf) < size? param->srvbufsize - param->srvinbuf:size, timeosec*1000)) > 0){
param->srvinbuf += len; param->srvinbuf += len;
param->nreads++; param->nreads++;
#ifndef NOPSTDINT
param->statssrv64 += len; param->statssrv64 += len;
#else
param->statssrv += len;
#endif
} }
return param->srvinbuf; return param->srvinbuf;
} }
@ -156,11 +152,7 @@ int sockgetcharsrv(struct clientparam * param, int timeosec, int timeousec){
param->srvinbuf = len; param->srvinbuf = len;
param->srvoffset = 1; param->srvoffset = 1;
param->nreads++; param->nreads++;
#ifndef NOPSTDINT
param->statssrv64 += len; param->statssrv64 += len;
#else
param->statssrv += len;
#endif
return (int)*param->srvbuf; return (int)*param->srvbuf;
} }

View File

@ -13,11 +13,7 @@
int sockmap(struct clientparam * param, int timeo){ int sockmap(struct clientparam * param, int timeo){
int res=0; int res=0;
#ifndef NOPSTDINT
uint64_t sent=0, received=0; uint64_t sent=0, received=0;
#else
unsigned sent=0, received=0;
#endif
SASIZETYPE sasize; SASIZETYPE sasize;
struct pollfd fds[2]; struct pollfd fds[2];
int sleeptime = 0, stop = 0; int sleeptime = 0, stop = 0;
@ -36,20 +32,12 @@ int sockmap(struct clientparam * param, int timeo){
#if DEBUGLEVEL > 2 #if DEBUGLEVEL > 2
(*param->srv->logfunc)(param, "Starting sockets mapping"); (*param->srv->logfunc)(param, "Starting sockets mapping");
#endif #endif
#ifndef NOPSTDINT
if(!param->waitclient64){ if(!param->waitclient64){
#else
if(!param->waitclient){
#endif
if(!param->srvbuf && (!(param->srvbuf=myalloc(bufsize)) || !(param->srvbufsize = bufsize))){ if(!param->srvbuf && (!(param->srvbuf=myalloc(bufsize)) || !(param->srvbufsize = bufsize))){
return (21); return (21);
} }
} }
#ifndef NOPSTDINT
if(!param->waitserver64){ if(!param->waitserver64){
#else
if(!param->waitserver){
#endif
if(!param->clibuf && (!(param->clibuf=myalloc(bufsize)) || !(param->clibufsize = bufsize))){ if(!param->clibuf && (!(param->clibuf=myalloc(bufsize)) || !(param->clibufsize = bufsize))){
return (21); return (21);
} }
@ -81,7 +69,6 @@ int sockmap(struct clientparam * param, int timeo){
while (!stop&&!conf.timetoexit){ while (!stop&&!conf.timetoexit){
sasize = sizeof(struct sockaddr_in); sasize = sizeof(struct sockaddr_in);
#ifndef NOPSTDINT
if((param->maxtrafin64 && param->statssrv64 >= param->maxtrafin64) || (param->maxtrafout64 && param->statscli64 >= param->maxtrafout64)){ if((param->maxtrafin64 && param->statssrv64 >= param->maxtrafin64) || (param->maxtrafout64 && param->statscli64 >= param->maxtrafout64)){
return (10); return (10);
} }
@ -90,47 +77,25 @@ int sockmap(struct clientparam * param, int timeo){
(*param->srv->logfunc)(param, NULL); (*param->srv->logfunc)(param, NULL);
fds[0].events = fds[1].events = 0; fds[0].events = fds[1].events = 0;
if(param->srvinbuf > param->srvoffset && !param->waitclient64) { if(param->srvinbuf > param->srvoffset && !param->waitclient64) {
#else
if((param->maxtrafin && param->statssrv >= param->maxtrafin) || (param->maxtrafout && param->statscli >= param->maxtrafout)){
return (10);
}
if((param->srv->logdumpsrv && (param->statssrv > param->srv->logdumpsrv)) ||
(param->srv->logdumpcli && (param->statscli > param->srv->logdumpcli)))
(*param->srv->logfunc)(param, NULL);
fds[0].events = fds[1].events = 0;
if(param->srvinbuf > param->srvoffset && !param->waitclient) {
#endif
#if DEBUGLEVEL > 2 #if DEBUGLEVEL > 2
(*param->srv->logfunc)(param, "will send to client"); (*param->srv->logfunc)(param, "will send to client");
#endif #endif
fds[0].events |= POLLOUT; fds[0].events |= POLLOUT;
} }
#ifndef NOPSTDINT
if((param->srvbufsize - param->srvinbuf) > minsize && !param->waitclient64 && (!param->waitserver64 ||(received + param->srvinbuf - param->srvoffset < param->waitserver64))) { if((param->srvbufsize - param->srvinbuf) > minsize && !param->waitclient64 && (!param->waitserver64 ||(received + param->srvinbuf - param->srvoffset < param->waitserver64))) {
#else
if((param->srvbufsize - param->srvinbuf) > minsize && !param->waitclient && (!param->waitserver ||(received + param->srvinbuf - param->srvoffset < param->waitserver))) {
#endif
#if DEBUGLEVEL > 2 #if DEBUGLEVEL > 2
(*param->srv->logfunc)(param, "Will recv from server"); (*param->srv->logfunc)(param, "Will recv from server");
#endif #endif
fds[1].events |= POLLIN; fds[1].events |= POLLIN;
} }
#ifndef NOPSTDINT
if(param->cliinbuf > param->clioffset && !param->waitserver64) { if(param->cliinbuf > param->clioffset && !param->waitserver64) {
#else
if(param->cliinbuf > param->clioffset && !param->waitserver) {
#endif
#if DEBUGLEVEL > 2 #if DEBUGLEVEL > 2
(*param->srv->logfunc)(param, "Will send to server"); (*param->srv->logfunc)(param, "Will send to server");
#endif #endif
fds[1].events |= POLLOUT; fds[1].events |= POLLOUT;
} }
#ifndef NOPSTDINT
if((param->clibufsize - param->cliinbuf) > minsize && !param->waitserver64 &&(!param->srv->singlepacket || param->service != S_UDPPM) ) { if((param->clibufsize - param->cliinbuf) > minsize && !param->waitserver64 &&(!param->srv->singlepacket || param->service != S_UDPPM) ) {
#else
if((param->clibufsize - param->cliinbuf) > minsize && !param->waitserver &&(!param->srv->singlepacket || param->service != S_UDPPM) ) {
#endif
#if DEBUGLEVEL > 2 #if DEBUGLEVEL > 2
(*param->srv->logfunc)(param, "Will recv from client"); (*param->srv->logfunc)(param, "Will recv from client");
#endif #endif
@ -163,11 +128,7 @@ int sockmap(struct clientparam * param, int timeo){
if(param->bandlimfunc) { if(param->bandlimfunc) {
sleeptime = (*param->bandlimfunc)(param, param->srvinbuf - param->srvoffset, 0); sleeptime = (*param->bandlimfunc)(param, param->srvinbuf - param->srvoffset, 0);
} }
#ifndef NOPSTDINT
res = so._sendto(param->clisock, param->srvbuf + param->srvoffset,(!param->waitserver64 || (param->waitserver64 - received) > (param->srvinbuf - param->srvoffset))? param->srvinbuf - param->srvoffset : (int)(param->waitserver64 - received), 0, (struct sockaddr*)&param->sinc, sasize); res = so._sendto(param->clisock, param->srvbuf + param->srvoffset,(!param->waitserver64 || (param->waitserver64 - received) > (param->srvinbuf - param->srvoffset))? param->srvinbuf - param->srvoffset : (int)(param->waitserver64 - received), 0, (struct sockaddr*)&param->sinc, sasize);
#else
res = so._sendto(param->clisock, param->srvbuf + param->srvoffset,(!param->waitserver || ((unsigned)param->waitserver - received) > (param->srvinbuf - param->srvoffset))? param->srvinbuf - param->srvoffset : param->waitserver - received, 0, (struct sockaddr*)&param->sinc, sasize);
#endif
if(res < 0) { if(res < 0) {
if(errno != EAGAIN) return 96; if(errno != EAGAIN) return 96;
continue; continue;
@ -175,11 +136,7 @@ int sockmap(struct clientparam * param, int timeo){
param->srvoffset += res; param->srvoffset += res;
received += res; received += res;
if(param->srvoffset == param->srvinbuf) param->srvoffset = param->srvinbuf = 0; if(param->srvoffset == param->srvinbuf) param->srvoffset = param->srvinbuf = 0;
#ifndef NOPSTDINT
if(param->waitserver64 && param->waitserver64<= received){ if(param->waitserver64 && param->waitserver64<= received){
#else
if(param->waitserver && param->waitserver<= received){
#endif
return (98); return (98);
} }
if(param->service == S_UDPPM && param->srv->singlepacket) { if(param->service == S_UDPPM && param->srv->singlepacket) {
@ -196,11 +153,7 @@ int sockmap(struct clientparam * param, int timeo){
sl1 = (*param->bandlimfunc)(param, 0, param->cliinbuf - param->clioffset); sl1 = (*param->bandlimfunc)(param, 0, param->cliinbuf - param->clioffset);
if(sl1 > sleeptime) sleeptime = sl1; if(sl1 > sleeptime) sleeptime = sl1;
} }
#ifndef NOPSTDINT
res = so._sendto(param->remsock, param->clibuf + param->clioffset, (!param->waitclient64 || (param->waitclient64 - sent) > (param->cliinbuf - param->clioffset))? param->cliinbuf - param->clioffset : (int)(param->waitclient64 - sent), 0, (struct sockaddr*)&param->sins, sasize); res = so._sendto(param->remsock, param->clibuf + param->clioffset, (!param->waitclient64 || (param->waitclient64 - sent) > (param->cliinbuf - param->clioffset))? param->cliinbuf - param->clioffset : (int)(param->waitclient64 - sent), 0, (struct sockaddr*)&param->sins, sasize);
#else
res = so._sendto(param->remsock, param->clibuf + param->clioffset, (!param->waitclient || ((unsigned)param->waitclient - sent) > (param->cliinbuf - param->clioffset))? param->cliinbuf - param->clioffset : param->waitclient - sent, 0, (struct sockaddr*)&param->sins, sasize);
#endif
if(res < 0) { if(res < 0) {
if(errno != EAGAIN) return 97; if(errno != EAGAIN) return 97;
continue; continue;
@ -209,13 +162,8 @@ int sockmap(struct clientparam * param, int timeo){
if(param->clioffset == param->cliinbuf) param->clioffset = param->cliinbuf = 0; if(param->clioffset == param->cliinbuf) param->clioffset = param->cliinbuf = 0;
sent += res; sent += res;
param->nwrites++; param->nwrites++;
#ifndef NOPSTDINT
param->statscli64 += res; param->statscli64 += res;
if(param->waitclient64 && param->waitclient64<= sent) { if(param->waitclient64 && param->waitclient64<= sent) {
#else
param->statscli += res;
if(param->waitclient && param->waitclient<= sent) {
#endif
return (99); return (99);
} }
} }
@ -267,11 +215,7 @@ int sockmap(struct clientparam * param, int timeo){
} }
param->srvinbuf += res; param->srvinbuf += res;
param->nreads++; param->nreads++;
#ifndef NOPSTDINT
param->statssrv64 += res; param->statssrv64 += res;
#else
param->statssrv += res;
#endif
if(!param->nolongdatfilter){ if(!param->nolongdatfilter){
action = handledatfltsrv(param, &param->srvbuf, &param->srvbufsize, param->srvinbuf - res, &param->srvinbuf); action = handledatfltsrv(param, &param->srvbuf, &param->srvbufsize, param->srvinbuf - res, &param->srvinbuf);
if(action == HANDLED){ if(action == HANDLED){
@ -293,42 +237,26 @@ int sockmap(struct clientparam * param, int timeo){
#if DEBUGLEVEL > 2 #if DEBUGLEVEL > 2
(*param->srv->logfunc)(param, "finished with mapping"); (*param->srv->logfunc)(param, "finished with mapping");
#endif #endif
#ifndef NOPSTDINT
while(!param->waitclient64 && param->srvinbuf > param->srvoffset && param->clisock != INVALID_SOCKET){ while(!param->waitclient64 && param->srvinbuf > param->srvoffset && param->clisock != INVALID_SOCKET){
#else
while(!param->waitclient && param->srvinbuf > param->srvoffset && param->clisock != INVALID_SOCKET){
#endif
#if DEBUGLEVEL > 2 #if DEBUGLEVEL > 2
(*param->srv->logfunc)(param, "flushing buffer to client"); (*param->srv->logfunc)(param, "flushing buffer to client");
#endif #endif
res = socksendto(param->clisock, &param->sinc, param->srvbuf + param->srvoffset, param->srvinbuf - param->srvoffset, conf.timeouts[STRING_S] * 1000); res = socksendto(param->clisock, &param->sinc, param->srvbuf + param->srvoffset, param->srvinbuf - param->srvoffset, conf.timeouts[STRING_S] * 1000);
if(res > 0){ if(res > 0){
param->srvoffset += res; param->srvoffset += res;
#ifndef NOPSTDINT
param->statssrv64 += res; param->statssrv64 += res;
#else
param->statssrv += res;
#endif
if(param->srvoffset == param->srvinbuf) param->srvoffset = param->srvinbuf = 0; if(param->srvoffset == param->srvinbuf) param->srvoffset = param->srvinbuf = 0;
} }
else break; else break;
} }
#ifndef NOPSTDINT
while(!param->waitserver64 && param->cliinbuf > param->clioffset && param->remsock != INVALID_SOCKET){ while(!param->waitserver64 && param->cliinbuf > param->clioffset && param->remsock != INVALID_SOCKET){
#else
while(!param->waitserver && param->cliinbuf > param->clioffset && param->remsock != INVALID_SOCKET){
#endif
#if DEBUGLEVEL > 2 #if DEBUGLEVEL > 2
(*param->srv->logfunc)(param, "flushing buffer to server"); (*param->srv->logfunc)(param, "flushing buffer to server");
#endif #endif
res = socksendto(param->remsock, &param->sins, param->clibuf + param->clioffset, param->cliinbuf - param->clioffset, conf.timeouts[STRING_S] * 1000); res = socksendto(param->remsock, &param->sins, param->clibuf + param->clioffset, param->cliinbuf - param->clioffset, conf.timeouts[STRING_S] * 1000);
if(res > 0){ if(res > 0){
param->clioffset += res; param->clioffset += res;
#ifndef NOPSTDINT
param->statscli64 += res; param->statscli64 += res;
#else
param->statscli += res;
#endif
if(param->cliinbuf == param->clioffset) param->cliinbuf = param->clioffset = 0; if(param->cliinbuf == param->clioffset) param->cliinbuf = param->clioffset = 0;
} }
else break; else break;

View File

@ -339,11 +339,7 @@ fflush(stderr);
param->res = 467; param->res = 467;
break; break;
} }
#ifndef NOPSTDINT
param->statscli64+=(len - i); param->statscli64+=(len - i);
#else
param->statscli+=(len - i);
#endif
param->nwrites++; param->nwrites++;
#if SOCKSTRACE > 1 #if SOCKSTRACE > 1
fprintf(stderr, "UDP packet relayed from client to %s:%hu size %d, header %d\n", fprintf(stderr, "UDP packet relayed from client to %s:%hu size %d, header %d\n",
@ -370,11 +366,7 @@ fflush(stderr);
param->res = 468; param->res = 468;
break; break;
} }
#ifndef NOPSTDINT
param->statssrv64+=len; param->statssrv64+=len;
#else
param->statssrv+=len;
#endif
param->nreads++; param->nreads++;
memcpy(buf+4, &tsin.sin_addr.s_addr, 4); memcpy(buf+4, &tsin.sin_addr.s_addr, 4);
memcpy(buf+8, &tsin.sin_port, 2); memcpy(buf+8, &tsin.sin_port, 2);

View File

@ -8,6 +8,9 @@
#include <sys/stat.h> #include <sys/stat.h>
#ifndef NOPSTDINT #ifndef NOPSTDINT
#include "pstdint.h" #include "pstdint.h"
#else
typedef unsigned long uint64_t
#define PRINTF_INT64_MODIFIER "l"
#endif #endif
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
@ -260,15 +263,8 @@ struct trafcount {
struct ace *ace; struct ace *ace;
unsigned number; unsigned number;
ROTATION type; ROTATION type;
#ifndef NOPSTDINT
uint64_t traf64; uint64_t traf64;
uint64_t traflim64; uint64_t traflim64;
#else
unsigned long traf;
unsigned long trafgb;
unsigned long traflim;
unsigned long traflimgb;
#endif
char * comment; char * comment;
int disabled; int disabled;
time_t cleared; time_t cleared;
@ -385,13 +381,8 @@ struct clientparam {
int res, int res,
status; status;
#ifndef NOPSTDINT
uint64_t waitclient64, uint64_t waitclient64,
waitserver64; waitserver64;
#else
unsigned waitclient,
waitserver;
#endif
int pwtype, int pwtype,
threadid, threadid,
weight, weight,
@ -416,26 +407,15 @@ struct clientparam {
clibufsize, clibufsize,
srvbufsize, srvbufsize,
msec_start; msec_start;
#ifndef NOPSTDINT
uint64_t uint64_t
maxtrafin64, maxtrafin64,
maxtrafout64; maxtrafout64;
#else
unsigned
maxtrafin,
maxtrafout;
#endif
struct sockaddr_in sinc, struct sockaddr_in sinc,
sins, sins,
req; req;
#ifndef NOPSTDINT
uint64_t statscli64, uint64_t statscli64,
statssrv64; statssrv64;
#else
unsigned long statscli,
statssrv;
#endif
unsigned long unsigned long
nreads, nreads,
nwrites, nwrites,

View File

@ -475,7 +475,6 @@ void * adminchild(struct clientparam* param) {
); );
} }
else { else {
#ifndef NOPSTDINT
inbuf += sprintf(buf+inbuf, inbuf += sprintf(buf+inbuf,
"</td><td>%"PRINTF_INT64_MODIFIER"u</td>" "</td><td>%"PRINTF_INT64_MODIFIER"u</td>"
"<td>MB%s</td>" "<td>MB%s</td>"
@ -486,18 +485,6 @@ void * adminchild(struct clientparam* param) {
cp->traf64, cp->traf64,
cp->cleared?ctime(&cp->cleared):"never" cp->cleared?ctime(&cp->cleared):"never"
); );
#else
inbuf += sprintf(buf+inbuf,
"</td><td>%.3f</td>"
"<td>MB%s</td>"
"<td>%.3f MB</td>"
"<td>%s</td>",
(1024.0 * (float)cp->traflimgb) + (float)cp->traflim/1048576.0,
rotations[cp->type],
(1024.0 * (float)cp->trafgb) + (float)cp->traf/1048576.0,
cp->cleared?ctime(&cp->cleared):"never"
);
#endif
inbuf += sprintf(buf + inbuf, inbuf += sprintf(buf + inbuf,
"<td>%s</td>" "<td>%s</td>"
"<td>%i</td>" "<td>%i</td>"