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.

#458

Signed-off-by: 张洁俊 <[email protected]>
  • Loading branch information
Zhang-jie-jun authored Jan 19, 2024
1 parent f5e372a commit 0903c1d
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 0903c1d

Please sign in to comment.