mirror of
https://github.com/3proxy/3proxy.git
synced 2026-10-16 00:25:48 +08:00
Reach the configuration through a pointer
conf is now a pointer to the current configuration rather than the structure itself: at first confboot, which exists before main() runs, as plugins and the standalone services use it too; later configurations will start from confdefaults. Both are made from confinit.h, the one list of initial values. The timeouts are an array of the configuration instead of a pointer to a global one. Nothing behaves differently yet. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
8bd5c0f0fa
commit
737bdc7d24
84
src/3proxy.c
84
src/3proxy.c
@ -29,7 +29,7 @@ void httpsrv_init(void);
|
||||
#endif
|
||||
|
||||
#ifndef DEFAULTCONFIG
|
||||
#define DEFAULTCONFIG conf.stringtable[25]
|
||||
#define DEFAULTCONFIG conf->stringtable[25]
|
||||
#endif
|
||||
|
||||
FILE * confopen();
|
||||
@ -73,13 +73,13 @@ void __stdcall CommandHandler( DWORD dwCommand )
|
||||
case SERVICE_CONTROL_SHUTDOWN:
|
||||
SetStatus( SERVICE_STOP_PENDING, 0, 1 );
|
||||
timetoexit = 1;
|
||||
conf.paused++;
|
||||
conf->paused++;
|
||||
/* ServiceMain() reports the service stopped once cyclestep() has
|
||||
seen this and the services are done */
|
||||
break;
|
||||
case SERVICE_CONTROL_PAUSE:
|
||||
SetStatus( SERVICE_PAUSE_PENDING, 0, 1 );
|
||||
conf.paused++;
|
||||
conf->paused++;
|
||||
SetStatus( SERVICE_PAUSED, 0, 0 );
|
||||
break;
|
||||
case SERVICE_CONTROL_CONTINUE:
|
||||
@ -95,7 +95,7 @@ void __stdcall CommandHandler( DWORD dwCommand )
|
||||
void __stdcall ServiceMain(int argc, unsigned char* argv[] )
|
||||
{
|
||||
|
||||
hSrv = RegisterServiceCtrlHandler((LPCSTR)conf.stringtable[1], (LPHANDLER_FUNCTION)CommandHandler);
|
||||
hSrv = RegisterServiceCtrlHandler((LPCSTR)conf->stringtable[1], (LPHANDLER_FUNCTION)CommandHandler);
|
||||
if( hSrv == 0 ) return;
|
||||
|
||||
SetStatus( SERVICE_START_PENDING, 0, 1 );
|
||||
@ -122,7 +122,7 @@ int even = 0;
|
||||
|
||||
void mysigpause (int sig){
|
||||
|
||||
conf.paused++;
|
||||
conf->paused++;
|
||||
even = !even;
|
||||
if(!even){
|
||||
needreload = 1;
|
||||
@ -130,7 +130,7 @@ void mysigpause (int sig){
|
||||
}
|
||||
|
||||
void mysigterm (int sig){
|
||||
conf.paused++;
|
||||
conf->paused++;
|
||||
timetoexit = 1;
|
||||
}
|
||||
|
||||
@ -207,13 +207,13 @@ void dumpcounters(struct trafcount *tlin, int counterd){
|
||||
if(counterd >= 0 && tlin) {
|
||||
|
||||
curtime = time(0);
|
||||
if(cheader.updated && conf.countertype && timechanged(cheader.updated, curtime, conf.countertype)){
|
||||
if(cheader.updated && conf->countertype && timechanged(cheader.updated, curtime, conf->countertype)){
|
||||
FILE * cfp;
|
||||
|
||||
cfp = fopen((char *)dologname(tmpbuf, (unsigned char *)conf.counterfile, NULL, conf.countertype, cheader.updated), "w");
|
||||
cfp = fopen((char *)dologname(tmpbuf, (unsigned char *)conf->counterfile, NULL, conf->countertype, cheader.updated), "w");
|
||||
if(cfp){
|
||||
for(tl = tlin; cfp && tl; tl = tl->next){
|
||||
if(tl->type >= conf.countertype)
|
||||
if(tl->type >= conf->countertype)
|
||||
fprintf(cfp, "%05d %020"PRIu64"%s%s\n", tl->number, tl->v->traf64, tl->comment?" #" : "", tl->comment? tl->comment : "");
|
||||
}
|
||||
fclose(cfp);
|
||||
@ -291,12 +291,12 @@ void cyclestep(void){
|
||||
needreload = 0;
|
||||
}
|
||||
doschedule();
|
||||
if(conf.stdlog)fflush(conf.stdlog);
|
||||
if(conf->stdlog)fflush(conf->stdlog);
|
||||
if(timechanged(minutecounter, curtime, MINUTELY)) {
|
||||
struct filemon *fm;
|
||||
struct stat sb;
|
||||
|
||||
for(fm=conf.fmon; fm; fm=fm->next){
|
||||
for(fm=conf->fmon; fm; fm=fm->next){
|
||||
if(!stat(fm->path, &sb)){
|
||||
if(fm->sb.st_mtime != sb.st_mtime || fm->sb.st_size != sb.st_size){
|
||||
stat(fm->path, &fm->sb);
|
||||
@ -314,15 +314,15 @@ void cyclestep(void){
|
||||
basetime = mktime(tm);
|
||||
}
|
||||
}
|
||||
if(conf.logname) {
|
||||
if(timechanged(conf.logtime, curtime, conf.logtype)) {
|
||||
if(conf.stdlog) conf.stdlog = freopen((char *)dologname (tmpbuf, conf.logname, NULL, conf.logtype, curtime), "a", conf.stdlog);
|
||||
else conf.stdlog = fopen((char *)dologname (tmpbuf, conf.logname, NULL, conf.logtype, curtime), "a");
|
||||
conf.logtime = curtime;
|
||||
if(conf.logtype != NONE && conf.rotate) {
|
||||
if(conf->logname) {
|
||||
if(timechanged(conf->logtime, curtime, conf->logtype)) {
|
||||
if(conf->stdlog) conf->stdlog = freopen((char *)dologname (tmpbuf, conf->logname, NULL, conf->logtype, curtime), "a", conf->stdlog);
|
||||
else conf->stdlog = fopen((char *)dologname (tmpbuf, conf->logname, NULL, conf->logtype, curtime), "a");
|
||||
conf->logtime = curtime;
|
||||
if(conf->logtype != NONE && conf->rotate) {
|
||||
int t;
|
||||
t = 1;
|
||||
switch(conf.logtype){
|
||||
switch(conf->logtype){
|
||||
case ANNUALLY:
|
||||
t = t * 12;
|
||||
case MONTHLY:
|
||||
@ -338,38 +338,38 @@ void cyclestep(void){
|
||||
default:
|
||||
break;
|
||||
}
|
||||
dologname (tmpbuf, conf.logname, (conf.archiver)?conf.archiver[1]:NULL, conf.logtype, (conf.logtime - (time_t)t * conf.rotate));
|
||||
dologname (tmpbuf, conf->logname, (conf->archiver)?conf->archiver[1]:NULL, conf->logtype, (conf->logtime - (time_t)t * conf->rotate));
|
||||
remove ((char *) tmpbuf);
|
||||
if(conf.archiver) {
|
||||
if(conf->archiver) {
|
||||
int i;
|
||||
*tmpbuf = 0;
|
||||
for(i = 2; i < conf.archiverc && strlen((char *)tmpbuf) < 512; i++){
|
||||
for(i = 2; i < conf->archiverc && strlen((char *)tmpbuf) < 512; i++){
|
||||
strcat((char *)tmpbuf, " ");
|
||||
if(!strcmp((char *)conf.archiver[i], "%A")){
|
||||
if(!strcmp((char *)conf->archiver[i], "%A")){
|
||||
strcat((char *)tmpbuf, "\"");
|
||||
dologname (tmpbuf + strlen((char *)tmpbuf), conf.logname, conf.archiver[1], conf.logtype, (conf.logtime - t));
|
||||
dologname (tmpbuf + strlen((char *)tmpbuf), conf->logname, conf->archiver[1], conf->logtype, (conf->logtime - t));
|
||||
strcat((char *)tmpbuf, "\"");
|
||||
}
|
||||
else if(!strcmp((char *)conf.archiver[i], "%F")){
|
||||
else if(!strcmp((char *)conf->archiver[i], "%F")){
|
||||
strcat((char *)tmpbuf, "\"");
|
||||
dologname (tmpbuf+strlen((char *)tmpbuf), conf.logname, NULL, conf.logtype, (conf.logtime-t));
|
||||
dologname (tmpbuf+strlen((char *)tmpbuf), conf->logname, NULL, conf->logtype, (conf->logtime-t));
|
||||
strcat((char *)tmpbuf, "\"");
|
||||
}
|
||||
else
|
||||
strcat((char *)tmpbuf, (char *)conf.archiver[i]);
|
||||
strcat((char *)tmpbuf, (char *)conf->archiver[i]);
|
||||
}
|
||||
if(system((char *)tmpbuf+1)){}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if(conf.counterd >= 0 && conf.trafcounter) {
|
||||
if(conf->counterd >= 0 && conf->trafcounter) {
|
||||
if(timechanged(cheader.updated, curtime, MINUTELY)){
|
||||
dumpcounters(conf.trafcounter, conf.counterd);
|
||||
dumpcounters(conf->trafcounter, conf->counterd);
|
||||
}
|
||||
}
|
||||
if(timetoexit){
|
||||
conf.paused++;
|
||||
conf->paused++;
|
||||
doschedule();
|
||||
waitservices();
|
||||
pooldrain();
|
||||
@ -424,7 +424,7 @@ int WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int
|
||||
hwnd = CreateWindowEx(0,L"3proxy",L"3proxy",WS_VISIBLE|WS_POPUP,0,0,0,0,0,0,hInstance,0);
|
||||
#endif
|
||||
|
||||
conf.stringtable = strings;
|
||||
conf->stringtable = strings;
|
||||
#ifdef _WIN32
|
||||
#ifndef _WINCE
|
||||
if((argc == 2 || argc == 3)&& !strcmp((char *)argv[1], "--install")) {
|
||||
@ -432,8 +432,8 @@ int WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int
|
||||
sprintf((char *)tmpbuf, "%s will be installed and started.\n"
|
||||
"By clicking Yes you confirm you read and accepted License Agreement.\n"
|
||||
"You can use Administration/Services to control %s service.",
|
||||
conf.stringtable[1], conf.stringtable[2]);
|
||||
if(MessageBox(NULL, (LPCSTR)tmpbuf, (LPCSTR)conf.stringtable[2], MB_YESNO|MB_ICONASTERISK) != IDYES) return 1;
|
||||
conf->stringtable[1], conf->stringtable[2]);
|
||||
if(MessageBox(NULL, (LPCSTR)tmpbuf, (LPCSTR)conf->stringtable[2], MB_YESNO|MB_ICONASTERISK) != IDYES) return 1;
|
||||
|
||||
|
||||
*tmpbuf = '\"';
|
||||
@ -454,7 +454,7 @@ int WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int
|
||||
perror("Failed to open Service Manager");
|
||||
RETURN(101);
|
||||
}
|
||||
if (!(sch = CreateService(sch, (LPCSTR)conf.stringtable[1], (LPCSTR)conf.stringtable[2], GENERIC_EXECUTE, SERVICE_WIN32_OWN_PROCESS, SERVICE_AUTO_START, SERVICE_ERROR_IGNORE, (char *)tmpbuf, NULL, NULL, NULL, NULL, NULL))){
|
||||
if (!(sch = CreateService(sch, (LPCSTR)conf->stringtable[1], (LPCSTR)conf->stringtable[2], GENERIC_EXECUTE, SERVICE_WIN32_OWN_PROCESS, SERVICE_AUTO_START, SERVICE_ERROR_IGNORE, (char *)tmpbuf, NULL, NULL, NULL, NULL, NULL))){
|
||||
perror("Failed to create service");
|
||||
RETURN(103);
|
||||
}
|
||||
@ -475,7 +475,7 @@ int WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int
|
||||
RETURN(104);
|
||||
}
|
||||
if(RegSetValueEx( runsrv,
|
||||
(LPCSTR)conf.stringtable[1],
|
||||
(LPCSTR)conf->stringtable[1],
|
||||
0,
|
||||
REG_EXPAND_SZ,
|
||||
(BYTE *)tmpbuf,
|
||||
@ -496,7 +496,7 @@ int WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int
|
||||
perror("Failed to open Service Manager\n");
|
||||
RETURN(106);
|
||||
}
|
||||
if (!(sch = OpenService(sch, (LPCSTR)conf.stringtable[1], DELETE))){
|
||||
if (!(sch = OpenService(sch, (LPCSTR)conf->stringtable[1], DELETE))){
|
||||
perror("Failed to open service");
|
||||
RETURN(107);
|
||||
}
|
||||
@ -515,7 +515,7 @@ int WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int
|
||||
perror("Failed to open registry");
|
||||
RETURN(109);
|
||||
}
|
||||
if(RegDeleteValue(runsrv, (LPCSTR)conf.stringtable[1]) != ERROR_SUCCESS){
|
||||
if(RegDeleteValue(runsrv, (LPCSTR)conf->stringtable[1]) != ERROR_SUCCESS){
|
||||
perror("Failed to clear registry");
|
||||
RETURN(110);
|
||||
}
|
||||
@ -528,8 +528,8 @@ int WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
conf.conffile = strdup((argc==2)?argv[1]:(char*)DEFAULTCONFIG);
|
||||
if(conf.conffile && *conf.conffile != '-') {
|
||||
conf->conffile = strdup((argc==2)?argv[1]:(char*)DEFAULTCONFIG);
|
||||
if(conf->conffile && *conf->conffile != '-') {
|
||||
fp = confopen();
|
||||
#ifndef _WIN32
|
||||
if(!fp) fp = stdin;
|
||||
@ -545,7 +545,7 @@ int WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int
|
||||
fprintf(stderr, "\n if conffile is missing, configuration is expected from stdin\n");
|
||||
#endif
|
||||
fprintf(stderr, "available socket options:\n\t%s\n", printopts("\n\t"));
|
||||
fprintf(stderr, "\n%s %s\n%s\n", conf.stringtable[2], conf.stringtable[3], copyright);
|
||||
fprintf(stderr, "\n%s %s\n%s\n", conf->stringtable[2], conf->stringtable[3], copyright);
|
||||
|
||||
return 1;
|
||||
}
|
||||
@ -581,10 +581,10 @@ int WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int
|
||||
httpsrv_init();
|
||||
#endif
|
||||
|
||||
freeconf(&conf);
|
||||
freeconf(conf);
|
||||
initcommands();
|
||||
res = readconfig(fp);
|
||||
conf.version++;
|
||||
conf->version++;
|
||||
|
||||
/* readconfig() names the failing line, which an exit status would cut
|
||||
to 8 bits: a failed configuration exits with 1 */
|
||||
@ -597,7 +597,7 @@ int WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int
|
||||
if(service){
|
||||
SERVICE_TABLE_ENTRY ste[] =
|
||||
{
|
||||
{ (LPSTR)conf.stringtable[1], (LPSERVICE_MAIN_FUNCTION)ServiceMain},
|
||||
{ (LPSTR)conf->stringtable[1], (LPSERVICE_MAIN_FUNCTION)ServiceMain},
|
||||
{ NULL, NULL }
|
||||
};
|
||||
if(!StartServiceCtrlDispatcher( ste ))cyclestep();
|
||||
|
||||
14
src/auth.c
14
src/auth.c
@ -17,7 +17,7 @@ int alwaysauth(struct clientparam * param){
|
||||
int countout = 0;
|
||||
|
||||
|
||||
if(conf.connlimiter && !param->connlim && startconnlims(param)) return 10;
|
||||
if(conf->connlimiter && !param->connlim && startconnlims(param)) return 10;
|
||||
#ifdef WITH_HTTPSRV
|
||||
/* The http server answers the request itself, so authorization must not
|
||||
try to reach a destination that does not exist. A request it has handed
|
||||
@ -27,15 +27,15 @@ int alwaysauth(struct clientparam * param){
|
||||
res = doconnect(param);
|
||||
#endif
|
||||
if(!res){
|
||||
if(conf.bandlimfunc && (conf.bandlimiter||conf.bandlimiterout)){
|
||||
if(conf->bandlimfunc && (conf->bandlimiter||conf->bandlimiterout)){
|
||||
_3proxy_mutex_lock(&bandlim_mutex);
|
||||
initbandlims(param);
|
||||
_3proxy_mutex_unlock(&bandlim_mutex);
|
||||
}
|
||||
|
||||
if(conf.trafcountfunc && conf.trafcounter) {
|
||||
if(conf->trafcountfunc && conf->trafcounter) {
|
||||
_3proxy_mutex_lock(&tc_mutex);
|
||||
for(tc = conf.trafcounter; tc; tc = tc->next) {
|
||||
for(tc = conf->trafcounter; tc; tc = tc->next) {
|
||||
if(tc->disabled) continue;
|
||||
if(ACLmatches(tc->ace, param)){
|
||||
if(tc->ace->action == NOCOUNTIN) {
|
||||
@ -51,11 +51,11 @@ int alwaysauth(struct clientparam * param){
|
||||
_3proxy_mutex_unlock(&tc_mutex);
|
||||
return 10;
|
||||
}
|
||||
param->trafcountfunc = conf.trafcountfunc;
|
||||
param->trafcountfunc = conf->trafcountfunc;
|
||||
param->maxtrafin64 = tc->traflim64 - tc->v->traf64;
|
||||
}
|
||||
}
|
||||
if(countout)for(tc = conf.trafcounter; tc; tc = tc->next) {
|
||||
if(countout)for(tc = conf->trafcounter; tc; tc = tc->next) {
|
||||
if(tc->disabled) continue;
|
||||
if(ACLmatches(tc->ace, param)){
|
||||
if(tc->ace->action == NOCOUNTOUT || tc->ace->action == NOCOUNTALL) break;
|
||||
@ -66,7 +66,7 @@ int alwaysauth(struct clientparam * param){
|
||||
_3proxy_mutex_unlock(&tc_mutex);
|
||||
return 10;
|
||||
}
|
||||
param->trafcountfunc = conf.trafcountfunc;
|
||||
param->trafcountfunc = conf->trafcountfunc;
|
||||
param->maxtrafout64 = tc->traflim64 - tc->v->traf64;
|
||||
}
|
||||
}
|
||||
|
||||
@ -306,7 +306,7 @@ int radsend(struct clientparam * param, int auth, int stop){
|
||||
char buf[64];
|
||||
|
||||
|
||||
if(!conf.nradservers) {
|
||||
if(!conf->nradservers) {
|
||||
return 4;
|
||||
}
|
||||
|
||||
@ -371,12 +371,12 @@ int radsend(struct clientparam * param, int auth, int stop){
|
||||
total_length += (2+len);
|
||||
|
||||
/* NAS-Identifier */
|
||||
if(conf.stringtable){
|
||||
if(conf->stringtable){
|
||||
*ptr++ = PW_NAS_IDENTIFIER;
|
||||
len = strlen((char *)conf.stringtable[SERVICES+param->service]);
|
||||
len = strlen((char *)conf->stringtable[SERVICES+param->service]);
|
||||
if(len > 253) len = 253;
|
||||
*ptr++ = (2 + len);
|
||||
memcpy(ptr, conf.stringtable[SERVICES+param->service], len);
|
||||
memcpy(ptr, conf->stringtable[SERVICES+param->service], len);
|
||||
ptr += len;
|
||||
total_length+=(len+2);
|
||||
}
|
||||
@ -506,7 +506,7 @@ int radsend(struct clientparam * param, int auth, int stop){
|
||||
memcpy(ptr, param->password, len);
|
||||
rad_pwencode((char *)ptr,
|
||||
&len,
|
||||
conf.radiussecret,
|
||||
conf->radiussecret,
|
||||
(char *)packet.vector);
|
||||
*(ptr-1) = len + 2;
|
||||
ptr+=len;
|
||||
@ -517,17 +517,17 @@ int radsend(struct clientparam * param, int auth, int stop){
|
||||
packet.length = htons(total_length);
|
||||
|
||||
if(!auth){
|
||||
len = strlen(conf.radiussecret);
|
||||
memcpy(ptr,conf.radiussecret,len);
|
||||
len = strlen(conf->radiussecret);
|
||||
memcpy(ptr,conf->radiussecret,len);
|
||||
md5_calc(packet.vector, (u_char *)&packet, total_length + len);
|
||||
}
|
||||
memcpy(vector, packet.vector, AUTH_VECTOR_LEN);
|
||||
|
||||
for (loop = 0; loop < conf.nradservers && loop < MAXRADIUS; loop++) {
|
||||
for (loop = 0; loop < conf->nradservers && loop < MAXRADIUS; loop++) {
|
||||
SOCKET remsock;
|
||||
|
||||
|
||||
saremote = auth?conf.radiuslist[loop].authaddr : conf.radiuslist[loop].logaddr;
|
||||
saremote = auth?conf->radiuslist[loop].authaddr : conf->radiuslist[loop].logaddr;
|
||||
#ifdef NOIPV6
|
||||
if(*SAFAMILY(&saremote)!= AF_INET) {
|
||||
continue;
|
||||
@ -548,9 +548,9 @@ int radsend(struct clientparam * param, int auth, int stop){
|
||||
remsock = sockfd;
|
||||
/*
|
||||
}
|
||||
else remsock = conf.radiuslist[loop].logsock;
|
||||
else remsock = conf->radiuslist[loop].logsock;
|
||||
*/
|
||||
so._bind(so.state, remsock,(struct sockaddr *)&conf.radiuslist[loop].localaddr,SASIZE(&conf.radiuslist[loop].localaddr));
|
||||
so._bind(so.state, remsock,(struct sockaddr *)&conf->radiuslist[loop].localaddr,SASIZE(&conf->radiuslist[loop].localaddr));
|
||||
len = so._sendto(so.state, remsock, (char *)&packet, total_length, 0,
|
||||
(struct sockaddr *)&saremote, sizeof(saremote));
|
||||
if(len != ntohs(packet.length)){
|
||||
@ -560,7 +560,7 @@ int radsend(struct clientparam * param, int auth, int stop){
|
||||
memset(fds, 0, sizeof(fds));
|
||||
fds[0].fd = remsock;
|
||||
fds[0].events = POLLIN;
|
||||
if(so._poll(so.state, fds, 1, conf.timeouts[SINGLEBYTE_L]*1000) <= 0) {
|
||||
if(so._poll(so.state, fds, 1, conf->timeouts[SINGLEBYTE_L]*1000) <= 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -582,7 +582,7 @@ int radsend(struct clientparam * param, int auth, int stop){
|
||||
continue;
|
||||
}
|
||||
|
||||
if (calc_replydigest((char *)&rpacket, (char *)packet.vector, conf.radiussecret,
|
||||
if (calc_replydigest((char *)&rpacket, (char *)packet.vector, conf->radiussecret,
|
||||
data_len) ){
|
||||
continue;
|
||||
}
|
||||
|
||||
82
src/common.c
82
src/common.c
@ -204,20 +204,6 @@ char *rotations[] = {
|
||||
time_t curtime;
|
||||
int timetoexit = 0, needreload = 0;
|
||||
|
||||
int timeouts[12] = {
|
||||
1, /* SINGLEBYTE_S */
|
||||
5, /* SINGLEBYTE_L */
|
||||
30, /* STRING_S */
|
||||
60, /* STRING_L */
|
||||
180, /* CONNECTION_S */
|
||||
1800, /* CONNECTION_L */
|
||||
15, /* DNS_TO */
|
||||
60, /* CHAIN_TO */
|
||||
15, /* CONNECT_TO */
|
||||
5, /* CONNBACK_TO */
|
||||
5, /* LINGER_TO */
|
||||
0
|
||||
};
|
||||
|
||||
#ifndef _WIN32
|
||||
/* PTHREAD_STACK_MIN is 128K on glibc/aarch64 and glibc/powerpc and may be
|
||||
@ -234,67 +220,15 @@ size_t threadstacksize(int extra){
|
||||
|
||||
struct threadpool tpool;
|
||||
|
||||
struct extparam conf = {
|
||||
.timeouts = timeouts,
|
||||
.acl = NULL,
|
||||
.conffile = NULL,
|
||||
.bandlimiter = NULL,
|
||||
.bandlimiterout = NULL,
|
||||
.connlimiter = NULL,
|
||||
.trafcounter = NULL,
|
||||
.services = NULL,
|
||||
.stacksize = 0,
|
||||
.poolmax = -1,
|
||||
.pooltimeout = 60,
|
||||
.counterd = -1,
|
||||
.rotate = 0,
|
||||
.paused = 0,
|
||||
.archiverc = 0,
|
||||
.demon = 0,
|
||||
.maxchild = DEFAULT_MAXCHILD,
|
||||
.backlog = 0,
|
||||
.version = 0,
|
||||
.noforce = 0,
|
||||
.bandlimver = 0,
|
||||
.parentretries = 2,
|
||||
.authcachetype = 6,
|
||||
.authcachetime = 600,
|
||||
.filtermaxsize = 1048576,
|
||||
.gracetraf = 0,
|
||||
.gracenum = 0,
|
||||
.gracedelay = 0,
|
||||
.maxseg = 0,
|
||||
.logname = NULL,
|
||||
.archiver = NULL,
|
||||
.logtype = NONE,
|
||||
.countertype = NONE,
|
||||
.counterfile = NULL,
|
||||
#ifndef NOIPV6
|
||||
.intsa = {AF_INET},
|
||||
.extsa6 = {AF_INET6},
|
||||
.extsa = {AF_INET},
|
||||
#else
|
||||
.intsa = {AF_INET},
|
||||
.extsa = {AF_INET},
|
||||
#endif
|
||||
.pwl = NULL,
|
||||
.authenticate = NULL,
|
||||
.authfunc = doconnect,
|
||||
.logfunc = lognone,
|
||||
.bandlimfunc = NULL,
|
||||
.trafcountfunc = NULL,
|
||||
.logtarget = NULL,
|
||||
.logformat = NULL,
|
||||
.fmon = NULL,
|
||||
.filters = NULL,
|
||||
.authfuncs = NULL,
|
||||
.stdlog = NULL,
|
||||
.stringtable = NULL,
|
||||
.logtime = (time_t)0,
|
||||
.logdumpsrv = 0,
|
||||
.logdumpcli = 0,
|
||||
.delimchar = '@',
|
||||
/* A configuration starts as confdefaults; conf is the current one, at first
|
||||
confboot, which exists before main() runs. */
|
||||
const struct extparam confdefaults = {
|
||||
#include "confinit.h"
|
||||
};
|
||||
struct extparam confboot = {
|
||||
#include "confinit.h"
|
||||
};
|
||||
struct extparam *conf = &confboot;
|
||||
|
||||
|
||||
char* NULLADDR="\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0";
|
||||
|
||||
298
src/conf.c
298
src/conf.c
@ -31,7 +31,7 @@ void transparent_install(void);
|
||||
#endif
|
||||
|
||||
#ifndef DEFAULTCONFIG
|
||||
#define DEFAULTCONFIG conf.stringtable[25]
|
||||
#define DEFAULTCONFIG conf->stringtable[25]
|
||||
#endif
|
||||
|
||||
_3proxy_mutex_t bandlim_mutex;
|
||||
@ -63,12 +63,12 @@ struct trafvalue * trafvalue(unsigned number){
|
||||
if(!(tc = malloc(sizeof(*tc)))) return NULL;
|
||||
memset(tc, 0, sizeof(*tc));
|
||||
tc->number = number;
|
||||
if(conf.counterd >= 0) {
|
||||
lseek(conf.counterd,
|
||||
if(conf->counterd >= 0) {
|
||||
lseek(conf->counterd,
|
||||
sizeof(struct counter_header) + (number - 1) * sizeof(struct counter_record),
|
||||
SEEK_SET);
|
||||
memset(&crecord, 0, sizeof(struct counter_record));
|
||||
if(read(conf.counterd, &crecord, sizeof(struct counter_record)) == sizeof(struct counter_record)){
|
||||
if(read(conf->counterd, &crecord, sizeof(struct counter_record)) == sizeof(struct counter_record)){
|
||||
if(crecord.cleared < 0 || crecord.cleared >= MAX_COUNTER_TIME || crecord.updated < 0 || crecord.updated >= MAX_COUNTER_TIME){
|
||||
free(tc);
|
||||
return NULL;
|
||||
@ -99,7 +99,7 @@ static pthread_attr_t pa;
|
||||
char * curconf = NULL;
|
||||
|
||||
FILE * confopen(){
|
||||
curconf = conf.conffile;
|
||||
curconf = conf->conffile;
|
||||
#ifndef _WIN32
|
||||
if(chrootp){
|
||||
if(strstr(curconf, chrootp) == curconf)
|
||||
@ -206,15 +206,15 @@ int start_proxy_thread(struct child * chp){
|
||||
_3proxy_mutex_unlock(&runningservices_mutex);
|
||||
#ifdef _WIN32
|
||||
#ifndef _WINCE
|
||||
h = (HANDLE)_beginthreadex((LPSECURITY_ATTRIBUTES )NULL, 16384+conf.stacksize, (void *)startsrv, service, (DWORD)0, &thread);
|
||||
h = (HANDLE)_beginthreadex((LPSECURITY_ATTRIBUTES )NULL, 16384+conf->stacksize, (void *)startsrv, service, (DWORD)0, &thread);
|
||||
#else
|
||||
h = (HANDLE)CreateThread((LPSECURITY_ATTRIBUTES )NULL, 16384+conf.stacksize, (void *)startsrv, service, (DWORD)0, &thread);
|
||||
h = (HANDLE)CreateThread((LPSECURITY_ATTRIBUTES )NULL, 16384+conf->stacksize, (void *)startsrv, service, (DWORD)0, &thread);
|
||||
#endif
|
||||
if(h)CloseHandle(h);
|
||||
else {
|
||||
#else
|
||||
pthread_attr_init(&pa);
|
||||
pthread_attr_setstacksize(&pa,threadstacksize(conf.stacksize));
|
||||
pthread_attr_setstacksize(&pa,threadstacksize(conf->stacksize));
|
||||
pthread_attr_setdetachstate(&pa,PTHREAD_CREATE_DETACHED);
|
||||
res = pthread_create(&thread, &pa, startsrv, service);
|
||||
pthread_attr_destroy(&pa);
|
||||
@ -360,11 +360,11 @@ static int h_proxy(int argc, unsigned char ** argv){
|
||||
static int h_internal(int argc, unsigned char ** argv){
|
||||
#ifdef WITH_UN
|
||||
if(!strncmp((char *)argv[1], "unix:", 5)){
|
||||
make_un(argv[1] +5, (struct sockaddr_un *)&conf.intsa);
|
||||
make_un(argv[1] +5, (struct sockaddr_un *)&conf->intsa);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
getip46(46, argv[1], (struct sockaddr *)&conf.intsa);
|
||||
getip46(46, argv[1], (struct sockaddr *)&conf->intsa);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -375,10 +375,10 @@ static int h_external(int argc, unsigned char ** argv){
|
||||
memset(&sa6, 0, sizeof(sa6));
|
||||
res = getip46(46, argv[1], (struct sockaddr *)&sa6);
|
||||
if(!res) return 1;
|
||||
if (*SAFAMILY(&sa6)==AF_INET) conf.extsa = sa6;
|
||||
else conf.extsa6 = sa6;
|
||||
if (*SAFAMILY(&sa6)==AF_INET) conf->extsa = sa6;
|
||||
else conf->extsa6 = sa6;
|
||||
#else
|
||||
res = getip46(46, argv[1], (struct sockaddr *)&conf.extsa);
|
||||
res = getip46(46, argv[1], (struct sockaddr *)&conf->extsa);
|
||||
if(!res) return 1;
|
||||
#endif
|
||||
return 0;
|
||||
@ -397,31 +397,31 @@ static int h_log(int argc, unsigned char ** argv){
|
||||
|
||||
|
||||
havelog = 1;
|
||||
if(argc > 1 && conf.logtarget && !strcmp((char *)conf.logtarget, (char *)argv[1])) {
|
||||
if(argc > 1 && conf->logtarget && !strcmp((char *)conf->logtarget, (char *)argv[1])) {
|
||||
notchanged = 1;
|
||||
}
|
||||
if(!notchanged && conf.logtarget){
|
||||
free(conf.logtarget);
|
||||
conf.logtarget = NULL;
|
||||
if(!notchanged && conf->logtarget){
|
||||
free(conf->logtarget);
|
||||
conf->logtarget = NULL;
|
||||
}
|
||||
if(argc > 1) {
|
||||
if(!strcmp((char *) argv[1], "/dev/null")) {
|
||||
conf.logfunc = lognone;
|
||||
conf->logfunc = lognone;
|
||||
return 0;
|
||||
}
|
||||
if(!notchanged) conf.logtarget = (unsigned char *)strdup((char *)argv[1]);
|
||||
if(!notchanged) conf->logtarget = (unsigned char *)strdup((char *)argv[1]);
|
||||
if(*argv[1]=='@'){
|
||||
#ifndef _WIN32
|
||||
conf.logfunc = logsyslog;
|
||||
conf->logfunc = logsyslog;
|
||||
if(notchanged) return 0;
|
||||
/* connected now: after a chroot there is no /dev/log to find */
|
||||
openlog((char *)conf.logtarget+1, LOG_PID | LOG_NDELAY, LOG_DAEMON);
|
||||
openlog((char *)conf->logtarget+1, LOG_PID | LOG_NDELAY, LOG_DAEMON);
|
||||
#endif
|
||||
}
|
||||
#ifdef WITH_ODBC
|
||||
else if(*argv[1]=='&'){
|
||||
conf.logfunc = logsql;
|
||||
if(conf.stacksize < LOGSTACKSIZE) conf.stacksize = LOGSTACKSIZE;
|
||||
conf->logfunc = logsql;
|
||||
if(conf->stacksize < LOGSTACKSIZE) conf->stacksize = LOGSTACKSIZE;
|
||||
if(notchanged) return 0;
|
||||
_3proxy_mutex_lock(&log_mutex);
|
||||
close_sql();
|
||||
@ -431,50 +431,50 @@ static int h_log(int argc, unsigned char ** argv){
|
||||
#endif
|
||||
#ifndef NORADIUS
|
||||
else if(!strcmp((char *)argv[1],"radius")){
|
||||
conf.logfunc = logradius;
|
||||
conf->logfunc = logradius;
|
||||
}
|
||||
#endif
|
||||
else {
|
||||
if(argc > 2) {
|
||||
conf.logtype = getrotate(*argv[2]);
|
||||
conf->logtype = getrotate(*argv[2]);
|
||||
}
|
||||
conf.logfunc = logstdout;
|
||||
conf->logfunc = logstdout;
|
||||
if(notchanged) return 0;
|
||||
conf.logtime = time(0);
|
||||
if(conf.logname)free(conf.logname);
|
||||
conf.logname = (unsigned char *)strdup((char *)argv[1]);
|
||||
if(conf.stdlog) conf.stdlog = freopen((char *)dologname (tmpbuf, conf.logname, NULL, conf.logtype, conf.logtime), "a", conf.stdlog);
|
||||
else conf.stdlog = fopen((char *)dologname (tmpbuf, conf.logname, NULL, conf.logtype, conf.logtime), "a");
|
||||
if(!conf.stdlog){
|
||||
conf->logtime = time(0);
|
||||
if(conf->logname)free(conf->logname);
|
||||
conf->logname = (unsigned char *)strdup((char *)argv[1]);
|
||||
if(conf->stdlog) conf->stdlog = freopen((char *)dologname (tmpbuf, conf->logname, NULL, conf->logtype, conf->logtime), "a", conf->stdlog);
|
||||
else conf->stdlog = fopen((char *)dologname (tmpbuf, conf->logname, NULL, conf->logtype, conf->logtime), "a");
|
||||
if(!conf->stdlog){
|
||||
perror((char *)tmpbuf);
|
||||
return 1;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
else conf.logfunc = logstdout;
|
||||
else conf->logfunc = logstdout;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int h_stacksize(int argc, unsigned char **argv){
|
||||
conf.stacksize = atoi((char *)argv[1]);
|
||||
conf->stacksize = atoi((char *)argv[1]);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int h_threadpool(int argc, unsigned char **argv){
|
||||
conf.poolmax = atoi((char *)argv[1]);
|
||||
if(argc > 2) conf.pooltimeout = atoi((char *)argv[2]);
|
||||
conf->poolmax = atoi((char *)argv[1]);
|
||||
if(argc > 2) conf->pooltimeout = atoi((char *)argv[2]);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int h_force(int argc, unsigned char **argv){
|
||||
conf.noforce = 0;
|
||||
conf->noforce = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int h_noforce(int argc, unsigned char **argv){
|
||||
conf.noforce = 1;
|
||||
conf->noforce = 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -483,15 +483,15 @@ static int h_service(int argc, unsigned char **argv){
|
||||
}
|
||||
|
||||
static int h_daemon(int argc, unsigned char **argv){
|
||||
if(!conf.demon)daemonize();
|
||||
conf.demon = 1;
|
||||
if(!conf->demon)daemonize();
|
||||
conf->demon = 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int h_config(int argc, unsigned char **argv){
|
||||
if(conf.conffile)free(conf.conffile);
|
||||
conf.conffile = strdup((char *)argv[1]);
|
||||
if(!conf.conffile) return 21;
|
||||
if(conf->conffile)free(conf->conffile);
|
||||
conf->conffile = strdup((char *)argv[1]);
|
||||
if(!conf->conffile) return 21;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -512,23 +512,23 @@ static int h_include(int argc, unsigned char **argv){
|
||||
static int h_archiver(int argc, unsigned char **argv){
|
||||
int j;
|
||||
|
||||
conf.archiver = malloc(argc * sizeof(char *));
|
||||
if(conf.archiver) {
|
||||
conf.archiverc = argc;
|
||||
for(j = 0; j < conf.archiverc; j++) conf.archiver[j] = (unsigned char *)strdup((char *)argv[j]);
|
||||
conf->archiver = malloc(argc * sizeof(char *));
|
||||
if(conf->archiver) {
|
||||
conf->archiverc = argc;
|
||||
for(j = 0; j < conf->archiverc; j++) conf->archiver[j] = (unsigned char *)strdup((char *)argv[j]);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int h_counter(int argc, unsigned char **argv){
|
||||
struct counter_header ch1;
|
||||
if(conf.counterd >=0)close(conf.counterd);
|
||||
conf.counterd = open((char *)argv[1], O_BINARY|O_RDWR|O_CREAT, 0660);
|
||||
if(conf.counterd<0){
|
||||
if(conf->counterd >=0)close(conf->counterd);
|
||||
conf->counterd = open((char *)argv[1], O_BINARY|O_RDWR|O_CREAT, 0660);
|
||||
if(conf->counterd<0){
|
||||
fprintf(stderr, "Unable to open counter file %s, line %d\n", argv[1], linenum);
|
||||
return 1;
|
||||
}
|
||||
if(read(conf.counterd, &ch1, sizeof(ch1))==sizeof(ch1)){
|
||||
if(read(conf->counterd, &ch1, sizeof(ch1))==sizeof(ch1)){
|
||||
if(memcmp(&ch1, &cheader, 4)){
|
||||
fprintf(stderr, "Not a counter file %s, line %d\n", argv[1], linenum);
|
||||
return 2;
|
||||
@ -540,26 +540,26 @@ static int h_counter(int argc, unsigned char **argv){
|
||||
cheader.updated = ch1.updated;
|
||||
}
|
||||
if(argc >=4) {
|
||||
conf.countertype = getrotate(*argv[2]);
|
||||
if(conf.counterfile) free(conf.counterfile);
|
||||
conf.counterfile = strdup((char *)argv[3]);
|
||||
conf->countertype = getrotate(*argv[2]);
|
||||
if(conf->counterfile) free(conf->counterfile);
|
||||
conf->counterfile = strdup((char *)argv[3]);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int h_rotate(int argc, unsigned char **argv){
|
||||
conf.rotate = atoi((char *)argv[1]);
|
||||
conf->rotate = atoi((char *)argv[1]);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int h_maxseg(int argc, unsigned char **argv){
|
||||
conf.maxseg = atoi((char *)argv[1]);
|
||||
conf->maxseg = atoi((char *)argv[1]);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int h_logformat(int argc, unsigned char **argv){
|
||||
unsigned char * old = conf.logformat;
|
||||
conf.logformat = (unsigned char *)strdup((char *)argv[1]);
|
||||
unsigned char * old = conf->logformat;
|
||||
conf->logformat = (unsigned char *)strdup((char *)argv[1]);
|
||||
if(old) free(old);
|
||||
return 0;
|
||||
}
|
||||
@ -567,8 +567,8 @@ static int h_logformat(int argc, unsigned char **argv){
|
||||
static int h_timeouts(int argc, unsigned char **argv){
|
||||
int j;
|
||||
|
||||
for(j = 0; conf.timeouts[j] && j + 1 < argc; j++) {
|
||||
if((conf.timeouts[j] = atoi((char *)argv[j + 1])) <= 0 || conf.timeouts[j] > 2000000){
|
||||
for(j = 0; conf->timeouts[j] && j + 1 < argc; j++) {
|
||||
if((conf->timeouts[j] = atoi((char *)argv[j + 1])) <= 0 || conf->timeouts[j] > 2000000){
|
||||
fprintf(stderr, "Invalid timeout: %s, line %d\n", argv[j + 1], linenum);
|
||||
return(1);
|
||||
}
|
||||
@ -583,9 +583,9 @@ static int h_noop(int argc, unsigned char **argv){
|
||||
static int h_auth(int argc, unsigned char **argv){
|
||||
struct auth *au, * newau;
|
||||
|
||||
freeauth(conf.authfuncs);
|
||||
conf.authfuncs = NULL;
|
||||
if(!conf.bandlimfunc)conf.bandlimfunc = bandlimitfunc;
|
||||
freeauth(conf->authfuncs);
|
||||
conf->authfuncs = NULL;
|
||||
if(!conf->bandlimfunc)conf->bandlimfunc = bandlimitfunc;
|
||||
for(argc--; argc; argc--){
|
||||
for(au = authfuncs; au; au=au->next){
|
||||
if(!strcmp((char *)argv[argc], au->desc)){
|
||||
@ -593,17 +593,17 @@ static int h_auth(int argc, unsigned char **argv){
|
||||
if(!newau) {
|
||||
return 21;
|
||||
}
|
||||
newau->next = conf.authfuncs;
|
||||
conf.authfuncs = newau;
|
||||
conf.authfuncs->desc = au->desc;
|
||||
conf.authfuncs->authenticate = au->authenticate;
|
||||
conf.authfuncs->authorize = au->authorize;
|
||||
newau->next = conf->authfuncs;
|
||||
conf->authfuncs = newau;
|
||||
conf->authfuncs->desc = au->desc;
|
||||
conf->authfuncs->authenticate = au->authenticate;
|
||||
conf->authfuncs->authorize = au->authorize;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(!au) return 1;
|
||||
}
|
||||
conf.authfunc = doauth;
|
||||
conf->authfunc = doauth;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -667,19 +667,19 @@ static int h_users(int argc, unsigned char **argv){
|
||||
}
|
||||
|
||||
static int h_maxconn(int argc, unsigned char **argv){
|
||||
conf.maxchild = atoi((char *)argv[1]);
|
||||
if(!conf.maxchild) {
|
||||
conf->maxchild = atoi((char *)argv[1]);
|
||||
if(!conf->maxchild) {
|
||||
return(1);
|
||||
}
|
||||
#ifndef _WIN32
|
||||
{
|
||||
struct rlimit rl;
|
||||
if(!getrlimit(RLIMIT_NOFILE, &rl)){
|
||||
if((conf.maxchild<<1) > rl.rlim_cur)
|
||||
if((conf->maxchild<<1) > rl.rlim_cur)
|
||||
fprintf(stderr, "[line %d] Warning: current open file ulimits are too low (cur: %d/max: %d),"
|
||||
" maxconn requires at least %d for every running service."
|
||||
" Configure ulimits according to system documentation\n",
|
||||
linenum, (int)rl.rlim_cur, (int)rl.rlim_max, (conf.maxchild<<1));
|
||||
linenum, (int)rl.rlim_cur, (int)rl.rlim_max, (conf->maxchild<<1));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@ -687,23 +687,23 @@ static int h_maxconn(int argc, unsigned char **argv){
|
||||
}
|
||||
|
||||
static int h_backlog(int argc, unsigned char **argv){
|
||||
conf.backlog = atoi((char *)argv[1]);
|
||||
if(conf.backlog < 0) {
|
||||
conf->backlog = atoi((char *)argv[1]);
|
||||
if(conf->backlog < 0) {
|
||||
return(1);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int h_flush(int argc, unsigned char **argv){
|
||||
freeacl(conf.acl);
|
||||
conf.acl = NULL;
|
||||
freeacl(conf->acl);
|
||||
conf->acl = NULL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
static int h_flushusers(int argc, unsigned char **argv){
|
||||
freepwl(conf.pwl);
|
||||
conf.pwl = NULL;
|
||||
freepwl(conf->pwl);
|
||||
conf->pwl = NULL;
|
||||
return 0;
|
||||
}
|
||||
*/
|
||||
@ -711,16 +711,16 @@ static int h_flushusers(int argc, unsigned char **argv){
|
||||
static int h_nserver(int argc, unsigned char **argv){
|
||||
char *str;
|
||||
|
||||
if(conf.numservers < MAXNSERVERS) {
|
||||
if(conf->numservers < MAXNSERVERS) {
|
||||
if((str = strchr((char *)argv[1], '/')))
|
||||
*str = 0;
|
||||
*SAPORT(&conf.nservers[conf.numservers].addr) = htons(53);
|
||||
if(parsehost(46, argv[1], (struct sockaddr *)&conf.nservers[conf.numservers].addr)) return 1;
|
||||
*SAPORT(&conf->nservers[conf->numservers].addr) = htons(53);
|
||||
if(parsehost(46, argv[1], (struct sockaddr *)&conf->nservers[conf->numservers].addr)) return 1;
|
||||
if(str) {
|
||||
conf.nservers[conf.numservers].usetcp = strstr(str + 1, "tcp")? 1:0;
|
||||
conf->nservers[conf->numservers].usetcp = strstr(str + 1, "tcp")? 1:0;
|
||||
*str = '/';
|
||||
}
|
||||
conf.numservers++;
|
||||
conf->numservers++;
|
||||
|
||||
}
|
||||
resolvfunc = myresolver;
|
||||
@ -732,10 +732,10 @@ static int h_authnserver(int argc, unsigned char **argv){
|
||||
|
||||
if((str = strchr((char *)argv[1], '/')))
|
||||
*str = 0;
|
||||
if(parsehost(46, argv[1], (struct sockaddr *)&conf.authnserver.addr)) return 1;
|
||||
*SAPORT(&conf.authnserver.addr) = htons(53);
|
||||
if(parsehost(46, argv[1], (struct sockaddr *)&conf->authnserver.addr)) return 1;
|
||||
*SAPORT(&conf->authnserver.addr) = htons(53);
|
||||
if(str) {
|
||||
conf.authnserver.usetcp = strstr(str + 1, "tcp")? 1:0;
|
||||
conf->authnserver.usetcp = strstr(str + 1, "tcp")? 1:0;
|
||||
*str = '/';
|
||||
}
|
||||
return 0;
|
||||
@ -765,7 +765,7 @@ static int h_parentretries(int argc, unsigned char **argv){
|
||||
int res;
|
||||
|
||||
res = atoi((char *)argv[1]);
|
||||
if(res > 0) conf.parentretries = res;
|
||||
if(res > 0) conf->parentretries = res;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -833,8 +833,8 @@ static int h_monitor(int argc, unsigned char **argv){
|
||||
else {
|
||||
fm->path = strdup((char *)argv[1]);
|
||||
if(!fm->path) return 21;
|
||||
fm->next = conf.fmon;
|
||||
conf.fmon = fm;
|
||||
fm->next = conf->fmon;
|
||||
conf->fmon = fm;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@ -940,9 +940,9 @@ static int addhttprule(char *op, char *host, char *url, char *params)
|
||||
}
|
||||
if(params) rule->params = (unsigned char *)strdup(params);
|
||||
|
||||
if(!conf.httprules) conf.httprules = rule;
|
||||
if(!conf->httprules) conf->httprules = rule;
|
||||
else {
|
||||
for(tail = conf.httprules; tail->next; tail = tail->next);
|
||||
for(tail = conf->httprules; tail->next; tail = tail->next);
|
||||
tail->next = rule;
|
||||
}
|
||||
return 0;
|
||||
@ -1048,7 +1048,7 @@ static int h_parent(int argc, unsigned char **argv){
|
||||
char * cidr = NULL;
|
||||
int i;
|
||||
|
||||
acl = conf.acl;
|
||||
acl = conf->acl;
|
||||
while(acl && acl->next) acl = acl->next;
|
||||
if(!acl || (acl->action && acl->action != 2)) {
|
||||
fprintf(stderr, "Chaining error: last ACL entry was not \"allow\" or \"redirect\" on line %d\n", linenum);
|
||||
@ -1244,9 +1244,9 @@ static int h_http(int argc, unsigned char **argv){
|
||||
return(1);
|
||||
}
|
||||
|
||||
if(!conf.httprules) conf.httprules = rule;
|
||||
if(!conf->httprules) conf->httprules = rule;
|
||||
else {
|
||||
for(tail = conf.httprules; tail->next; tail = tail->next);
|
||||
for(tail = conf->httprules; tail->next; tail = tail->next);
|
||||
tail->next = rule;
|
||||
}
|
||||
return 0;
|
||||
@ -1256,7 +1256,7 @@ static int h_http(int argc, unsigned char **argv){
|
||||
static int h_nolog(int argc, unsigned char **argv){
|
||||
struct ace *acl = NULL;
|
||||
|
||||
acl = conf.acl;
|
||||
acl = conf->acl;
|
||||
if(!acl) {
|
||||
fprintf(stderr, "Chaining error: last ACL entry was not \"allow/deny\" on line %d\n", linenum);
|
||||
return(1);
|
||||
@ -1639,13 +1639,13 @@ static int h_ace(int argc, unsigned char **argv){
|
||||
acl->chains->weight = WEIGHTSCALE;
|
||||
case ALLOW:
|
||||
case DENY:
|
||||
if(!conf.acl){
|
||||
conf.acl = acl;
|
||||
if(!conf->acl){
|
||||
conf->acl = acl;
|
||||
}
|
||||
else {
|
||||
struct ace * acei;
|
||||
|
||||
for(acei = conf.acl; acei->next; acei = acei->next);
|
||||
for(acei = conf->acl; acei->next; acei = acei->next);
|
||||
acei->next = acl;
|
||||
}
|
||||
break;
|
||||
@ -1663,13 +1663,13 @@ static int h_ace(int argc, unsigned char **argv){
|
||||
sscanf((char *)argv[2], "%u", &ncl->period);
|
||||
}
|
||||
_3proxy_mutex_lock(&connlim_mutex);
|
||||
if(!conf.connlimiter){
|
||||
conf.connlimiter = ncl;
|
||||
if(!conf->connlimiter){
|
||||
conf->connlimiter = ncl;
|
||||
}
|
||||
else {
|
||||
struct connlim * cli;
|
||||
|
||||
for(cli = conf.connlimiter; cli->next; cli = cli->next);
|
||||
for(cli = conf->connlimiter; cli->next; cli = cli->next);
|
||||
cli->next = ncl;
|
||||
}
|
||||
_3proxy_mutex_unlock(&connlim_mutex);
|
||||
@ -1696,28 +1696,28 @@ static int h_ace(int argc, unsigned char **argv){
|
||||
}
|
||||
_3proxy_mutex_lock(&bandlim_mutex);
|
||||
if(!strcmp((char *)argv[0], "bandlimin") || !strcmp((char *)argv[0], "nobandlimin")){
|
||||
if(!conf.bandlimiter){
|
||||
conf.bandlimiter = nbl;
|
||||
if(!conf->bandlimiter){
|
||||
conf->bandlimiter = nbl;
|
||||
}
|
||||
else {
|
||||
struct bandlim * bli;
|
||||
|
||||
for(bli = conf.bandlimiter; bli->next; bli = bli->next);
|
||||
for(bli = conf->bandlimiter; bli->next; bli = bli->next);
|
||||
bli->next = nbl;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if(!conf.bandlimiterout){
|
||||
conf.bandlimiterout = nbl;
|
||||
if(!conf->bandlimiterout){
|
||||
conf->bandlimiterout = nbl;
|
||||
}
|
||||
else {
|
||||
struct bandlim * bli;
|
||||
|
||||
for(bli = conf.bandlimiterout; bli->next; bli = bli->next);
|
||||
for(bli = conf->bandlimiterout; bli->next; bli = bli->next);
|
||||
bli->next = nbl;
|
||||
}
|
||||
}
|
||||
conf.bandlimver++;
|
||||
conf->bandlimver++;
|
||||
_3proxy_mutex_unlock(&bandlim_mutex);
|
||||
break;
|
||||
|
||||
@ -1727,7 +1727,7 @@ static int h_ace(int argc, unsigned char **argv){
|
||||
case NOCOUNTOUT:
|
||||
case COUNTALL:
|
||||
case NOCOUNTALL:
|
||||
if(!conf.trafcountfunc) conf.trafcountfunc = trafcountfunc;
|
||||
if(!conf->trafcountfunc) conf->trafcountfunc = trafcountfunc;
|
||||
tl = malloc(sizeof(struct trafcount));
|
||||
if(!tl) {
|
||||
freeacl(acl);
|
||||
@ -1765,13 +1765,13 @@ static int h_ace(int argc, unsigned char **argv){
|
||||
}
|
||||
else tl->v = &tl->own;
|
||||
_3proxy_mutex_lock(&tc_mutex);
|
||||
if(!conf.trafcounter){
|
||||
conf.trafcounter = tl;
|
||||
if(!conf->trafcounter){
|
||||
conf->trafcounter = tl;
|
||||
}
|
||||
else {
|
||||
struct trafcount * ntl;
|
||||
|
||||
for(ntl = conf.trafcounter; ntl->next; ntl = ntl->next);
|
||||
for(ntl = conf->trafcounter; ntl->next; ntl = ntl->next);
|
||||
ntl->next = tl;
|
||||
}
|
||||
_3proxy_mutex_unlock(&tc_mutex);
|
||||
@ -1781,19 +1781,19 @@ static int h_ace(int argc, unsigned char **argv){
|
||||
}
|
||||
|
||||
static int h_logdump(int argc, unsigned char **argv){
|
||||
conf.logdumpsrv = (unsigned) atoi((char *) *(argv + 1));
|
||||
if(argc > 2) conf.logdumpcli = (unsigned) atoi((char *) *(argv + 2));
|
||||
conf->logdumpsrv = (unsigned) atoi((char *) *(argv + 1));
|
||||
if(argc > 2) conf->logdumpcli = (unsigned) atoi((char *) *(argv + 2));
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int h_filtermaxsize(int argc, unsigned char **argv){
|
||||
conf.filtermaxsize = atoi((char *) *(argv + 1));
|
||||
conf->filtermaxsize = atoi((char *) *(argv + 1));
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int h_delimchar(int argc, unsigned char **argv){
|
||||
conf.delimchar = *argv[1];
|
||||
conf->delimchar = *argv[1];
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -1802,21 +1802,21 @@ static int h_delimchar(int argc, unsigned char **argv){
|
||||
static int h_radius(int argc, unsigned char **argv){
|
||||
uint16_t port;
|
||||
|
||||
memset(conf.radiuslist, 0, sizeof(conf.radiuslist));
|
||||
memset(conf->radiuslist, 0, sizeof(conf->radiuslist));
|
||||
if(strlen((char *)argv[1]) > 63) argv[1][63] = 0;
|
||||
strcpy(conf.radiussecret, (char *)argv[1]);
|
||||
for( conf.nradservers=0; conf.nradservers < MAXRADIUS && conf.nradservers < argc -2; conf.nradservers++){
|
||||
strcpy(conf->radiussecret, (char *)argv[1]);
|
||||
for( conf->nradservers=0; conf->nradservers < MAXRADIUS && conf->nradservers < argc -2; conf->nradservers++){
|
||||
char *s = 0;
|
||||
if((s=strchr((char *)argv[conf.nradservers + 2], '/'))){
|
||||
if((s=strchr((char *)argv[conf->nradservers + 2], '/'))){
|
||||
*s = 0;
|
||||
s++;
|
||||
}
|
||||
if( !getip46(46, argv[conf.nradservers + 2], (struct sockaddr *)&conf.radiuslist[conf.nradservers].authaddr)) return 1;
|
||||
if( s && !getip46(46, (unsigned char *)s, (struct sockaddr *)&conf.radiuslist[conf.nradservers].localaddr)) return 2;
|
||||
if(!*SAPORT(&conf.radiuslist[conf.nradservers].authaddr))*SAPORT(&conf.radiuslist[conf.nradservers].authaddr) = htons(1812);
|
||||
port = ntohs(*SAPORT(&conf.radiuslist[conf.nradservers].authaddr));
|
||||
conf.radiuslist[conf.nradservers].logaddr = conf.radiuslist[conf.nradservers].authaddr;
|
||||
*SAPORT(&conf.radiuslist[conf.nradservers].logaddr) = htons(port+1);
|
||||
if( !getip46(46, argv[conf->nradservers + 2], (struct sockaddr *)&conf->radiuslist[conf->nradservers].authaddr)) return 1;
|
||||
if( s && !getip46(46, (unsigned char *)s, (struct sockaddr *)&conf->radiuslist[conf->nradservers].localaddr)) return 2;
|
||||
if(!*SAPORT(&conf->radiuslist[conf->nradservers].authaddr))*SAPORT(&conf->radiuslist[conf->nradservers].authaddr) = htons(1812);
|
||||
port = ntohs(*SAPORT(&conf->radiuslist[conf->nradservers].authaddr));
|
||||
conf->radiuslist[conf->nradservers].logaddr = conf->radiuslist[conf->nradservers].authaddr;
|
||||
*SAPORT(&conf->radiuslist[conf->nradservers].logaddr) = htons(port+1);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@ -1824,23 +1824,23 @@ static int h_radius(int argc, unsigned char **argv){
|
||||
static int h_authcache(int argc, unsigned char **argv){
|
||||
int authcachesize = 0;
|
||||
|
||||
conf.authcachetype = 0;
|
||||
if(strstr((char *) *(argv + 1), "ip")) conf.authcachetype |= 1;
|
||||
if(strstr((char *) *(argv + 1), "user")) conf.authcachetype |= 2;
|
||||
if(strstr((char *) *(argv + 1), "pass")) conf.authcachetype |= 4;
|
||||
if(strstr((char *) *(argv + 1), "limit")) conf.authcachetype |= 8;
|
||||
if(strstr((char *) *(argv + 1), "acl")) conf.authcachetype |= 16;
|
||||
if(strstr((char *) *(argv + 1), "ext")) conf.authcachetype |= 32;
|
||||
if(strstr((char *) *(argv + 1), "dstaddr")) conf.authcachetype |= 64;
|
||||
if(strstr((char *) *(argv + 1), "dstport")) conf.authcachetype |= 128;
|
||||
if(strstr((char *) *(argv + 1), "dsthost")) conf.authcachetype |= 256;
|
||||
if(strstr((char *) *(argv + 1), "dstoper")) conf.authcachetype |= 512;
|
||||
if(strstr((char *) *(argv + 1), "srvaddr")) conf.authcachetype |= 1024;
|
||||
if(strstr((char *) *(argv + 1), "srvport")) conf.authcachetype |= 2048;
|
||||
if(argc > 2) conf.authcachetime = (unsigned) atoi((char *) *(argv + 2));
|
||||
conf->authcachetype = 0;
|
||||
if(strstr((char *) *(argv + 1), "ip")) conf->authcachetype |= 1;
|
||||
if(strstr((char *) *(argv + 1), "user")) conf->authcachetype |= 2;
|
||||
if(strstr((char *) *(argv + 1), "pass")) conf->authcachetype |= 4;
|
||||
if(strstr((char *) *(argv + 1), "limit")) conf->authcachetype |= 8;
|
||||
if(strstr((char *) *(argv + 1), "acl")) conf->authcachetype |= 16;
|
||||
if(strstr((char *) *(argv + 1), "ext")) conf->authcachetype |= 32;
|
||||
if(strstr((char *) *(argv + 1), "dstaddr")) conf->authcachetype |= 64;
|
||||
if(strstr((char *) *(argv + 1), "dstport")) conf->authcachetype |= 128;
|
||||
if(strstr((char *) *(argv + 1), "dsthost")) conf->authcachetype |= 256;
|
||||
if(strstr((char *) *(argv + 1), "dstoper")) conf->authcachetype |= 512;
|
||||
if(strstr((char *) *(argv + 1), "srvaddr")) conf->authcachetype |= 1024;
|
||||
if(strstr((char *) *(argv + 1), "srvport")) conf->authcachetype |= 2048;
|
||||
if(argc > 2) conf->authcachetime = (unsigned) atoi((char *) *(argv + 2));
|
||||
if(argc > 3) authcachesize = (unsigned) atoi((char *) *(argv + 3));
|
||||
if(!conf.authcachetype) conf.authcachetype = 6;
|
||||
if(!conf.authcachetime) conf.authcachetime = 600;
|
||||
if(!conf->authcachetype) conf->authcachetype = 6;
|
||||
if(!conf->authcachetime) conf->authcachetime = 600;
|
||||
if(!authcachesize) authcachesize = 65536*4;
|
||||
if(auth_table.growlimit != authcachesize && inithashtable(&auth_table, authcachesize < 1024? authcachesize:1024, authcachesize < 1024? authcachesize:1024, authcachesize)){
|
||||
fprintf(stderr, "Failed to initialize auth cache\n");
|
||||
@ -2448,7 +2448,7 @@ void freeconf(struct extparam *confp){
|
||||
confp->maxchild = DEFAULT_MAXCHILD;
|
||||
confp->backlog = 0;
|
||||
resolvfunc = NULL;
|
||||
conf.numservers = 0;
|
||||
conf->numservers = 0;
|
||||
acl = confp->acl;
|
||||
confp->acl = NULL;
|
||||
|
||||
@ -2500,16 +2500,16 @@ int reload (void){
|
||||
#ifdef WITH_TRANSPARENT
|
||||
transparent_install();
|
||||
#endif
|
||||
conf.paused++;
|
||||
freeconf(&conf);
|
||||
conf.paused++;
|
||||
conf->paused++;
|
||||
freeconf(conf);
|
||||
conf->paused++;
|
||||
|
||||
fp = confopen();
|
||||
if(fp){
|
||||
error = readconfig(fp);
|
||||
conf.version++;
|
||||
conf->version++;
|
||||
if(error) {
|
||||
freeconf(&conf);
|
||||
freeconf(conf);
|
||||
}
|
||||
fclose(fp);
|
||||
}
|
||||
|
||||
74
src/confinit.h
Normal file
74
src/confinit.h
Normal file
@ -0,0 +1,74 @@
|
||||
/* The configuration as it is before any command: included where both the
|
||||
template for a new configuration and the first one are defined. */
|
||||
.timeouts = {
|
||||
1, /* SINGLEBYTE_S */
|
||||
5, /* SINGLEBYTE_L */
|
||||
30, /* STRING_S */
|
||||
60, /* STRING_L */
|
||||
180, /* CONNECTION_S */
|
||||
1800, /* CONNECTION_L */
|
||||
15, /* DNS_TO */
|
||||
60, /* CHAIN_TO */
|
||||
15, /* CONNECT_TO */
|
||||
5, /* CONNBACK_TO */
|
||||
5, /* LINGER_TO */
|
||||
0
|
||||
},
|
||||
.acl = NULL,
|
||||
.conffile = NULL,
|
||||
.bandlimiter = NULL,
|
||||
.bandlimiterout = NULL,
|
||||
.connlimiter = NULL,
|
||||
.trafcounter = NULL,
|
||||
.services = NULL,
|
||||
.stacksize = 0,
|
||||
.poolmax = -1,
|
||||
.pooltimeout = 60,
|
||||
.counterd = -1,
|
||||
.rotate = 0,
|
||||
.paused = 0,
|
||||
.archiverc = 0,
|
||||
.demon = 0,
|
||||
.maxchild = DEFAULT_MAXCHILD,
|
||||
.backlog = 0,
|
||||
.version = 0,
|
||||
.noforce = 0,
|
||||
.bandlimver = 0,
|
||||
.parentretries = 2,
|
||||
.authcachetype = 6,
|
||||
.authcachetime = 600,
|
||||
.filtermaxsize = 1048576,
|
||||
.gracetraf = 0,
|
||||
.gracenum = 0,
|
||||
.gracedelay = 0,
|
||||
.maxseg = 0,
|
||||
.logname = NULL,
|
||||
.archiver = NULL,
|
||||
.logtype = NONE,
|
||||
.countertype = NONE,
|
||||
.counterfile = NULL,
|
||||
#ifndef NOIPV6
|
||||
.intsa = {AF_INET},
|
||||
.extsa6 = {AF_INET6},
|
||||
.extsa = {AF_INET},
|
||||
#else
|
||||
.intsa = {AF_INET},
|
||||
.extsa = {AF_INET},
|
||||
#endif
|
||||
.pwl = NULL,
|
||||
.authenticate = NULL,
|
||||
.authfunc = doconnect,
|
||||
.logfunc = lognone,
|
||||
.bandlimfunc = NULL,
|
||||
.trafcountfunc = NULL,
|
||||
.logtarget = NULL,
|
||||
.logformat = NULL,
|
||||
.fmon = NULL,
|
||||
.filters = NULL,
|
||||
.authfuncs = NULL,
|
||||
.stdlog = NULL,
|
||||
.stringtable = NULL,
|
||||
.logtime = (time_t)0,
|
||||
.logdumpsrv = 0,
|
||||
.logdumpcli = 0,
|
||||
.delimchar = '@',
|
||||
@ -514,7 +514,7 @@ static void * ef_server_next(struct node * node){
|
||||
|
||||
static void * ef_server_type(struct node * node){
|
||||
int service = ((struct srvparam *)node->value) -> service;
|
||||
return (service>=0 && service < MAX_SERVICE)? (void *)conf.stringtable[SERVICES + service] : (void *)"unknown";
|
||||
return (service>=0 && service < MAX_SERVICE)? (void *)conf->stringtable[SERVICES + service] : (void *)"unknown";
|
||||
}
|
||||
|
||||
static void * ef_server_child(struct node * node){
|
||||
@ -543,7 +543,7 @@ static void * ef_pool_limit(struct node * node){
|
||||
}
|
||||
|
||||
static void * ef_pool_timeout(struct node * node){
|
||||
return &conf.pooltimeout;
|
||||
return &conf->pooltimeout;
|
||||
}
|
||||
|
||||
static void * ef_pool_created(struct node * node){
|
||||
@ -693,7 +693,7 @@ static void * ef_client_next(struct node * node){
|
||||
|
||||
static void * ef_client_type(struct node * node){
|
||||
int service = ((struct clientparam *)node->value) -> service;
|
||||
return (service>=0 && service < MAX_SERVICE)? (void *)conf.stringtable[SERVICES + service] : (void *)"unknown";
|
||||
return (service>=0 && service < MAX_SERVICE)? (void *)conf->stringtable[SERVICES + service] : (void *)"unknown";
|
||||
}
|
||||
|
||||
static void * ef_client_operation(struct node * node){
|
||||
|
||||
12
src/dnspr.c
12
src/dnspr.c
@ -145,17 +145,17 @@ void * dnsprchild(struct clientparam* param) {
|
||||
}
|
||||
else ip = 0;
|
||||
}
|
||||
if(!ip && conf.numservers){
|
||||
if((param->remsock=param->srv->so._socket(param->sostate, SASOCK(&conf.nservers[0].addr), conf.nservers[0].usetcp? SOCK_STREAM:SOCK_DGRAM, conf.nservers[0].usetcp?IPPROTO_TCP:IPPROTO_UDP)) == INVALID_SOCKET) {
|
||||
if(!ip && conf->numservers){
|
||||
if((param->remsock=param->srv->so._socket(param->sostate, SASOCK(&conf->nservers[0].addr), conf->nservers[0].usetcp? SOCK_STREAM:SOCK_DGRAM, conf->nservers[0].usetcp?IPPROTO_TCP:IPPROTO_UDP)) == INVALID_SOCKET) {
|
||||
RETURN(818);
|
||||
}
|
||||
memset(¶m->sinsl, 0, sizeof(param->sinsl));
|
||||
*SAFAMILY(¶m->sinsl) = *SAFAMILY(&conf.nservers[0].addr);
|
||||
*SAFAMILY(¶m->sinsl) = *SAFAMILY(&conf->nservers[0].addr);
|
||||
if(bindwithrange(param, param->remsock, ¶m->sinsl, param->extport)) {
|
||||
RETURN(819);
|
||||
}
|
||||
param->sinsr = conf.nservers[0].addr;
|
||||
if(conf.nservers[0].usetcp) {
|
||||
param->sinsr = conf->nservers[0].addr;
|
||||
if(conf->nservers[0].usetcp) {
|
||||
if(connectwithpoll(param, param->remsock,(struct sockaddr *)¶m->sinsr,SASIZE(¶m->sinsr),param->srv->timeouts[CONNECT_TO])) RETURN(830);
|
||||
buf-=2;
|
||||
*(unsigned short*)buf = htons(i);
|
||||
@ -180,7 +180,7 @@ void * dnsprchild(struct clientparam* param) {
|
||||
}
|
||||
param->statssrv64 += len;
|
||||
param->nreads++;
|
||||
if(conf.nservers[0].usetcp) {
|
||||
if(conf->nservers[0].usetcp) {
|
||||
unsigned short us;
|
||||
us = ntohs(*(unsigned short *)buf);
|
||||
if(us > 4096) RETURN(833);
|
||||
|
||||
@ -16,7 +16,7 @@ int startconnlims (struct clientparam *param){
|
||||
|
||||
param->connlim = 1;
|
||||
_3proxy_mutex_lock(&connlim_mutex);
|
||||
for(ce = conf.connlimiter; ce; ce = ce->next) {
|
||||
for(ce = conf->connlimiter; ce; ce = ce->next) {
|
||||
if(ACLmatches(ce->ace, param)){
|
||||
if(ce->ace->action == NOCONNLIM)break;
|
||||
if(!ce->period){
|
||||
@ -44,7 +44,7 @@ int startconnlims (struct clientparam *param){
|
||||
}
|
||||
if(ret) {
|
||||
struct connlim * cee;
|
||||
for(cee = conf.connlimiter; cee != ce; cee = cee->next) {
|
||||
for(cee = conf->connlimiter; cee != ce; cee = cee->next) {
|
||||
if(ACLmatches(cee->ace, param) && !cee->period && cee->rating) {
|
||||
cee->rating--;
|
||||
}
|
||||
@ -59,7 +59,7 @@ void stopconnlims (struct clientparam *param){
|
||||
struct connlim * ce;
|
||||
|
||||
_3proxy_mutex_lock(&connlim_mutex);
|
||||
for(ce = conf.connlimiter; ce; ce = ce->next) {
|
||||
for(ce = conf->connlimiter; ce; ce = ce->next) {
|
||||
if(ACLmatches(ce->ace, param)){
|
||||
if(ce->ace->action == NOCONNLIM)break;
|
||||
if(!ce->period && ce->rating){
|
||||
@ -78,28 +78,28 @@ void initbandlims (struct clientparam *param){
|
||||
param->bandlimfunc = NULL;
|
||||
param->bandlims[0] = NULL;
|
||||
param->bandlimsout[0] = NULL;
|
||||
if(!conf.bandlimfunc || (!conf.bandlimiter && !conf.bandlimiterout)) return;
|
||||
for(i=0, be = conf.bandlimiter; be && i<MAXBANDLIMS; be = be->next) {
|
||||
if(!conf->bandlimfunc || (!conf->bandlimiter && !conf->bandlimiterout)) return;
|
||||
for(i=0, be = conf->bandlimiter; be && i<MAXBANDLIMS; be = be->next) {
|
||||
if(ACLmatches(be->ace, param)){
|
||||
if(be->ace->action == NOBANDLIM) {
|
||||
break;
|
||||
}
|
||||
param->bandlims[i++] = be;
|
||||
param->bandlimfunc = conf.bandlimfunc;
|
||||
param->bandlimfunc = conf->bandlimfunc;
|
||||
}
|
||||
}
|
||||
if(i<MAXBANDLIMS)param->bandlims[i] = NULL;
|
||||
for(i=0, be = conf.bandlimiterout; be && i<MAXBANDLIMS; be = be->next) {
|
||||
for(i=0, be = conf->bandlimiterout; be && i<MAXBANDLIMS; be = be->next) {
|
||||
if(ACLmatches(be->ace, param)){
|
||||
if(be->ace->action == NOBANDLIM) {
|
||||
break;
|
||||
}
|
||||
param->bandlimsout[i++] = be;
|
||||
param->bandlimfunc = conf.bandlimfunc;
|
||||
param->bandlimfunc = conf->bandlimfunc;
|
||||
}
|
||||
}
|
||||
if(i<MAXBANDLIMS)param->bandlimsout[i] = NULL;
|
||||
param->bandlimver = conf.bandlimver;
|
||||
param->bandlimver = conf->bandlimver;
|
||||
}
|
||||
|
||||
unsigned bandlimitfunc(struct clientparam *param, unsigned nbytesin, unsigned nbytesout){
|
||||
@ -125,9 +125,9 @@ unsigned bandlimitfunc(struct clientparam *param, unsigned nbytesin, unsigned nb
|
||||
|
||||
if(!nbytesin && !nbytesout) return 0;
|
||||
_3proxy_mutex_lock(&bandlim_mutex);
|
||||
if(param->bandlimver != conf.bandlimver){
|
||||
if(param->bandlimver != conf->bandlimver){
|
||||
initbandlims(param);
|
||||
param->bandlimver = conf.bandlimver;
|
||||
param->bandlimver = conf->bandlimver;
|
||||
}
|
||||
for(i=0; nbytesin&& i<MAXBANDLIMS && param->bandlims[i]; i++){
|
||||
if( !param->bandlims[i]->basetime ||
|
||||
@ -172,7 +172,7 @@ void trafcountfunc(struct clientparam *param){
|
||||
int countout = 0;
|
||||
|
||||
_3proxy_mutex_lock(&tc_mutex);
|
||||
for(tc = conf.trafcounter; tc; tc = tc->next) {
|
||||
for(tc = conf->trafcounter; tc; tc = tc->next) {
|
||||
if(ACLmatches(tc->ace, param)){
|
||||
|
||||
if(tc->ace->action == NOCOUNTIN) {
|
||||
@ -188,7 +188,7 @@ void trafcountfunc(struct clientparam *param){
|
||||
tc->v->updated = curtime;
|
||||
}
|
||||
}
|
||||
if(countout) for(tc = conf.trafcounter; tc; tc = tc->next) {
|
||||
if(countout) for(tc = conf->trafcounter; tc; tc = tc->next) {
|
||||
if(ACLmatches(tc->ace, param)){
|
||||
if(tc->ace->action == NOCOUNTOUT || tc->ace->action == NOCOUNTALL) break;
|
||||
if(tc->ace->action != COUNTOUT && tc->ace->action != COUNTALL ) {
|
||||
|
||||
@ -189,9 +189,9 @@ int dobuf2(struct clientparam * param, unsigned char * buf, const unsigned char
|
||||
|
||||
case 'N':
|
||||
if(param->service <= MAX_SERVICE) {
|
||||
len = (conf.stringtable)? (int)strlen((char *)conf.stringtable[SERVICES + param->service]) : 0;
|
||||
len = (conf->stringtable)? (int)strlen((char *)conf->stringtable[SERVICES + param->service]) : 0;
|
||||
if(len > 20) len = 20;
|
||||
memcpy(buf+i, (len)?conf.stringtable[SERVICES + param->service]:(unsigned char*)"-", (len)?len:1);
|
||||
memcpy(buf+i, (len)?conf->stringtable[SERVICES + param->service]:(unsigned char*)"-", (len)?len:1);
|
||||
i += (len)?len:1;
|
||||
}
|
||||
break;
|
||||
@ -345,11 +345,11 @@ void logstdout(struct clientparam * param, const unsigned char *s) {
|
||||
/* with no connection, an error from the main thread */
|
||||
tmpbuf = param? param->tmpbuf : logparam.tmpbuf;
|
||||
dobuf(param, tmpbuf, s, NULL);
|
||||
log = (param && param->srv && param->srv->stdlog)?param->srv->stdlog:conf.stdlog?conf.stdlog:stdout;
|
||||
log = (param && param->srv && param->srv->stdlog)?param->srv->stdlog:conf->stdlog?conf->stdlog:stdout;
|
||||
if(!param || !param->nolog)if(fprintf(log, "%s\n", tmpbuf) < 0) {
|
||||
perror("printf()");
|
||||
};
|
||||
if(log != conf.stdlog)fflush(log);
|
||||
if(log != conf->stdlog)fflush(log);
|
||||
}
|
||||
#ifndef _WIN32
|
||||
void logsyslog(struct clientparam * param, const unsigned char *s) {
|
||||
|
||||
@ -25,7 +25,7 @@ extern int linenum;
|
||||
extern char *conffile;
|
||||
|
||||
struct symbol symbols[] = {
|
||||
{symbols+1, "conf", (void *) &conf},
|
||||
{symbols+1, "conf", (void *) &confboot},
|
||||
{symbols+2, "socksend", (void *) socksend},
|
||||
{symbols+3, "socksendto", (void *) socksendto},
|
||||
{symbols+4, "sockrecvfrom", (void *) sockrecvfrom},
|
||||
@ -45,7 +45,7 @@ struct symbol symbols[] = {
|
||||
{symbols+18, "ipauth", (void *) ipauth},
|
||||
{symbols+19, "strongauth", (void *) strongauth},
|
||||
{symbols+20, "checkACL", (void *) checkACL},
|
||||
{symbols+21, "nservers", (void *) conf.nservers},
|
||||
{symbols+21, "nservers", (void *) confboot.nservers},
|
||||
{symbols+22, "udpresolve", (void *) udpresolve},
|
||||
{symbols+23, "bandlim_mutex", (void *) &bandlim_mutex},
|
||||
{symbols+24, "tc_mutex", (void *) &tc_mutex},
|
||||
@ -86,8 +86,8 @@ static void * findbyname(const char *name){
|
||||
|
||||
struct pluginlink pluginlink = {
|
||||
{symbols, "", NULL},
|
||||
&conf,
|
||||
conf.nservers,
|
||||
&confboot,
|
||||
confboot.nservers,
|
||||
&linenum,
|
||||
authfuncs,
|
||||
commandhandlers,
|
||||
|
||||
@ -1048,7 +1048,7 @@ for(;;){
|
||||
hlen += sprintf((char*)buf + hlen, "Via: 1.1 ");
|
||||
gethostname((char *)(buf + hlen), 256);
|
||||
hlen += (int)strlen((char *)(buf + hlen));
|
||||
hlen += sprintf((char*)buf + hlen, ":%d (%s %s)\r\nX-Forwarded-For: ", (int)ntohs(*SAPORT(¶m->srv->intsa)), conf.stringtable?conf.stringtable[2]:(unsigned char *)"", conf.stringtable?conf.stringtable[3]:(unsigned char *)"");
|
||||
hlen += sprintf((char*)buf + hlen, ":%d (%s %s)\r\nX-Forwarded-For: ", (int)ntohs(*SAPORT(¶m->srv->intsa)), conf->stringtable?conf->stringtable[2]:(unsigned char *)"", conf->stringtable?conf->stringtable[3]:(unsigned char *)"");
|
||||
if(anonymous != 2)hlen += myinet_ntop(*SAFAMILY(¶m->sincr), SAADDR(¶m->sincr), (char *)buf + hlen, 128);
|
||||
else {
|
||||
uint32_t tmp = myrand();
|
||||
|
||||
@ -225,9 +225,10 @@ extern time_t basetime;
|
||||
extern int timetoexit, needreload;
|
||||
extern time_t curtime; /* the clock, kept by the main thread */
|
||||
|
||||
extern struct extparam conf;
|
||||
extern struct extparam *conf;
|
||||
extern const struct extparam confdefaults;
|
||||
extern struct extparam confboot;
|
||||
|
||||
extern int timeouts[12];
|
||||
|
||||
/* directions sockmap() passes with splice(): -s1, -s2, -s3; with
|
||||
SPLICE_AUTO (-s alone, -s5 to -s7) only when it pays */
|
||||
|
||||
@ -148,7 +148,7 @@ static void freeworker(struct clientparam *param){
|
||||
static unsigned poollimit(void){
|
||||
unsigned limit;
|
||||
|
||||
if(conf.poolmax >= 0) limit = (unsigned)conf.poolmax;
|
||||
if(conf->poolmax >= 0) limit = (unsigned)conf->poolmax;
|
||||
else {
|
||||
limit = 32 * tpool.services;
|
||||
if(limit > tpool.maxchild) limit = tpool.maxchild;
|
||||
@ -173,7 +173,7 @@ static int poolpark(struct clientparam *param){
|
||||
tpool.idle = param;
|
||||
tpool.nidle++;
|
||||
param->pooled = 1;
|
||||
timeout = conf.pooltimeout;
|
||||
timeout = conf->pooltimeout;
|
||||
_3proxy_mutex_unlock(&tpool.mutex);
|
||||
|
||||
if(timeout <= 0) _3proxy_sem_lock(param->wake);
|
||||
@ -400,7 +400,7 @@ static void srvdiscard(struct srvstart *s){
|
||||
static void srvunlink(struct srvparam *srv){
|
||||
if(srv->next)srv->next->prev = srv->prev;
|
||||
if(srv->prev)srv->prev->next = srv->next;
|
||||
else conf.services = srv->next;
|
||||
else conf->services = srv->next;
|
||||
srv->next = srv->prev = NULL;
|
||||
}
|
||||
#endif
|
||||
@ -519,19 +519,19 @@ static int srvprepare(struct srvstart *s, int argc, char **argv){
|
||||
/* http lines accumulate until a service claims them, so each httpsrv takes
|
||||
the rules written above it and the next one starts empty. */
|
||||
if(srv->service == S_HTTPSRV){
|
||||
srv->httprules = conf.httprules;
|
||||
conf.httprules = NULL;
|
||||
srv->httprules = conf->httprules;
|
||||
conf->httprules = NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef STDMAIN
|
||||
if(conf.acl){
|
||||
srv->acl = copyacl(conf.acl);
|
||||
if(conf->acl){
|
||||
srv->acl = copyacl(conf->acl);
|
||||
if(!srv->acl) return 2;
|
||||
}
|
||||
|
||||
if(conf.authfuncs){
|
||||
srv->authfuncs = copyauth(conf.authfuncs);
|
||||
if(conf->authfuncs){
|
||||
srv->authfuncs = copyauth(conf->authfuncs);
|
||||
if(!srv->authfuncs) return 2;
|
||||
}
|
||||
#else
|
||||
@ -543,8 +543,8 @@ static int srvprepare(struct srvstart *s, int argc, char **argv){
|
||||
if(*argv[i]=='-') {
|
||||
switch(argv[i][1]) {
|
||||
case 'd':
|
||||
if(!conf.demon)daemonize();
|
||||
conf.demon = 1;
|
||||
if(!conf->demon)daemonize();
|
||||
conf->demon = 1;
|
||||
break;
|
||||
#if defined SO_BINDTODEVICE || defined IP_BOUND_IF
|
||||
case 'D':
|
||||
@ -767,7 +767,7 @@ static int srvprepare(struct srvstart *s, int argc, char **argv){
|
||||
"\tExample: %s -i127.0.0.1\n\n"
|
||||
"%s",
|
||||
argv[0],
|
||||
conf.stringtable?(char *)conf.stringtable[3]: VERSION " (" BUILDDATE ")",
|
||||
conf->stringtable?(char *)conf->stringtable[3]: VERSION " (" BUILDDATE ")",
|
||||
argv[0], loghelp, printopts("\n\t"), childdef.helpmessage, argv[0],
|
||||
#ifdef STDMAIN
|
||||
copyright
|
||||
@ -795,7 +795,7 @@ static int srvprepare(struct srvstart *s, int argc, char **argv){
|
||||
"\tExample: %s -d -i127.0.0.1 6666 serv.somehost.ru 6666\n\n"
|
||||
"%s",
|
||||
argv[0],
|
||||
conf.stringtable?(char *)conf.stringtable[3]: VERSION " (" BUILDDATE ")",
|
||||
conf->stringtable?(char *)conf->stringtable[3]: VERSION " (" BUILDDATE ")",
|
||||
argv[0], loghelp, printopts("\n\t"), childdef.helpmessage, argv[0],
|
||||
#ifdef STDMAIN
|
||||
copyright
|
||||
@ -841,7 +841,7 @@ static int srvprepare(struct srvstart *s, int argc, char **argv){
|
||||
#endif
|
||||
|
||||
#ifndef STDMAIN
|
||||
if((error = copyfilter(conf.filters, srv))) return error;
|
||||
if((error = copyfilter(conf->filters, srv))) return error;
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
@ -1282,7 +1282,7 @@ static int srvrun(struct srvstart *s){
|
||||
/* A connection is only taken with a slot of maxchild in hand, which
|
||||
goes to its child; a slot not handed on is kept for the next one.
|
||||
The wait is timed to notice a reload. */
|
||||
while(!haveslot && conf.paused == srv->paused){
|
||||
while(!haveslot && conf->paused == srv->paused){
|
||||
if(!_3proxy_sem_timedlock(srv->childslots, 1000)){
|
||||
haveslot = 1;
|
||||
nfull = 0;
|
||||
@ -1294,7 +1294,7 @@ static int srvrun(struct srvstart *s){
|
||||
}
|
||||
}
|
||||
if (connectback) break;
|
||||
if (conf.paused != srv->paused) break;
|
||||
if (conf->paused != srv->paused) break;
|
||||
error = srv->so._poll(srv->so.state, &srv->fds, 1, 1000);
|
||||
if (error >= 1) break;
|
||||
if (error == 0) continue;
|
||||
@ -1304,7 +1304,7 @@ static int srvrun(struct srvstart *s){
|
||||
break;
|
||||
}
|
||||
}
|
||||
if((conf.paused != srv->paused) || (error < 0)) break;
|
||||
if((conf->paused != srv->paused) || (error < 0)) break;
|
||||
error = 0;
|
||||
#if defined NOTCPMAIN
|
||||
next = udpnext(s);
|
||||
@ -1431,12 +1431,12 @@ int mainprepare(int argc, char** argv, void **service){
|
||||
}
|
||||
/* listed only once it is sure to run: the thread reading the
|
||||
configuration links and unlinks it here, the service unlinks itself */
|
||||
if(!conf.services){
|
||||
conf.services = &s->srv;
|
||||
if(!conf->services){
|
||||
conf->services = &s->srv;
|
||||
}
|
||||
else {
|
||||
s->srv.next = conf.services;
|
||||
conf.services = conf.services->prev = &s->srv;
|
||||
s->srv.next = conf->services;
|
||||
conf->services = conf->services->prev = &s->srv;
|
||||
}
|
||||
*service = s;
|
||||
return 0;
|
||||
@ -1468,27 +1468,27 @@ _3proxy_sem_t udpinit;
|
||||
void srvinit(struct srvparam * srv, struct clientparam *param){
|
||||
|
||||
memset(srv, 0, sizeof(struct srvparam));
|
||||
srv->version = conf.version + 1;
|
||||
srv->paused = conf.paused;
|
||||
srv->logfunc = havelog?conf.logfunc:lognone;
|
||||
srv->noforce = conf.noforce;
|
||||
srv->logformat = conf.logformat? (unsigned char *)strdup((char *)conf.logformat) : NULL;
|
||||
srv->authfunc = conf.authfunc;
|
||||
srv->maxchild = conf.maxchild;
|
||||
srv->backlog = conf.backlog;
|
||||
srv->stacksize = conf.stacksize;
|
||||
memcpy(srv->timeouts, conf.timeouts, sizeof(srv->timeouts));
|
||||
srv->filtermaxsize = conf.filtermaxsize;
|
||||
srv->parentretries = conf.parentretries;
|
||||
srv->maxseg = conf.maxseg;
|
||||
srv->delimchar = conf.delimchar;
|
||||
srv->version = conf->version + 1;
|
||||
srv->paused = conf->paused;
|
||||
srv->logfunc = havelog?conf->logfunc:lognone;
|
||||
srv->noforce = conf->noforce;
|
||||
srv->logformat = conf->logformat? (unsigned char *)strdup((char *)conf->logformat) : NULL;
|
||||
srv->authfunc = conf->authfunc;
|
||||
srv->maxchild = conf->maxchild;
|
||||
srv->backlog = conf->backlog;
|
||||
srv->stacksize = conf->stacksize;
|
||||
memcpy(srv->timeouts, conf->timeouts, sizeof(srv->timeouts));
|
||||
srv->filtermaxsize = conf->filtermaxsize;
|
||||
srv->parentretries = conf->parentretries;
|
||||
srv->maxseg = conf->maxseg;
|
||||
srv->delimchar = conf->delimchar;
|
||||
srv->time_start = time(NULL);
|
||||
if(havelog && conf.logtarget){
|
||||
srv->logtarget = (unsigned char *)strdup((char *)conf.logtarget);
|
||||
if(havelog && conf->logtarget){
|
||||
srv->logtarget = (unsigned char *)strdup((char *)conf->logtarget);
|
||||
}
|
||||
srv->srvsock = INVALID_SOCKET;
|
||||
srv->logdumpsrv = conf.logdumpsrv;
|
||||
srv->logdumpcli = conf.logdumpcli;
|
||||
srv->logdumpsrv = conf->logdumpsrv;
|
||||
srv->logdumpcli = conf->logdumpcli;
|
||||
srv->cbsock = INVALID_SOCKET;
|
||||
srv->needuser = 1;
|
||||
#ifdef __linux__
|
||||
@ -1516,14 +1516,14 @@ void srvinit(struct srvparam * srv, struct clientparam *param){
|
||||
}
|
||||
udpinited = 1;
|
||||
#endif
|
||||
srv->intsa = conf.intsa;
|
||||
srv->extsa = conf.extsa;
|
||||
srv->intsa = conf->intsa;
|
||||
srv->extsa = conf->extsa;
|
||||
#ifndef NOIPV6
|
||||
srv->extsa6 = conf.extsa6;
|
||||
srv->extsa6 = conf->extsa6;
|
||||
#endif
|
||||
srv->so = so;
|
||||
srv->authcachetime = conf.authcachetime;
|
||||
srv->authcachetype = conf.authcachetype;
|
||||
srv->authcachetime = conf->authcachetime;
|
||||
srv->authcachetype = conf->authcachetype;
|
||||
}
|
||||
|
||||
void srvinit2(struct srvparam * srv, struct clientparam *param){
|
||||
|
||||
@ -26,7 +26,7 @@ uint32_t udpresolve(int af, unsigned char * name, unsigned char * value, uint32_
|
||||
if((af == AF_INET6) && (retval = hashresolv(&dns6_table, name, value, retttl))) {
|
||||
return retval;
|
||||
}
|
||||
n = (makeauth && !SAISNULL(&conf.authnserver.addr))? 1 : conf.numservers;
|
||||
n = (makeauth && !SAISNULL(&conf->authnserver.addr))? 1 : conf->numservers;
|
||||
for(i=0; i<n; i++){
|
||||
unsigned short nq, na;
|
||||
unsigned char b[4098], *buf, *s1, *s2;
|
||||
@ -49,13 +49,13 @@ uint32_t udpresolve(int af, unsigned char * name, unsigned char * value, uint32_
|
||||
memset(sinsr, 0, sizeof(addr));
|
||||
|
||||
|
||||
if(makeauth && !SAISNULL(&conf.authnserver.addr)){
|
||||
usetcp = conf.authnserver.usetcp;
|
||||
*SAFAMILY(sinsl) = *SAFAMILY(&conf.authnserver.addr);
|
||||
if(makeauth && !SAISNULL(&conf->authnserver.addr)){
|
||||
usetcp = conf->authnserver.usetcp;
|
||||
*SAFAMILY(sinsl) = *SAFAMILY(&conf->authnserver.addr);
|
||||
}
|
||||
else {
|
||||
usetcp = conf.nservers[i].usetcp;
|
||||
*SAFAMILY(sinsl) = *SAFAMILY(&conf.nservers[i].addr);
|
||||
usetcp = conf->nservers[i].usetcp;
|
||||
*SAFAMILY(sinsl) = *SAFAMILY(&conf->nservers[i].addr);
|
||||
}
|
||||
if((sock=so._socket(so.state, SASOCK(sinsl), usetcp?SOCK_STREAM:SOCK_DGRAM, usetcp?IPPROTO_TCP:IPPROTO_UDP)) == INVALID_SOCKET) break;
|
||||
if(so._bind(so.state, sock,(struct sockaddr *)sinsl,SASIZE(sinsl))){
|
||||
@ -63,14 +63,14 @@ uint32_t udpresolve(int af, unsigned char * name, unsigned char * value, uint32_
|
||||
so._closesocket(so.state, sock);
|
||||
break;
|
||||
}
|
||||
if(makeauth && !SAISNULL(&conf.authnserver.addr)){
|
||||
*sinsr = conf.authnserver.addr;
|
||||
if(makeauth && !SAISNULL(&conf->authnserver.addr)){
|
||||
*sinsr = conf->authnserver.addr;
|
||||
}
|
||||
else {
|
||||
*sinsr = conf.nservers[i].addr;
|
||||
*sinsr = conf->nservers[i].addr;
|
||||
}
|
||||
if(usetcp){
|
||||
if(connectwithpoll(NULL, sock,(struct sockaddr *)sinsr,SASIZE(sinsr),conf.timeouts[CONNECT_TO])) {
|
||||
if(connectwithpoll(NULL, sock,(struct sockaddr *)sinsr,SASIZE(sinsr),conf->timeouts[CONNECT_TO])) {
|
||||
so._shutdown(so.state, sock, SHUT_RDWR);
|
||||
so._closesocket(so.state, sock);
|
||||
break;
|
||||
@ -115,13 +115,13 @@ uint32_t udpresolve(int af, unsigned char * name, unsigned char * value, uint32_
|
||||
len+=2;
|
||||
}
|
||||
|
||||
if(socksendto(NULL, sock, (struct sockaddr *)sinsr, buf, len, conf.timeouts[SINGLEBYTE_L]*1000) != len){
|
||||
if(socksendto(NULL, sock, (struct sockaddr *)sinsr, buf, len, conf->timeouts[SINGLEBYTE_L]*1000) != len){
|
||||
so._shutdown(so.state, sock, SHUT_RDWR);
|
||||
so._closesocket(so.state, sock);
|
||||
continue;
|
||||
}
|
||||
if(param) param->statscli64 += len;
|
||||
len = sockrecvfrom(NULL, sock, (struct sockaddr *)&from, buf, 4096, conf.timeouts[DNS_TO]*1000);
|
||||
len = sockrecvfrom(NULL, sock, (struct sockaddr *)&from, buf, 4096, conf->timeouts[DNS_TO]*1000);
|
||||
if(len > 13 && usetcp){
|
||||
unsigned short us;
|
||||
us = ntohs(*(unsigned short*)buf);
|
||||
@ -129,7 +129,7 @@ uint32_t udpresolve(int af, unsigned char * name, unsigned char * value, uint32_
|
||||
buf+=2;
|
||||
if(us > 4096 || us < len) len = 0;
|
||||
else if(us > len){
|
||||
if(sockrecvfrom(NULL, sock, (struct sockaddr *)&from, buf+len, us-len, conf.timeouts[DNS_TO]*1000) != us-len) len = 0;
|
||||
if(sockrecvfrom(NULL, sock, (struct sockaddr *)&from, buf+len, us-len, conf->timeouts[DNS_TO]*1000) != us-len) len = 0;
|
||||
else len = us;
|
||||
}
|
||||
}
|
||||
|
||||
@ -252,10 +252,10 @@ log(logbuf);
|
||||
(param->srv->logdumpcli && (param->statscli64 > param->srv->logdumpcli)))
|
||||
dolog(param, NULL);
|
||||
|
||||
if(param->version < conf.version){
|
||||
if(param->version < conf->version){
|
||||
if(!param->srv->noforce && (res = (*param->srv->authfunc)(param)) && res != 2) {RETURN(res);}
|
||||
param->paused = conf.paused;
|
||||
param->version = conf.version;
|
||||
param->paused = conf->paused;
|
||||
param->version = conf->version;
|
||||
}
|
||||
|
||||
if((param->maxtrafin64 && param->statssrv64 >= param->maxtrafin64) || (param->maxtrafout64 && param->statscli64 >= param->maxtrafout64)){
|
||||
|
||||
@ -94,9 +94,9 @@ int init_sql(char * s){
|
||||
}
|
||||
|
||||
void sqlerr (char *buf){
|
||||
if(conf.stdlog){
|
||||
fprintf(conf.stdlog, "%s\n", buf);
|
||||
fflush(conf.stdlog);
|
||||
if(conf->stdlog){
|
||||
fprintf(conf->stdlog, "%s\n", buf);
|
||||
fflush(conf->stdlog);
|
||||
}
|
||||
_3proxy_mutex_unlock(&log_mutex);
|
||||
}
|
||||
|
||||
@ -859,7 +859,7 @@ struct filemon {
|
||||
|
||||
|
||||
struct extparam {
|
||||
int *timeouts;
|
||||
int timeouts[12];
|
||||
struct ace * acl;
|
||||
#ifdef WITH_HTTPSRV
|
||||
struct httprule *httprules;
|
||||
|
||||
@ -353,9 +353,9 @@ static char * admin_open(struct printparam *pp, struct clientparam *param)
|
||||
buf = malloc(LINESIZE);
|
||||
if(!buf) return NULL;
|
||||
|
||||
sprintf(buf, ok, conf.stringtable?(char *)conf.stringtable[2]:"3proxy",
|
||||
conf.stringtable?(char *)conf.stringtable[2]:"3[APA3A] tiny proxy",
|
||||
conf.stringtable?(char *)conf.stringtable[3]:"");
|
||||
sprintf(buf, ok, conf->stringtable?(char *)conf->stringtable[2]:"3proxy",
|
||||
conf->stringtable?(char *)conf->stringtable[2]:"3[APA3A] tiny proxy",
|
||||
conf->stringtable?(char *)conf->stringtable[3]:"");
|
||||
printstr(pp, buf);
|
||||
return buf;
|
||||
}
|
||||
@ -374,7 +374,7 @@ int op_admin(struct httpreq *r, const unsigned char *params)
|
||||
|
||||
buf = admin_open(&pp, r->param);
|
||||
if(!buf) return 1;
|
||||
printstr(&pp, (char *)conf.stringtable[WEBBANNERS]);
|
||||
printstr(&pp, (char *)conf->stringtable[WEBBANNERS]);
|
||||
admin_close(&pp, buf);
|
||||
return 0;
|
||||
}
|
||||
@ -398,7 +398,7 @@ int op_admin_counters(struct httpreq *r, const unsigned char *params)
|
||||
{
|
||||
struct trafcount *cp;
|
||||
int num = 0;
|
||||
for(cp = conf.trafcounter; cp; cp = cp->next, num++){
|
||||
for(cp = conf->trafcounter; cp; cp = cp->next, num++){
|
||||
int inbuf = 0;
|
||||
|
||||
if(cp->ace && (limited || param->redirected)){
|
||||
@ -489,7 +489,7 @@ int op_admin_reload(struct httpreq *r, const unsigned char *params)
|
||||
buf = admin_open(&pp, r->param);
|
||||
if(!buf) return 1;
|
||||
|
||||
if(r->param->srv->s_option) printstr(&pp, (char *)conf.stringtable[WEBBANNERS]);
|
||||
if(r->param->srv->s_option) printstr(&pp, (char *)conf->stringtable[WEBBANNERS]);
|
||||
else {
|
||||
needreload = 1;
|
||||
printstr(&pp, "<h3>Reload scheduled</h3>");
|
||||
@ -520,7 +520,7 @@ int op_admin_services(struct httpreq *r, const unsigned char *params)
|
||||
printstr(&pp, "<threadpool>");
|
||||
printval(&tpool, TYPE_THREADPOOL, 0, &pp);
|
||||
printstr(&pp, "</threadpool>\r\n");
|
||||
printval(conf.services, TYPE_SERVER, 0, &pp);
|
||||
printval(conf->services, TYPE_SERVER, 0, &pp);
|
||||
printstr(&pp, postxml);
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user