Fix IPv6 format for DNS address received from android (#1350)

this adds the address in the expected format in Go [ipv6]:port
This commit is contained in:
Maycon Santos 2023-12-01 14:26:42 +01:00 committed by GitHub
parent 7a46a63a14
commit b8c46e2654
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -488,7 +488,18 @@ func (s *DefaultServer) addHostRootZone() {
handler := newUpstreamResolver(s.ctx)
handler.upstreamServers = make([]string, len(s.hostsDnsList))
for n, ua := range s.hostsDnsList {
handler.upstreamServers[n] = fmt.Sprintf("%s:53", ua)
a, err := netip.ParseAddr(ua)
if err != nil {
log.Errorf("invalid upstream IP address: %s, error: %s", ua, err)
continue
}
ipString := ua
if !a.Is4() {
ipString = fmt.Sprintf("[%s]", ua)
}
handler.upstreamServers[n] = fmt.Sprintf("%s:53", ipString)
}
handler.deactivate = func() {}
handler.reactivate = func() {}