From 978d541503c2c9eabce0a2bc20e7851b6be479d2 Mon Sep 17 00:00:00 2001 From: DataHearth Date: Tue, 31 Jan 2023 20:16:41 +0100 Subject: [PATCH] fix ipv6 support with port splitting --- pkg/provider/main.go | 10 +--------- pkg/watcher/watcher.go | 2 +- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/pkg/provider/main.go b/pkg/provider/main.go index 4ad19a2..e3f92a1 100644 --- a/pkg/provider/main.go +++ b/pkg/provider/main.go @@ -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 { diff --git a/pkg/watcher/watcher.go b/pkg/watcher/watcher.go index 89e4f6d..662c52d 100644 --- a/pkg/watcher/watcher.go +++ b/pkg/watcher/watcher.go @@ -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)