Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix IPv6 format for DNS address received from android #1350

Merged
merged 2 commits into from
Dec 1, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 20 additions & 2 deletions client/internal/dns/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,14 @@
}

func getNSHostPort(ns nbdns.NameServer) string {
return fmt.Sprintf("%s:%d", ns.IP.String(), ns.Port)
log.Debugf("getNSHostPort: %s : %d", ns.IP.String(), ns.Port)
if ns.IP.Is4() {
return fmt.Sprintf("%s:%d", ns.IP.String(), ns.Port)
}

n := fmt.Sprintf("[%s]:%d", ns.IP.String(), ns.Port)
log.Debugf("formated ns: %s", n)

Check failure on line 430 in client/internal/dns/server.go

View workflow job for this annotation

GitHub Actions / codespell

formated ==> formatted
mlsmaycon marked this conversation as resolved.
Show resolved Hide resolved
mlsmaycon marked this conversation as resolved.
Show resolved Hide resolved
return n
}

// upstreamCallbacks returns two functions, the first one is used to deactivate
Expand Down Expand Up @@ -488,7 +495,18 @@
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)
mlsmaycon marked this conversation as resolved.
Show resolved Hide resolved
}

handler.upstreamServers[n] = fmt.Sprintf("%s:53", ipString)
}
handler.deactivate = func() {}
handler.reactivate = func() {}
Expand Down
Loading