From 0903c1d4fa4df433bc7ff2f3680240b38f3ebd58 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=B4=81=E4=BF=8A?= <82801500+Zhang-jie-jun@users.noreply.github.com> Date: Fri, 19 Jan 2024 09:21:33 +0800 Subject: [PATCH] fix:When using the opensearch-go library to access an opensearch cluster deployed with IPV6, an access error will occur when calling other APIs after calling the DiscoverNodes method. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://github.com/opensearch-project/opensearch-go/issues/458 Signed-off-by: 张洁俊 <82801500+Zhang-jie-jun@users.noreply.github.com> --- opensearchtransport/discovery.go | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) diff --git a/opensearchtransport/discovery.go b/opensearchtransport/discovery.go index f4463f3f2..baef105ee 100644 --- a/opensearchtransport/discovery.go +++ b/opensearchtransport/discovery.go @@ -33,7 +33,6 @@ import ( "io" "net/http" "net/url" - "strings" "sync" "time" ) @@ -176,24 +175,9 @@ func (c *Client) getNodesInfo() ([]nodeInfo, error) { } func (c *Client) getNodeURL(node nodeInfo, scheme string) *url.URL { - var ( - host string - port string - - addrs = strings.Split(node.HTTP.PublishAddress, "/") - ports = strings.Split(node.HTTP.PublishAddress, ":") - ) - - if len(addrs) > 1 { - host = addrs[0] - } else { - host = strings.Split(addrs[0], ":")[0] - } - - port = ports[len(ports)-1] u := &url.URL{ Scheme: scheme, - Host: host + ":" + port, + Host: node.HTTP.PublishAddress, } return u