ip/resolver: use ip.ParseIP() helper function
This commit is contained in:
parent
2204be7777
commit
acf8976f53
3 changed files with 8 additions and 13 deletions
|
|
@ -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)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue