fix ipv6 support with port splitting

This commit is contained in:
DataHearth 2023-01-31 20:16:41 +01:00
parent 236c82e272
commit 978d541503
No known key found for this signature in database
GPG Key ID: E88FD356ACC5F3C4
2 changed files with 2 additions and 10 deletions

View File

@ -138,15 +138,7 @@ func (p *provider) retrieveSubdomainIP(addr string) (string, error) {
return "", fmt.Errorf("%v: %v", utils.ErrIpLenght, ips)
}
ip := ips[0].String()
if strings.Contains(ip, ":") {
ip, _, err = net.SplitHostPort(ip)
if err != nil {
return "", fmt.Errorf("%v: %v", utils.ErrSplitAddr, ip)
}
}
return ip, nil
return ips[0].String(), nil
}
func (p *provider) checkResponse(body []byte, tokenBased bool, ip string) error {

View File

@ -120,7 +120,7 @@ func (w *watcher) retrieveServerIP() (string, error) {
}
var ip string
if rsp.Header.Get("content-type") == "application/json" {
if strings.Contains(rsp.Header.Get("content-type"), "application/json") {
body := make(map[string]interface{})
if err := json.Unmarshal(b, &body); err != nil {
return "", fmt.Errorf("failed to unmarshal JSON body: %v", err)