Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Phillip Stephens <[email protected]>
  • Loading branch information
developStorm and phillip-stephens authored Apr 17, 2024
1 parent 5dc0e1c commit 9664016
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions utility.go
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@ func LogPanic(format string, args ...interface{}) {
panic(err)
}

// addDefaultPortToDNSServerName validates that the input DNS server address is correct and appends the default DNS port 53 if no port is specified
func AddDefaultPortToDNSServerName(inAddr string) (string, error) {
// Try to split host and port to see if the port is already specified.
host, port, err := net.SplitHostPort(inAddr)
Expand All @@ -241,9 +242,9 @@ func AddDefaultPortToDNSServerName(inAddr string) (string, error) {
return "", fmt.Errorf("invalid IP address")
}

// If the original input does not have a port, specify port 53
// If the original input does not have a port, specify port 53 as the default
if port == "" {
port = "53"
port = defaultDNSPort
}

return net.JoinHostPort(ip.String(), port), nil
Expand Down

0 comments on commit 9664016

Please sign in to comment.