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

@ -5,6 +5,8 @@ import (
"encoding/json"
"net"
"net/http"
"dnsupdater/ip"
)
type Service struct {
@ -22,12 +24,7 @@ func (s Service) Name() string {
}
func (s Service) Lookup(ctx context.Context) (net.IP, error) {
req, err := http.NewRequestWithContext(ctx, "GET", s.url, nil)
if err != nil {
return nil, err
}
resp, err := http.DefaultClient.Do(req)
resp, err := httphelper.Get(ctx, s.url, nil)
if err != nil {
return nil, err
}
@ -41,5 +38,5 @@ func (s Service) Lookup(ctx context.Context) (net.IP, error) {
return nil, err
}
return net.ParseIP(v.Ip), err
return ip.ParseIP(v.Ip)
}