Skip to content

Commit

Permalink
fix:When using the opensearch-go library to access an opensearch clus…
Browse files Browse the repository at this point in the history
…ter deployed with IPV6, an access error will occur when calling other APIs after calling the DiscoverNodes method.

opensearch-project#458

Signed-off-by: 张洁俊 <82801500+Zhang-jie-jun@users.noreply.github.com>
Signed-off-by: 张洁俊(Jack) <zhang.jiejun@outlook.com>
  • Loading branch information
Zhang-jie-jun authored and 张洁俊(Jack) committed Jan 22, 2024
1 parent f5e372a commit 3d1442a
Showing 1 changed file with 1 addition and 17 deletions.
18 changes: 1 addition & 17 deletions opensearchtransport/discovery.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ import (
"io"
"net/http"
"net/url"
"strings"
"sync"
"time"
)
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 3d1442a

Please sign in to comment.