1
0
Fork 0

ip/resolver: use ip.ParseIP() helper function

This commit is contained in:
Henrik Hautakoski 2023-12-02 14:19:13 +01:00
parent 2204be7777
commit acf8976f53
3 changed files with 8 additions and 13 deletions

View file

@ -7,6 +7,8 @@ import (
"net"
"net/http"
"strings"
"dnsupdater/ip"
)
type Service struct {
@ -44,9 +46,5 @@ func (s Service) Lookup(ctx context.Context) (net.IP, error) {
// Trim spaces and stuff.
ip_str := strings.TrimSpace(string(body))
ip := net.ParseIP(ip_str)
if ip == nil {
err = fmt.Errorf("Failed to parse ip: %s", ip_str)
}
return ip, err
return ip.ParseIP(ip_str)
}