Skip to content

Commit

Permalink
Fix IPv6 format for DNS address received from android (#1350)
Browse files Browse the repository at this point in the history
this adds the address in the expected format in Go [ipv6]:port
  • Loading branch information
mlsmaycon authored Dec 1, 2023
1 parent 7a46a63 commit b8c46e2
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion client/internal/dns/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {}
Expand Down

0 comments on commit b8c46e2

Please sign in to comment.