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

Support /dns protocol in multiaddr #1575

Merged
merged 9 commits into from
May 18, 2020
Merged

Conversation

mzabaluev
Copy link
Contributor

The /dns protocol has been added to the spec and has had a de-facto meaning for years (citing multiformats/multiaddr#100)

This adds address parsing and encoding support for /dns to the multiaddr library.

The /dns protocol has been added to the spec and has had a de-facto
meaning for years.
See multiformats/multiaddr#100

This adds address parsing and encoding support for /dns to the multiaddr
format library.
@mzabaluev
Copy link
Contributor Author

Address resolution for this is not yet implemented in libp2p, but other users of the parity-multiaddr crate could make use of the protocol component in their own ways, e.g. translating a /dns multiaddr to an URL to give to a Happy Eyeballs capable HTTP stack.

@tomaka
Copy link
Member

tomaka commented May 14, 2020

Support for it is probably very easy to add to libp2p-dns.
I just don't want to lose track of a semi-implemented feature, and I don't think it's worth opening an issue just for this, so support should probably be added to this PR, or whoever merges this should quickly submit a PR afterwards.

@mzabaluev
Copy link
Contributor Author

OK, I will try to do here shortly.

@mzabaluev
Copy link
Contributor Author

@tomaka I have added /dns support to libp2p-dns and a few other places. I get a unit test failure in libp2p-dns, but the same test is also failing in master.

Commits c02bf8d and possibly f76331f may be too disruptive, as they change the behavior of URL-to-multiaddr translations, albeit improving it with regard to IPv6 support.

@mzabaluev mzabaluev requested a review from tomaka May 14, 2020 22:12
Copy link
Member

@tomaka tomaka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the efforts!

Commits c02bf8d and possibly f76331f may be too disruptive, as they change the behavior of URL-to-multiaddr translations, albeit improving it with regard to IPv6 support.

I think that's ok. The new behaviour is exactly what the function is supposed to do.

@@ -70,7 +70,7 @@ fn from_url_inner_http_ws(url: url::Url, lossy: bool) -> std::result::Result<Mul
if let Ok(ip) = hostname.parse::<IpAddr>() {
Protocol::from(ip)
} else {
Protocol::Dns4(hostname.into())
Protocol::Dns(hostname.into())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, that's actually a great change 🎉

@@ -371,7 +373,7 @@ fn location_to_multiaddr<T>(location: &str) -> Result<Multiaddr, Error<T>> {
let mut a = Multiaddr::empty();
match url.host() {
Some(url::Host::Domain(h)) => {
a.push(Protocol::Dns4(h.into()))
a.push(Protocol::Dns(h.into()))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same

@tomaka tomaka merged commit 82156de into libp2p:master May 18, 2020
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.

2 participants