mirror of
https://github.com/3proxy/3proxy.git
synced 2025-06-08 12:34:48 +08:00
Merge f27789c5f6
into 8b57982a09
This commit is contained in:
commit
cc5028099e
@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
BUILDDIR = ../bin/
|
BUILDDIR = ../bin/
|
||||||
CC = cl
|
CC = cl
|
||||||
CFLAGS = /nologo /MT /W3 /Ox /GS /EHs- /GA /GF /D "MSVC" /D "WITH_STD_MALLOC" /D "WITH_WSAPOLL" /D "NDEBUG" /D "WIN32" /D "WITH_SSL" /D "_CONSOLE" /D "_MBCS" /D "_WIN32" /D "PRINTF_INT64_MODIFIER=\"I64\"" /Fp"proxy.pch" /FD /c $(VERSION) $(BUILDDATE)
|
CFLAGS = /nologo /MT /W3 /Ox /GS /EHs- /GA /GF /D "MSVC" /D "WITH_STD_MALLOC" /D "WITH_WSAPOLL" /D "NDEBUG" /D "WIN32" /D "WITH_SSL" /D "_CONSOLE" /D "_MBCS" /D "_WIN32" /D "PRIu64=\"I64\"" /Fp"proxy.pch" /FD /c $(VERSION) $(BUILDDATE)
|
||||||
COUT = /Fo
|
COUT = /Fo
|
||||||
LN = link
|
LN = link
|
||||||
LDFLAGS = /nologo /subsystem:console /incremental:no /machine:I386
|
LDFLAGS = /nologo /subsystem:console /incremental:no /machine:I386
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
BUILDDIR = ../bin64/
|
BUILDDIR = ../bin64/
|
||||||
CC = cl
|
CC = cl
|
||||||
CFLAGS = /nologo /MT /W3 /Ox /EHs- /GS /GA /GF /D "MSVC" /D "WITH_STD_MALLOC" /D "WITH_SSL" /D "WITH_WSAPOLL" /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "_WIN32" /D "PRINTF_INT64_MODIFIER=\"I64\"" /Fp"proxy.pch" /FD /c $(VERSION) $(BUILDDATE)
|
CFLAGS = /nologo /MT /W3 /Ox /EHs- /GS /GA /GF /D "MSVC" /D "WITH_STD_MALLOC" /D "WITH_SSL" /D "WITH_WSAPOLL" /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "_WIN32" /D "PRIu64=\"I64\"" /Fp"proxy.pch" /FD /c $(VERSION) $(BUILDDATE)
|
||||||
COUT = /Fo
|
COUT = /Fo
|
||||||
LN = link
|
LN = link
|
||||||
LDFLAGS = /nologo /subsystem:console /incremental:no /machine:x64
|
LDFLAGS = /nologo /subsystem:console /incremental:no /machine:x64
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
BUILDDIR = ../bin64/
|
BUILDDIR = ../bin64/
|
||||||
CC = cl
|
CC = cl
|
||||||
CFLAGS = /nologo /MT /W3 /Ox /EHs- /GS /GA /GF /D "MSVC" /D "WITH_STD_MALLOC" /D "WITH_WSAPOLL" /D "WITH_SSL" /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "_WIN32" /D "PRINTF_INT64_MODIFIER=\"I64\"" /Fp"proxy.pch" /FD /c $(VERSION) $(BUILDDATE)
|
CFLAGS = /nologo /MT /W3 /Ox /EHs- /GS /GA /GF /D "MSVC" /D "WITH_STD_MALLOC" /D "WITH_WSAPOLL" /D "WITH_SSL" /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "_WIN32" /D "PRIu64=\"I64\"" /Fp"proxy.pch" /FD /c $(VERSION) $(BUILDDATE)
|
||||||
COUT = /Fo
|
COUT = /Fo
|
||||||
LN = link
|
LN = link
|
||||||
LDFLAGS = /nologo /subsystem:console /incremental:no /machine:arm64
|
LDFLAGS = /nologo /subsystem:console /incremental:no /machine:arm64
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
BUILDDIR = ../bin/
|
BUILDDIR = ../bin/
|
||||||
CC = cl
|
CC = cl
|
||||||
CFLAGS = /DARM /D "NOODBC" /nologo /MT /W3 /Wp64 /Ox /GS /EHs- /GA /GF /D "MSVC" /D "_WINCE" /D "WITH_STD_MALLOC" /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "_WIN32" /D "PRINTF_INT64_MODIFIER=\"I64\"" /Fp"proxy.pch" /FD /c
|
CFLAGS = /DARM /D "NOODBC" /nologo /MT /W3 /Wp64 /Ox /GS /EHs- /GA /GF /D "MSVC" /D "_WINCE" /D "WITH_STD_MALLOC" /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "_WIN32" /D "PRIu64=\"I64\"" /Fp"proxy.pch" /FD /c
|
||||||
COUT = /Fo
|
COUT = /Fo
|
||||||
LN = link
|
LN = link
|
||||||
LDFLAGS = /nologo /subsystem:console /incremental:no
|
LDFLAGS = /nologo /subsystem:console /incremental:no
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
BUILDDIR = ../bin/
|
BUILDDIR = ../bin/
|
||||||
CC = cl
|
CC = cl
|
||||||
CFLAGS = /nologo /Ox /MT /D "NOIPV6" /D "NODEBUG" /D "NOODBC" /D "NORADIUS" /D"WATCOM" /D "MSVC" /D "WITH_STD_MALLOC" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "_WIN32" /D "PRINTF_INT64_MODIFIER=\"I64\"" /c $(VERSION) $(BUILDDATE)
|
CFLAGS = /nologo /Ox /MT /D "NOIPV6" /D "NODEBUG" /D "NOODBC" /D "NORADIUS" /D"WATCOM" /D "MSVC" /D "WITH_STD_MALLOC" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "_WIN32" /D "PRIu64=\"I64\"" /c $(VERSION) $(BUILDDATE)
|
||||||
COUT = /Fo
|
COUT = /Fo
|
||||||
LN = link
|
LN = link
|
||||||
LDFLAGS = /nologo /subsystem:console /incremental:no
|
LDFLAGS = /nologo /subsystem:console /incremental:no
|
||||||
|
14
src/3proxy.c
14
src/3proxy.c
@ -209,7 +209,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)
|
||||||
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"PRIu64"u%s%s\n", tl->number, tl->traf64, tl->comment?" #" : "", tl->comment? tl->comment : "");
|
||||||
}
|
}
|
||||||
fclose(cfp);
|
fclose(cfp);
|
||||||
}
|
}
|
||||||
@ -535,10 +535,10 @@ int WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int
|
|||||||
if(service){
|
if(service){
|
||||||
SERVICE_TABLE_ENTRY ste[] =
|
SERVICE_TABLE_ENTRY ste[] =
|
||||||
{
|
{
|
||||||
{ (LPSTR)conf.stringtable[1], (LPSERVICE_MAIN_FUNCTION)ServiceMain},
|
{ (LPSTR)conf.stringtable[1], (LPSERVICE_MAIN_FUNCTION)ServiceMain},
|
||||||
{ NULL, NULL }
|
{ NULL, NULL }
|
||||||
};
|
};
|
||||||
if(!StartServiceCtrlDispatcher( ste ))cyclestep();
|
if(!StartServiceCtrlDispatcher( ste ))cyclestep();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
@ -558,6 +558,12 @@ int WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int
|
|||||||
|
|
||||||
CLEARRETURN:
|
CLEARRETURN:
|
||||||
|
|
||||||
|
freeconf(&conf);
|
||||||
|
myfree(conf.conffile);
|
||||||
|
freeauth(conf.authfuncs);
|
||||||
|
destroyhashtable(&dns_table);
|
||||||
|
destroyhashtable(&dns6_table);
|
||||||
|
fprintf(stderr, "hi\n");
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -391,7 +391,7 @@ int radsend(struct clientparam * param, int auth, int stop){
|
|||||||
/* NAS-Identifier */
|
/* NAS-Identifier */
|
||||||
if(conf.stringtable){
|
if(conf.stringtable){
|
||||||
*ptr++ = PW_NAS_IDENTIFIER;
|
*ptr++ = PW_NAS_IDENTIFIER;
|
||||||
len = strlen(conf.stringtable[SERVICES+param->service]);
|
len = strlen((char *)conf.stringtable[SERVICES+param->service]);
|
||||||
*ptr++ = (2 + len);
|
*ptr++ = (2 + len);
|
||||||
memcpy(ptr, conf.stringtable[SERVICES+param->service], len);
|
memcpy(ptr, conf.stringtable[SERVICES+param->service], len);
|
||||||
ptr += len;
|
ptr += len;
|
||||||
@ -416,7 +416,7 @@ int radsend(struct clientparam * param, int auth, int stop){
|
|||||||
/* Called-Station-ID */
|
/* Called-Station-ID */
|
||||||
if(param->hostname){
|
if(param->hostname){
|
||||||
*ptr++ = PW_CALLED_STATION_ID;
|
*ptr++ = PW_CALLED_STATION_ID;
|
||||||
len = strlen(param->hostname);
|
len = strlen((char *)param->hostname);
|
||||||
*ptr++ = (2 + len);
|
*ptr++ = (2 + len);
|
||||||
memcpy(ptr, param->hostname, len);
|
memcpy(ptr, param->hostname, len);
|
||||||
ptr += len;
|
ptr += len;
|
||||||
@ -456,7 +456,7 @@ int radsend(struct clientparam * param, int auth, int stop){
|
|||||||
|
|
||||||
/* Username */
|
/* Username */
|
||||||
if(param->username){
|
if(param->username){
|
||||||
len = strlen(param->username);
|
len = strlen((char *)param->username);
|
||||||
if(len>128)len=128;
|
if(len>128)len=128;
|
||||||
*ptr++ = PW_USER_NAME;
|
*ptr++ = PW_USER_NAME;
|
||||||
*ptr++ = len + 2;
|
*ptr++ = len + 2;
|
||||||
@ -499,12 +499,12 @@ int radsend(struct clientparam * param, int auth, int stop){
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(auth && param->password){
|
if(auth && param->password){
|
||||||
len = strlen(param->password);
|
len = strlen((char *)param->password);
|
||||||
if(len > 128) len = 128;
|
if(len > 128) len = 128;
|
||||||
*ptr++ = PW_PASSWORD;
|
*ptr++ = PW_PASSWORD;
|
||||||
ptr++;
|
ptr++;
|
||||||
memcpy(ptr, param->password, len);
|
memcpy(ptr, param->password, len);
|
||||||
rad_pwencode(ptr,
|
rad_pwencode((char *)ptr,
|
||||||
&len,
|
&len,
|
||||||
radiussecret,
|
radiussecret,
|
||||||
(char *)packet.vector);
|
(char *)packet.vector);
|
||||||
@ -582,7 +582,7 @@ int radsend(struct clientparam * param, int auth, int stop){
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (calc_replydigest((char *)&rpacket, packet.vector, radiussecret,
|
if (calc_replydigest((char *)&rpacket, (char *)packet.vector, radiussecret,
|
||||||
data_len) ){
|
data_len) ){
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,7 @@ void * autochild(struct clientparam* param) {
|
|||||||
len = sockfillbuffcli(param, 1, CONNECTION_S);
|
len = sockfillbuffcli(param, 1, CONNECTION_S);
|
||||||
if (len != 1){
|
if (len != 1){
|
||||||
param->res = 801;
|
param->res = 801;
|
||||||
dolog(param, "");
|
dolog(param, (unsigned char *)"");
|
||||||
}
|
}
|
||||||
if(*param->clibuf == 4 || *param->clibuf == 5) return sockschild(param);
|
if(*param->clibuf == 4 || *param->clibuf == 5) return sockschild(param);
|
||||||
return proxychild(param);
|
return proxychild(param);
|
||||||
|
@ -114,7 +114,6 @@ struct extparam conf = {
|
|||||||
#else
|
#else
|
||||||
{AF_INET},{AF_INET},
|
{AF_INET},{AF_INET},
|
||||||
#endif
|
#endif
|
||||||
NULL,
|
|
||||||
NULL,
|
NULL,
|
||||||
doconnect,
|
doconnect,
|
||||||
lognone,
|
lognone,
|
||||||
|
91
src/conf.c
91
src/conf.c
@ -324,7 +324,7 @@ static int h_log(int argc, unsigned char ** argv){
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#ifndef NORADIUS
|
#ifndef NORADIUS
|
||||||
else if(!strcmp(argv[1],"radius")){
|
else if(!strcmp((char *)argv[1],"radius")){
|
||||||
conf.logfunc = logradius;
|
conf.logfunc = logradius;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -400,7 +400,7 @@ static int h_include(int argc, unsigned char **argv){
|
|||||||
static int h_archiver(int argc, unsigned char **argv){
|
static int h_archiver(int argc, unsigned char **argv){
|
||||||
int j;
|
int j;
|
||||||
|
|
||||||
conf.archiver = myalloc(argc * sizeof(char *));
|
conf.archiver = myalloc(argc * sizeof(unsigned char *));
|
||||||
if(conf.archiver) {
|
if(conf.archiver) {
|
||||||
conf.archiverc = argc;
|
conf.archiverc = argc;
|
||||||
for(j = 0; j < conf.archiverc; j++) conf.archiver[j] = (unsigned char *)mystrdup((char *)argv[j]);
|
for(j = 0; j < conf.archiverc; j++) conf.archiver[j] = (unsigned char *)mystrdup((char *)argv[j]);
|
||||||
@ -532,9 +532,21 @@ static int h_users(int argc, unsigned char **argv){
|
|||||||
pwl->password = (unsigned char *) mystrdup((char *)arg + 1);
|
pwl->password = (unsigned char *) mystrdup((char *)arg + 1);
|
||||||
pwl->pwtype = UN;
|
pwl->pwtype = UN;
|
||||||
}
|
}
|
||||||
if(!pwl->password) return 3;
|
if(!pwl->password){
|
||||||
|
if(pwl->user){
|
||||||
|
myfree(pwl->user);
|
||||||
|
}
|
||||||
|
myfree(pwl);
|
||||||
|
return 3;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(!pwl->user){
|
||||||
|
if(pwl->password){
|
||||||
|
myfree(pwl->password);
|
||||||
|
}
|
||||||
|
myfree(pwl);
|
||||||
|
return 21;
|
||||||
}
|
}
|
||||||
if(!pwl->user) return 21;
|
|
||||||
pthread_mutex_lock(&pwl_mutex);
|
pthread_mutex_lock(&pwl_mutex);
|
||||||
pwl->next = conf.pwl;
|
pwl->next = conf.pwl;
|
||||||
conf.pwl = pwl;
|
conf.pwl = pwl;
|
||||||
@ -715,7 +727,10 @@ static int h_monitor(int argc, unsigned char **argv){
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
fm->path = mystrdup((char *)argv[1]);
|
fm->path = mystrdup((char *)argv[1]);
|
||||||
if(!fm->path) return 21;
|
if(!fm->path){
|
||||||
|
myfree(fm);
|
||||||
|
return 21;
|
||||||
|
}
|
||||||
fm->next = conf.fmon;
|
fm->next = conf.fmon;
|
||||||
conf.fmon = fm;
|
conf.fmon = fm;
|
||||||
}
|
}
|
||||||
@ -743,6 +758,7 @@ static int h_parent(int argc, unsigned char **argv){
|
|||||||
chains->weight = (unsigned)atoi((char *)argv[1]);
|
chains->weight = (unsigned)atoi((char *)argv[1]);
|
||||||
if(chains->weight == 0 || chains->weight >1000) {
|
if(chains->weight == 0 || chains->weight >1000) {
|
||||||
fprintf(stderr, "Chaining error: bad chain weight %u line %d\n", chains->weight, linenum);
|
fprintf(stderr, "Chaining error: bad chain weight %u line %d\n", chains->weight, linenum);
|
||||||
|
myfree(chains);
|
||||||
return(3);
|
return(3);
|
||||||
}
|
}
|
||||||
if(!strcmp((char *)argv[2], "tcp"))chains->type = R_TCP;
|
if(!strcmp((char *)argv[2], "tcp"))chains->type = R_TCP;
|
||||||
@ -762,9 +778,10 @@ static int h_parent(int argc, unsigned char **argv){
|
|||||||
else if(!strcmp((char *)argv[2], "smtp"))chains->type = R_SMTP;
|
else if(!strcmp((char *)argv[2], "smtp"))chains->type = R_SMTP;
|
||||||
else {
|
else {
|
||||||
fprintf(stderr, "Chaining error: bad chain type (%s)\n", argv[2]);
|
fprintf(stderr, "Chaining error: bad chain type (%s)\n", argv[2]);
|
||||||
|
myfree(chains);
|
||||||
return(4);
|
return(4);
|
||||||
}
|
}
|
||||||
cidr = strchr(argv[3], '/');
|
cidr = strchr((char *)argv[3], '/');
|
||||||
if(cidr) *cidr = 0;
|
if(cidr) *cidr = 0;
|
||||||
if(!getip46(46, argv[3], (struct sockaddr *)&chains->addr)) return (5);
|
if(!getip46(46, argv[3], (struct sockaddr *)&chains->addr)) return (5);
|
||||||
chains->exthost = (unsigned char *)mystrdup((char *)argv[3]);
|
chains->exthost = (unsigned char *)mystrdup((char *)argv[3]);
|
||||||
@ -827,7 +844,7 @@ int scanipl(unsigned char *arg, struct iplist *dst){
|
|||||||
memcpy(&dst->ip_from, SAADDR(&sa), SAADDRLEN(&sa));
|
memcpy(&dst->ip_from, SAADDR(&sa), SAADDRLEN(&sa));
|
||||||
dst->family = *SAFAMILY(&sa);
|
dst->family = *SAFAMILY(&sa);
|
||||||
if(dash){
|
if(dash){
|
||||||
if(afdetect(dash+1) == -1) return 1;
|
if(afdetect((unsigned char *)dash+1) == -1) return 1;
|
||||||
if(!getip46(46, (unsigned char *)dash+1, (struct sockaddr *)&sa)) return 2;
|
if(!getip46(46, (unsigned char *)dash+1, (struct sockaddr *)&sa)) return 2;
|
||||||
memcpy(&dst->ip_to, SAADDR(&sa), SAADDRLEN(&sa));
|
memcpy(&dst->ip_to, SAADDR(&sa), SAADDRLEN(&sa));
|
||||||
if(*SAFAMILY(&sa) != dst->family || memcmp(&dst->ip_to, &dst->ip_from, SAADDRLEN(&sa)) < 0) return 3;
|
if(*SAFAMILY(&sa) != dst->family || memcmp(&dst->ip_to, &dst->ip_from, SAADDRLEN(&sa)) < 0) return 3;
|
||||||
@ -881,11 +898,15 @@ struct ace * make_ace (int argc, unsigned char ** argv){
|
|||||||
}
|
}
|
||||||
if(!userl) {
|
if(!userl) {
|
||||||
fprintf(stderr, "No memory for ACL entry, line %d\n", linenum);
|
fprintf(stderr, "No memory for ACL entry, line %d\n", linenum);
|
||||||
|
freeacl(acl);
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
memset(userl, 0, sizeof(struct userlist));
|
memset(userl, 0, sizeof(struct userlist));
|
||||||
userl->user=(unsigned char*)mystrdup((char *)arg);
|
userl->user=(unsigned char*)mystrdup((char *)arg);
|
||||||
if(!userl->user) return NULL;
|
if(!userl->user){
|
||||||
|
freeacl(acl);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
} while((arg = (unsigned char *)strtok((char *)NULL, ",")));
|
} while((arg = (unsigned char *)strtok((char *)NULL, ",")));
|
||||||
}
|
}
|
||||||
if(argc > 1 && strcmp("*", (char *)argv[1])) {
|
if(argc > 1 && strcmp("*", (char *)argv[1])) {
|
||||||
@ -900,11 +921,13 @@ struct ace * make_ace (int argc, unsigned char ** argv){
|
|||||||
}
|
}
|
||||||
if(!ipl) {
|
if(!ipl) {
|
||||||
fprintf(stderr, "No memory for ACL entry, line %d\n", linenum);
|
fprintf(stderr, "No memory for ACL entry, line %d\n", linenum);
|
||||||
|
freeacl(acl);
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
memset(ipl, 0, sizeof(struct iplist));
|
memset(ipl, 0, sizeof(struct iplist));
|
||||||
if (scanipl(arg, ipl)) {
|
if (scanipl(arg, ipl)) {
|
||||||
fprintf(stderr, "Invalid IP, IP range or CIDR, line %d\n", linenum);
|
fprintf(stderr, "Invalid IP, IP range or CIDR, line %d\n", linenum);
|
||||||
|
freeacl(acl);
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
} while((arg = (unsigned char *)strtok((char *)NULL, ",")));
|
} while((arg = (unsigned char *)strtok((char *)NULL, ",")));
|
||||||
@ -928,6 +951,7 @@ struct ace * make_ace (int argc, unsigned char ** argv){
|
|||||||
}
|
}
|
||||||
if(!hostnamel){
|
if(!hostnamel){
|
||||||
fprintf(stderr, "No memory for ACL entry, line %d\n", linenum);
|
fprintf(stderr, "No memory for ACL entry, line %d\n", linenum);
|
||||||
|
freeacl(acl);
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
memset(hostnamel, 0, sizeof(struct hostname));
|
memset(hostnamel, 0, sizeof(struct hostname));
|
||||||
@ -946,6 +970,7 @@ struct ace * make_ace (int argc, unsigned char ** argv){
|
|||||||
hostnamel->name = (unsigned char *) mystrdup( (char *)pattern);
|
hostnamel->name = (unsigned char *) mystrdup( (char *)pattern);
|
||||||
if(!hostnamel->name) {
|
if(!hostnamel->name) {
|
||||||
fprintf(stderr, "No memory for ACL entry, line %d\n", linenum);
|
fprintf(stderr, "No memory for ACL entry, line %d\n", linenum);
|
||||||
|
freeacl(acl);
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -960,6 +985,7 @@ struct ace * make_ace (int argc, unsigned char ** argv){
|
|||||||
}
|
}
|
||||||
if(!ipl) {
|
if(!ipl) {
|
||||||
fprintf(stderr, "No memory for ACL entry, line %d\n", linenum);
|
fprintf(stderr, "No memory for ACL entry, line %d\n", linenum);
|
||||||
|
freeacl(acl);
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
*ipl = tmpip;
|
*ipl = tmpip;
|
||||||
@ -978,12 +1004,14 @@ struct ace * make_ace (int argc, unsigned char ** argv){
|
|||||||
}
|
}
|
||||||
if(!portl) {
|
if(!portl) {
|
||||||
fprintf(stderr, "No memory for ACL entry, line %d\n", linenum);
|
fprintf(stderr, "No memory for ACL entry, line %d\n", linenum);
|
||||||
|
freeacl(acl);
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
memset(portl, 0, sizeof(struct portlist));
|
memset(portl, 0, sizeof(struct portlist));
|
||||||
res = sscanf((char *)arg, "%hu-%hu", &portl->startport, &portl->endport);
|
res = sscanf((char *)arg, "%hu-%hu", &portl->startport, &portl->endport);
|
||||||
if(res < 1) {
|
if(res < 1) {
|
||||||
fprintf(stderr, "Invalid port or port range, line %d\n", linenum);
|
fprintf(stderr, "Invalid port or port range, line %d\n", linenum);
|
||||||
|
freeacl(acl);
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
if (res == 1) portl->endport = portl->startport;
|
if (res == 1) portl->endport = portl->startport;
|
||||||
@ -1051,6 +1079,7 @@ struct ace * make_ace (int argc, unsigned char ** argv){
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
fprintf(stderr, "Unknown operation type: %s line %d\n", arg, linenum);
|
fprintf(stderr, "Unknown operation type: %s line %d\n", arg, linenum);
|
||||||
|
freeacl(acl);
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
} while((arg = (unsigned char *)strtok((char *)NULL, ",")));
|
} while((arg = (unsigned char *)strtok((char *)NULL, ",")));
|
||||||
@ -1315,6 +1344,8 @@ static int h_ace(int argc, unsigned char **argv){
|
|||||||
tl->cleared = crecord.cleared;
|
tl->cleared = crecord.cleared;
|
||||||
tl->updated = crecord.updated;
|
tl->updated = crecord.updated;
|
||||||
if(tl->cleared < 0 || tl->cleared >= MAX_COUNTER_TIME || tl->updated < 0 || tl->updated >= MAX_COUNTER_TIME){
|
if(tl->cleared < 0 || tl->cleared >= MAX_COUNTER_TIME || tl->updated < 0 || tl->updated >= MAX_COUNTER_TIME){
|
||||||
|
myfree(tl);
|
||||||
|
freeacl(acl);
|
||||||
fprintf(stderr, "Invalid, incompatible or corrupted counter file.\n");
|
fprintf(stderr, "Invalid, incompatible or corrupted counter file.\n");
|
||||||
return(6);
|
return(6);
|
||||||
}
|
}
|
||||||
@ -1374,16 +1405,16 @@ static int h_radius(int argc, unsigned char **argv){
|
|||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
memset(radiuslist, 0, sizeof(radiuslist));
|
memset(radiuslist, 0, sizeof(radiuslist));
|
||||||
if(strlen(argv[1]) > 63) argv[1][63] = 0;
|
if(strlen((char *)argv[1]) > 63) argv[1][63] = 0;
|
||||||
strcpy(radiussecret, argv[1]);
|
strcpy(radiussecret, (char *)argv[1]);
|
||||||
for( nradservers=0; nradservers < MAXRADIUS && nradservers < argc -2; nradservers++){
|
for( nradservers=0; nradservers < MAXRADIUS && nradservers < argc -2; nradservers++){
|
||||||
char *s = 0;
|
char *s = 0;
|
||||||
if((s=strchr(argv[nradservers + 2], '/'))){
|
if((s=strchr((char *)argv[nradservers + 2], '/'))){
|
||||||
*s = 0;
|
*s = 0;
|
||||||
s++;
|
s++;
|
||||||
}
|
}
|
||||||
if( !getip46(46, argv[nradservers + 2], (struct sockaddr *)&radiuslist[nradservers].authaddr)) return 1;
|
if( !getip46(46, argv[nradservers + 2], (struct sockaddr *)&radiuslist[nradservers].authaddr)) return 1;
|
||||||
if( s && !getip46(46, s+1, (struct sockaddr *)&radiuslist[nradservers].localaddr)) return 2;
|
if( s && !getip46(46, (unsigned char *)s+1, (struct sockaddr *)&radiuslist[nradservers].localaddr)) return 2;
|
||||||
if(!*SAPORT(&radiuslist[nradservers].authaddr))*SAPORT(&radiuslist[nradservers].authaddr) = htons(1812);
|
if(!*SAPORT(&radiuslist[nradservers].authaddr))*SAPORT(&radiuslist[nradservers].authaddr) = htons(1812);
|
||||||
port = ntohs(*SAPORT(&radiuslist[nradservers].authaddr));
|
port = ntohs(*SAPORT(&radiuslist[nradservers].authaddr));
|
||||||
radiuslist[nradservers].logaddr = radiuslist[nradservers].authaddr;
|
radiuslist[nradservers].logaddr = radiuslist[nradservers].authaddr;
|
||||||
@ -1731,6 +1762,7 @@ int readconfig(FILE * fp){
|
|||||||
int res = 0;
|
int res = 0;
|
||||||
|
|
||||||
if( !(buf = myalloc(bufsize)) || ! (argv = myalloc((NPARAMS + 1) * sizeof(unsigned char *))) ) {
|
if( !(buf = myalloc(bufsize)) || ! (argv = myalloc((NPARAMS + 1) * sizeof(unsigned char *))) ) {
|
||||||
|
if(buf) myfree(buf);
|
||||||
fprintf(stderr, "No memory for configuration");
|
fprintf(stderr, "No memory for configuration");
|
||||||
return(10);
|
return(10);
|
||||||
}
|
}
|
||||||
@ -1740,6 +1772,8 @@ int readconfig(FILE * fp){
|
|||||||
inbuf = (int)(strlen((char *)buf) + 1);
|
inbuf = (int)(strlen((char *)buf) + 1);
|
||||||
argc = parsestr (buf, argv, NPARAMS-1, &buf, &inbuf, &bufsize);
|
argc = parsestr (buf, argv, NPARAMS-1, &buf, &inbuf, &bufsize);
|
||||||
if(argc < 1) {
|
if(argc < 1) {
|
||||||
|
myfree(buf);
|
||||||
|
myfree(argv);
|
||||||
fprintf(stderr, "Parse error line %d\n", linenum);
|
fprintf(stderr, "Parse error line %d\n", linenum);
|
||||||
return(11);
|
return(11);
|
||||||
}
|
}
|
||||||
@ -1751,6 +1785,8 @@ int readconfig(FILE * fp){
|
|||||||
if(!writable){
|
if(!writable){
|
||||||
writable = freopen(curconf, "r+", fp);
|
writable = freopen(curconf, "r+", fp);
|
||||||
if(!writable){
|
if(!writable){
|
||||||
|
myfree(buf);
|
||||||
|
myfree(argv);
|
||||||
fprintf(stderr, "Unable to reopen config for writing: %s\n", curconf);
|
fprintf(stderr, "Unable to reopen config for writing: %s\n", curconf);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -1764,6 +1800,8 @@ int readconfig(FILE * fp){
|
|||||||
res = (*cm->handler)(argc, argv);
|
res = (*cm->handler)(argc, argv);
|
||||||
if(res > 0){
|
if(res > 0){
|
||||||
fprintf(stderr, "Command: '%s' failed with code %d, line %d\n", argv[0], res, linenum);
|
fprintf(stderr, "Command: '%s' failed with code %d, line %d\n", argv[0], res, linenum);
|
||||||
|
myfree(buf);
|
||||||
|
myfree(argv);
|
||||||
return(linenum);
|
return(linenum);
|
||||||
}
|
}
|
||||||
if(!res) break;
|
if(!res) break;
|
||||||
@ -1771,6 +1809,8 @@ int readconfig(FILE * fp){
|
|||||||
}
|
}
|
||||||
if(res != 1)continue;
|
if(res != 1)continue;
|
||||||
fprintf(stderr, "Unknown command: '%s' line %d\n", argv[0], linenum);
|
fprintf(stderr, "Unknown command: '%s' line %d\n", argv[0], linenum);
|
||||||
|
myfree(buf);
|
||||||
|
myfree(argv);
|
||||||
return(linenum);
|
return(linenum);
|
||||||
}
|
}
|
||||||
myfree(buf);
|
myfree(buf);
|
||||||
@ -1795,12 +1835,16 @@ void freeconf(struct extparam *confp){
|
|||||||
struct connlim * cl;
|
struct connlim * cl;
|
||||||
struct trafcount * tc;
|
struct trafcount * tc;
|
||||||
struct passwords *pw;
|
struct passwords *pw;
|
||||||
|
struct auth *authfuncs;
|
||||||
struct ace *acl;
|
struct ace *acl;
|
||||||
struct filemon *fm;
|
struct filemon *fm;
|
||||||
int counterd, archiverc;
|
int counterd, archiverc;
|
||||||
unsigned char *logname, *logtarget;
|
unsigned char *logname, *logtarget;
|
||||||
unsigned char **archiver;
|
unsigned char **archiver;
|
||||||
unsigned char * logformat;
|
unsigned char * logformat;
|
||||||
|
char * counterfile;
|
||||||
|
FILE *stdlog;
|
||||||
|
char* demanddialprog;
|
||||||
|
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
@ -1835,12 +1879,10 @@ void freeconf(struct extparam *confp){
|
|||||||
pthread_mutex_unlock(&pwl_mutex);
|
pthread_mutex_unlock(&pwl_mutex);
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
logtarget = confp->logtarget;
|
logtarget = confp->logtarget;
|
||||||
confp->logtarget = NULL;
|
confp->logtarget = NULL;
|
||||||
logname = confp->logname;
|
logname = confp->logname;
|
||||||
confp->logname = NULL;
|
confp->logname = NULL;
|
||||||
*/
|
|
||||||
confp->logfunc = lognone;
|
confp->logfunc = lognone;
|
||||||
logformat = confp->logformat;
|
logformat = confp->logformat;
|
||||||
confp->logformat = NULL;
|
confp->logformat = NULL;
|
||||||
@ -1869,6 +1911,14 @@ void freeconf(struct extparam *confp){
|
|||||||
numservers = 0;
|
numservers = 0;
|
||||||
acl = confp->acl;
|
acl = confp->acl;
|
||||||
confp->acl = NULL;
|
confp->acl = NULL;
|
||||||
|
authfuncs = confp->authfuncs;
|
||||||
|
confp->authfuncs = NULL;
|
||||||
|
counterfile = confp->counterfile;
|
||||||
|
confp->counterfile = NULL;
|
||||||
|
stdlog = confp->stdlog;
|
||||||
|
confp->stdlog = NULL;
|
||||||
|
demanddialprog = confp->demanddialprog;
|
||||||
|
confp->demanddialprog = NULL;
|
||||||
|
|
||||||
usleep(SLEEPTIME);
|
usleep(SLEEPTIME);
|
||||||
|
|
||||||
@ -1882,7 +1932,7 @@ void freeconf(struct extparam *confp){
|
|||||||
freeacl(tc->ace);
|
freeacl(tc->ace);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
freeauth(authfuncs);
|
||||||
freeacl(acl);
|
freeacl(acl);
|
||||||
freepwl(pw);
|
freepwl(pw);
|
||||||
for(; bl; bl = (struct bandlim *) itfree(bl, bl->next)) freeacl(bl->ace);
|
for(; bl; bl = (struct bandlim *) itfree(bl, bl->next)) freeacl(bl->ace);
|
||||||
@ -1895,14 +1945,12 @@ void freeconf(struct extparam *confp){
|
|||||||
for(; fm; fm = (struct filemon *)itfree(fm, fm->next)){
|
for(; fm; fm = (struct filemon *)itfree(fm, fm->next)){
|
||||||
if(fm->path) myfree(fm->path);
|
if(fm->path) myfree(fm->path);
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
if(logtarget) {
|
if(logtarget) {
|
||||||
myfree(logtarget);
|
myfree(logtarget);
|
||||||
}
|
}
|
||||||
if(logname) {
|
if(logname) {
|
||||||
myfree(logname);
|
myfree(logname);
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
if(logformat) {
|
if(logformat) {
|
||||||
myfree(logformat);
|
myfree(logformat);
|
||||||
}
|
}
|
||||||
@ -1911,6 +1959,15 @@ void freeconf(struct extparam *confp){
|
|||||||
myfree(archiver);
|
myfree(archiver);
|
||||||
}
|
}
|
||||||
havelog = 0;
|
havelog = 0;
|
||||||
|
if(counterfile){
|
||||||
|
myfree(counterfile);
|
||||||
|
}
|
||||||
|
if(stdlog){
|
||||||
|
fclose(stdlog);
|
||||||
|
}
|
||||||
|
if(demanddialprog){
|
||||||
|
myfree(demanddialprog);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int reload (void){
|
int reload (void){
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
|
|
||||||
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, "%"PRIu64"u", *(uint64_t *)node->value));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void pr_integer(struct node *node, CBFUNC cbf, void*cb){
|
static void pr_integer(struct node *node, CBFUNC cbf, void*cb){
|
||||||
|
@ -246,15 +246,15 @@ 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 'L':
|
case 'L':
|
||||||
sprintf((char *)buf+i, "%"PRINTF_INT64_MODIFIER"u", param->cycles);
|
sprintf((char *)buf+i, "%"PRIu64"u", param->cycles);
|
||||||
i += (int)strlen((char *)buf+i);
|
i += (int)strlen((char *)buf+i);
|
||||||
break;
|
break;
|
||||||
case 'I':
|
case 'I':
|
||||||
sprintf((char *)buf+i, "%"PRINTF_INT64_MODIFIER"u", param->statssrv64);
|
sprintf((char *)buf+i, "%"PRIu64"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, "%"PRIu64"u", param->statscli64);
|
||||||
i += (int)strlen((char *)buf+i);
|
i += (int)strlen((char *)buf+i);
|
||||||
break;
|
break;
|
||||||
case 'h':
|
case 'h':
|
||||||
|
@ -72,7 +72,7 @@ int savecounters(void)
|
|||||||
sprintf(tmpbuf,pat_file,ldap_dircount,tcd->ace->users->user);
|
sprintf(tmpbuf,pat_file,ldap_dircount,tcd->ace->users->user);
|
||||||
f=fopen(tmpbuf,"w+b");
|
f=fopen(tmpbuf,"w+b");
|
||||||
fseek(f,0,SEEK_SET);
|
fseek(f,0,SEEK_SET);
|
||||||
fprintf(f,"%"PRINTF_INT64_MODIFIER"u %lu %lu\n",tcd->traf64,
|
fprintf(f,"%"PRIu64"u %lu %lu\n",tcd->traf64,
|
||||||
(unsigned long)tcd->cleared,(unsigned long)tcd->updated);
|
(unsigned long)tcd->cleared,(unsigned long)tcd->updated);
|
||||||
|
|
||||||
fclose(f);
|
fclose(f);
|
||||||
@ -387,7 +387,7 @@ int h_trafgroup(int argc, unsigned char ** argv)
|
|||||||
|
|
||||||
fseek(f,0,SEEK_SET);
|
fseek(f,0,SEEK_SET);
|
||||||
fgets(buf, 256, f);
|
fgets(buf, 256, f);
|
||||||
sscanf(buf,"%"PRINTF_INT64_MODIFIER"u %lu %lu\n",&rcounter.traf64,
|
sscanf(buf,"%"PRIu64"u %lu %lu\n",&rcounter.traf64,
|
||||||
&rcounter.cleared, &rcounter.updated);
|
&rcounter.cleared, &rcounter.updated);
|
||||||
|
|
||||||
|
|
||||||
|
@ -240,7 +240,7 @@ void mylogfunc(struct clientparam * param, const unsigned char * pz) {
|
|||||||
}
|
}
|
||||||
if (DBGLEVEL == 1) {
|
if (DBGLEVEL == 1) {
|
||||||
#ifndef NOPSTDINT
|
#ifndef NOPSTDINT
|
||||||
fprintf(stdout, "Port=%hd; Before: srv=%"PRINTF_INT64_MODIFIER"d, cli=%"PRINTF_INT64_MODIFIER"d; After: srv=%"PRINTF_INT64_MODIFIER"d, cli=%"PRINTF_INT64_MODIFIER"d; nreads=%ld; nwrites=%ld; Rule=%d\n",myhtons(*SAPORT(¶m->sinsr)), statssrv_before, statscli_before, param->statssrv64, param->statscli64,param->nreads,param->nwrites,rule);
|
fprintf(stdout, "Port=%hd; Before: srv=%"PRIu64"d, cli=%"PRIu64"d; After: srv=%"PRIu64"d, cli=%"PRIu64"d; nreads=%ld; nwrites=%ld; Rule=%d\n",myhtons(*SAPORT(¶m->sinsr)), statssrv_before, statscli_before, param->statssrv64, param->statscli64,param->nreads,param->nwrites,rule);
|
||||||
#else
|
#else
|
||||||
fprintf(stdout, "Port=%hd; Before: srv=%lu, cli=%lu; After: srv=%lu, cli=%lu; nreads=%ld; nwrites=%ld; Rule=%d\n",myhtons(param->sins.sin_port), statssrv_before, statscli_before, param->statssrv, param->statscli,param->nreads,param->nwrites,rule);
|
fprintf(stdout, "Port=%hd; Before: srv=%lu, cli=%lu; After: srv=%lu, cli=%lu; nreads=%ld; nwrites=%ld; Rule=%d\n",myhtons(param->sins.sin_port), statssrv_before, statscli_before, param->statssrv, param->statscli,param->nreads,param->nwrites,rule);
|
||||||
#endif
|
#endif
|
||||||
|
12
src/proxy.c
12
src/proxy.c
@ -393,7 +393,7 @@ 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;
|
||||||
sscanf((char *)buf + 15, "%"PRINTF_INT64_MODIFIER"u", &contentlength64);
|
sscanf((char *)buf + 15, "%"PRIu64"u", &contentlength64);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
while( contentlength64 > 0 && (i = sockgetlinebuf(param, CLIENT, buf, (BUFSIZE < contentlength64)? BUFSIZE - 1:(int)contentlength64, '\n', conf.timeouts[STRING_S])) > 0){
|
while( contentlength64 > 0 && (i = sockgetlinebuf(param, CLIENT, buf, (BUFSIZE < contentlength64)? BUFSIZE - 1:(int)contentlength64, '\n', conf.timeouts[STRING_S])) > 0){
|
||||||
@ -503,7 +503,7 @@ for(;;){
|
|||||||
if(!sb)continue;
|
if(!sb)continue;
|
||||||
++sb;
|
++sb;
|
||||||
while(isspace(*sb))sb++;
|
while(isspace(*sb))sb++;
|
||||||
sscanf((char *)sb, "%"PRINTF_INT64_MODIFIER"u",&contentlength64);
|
sscanf((char *)sb, "%"PRIu64"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);
|
||||||
}
|
}
|
||||||
@ -581,7 +581,7 @@ for(;;){
|
|||||||
contentlength64 = param->cliinbuf;
|
contentlength64 = param->cliinbuf;
|
||||||
param->nolongdatfilter = 1;
|
param->nolongdatfilter = 1;
|
||||||
}
|
}
|
||||||
sprintf((char*)buf+strlen((char *)buf), "Content-Length: %"PRINTF_INT64_MODIFIER"u\r\n", contentlength64);
|
sprintf((char*)buf+strlen((char *)buf), "Content-Length: %"PRIu64"u\r\n", contentlength64);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@ -955,7 +955,7 @@ for(;;){
|
|||||||
if(!sb)continue;
|
if(!sb)continue;
|
||||||
++sb;
|
++sb;
|
||||||
while(isspace(*sb))sb++;
|
while(isspace(*sb))sb++;
|
||||||
sscanf((char *)sb, "%"PRINTF_INT64_MODIFIER"u", &contentlength64);
|
sscanf((char *)sb, "%"PRIu64"u", &contentlength64);
|
||||||
hascontent = 1;
|
hascontent = 1;
|
||||||
if(param->unsafefilter && param->ndatfilterssrv > 0) {
|
if(param->unsafefilter && param->ndatfilterssrv > 0) {
|
||||||
hascontent = 2;
|
hascontent = 2;
|
||||||
@ -1033,7 +1033,7 @@ for(;;){
|
|||||||
}
|
}
|
||||||
if(action != PASS) RETURN(517);
|
if(action != PASS) RETURN(517);
|
||||||
contentlength64 = param->srvinbuf;
|
contentlength64 = param->srvinbuf;
|
||||||
sprintf((char*)buf+strlen((char *)buf), "Content-Length: %"PRINTF_INT64_MODIFIER"u\r\n", contentlength64);
|
sprintf((char*)buf+strlen((char *)buf), "Content-Length: %"PRIu64"u\r\n", contentlength64);
|
||||||
hascontent = 1;
|
hascontent = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1080,7 +1080,7 @@ for(;;){
|
|||||||
}
|
}
|
||||||
smallbuf[i] = 0;
|
smallbuf[i] = 0;
|
||||||
contentlength64 = 0;
|
contentlength64 = 0;
|
||||||
sscanf((char *)smallbuf, "%"PRINTF_INT64_MODIFIER"x", &contentlength64);
|
sscanf((char *)smallbuf, "%"PRIu64"x", &contentlength64);
|
||||||
if(contentlength64 == 0) {
|
if(contentlength64 == 0) {
|
||||||
param->chunked = 2;
|
param->chunked = 2;
|
||||||
}
|
}
|
||||||
|
@ -203,6 +203,7 @@ int afdetect(unsigned char *name);
|
|||||||
unsigned long myresolver(int, unsigned char *, unsigned char *);
|
unsigned long myresolver(int, unsigned char *, unsigned char *);
|
||||||
unsigned long fakeresolver (int, unsigned char *, unsigned char*);
|
unsigned long fakeresolver (int, unsigned char *, unsigned char*);
|
||||||
int inithashtable(struct hashtable *hashtable, unsigned nhashsize);
|
int inithashtable(struct hashtable *hashtable, unsigned nhashsize);
|
||||||
|
void destroyhashtable(struct hashtable *ht);
|
||||||
void freeparam(struct clientparam * param);
|
void freeparam(struct clientparam * param);
|
||||||
void clearstat(struct clientparam * param);
|
void clearstat(struct clientparam * param);
|
||||||
void dumpcounters(struct trafcount *tl, int counterd);
|
void dumpcounters(struct trafcount *tl, int counterd);
|
||||||
|
@ -505,7 +505,10 @@ int MODULEMAINFUNC (int argc, char** argv){
|
|||||||
""
|
""
|
||||||
#endif
|
#endif
|
||||||
);
|
);
|
||||||
|
srvfree(&srv);
|
||||||
|
if(cbc_string)myfree(cbc_string);
|
||||||
|
if(cbl_string)myfree(cbl_string);
|
||||||
|
if(fp) fclose(fp);
|
||||||
return (1);
|
return (1);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -538,6 +541,10 @@ int MODULEMAINFUNC (int argc, char** argv){
|
|||||||
""
|
""
|
||||||
#endif
|
#endif
|
||||||
);
|
);
|
||||||
|
srvfree(&srv);
|
||||||
|
if(cbc_string)myfree(cbc_string);
|
||||||
|
if(cbl_string)myfree(cbl_string);
|
||||||
|
if(fp) fclose(fp);
|
||||||
return (1);
|
return (1);
|
||||||
}
|
}
|
||||||
srv.target = (unsigned char *)mystrdup(argv[i+1]);
|
srv.target = (unsigned char *)mystrdup(argv[i+1]);
|
||||||
@ -558,6 +565,10 @@ int MODULEMAINFUNC (int argc, char** argv){
|
|||||||
}
|
}
|
||||||
defparam.clisock = 0;
|
defparam.clisock = 0;
|
||||||
if(! (newparam = myalloc (sizeof(defparam)))){
|
if(! (newparam = myalloc (sizeof(defparam)))){
|
||||||
|
srvfree(&srv);
|
||||||
|
if(cbc_string)myfree(cbc_string);
|
||||||
|
if(cbl_string)myfree(cbl_string);
|
||||||
|
if(fp) fclose(fp);
|
||||||
return 2;
|
return 2;
|
||||||
};
|
};
|
||||||
*newparam = defparam;
|
*newparam = defparam;
|
||||||
@ -601,6 +612,9 @@ int MODULEMAINFUNC (int argc, char** argv){
|
|||||||
}
|
}
|
||||||
if( sock == INVALID_SOCKET) {
|
if( sock == INVALID_SOCKET) {
|
||||||
perror("socket()");
|
perror("socket()");
|
||||||
|
srvfree(&srv);
|
||||||
|
if(cbl_string)myfree(cbl_string);
|
||||||
|
if(fp) fclose(fp);
|
||||||
return -2;
|
return -2;
|
||||||
}
|
}
|
||||||
setopts(sock, srv.lissockopts);
|
setopts(sock, srv.lissockopts);
|
||||||
@ -618,7 +632,10 @@ int MODULEMAINFUNC (int argc, char** argv){
|
|||||||
#endif
|
#endif
|
||||||
#if defined SO_BINDTODEVICE
|
#if defined SO_BINDTODEVICE
|
||||||
if(srv.ibindtodevice && so._setsockopt(sock, SOL_SOCKET, SO_BINDTODEVICE, srv.ibindtodevice, strlen(srv.ibindtodevice) + 1)) {
|
if(srv.ibindtodevice && so._setsockopt(sock, SOL_SOCKET, SO_BINDTODEVICE, srv.ibindtodevice, strlen(srv.ibindtodevice) + 1)) {
|
||||||
dolog(&defparam, "failed to bind device");
|
dolog(&defparam, (unsigned char *)"failed to bind device");
|
||||||
|
srvfree(&srv);
|
||||||
|
if(cbc_string)myfree(cbc_string);
|
||||||
|
if(fp) fclose(fp);
|
||||||
return -12;
|
return -12;
|
||||||
}
|
}
|
||||||
#elif defined IP_BOUND_IF
|
#elif defined IP_BOUND_IF
|
||||||
@ -627,11 +644,17 @@ int MODULEMAINFUNC (int argc, char** argv){
|
|||||||
idx = if_nametoindex(srv.ibindtodevice);
|
idx = if_nametoindex(srv.ibindtodevice);
|
||||||
if(!idx || (*SAFAMILY(&srv.intsa) == AF_INET && setsockopt(sock, IPPROTO_IP, IP_BOUND_IF, &idx, sizeof(idx)))) {
|
if(!idx || (*SAFAMILY(&srv.intsa) == AF_INET && setsockopt(sock, IPPROTO_IP, IP_BOUND_IF, &idx, sizeof(idx)))) {
|
||||||
dolog(&defparam, (unsigned char *)"failed to bind device");
|
dolog(&defparam, (unsigned char *)"failed to bind device");
|
||||||
|
srvfree(&srv);
|
||||||
|
if(cbc_string)myfree(cbc_string);
|
||||||
|
if(fp) fclose(fp);
|
||||||
return -12;
|
return -12;
|
||||||
}
|
}
|
||||||
#ifndef NOIPV6
|
#ifndef NOIPV6
|
||||||
if((*SAFAMILY(&srv.intsa) == AF_INET6 && so._setsockopt(sock, IPPROTO_IPV6, IPV6_BOUND_IF, &idx, sizeof(idx)))) {
|
if((*SAFAMILY(&srv.intsa) == AF_INET6 && so._setsockopt(sock, IPPROTO_IPV6, IPV6_BOUND_IF, &idx, sizeof(idx)))) {
|
||||||
dolog(&defparam, (unsigned char *)"failed to bind device");
|
dolog(&defparam, (unsigned char *)"failed to bind device");
|
||||||
|
srvfree(&srv);
|
||||||
|
if(cbc_string)myfree(cbc_string);
|
||||||
|
if(fp) fclose(fp);
|
||||||
return -12;
|
return -12;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -645,6 +668,9 @@ int MODULEMAINFUNC (int argc, char** argv){
|
|||||||
sleeptime = (sleeptime<<1);
|
sleeptime = (sleeptime<<1);
|
||||||
if(!sleeptime) {
|
if(!sleeptime) {
|
||||||
so._closesocket(sock);
|
so._closesocket(sock);
|
||||||
|
srvfree(&srv);
|
||||||
|
if(cbc_string)myfree(cbc_string);
|
||||||
|
if(fp) fclose(fp);
|
||||||
return -3;
|
return -3;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -652,6 +678,9 @@ int MODULEMAINFUNC (int argc, char** argv){
|
|||||||
if(so._listen (sock, srv.backlog?srv.backlog : 1+(srv.maxchild>>3))==-1) {
|
if(so._listen (sock, srv.backlog?srv.backlog : 1+(srv.maxchild>>3))==-1) {
|
||||||
sprintf((char *)buf, "listen(): %s", strerror(errno));
|
sprintf((char *)buf, "listen(): %s", strerror(errno));
|
||||||
if(!srv.silent)dolog(&defparam, buf);
|
if(!srv.silent)dolog(&defparam, buf);
|
||||||
|
srvfree(&srv);
|
||||||
|
if(cbc_string)myfree(cbc_string);
|
||||||
|
if(fp) fclose(fp);
|
||||||
return -4;
|
return -4;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -667,6 +696,9 @@ int MODULEMAINFUNC (int argc, char** argv){
|
|||||||
parsehost(srv.family, cbl_string, (struct sockaddr *)&cbsa);
|
parsehost(srv.family, cbl_string, (struct sockaddr *)&cbsa);
|
||||||
if((srv.cbsock=so._socket(SASOCK(&cbsa), SOCK_STREAM, IPPROTO_TCP))==INVALID_SOCKET) {
|
if((srv.cbsock=so._socket(SASOCK(&cbsa), SOCK_STREAM, IPPROTO_TCP))==INVALID_SOCKET) {
|
||||||
dolog(&defparam, (unsigned char *)"Failed to allocate connect back socket");
|
dolog(&defparam, (unsigned char *)"Failed to allocate connect back socket");
|
||||||
|
srvfree(&srv);
|
||||||
|
myfree(cbl_string);
|
||||||
|
if(fp) fclose(fp);
|
||||||
return -6;
|
return -6;
|
||||||
}
|
}
|
||||||
opt = 1;
|
opt = 1;
|
||||||
@ -680,10 +712,16 @@ int MODULEMAINFUNC (int argc, char** argv){
|
|||||||
|
|
||||||
if(so._bind(srv.cbsock, (struct sockaddr*)&cbsa, SASIZE(&cbsa))==-1) {
|
if(so._bind(srv.cbsock, (struct sockaddr*)&cbsa, SASIZE(&cbsa))==-1) {
|
||||||
dolog(&defparam, (unsigned char *)"Failed to bind connect back socket");
|
dolog(&defparam, (unsigned char *)"Failed to bind connect back socket");
|
||||||
|
srvfree(&srv);
|
||||||
|
myfree(cbl_string);
|
||||||
|
if(fp) fclose(fp);
|
||||||
return -7;
|
return -7;
|
||||||
}
|
}
|
||||||
if(so._listen(srv.cbsock, 1 + (srv.maxchild>>4))==-1) {
|
if(so._listen(srv.cbsock, 1 + (srv.maxchild>>4))==-1) {
|
||||||
dolog(&defparam, (unsigned char *)"Failed to listen connect back socket");
|
dolog(&defparam, (unsigned char *)"Failed to listen connect back socket");
|
||||||
|
srvfree(&srv);
|
||||||
|
myfree(cbl_string);
|
||||||
|
if(fp) fclose(fp);
|
||||||
return -8;
|
return -8;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,8 +15,9 @@
|
|||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#ifndef PRINTF_INT64_MODIFIER
|
#include <inttypes.h>
|
||||||
#define PRINTF_INT64_MODIFIER "ll"
|
#ifndef PRIu64
|
||||||
|
#define PRIu64 "ll"
|
||||||
#endif
|
#endif
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
@ -596,7 +597,6 @@ struct extparam {
|
|||||||
struct sockaddr_in extsa;
|
struct sockaddr_in extsa;
|
||||||
#endif
|
#endif
|
||||||
struct passwords *pwl;
|
struct passwords *pwl;
|
||||||
struct auth * authenticate;
|
|
||||||
AUTHFUNC authfunc;
|
AUTHFUNC authfunc;
|
||||||
LOGFUNC logfunc;
|
LOGFUNC logfunc;
|
||||||
BANDLIMFUNC bandlimfunc;
|
BANDLIMFUNC bandlimfunc;
|
||||||
@ -719,7 +719,7 @@ struct sockfuncs {
|
|||||||
int (*_getsockname)(SOCKET s, struct sockaddr * name, socklen_t * namelen);
|
int (*_getsockname)(SOCKET s, struct sockaddr * name, socklen_t * namelen);
|
||||||
int (*_getsockopt)(SOCKET s, int level, int optname, void * optval, socklen_t * optlen);
|
int (*_getsockopt)(SOCKET s, int level, int optname, void * optval, socklen_t * optlen);
|
||||||
int (*_setsockopt)(int s, int level, int optname, const void *optval, socklen_t optlen);
|
int (*_setsockopt)(int s, int level, int optname, const void *optval, socklen_t optlen);
|
||||||
int (*_poll)(struct pollfd *fds, unsigned int nfds, int timeout);
|
int (*_poll)(struct pollfd *fds, long unsigned int nfds, int timeout);
|
||||||
size_t (*_send)(SOCKET s, const void *msg, size_t len, int flags);
|
size_t (*_send)(SOCKET s, const void *msg, size_t len, int flags);
|
||||||
size_t (*_sendto)(SOCKET s, const void *msg, size_t len, int flags, const struct sockaddr *to, SASIZETYPE tolen);
|
size_t (*_sendto)(SOCKET s, const void *msg, size_t len, int flags, const struct sockaddr *to, SASIZETYPE tolen);
|
||||||
size_t (*_recv)(SOCKET s, void *buf, size_t len, int flags);
|
size_t (*_recv)(SOCKET s, void *buf, size_t len, int flags);
|
||||||
|
@ -510,9 +510,9 @@ void * adminchild(struct clientparam* param) {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
inbuf += sprintf(buf+inbuf,
|
inbuf += sprintf(buf+inbuf,
|
||||||
"</td><td>%"PRINTF_INT64_MODIFIER"u</td>"
|
"</td><td>%"PRIu64"u</td>"
|
||||||
"<td>MB%s</td>"
|
"<td>MB%s</td>"
|
||||||
"<td>%"PRINTF_INT64_MODIFIER"u.%"PRINTF_INT64_MODIFIER"u</td>"
|
"<td>%"PRIu64"u.%"PRIu64"u</td>"
|
||||||
"<td>%s</td>",
|
"<td>%s</td>",
|
||||||
cp->traflim64 / (1024 * 1024),
|
cp->traflim64 / (1024 * 1024),
|
||||||
rotations[cp->type],
|
rotations[cp->type],
|
||||||
|
Loading…
Reference in New Issue
Block a user