Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #462: Support DNS multiaddresses for node_multiaddress #463

Merged
merged 1 commit into from
Jun 12, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.9-stretch AS builder
FROM golang:1.10-stretch AS builder
MAINTAINER Hector Sanjuan <hector@protocol.ai>

# This dockerfile builds and runs ipfs-cluster-service.
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile-test
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.9-stretch AS builder
FROM golang:1.10-stretch AS builder
MAINTAINER Hector Sanjuan <hector@protocol.ai>

# This build state just builds the cluster binaries
Expand Down
19 changes: 18 additions & 1 deletion ipfsconn/ipfshttp/ipfshttp.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,13 @@ import (
logging "github.com/ipfs/go-log"
peer "github.com/libp2p/go-libp2p-peer"
ma "github.com/multiformats/go-multiaddr"
madns "github.com/multiformats/go-multiaddr-dns"
manet "github.com/multiformats/go-multiaddr-net"
)

// DNSTimeout is used when resolving DNS multiaddresses in this module
var DNSTimeout = 5 * time.Second

var logger = logging.Logger("ipfshttp")

// Connector implements the IPFSConnector interface
Expand Down Expand Up @@ -112,7 +116,20 @@ func NewConnector(cfg *Config) (*Connector, error) {
return nil, err
}

_, nodeAddr, err := manet.DialArgs(cfg.NodeAddr)
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]
}

_, nodeAddr, err := manet.DialArgs(nodeMAddr)
if err != nil {
return nil, err
}
Expand Down
2 changes: 1 addition & 1 deletion pstoremgr/pstoremgr.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ var logger = logging.Logger("pstoremgr")

// Timeouts for network operations triggered by the Manager
var (
DNSTimeout = 2 * time.Second
DNSTimeout = 5 * time.Second
ConnectTimeout = 10 * time.Second
)

Expand Down