mirror of
https://github.com/3proxy/3proxy.git
synced 2026-11-22 23:59:41 +08:00
resolver: the system's name servers and hosts file by default
Without nserver (or fakeresolve) names were resolved by the C library. 3proxy's own resolver is now the default, with the system's name servers: up to 3 from /etc/resolv.conf, on Windows from the registry (set for the system, set for an interface with an address, Tcpip6 interfaces, then those DHCP gave). With none found, the C library as before. nserver takes up to 3 as well (MAXNSERVERS), a fourth is warned about. The name servers in force belong to the process, not a configuration: nserver lines are kept aside while a configuration is read and replace them only once it is committed, so a reload resolves with those in force until then. Resolutions and dnspr read a copy of them. The system's are read at start, before the configuration and a chroot in it, and are in force while it is read, so its host names resolve with them; read again at a commit, and checked every 5 seconds from the main loop while the default is in force. What cannot be read then (within a chroot) stays as last read. The hosts file, read with them, is imported into tables of its own while the default is in force: its first address of a family for a name. A name is looked up as one nsrecord made first, then the hosts file, then the name cache, then name servers. A changed file replaces what was imported. No name cache is made for it: without nscache nothing is cached, as before. The name cache's keys are host names of any case now: DNS names are. Tests: sysdns, a name of the hosts file answered by dnspr without nserver, in any case, and not with one. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
8517a5675b
commit
d5e78a0900
11 files changed
+589
-45
No files matched your search
@@ -293,6 +293,7 @@ void cyclestep(void){
|
||||
needreload = 0;
|
||||
}
|
||||
doschedule();
|
||||
sysdnscheck();
|
||||
if(conf->stdlog)fflush(conf->stdlog);
|
||||
if(timechanged(minutecounter, curtime, MINUTELY)) {
|
||||
struct filemon *fm;
|
||||
@@ -555,6 +556,7 @@ int WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int
|
||||
#ifdef __linux__
|
||||
nsopen(); /* before a chroot in the configuration takes /proc away */
|
||||
#endif
|
||||
sysdnsinit(); /* the system's name servers and hosts, before a chroot too */
|
||||
_3proxy_mutex_init(&config_mutex);
|
||||
_3proxy_mutex_init(&confref_mutex);
|
||||
_3proxy_mutex_init(&listener_mutex);
|
||||
@@ -592,6 +594,7 @@ int WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int
|
||||
/* numbered before it is read, as a reload numbers the new one */
|
||||
conf->version++;
|
||||
res = readconfig(fp);
|
||||
if(!res) confdnscommit(conf);
|
||||
resolvfunc = conf->resolvfunc;
|
||||
|
||||
/* readconfig() names the failing line, which an exit status would cut
|
||||
|
||||
Reference in new issue
Block a user