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

getFirstListenerAvailable(): adjust logging levels and add success message #1513

Merged
merged 2 commits into from
Jan 31, 2024
Merged
Changes from all commits
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
7 changes: 4 additions & 3 deletions client/internal/dns/service_listener.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ func (s *serviceViaListener) setListenerStatus(running bool) {
s.listenerIsRunning = running
}

func (s *serviceViaListener) getFirstListenerAvailable() (string, int, error) {
func (s *serviceViaListener) getFirstDNSListenerAvailable() (string, int, error) {
ips := []string{defaultIP, customIP}
if runtime.GOOS != "darwin" {
ips = append([]string{s.wgInterface.Address().IP.String()}, ips...)
Expand All @@ -156,9 +156,10 @@ func (s *serviceViaListener) getFirstListenerAvailable() (string, int, error) {
if err != nil {
log.Errorf("got an error closing the probe listener, error: %s", err)
}
log.Infof("successfully found dns binding candidate at %s", addrString)
return ip, port, nil
}
log.Warnf("binding dns on %s is not available, error: %s", addrString, err)
log.Debugf("binding dns on %s is not available, error: %s", addrString, err)
}
}
return "", 0, fmt.Errorf("unable to find an unused ip and port combination. IPs tested: %v and ports %v", ips, ports)
Expand All @@ -169,7 +170,7 @@ func (s *serviceViaListener) evalListenAddress() (string, int, error) {
return s.customAddr.Addr().String(), int(s.customAddr.Port()), nil
}

return s.getFirstListenerAvailable()
return s.getFirstDNSListenerAvailable()
}

// shouldApplyPortFwd decides whether to apply eBPF program to capture DNS traffic on port 53.
Expand Down
Loading