mirror of
https://github.com/3proxy/3proxy.git
synced 2026-11-22 23:59:41 +08:00
resolver: per service, defaultresolve, fakeresolve or sysresolve
C/C++ CI Linux / ${{ matrix.target }} (ubuntu-24.04-arm) (push) Waiting to run
C/C++ CI Linux / ${{ matrix.target }} (ubuntu-latest) (push) Waiting to run
C/C++ CI MacOS / ${{ matrix.target }} (macos-15) (push) Waiting to run
C/C++ CI Windows / ${{ matrix.target }} (windows-2022) (push) Waiting to run
C/C++ CI cmake / ${{ matrix.target }} (macos-15) (push) Waiting to run
C/C++ CI cmake / ${{ matrix.target }} (ubuntu-24.04-arm) (push) Waiting to run
C/C++ CI cmake / ${{ matrix.target }} (ubuntu-latest) (push) Waiting to run
C/C++ CI cmake / ${{ matrix.target }} (windows-2022) (push) Waiting to run
C/C++ CI cmake / ubuntu-latest (wolfSSL) (push) Waiting to run
C/C++ CI Linux / ${{ matrix.target }} (ubuntu-24.04-arm) (push) Waiting to run
C/C++ CI Linux / ${{ matrix.target }} (ubuntu-latest) (push) Waiting to run
C/C++ CI MacOS / ${{ matrix.target }} (macos-15) (push) Waiting to run
C/C++ CI Windows / ${{ matrix.target }} (windows-2022) (push) Waiting to run
C/C++ CI cmake / ${{ matrix.target }} (macos-15) (push) Waiting to run
C/C++ CI cmake / ${{ matrix.target }} (ubuntu-24.04-arm) (push) Waiting to run
C/C++ CI cmake / ${{ matrix.target }} (ubuntu-latest) (push) Waiting to run
C/C++ CI cmake / ${{ matrix.target }} (windows-2022) (push) Waiting to run
C/C++ CI cmake / ubuntu-latest (wolfSSL) (push) Waiting to run
Each service resolves names the way the last of defaultresolve (the name servers in force, configured or the system's with the hosts file), fakeresolve (127.0.0.2) and sysresolve (the C library) read before it says; the last one in the configuration also applies outside services. defaultresolve is the new command, and the default. The name servers and the hosts file no longer depend on the mode: nserver lines, or the system's, are always in force, so dnspr keeps forwarding; with fakeresolve it does not, as before. fakeresolver moves to common.c, which the standalone services link without resolve.c. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
994526dbc4
commit
3d20e1104e
14 files changed
+181
-101
No files matched your search
+18
-14
@@ -376,7 +376,7 @@ static int h_proxy(int argc, unsigned char ** argv){
|
||||
childdef.service = S_DNSPR;
|
||||
childdef.helpmessage = " -s - simple DNS forwarding - do not use 3proxy resolver / name cache\n -Fip - fake: answer all A queries with this IP\n";
|
||||
#ifndef NOIPV6
|
||||
if(noresolver() || conf->resolvfunc == fakeresolver){
|
||||
if(noresolver() || conf->resolvmode == RESOLVE_FAKE){
|
||||
fprintf(stderr, "[line %d] Warning: no nserver/nscache configured, dnspr will not work as expected\n", linenum);
|
||||
}
|
||||
#endif
|
||||
@@ -741,8 +741,6 @@ static int h_flushusers(int argc, unsigned char **argv){
|
||||
force (the process has one list) once it is committed */
|
||||
static struct nserver cfgns[MAXNSERVERS];
|
||||
static int cfgnsn = 0;
|
||||
/* sysresolve: names resolved by the system routines */
|
||||
static int cfgsysresolve = 0;
|
||||
|
||||
static int h_nserver(int argc, unsigned char **argv){
|
||||
char *str;
|
||||
@@ -760,20 +758,20 @@ static int h_nserver(int argc, unsigned char **argv){
|
||||
cfgnsn++;
|
||||
}
|
||||
else fprintf(stderr, "[line %d] Warning: only %d name servers are used, nserver ignored\n", linenum, MAXNSERVERS);
|
||||
conf->resolvfunc = myresolver;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* The configuration's name servers, or the system's in their place */
|
||||
void confdnscommit(struct extparam *c){
|
||||
sysdnsapply(c, cfgns, cfgnsn, cfgsysresolve);
|
||||
void confdnscommit(void){
|
||||
sysdnsapply(cfgns, cfgnsn);
|
||||
}
|
||||
|
||||
/* Whether names would be resolved slowly: by the C library, or by name
|
||||
servers, the system's taken by default, without a cache */
|
||||
static int noresolver(void){
|
||||
if(cfgsysresolve || (!conf->resolvfunc && !sysdnscount())) return 1;
|
||||
return (!conf->resolvfunc || conf->resolvfunc == myresolver) && !dns_table.poolsize;
|
||||
if(conf->resolvmode == RESOLVE_FAKE) return 0;
|
||||
if(conf->resolvmode == RESOLVE_SYSTEM || (!cfgnsn && !sysdnscount())) return 1;
|
||||
return !dns_table.poolsize;
|
||||
}
|
||||
|
||||
static int h_authnserver(int argc, unsigned char **argv){
|
||||
@@ -790,14 +788,20 @@ static int h_authnserver(int argc, unsigned char **argv){
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* defaultresolve, fakeresolve, sysresolve: for the services after it,
|
||||
and, the last one, for names resolved outside a service */
|
||||
static int h_defaultresolve(int argc, unsigned char **argv){
|
||||
conf->resolvmode = RESOLVE_DEFAULT;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int h_fakeresolve(int argc, unsigned char **argv){
|
||||
conf->resolvfunc = fakeresolver;
|
||||
cfgsysresolve = 0;
|
||||
conf->resolvmode = RESOLVE_FAKE;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int h_sysresolve(int argc, unsigned char **argv){
|
||||
cfgsysresolve = 1;
|
||||
conf->resolvmode = RESOLVE_SYSTEM;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -2153,6 +2157,7 @@ struct commands commandhandlers[]={
|
||||
{NULL, "maxconn", h_maxconn, 2, 2},
|
||||
{NULL, "flush", h_flush, 1, 1},
|
||||
{NULL, "nserver", h_nserver, 2, 2},
|
||||
{NULL, "defaultresolve", h_defaultresolve, 1, 1},
|
||||
{NULL, "fakeresolve", h_fakeresolve, 1, 1},
|
||||
{NULL, "sysresolve", h_sysresolve, 1, 1},
|
||||
{NULL, "nscache", h_nscache, 2, 2},
|
||||
@@ -2543,7 +2548,6 @@ void confbegin(void){
|
||||
char * args[] = {"auth", "iponly", NULL};
|
||||
|
||||
cfgnsn = 0;
|
||||
cfgsysresolve = 0;
|
||||
|
||||
h_auth(2, (unsigned char **)args);
|
||||
}
|
||||
@@ -2675,8 +2679,8 @@ int reload (void){
|
||||
_3proxy_mutex_lock(&confref_mutex);
|
||||
runconf = new;
|
||||
_3proxy_mutex_unlock(&confref_mutex);
|
||||
confdnscommit(new);
|
||||
resolvfunc = new->resolvfunc;
|
||||
confdnscommit();
|
||||
resolvmode = new->resolvmode;
|
||||
/* the new services take over the listening sockets of the old ones on
|
||||
the same addresses, which then stop accepting, and start */
|
||||
for(d = deferred; d; d = d->next) mainclaim(d->service);
|
||||
|
||||
Reference in new issue
Block a user