From b0185201c640a3104783eebb82c19a506f548da2 Mon Sep 17 00:00:00 2001 From: Ainar Garipov Date: Tue, 18 Jul 2023 21:20:43 +0300 Subject: [PATCH] Pull request 1931: 6006-fix-cmdline-upd Updates #6006. Squashed commit of the following: commit f974a08856b894fd586cfbba703d98dbcf8c6a97 Author: Ainar Garipov Date: Tue Jul 18 20:51:58 2023 +0300 home: fix cmdline update --- internal/home/dns.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/internal/home/dns.go b/internal/home/dns.go index 7dfa8b85..87cb70fd 100644 --- a/internal/home/dns.go +++ b/internal/home/dns.go @@ -240,14 +240,20 @@ func newServerConfig( DNS64Prefixes: config.DNS.DNS64Prefixes, } - const initialClientsNum = 100 + var initialAddresses []netip.Addr + // Context.stats may be nil here if initDNSServer is called from + // [cmdlineUpdate]. + if sts := Context.stats; sts != nil { + const initialClientsNum = 100 + initialAddresses = Context.stats.TopClientsIP(initialClientsNum) + } // Do not set DialContext, PrivateSubnets, and UsePrivateRDNS, because they // are set by [dnsforward.Server.Prepare]. newConf.AddrProcConf = &client.DefaultAddrProcConfig{ Exchanger: Context.dnsServer, AddressUpdater: &Context.clients, - InitialAddresses: Context.stats.TopClientsIP(initialClientsNum), + InitialAddresses: initialAddresses, UseRDNS: config.Clients.Sources.RDNS, UseWHOIS: config.Clients.Sources.WHOIS, }