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 "no protocol with name dnsaddr" error #247

Merged
merged 1 commit into from
Feb 4, 2019
Merged

Conversation

avbasov
Copy link
Contributor

@avbasov avbasov commented Feb 1, 2019

No description provided.

@anacrolix
Copy link
Contributor

Thanks for the patch. Could you provide a little context on when you're seeing this error?

@avbasov
Copy link
Contributor Author

avbasov commented Feb 3, 2019

It's because of that new DefaultBootstrapPeers variable, which is initialised into the init function.
go-multiaddr module doesn't support a "dnsaddr" protocol by default. So, we have to import go-multiaddr-dns, otherwise I couldn't even build my app.

@anacrolix
Copy link
Contributor

I'm not able to reproduce the failure to build, or any DNS resolution issues. Do you have a code sample? Are you using a go-libp2p Host or some other resolver?

@avbasov
Copy link
Contributor Author

avbasov commented Feb 4, 2019

I've realized the case is not so obvious. I'm sorry. The error will occur if kad-dht is imported before go-libp2p. I use a forked version of kad-dht module, so I have different import order.

Here is an example.

package main

import (
	"context"

	"github.com/libp2p/go-libp2p-kad-dht"

	"github.com/libp2p/go-libp2p"
	"github.com/multiformats/go-multiaddr"
)

func main()  {
	sourceMultiAddr, err := multiaddr.NewMultiaddr("/ip4/0.0.0.0/tcp/21000")
	if err != nil {
		panic(err)
	}

	host, err := libp2p.New(context.Background(), libp2p.ListenAddrs(sourceMultiAddr))
	if err != nil {
		panic(err)
	}
	defer host.Close()

	kad, err := dht.New(context.Background(), host)
	if err != nil {
		panic(err)
	}
	defer kad.Close()
}

@vyzo vyzo merged commit d422d90 into libp2p:master Feb 4, 2019
@avbasov avbasov deleted the patch-1 branch March 14, 2019 08:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants