mirror of
https://github.com/3proxy/3proxy.git
synced 2026-11-22 23:59:41 +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:
1 parent
8bd5c0f0fa
commit
737bdc7d24
19 files changed
+398
-389
No files matched your search
+13
-13
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user