cmd/ctrld: force 127.0.0.1:53 for listener.0 only

This commit is contained in:
Cuong Manh Le
2023-05-15 21:13:23 +07:00
committed by Cuong Manh Le
parent 5b6a3a4c6f
commit 521f06dcc1
+3 -3
View File
@@ -88,7 +88,7 @@ func (p *prog) serveDNS(listenerNum string) error {
}) })
} }
g.Go(func() error { g.Go(func() error {
s, errCh := runDNSServer(dnsListenAddress(listenerConfig), proto, handler) s, errCh := runDNSServer(dnsListenAddress(listenerNum, listenerConfig), proto, handler)
defer s.Shutdown() defer s.Shutdown()
if listenerConfig.Port == 0 { if listenerConfig.Port == 0 {
switch s.Net { switch s.Net {
@@ -397,8 +397,8 @@ func needLocalIPv6Listener() bool {
return ctrldnet.SupportsIPv6ListenLocal() && runtime.GOOS == "windows" return ctrldnet.SupportsIPv6ListenLocal() && runtime.GOOS == "windows"
} }
func dnsListenAddress(lc *ctrld.ListenerConfig) string { func dnsListenAddress(lcNum string, lc *ctrld.ListenerConfig) string {
if addr := router.ListenAddress(); addr != "" { if addr := router.ListenAddress(); addr != "" && lcNum == "0" {
return addr return addr
} }
return net.JoinHostPort(lc.IP, strconv.Itoa(lc.Port)) return net.JoinHostPort(lc.IP, strconv.Itoa(lc.Port))