Merge pull request #2017 from ipfs-cluster/fix/2004-dns-resolve

Fix #2004: Do not pre-resolve node_multiaddress
This commit is contained in:
Hector Sanjuan 2024-01-09 22:08:32 +01:00 committed by GitHub
commit 254820d8b0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -27,7 +27,6 @@ import (
logging "github.com/ipfs/go-log/v2"
rpc "github.com/libp2p/go-libp2p-gorpc"
peer "github.com/libp2p/go-libp2p/core/peer"
madns "github.com/multiformats/go-multiaddr-dns"
manet "github.com/multiformats/go-multiaddr/net"
"github.com/multiformats/go-multicodec"
multihash "github.com/multiformats/go-multihash"
@ -141,20 +140,7 @@ func NewConnector(cfg *Config) (*Connector, error) {
return nil, err
}
nodeMAddr := cfg.NodeAddr
// dns multiaddresses need to be resolved first
if madns.Matches(nodeMAddr) {
ctx, cancel := context.WithTimeout(context.Background(), DNSTimeout)
defer cancel()
resolvedAddrs, err := madns.Resolve(ctx, cfg.NodeAddr)
if err != nil {
logger.Error(err)
return nil, err
}
nodeMAddr = resolvedAddrs[0]
}
nodeNetwork, nodeAddr, err := manet.DialArgs(nodeMAddr)
nodeNetwork, nodeAddr, err := manet.DialArgs(cfg.NodeAddr)
if err != nil {
return nil, err
}