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

allow adding public_peers with DNS name #1164

Closed
wants to merge 4 commits into from

Conversation

eugene-babichenko
Copy link
Contributor

Resolves #785

@NicolasDP NicolasDP requested a review from a team November 21, 2019 15:59
@NicolasDP NicolasDP added enhancement New feature or request A-jormungandr Area: Issues affecting jörmungandr labels Nov 21, 2019
Copy link
Contributor

@NicolasDP NicolasDP left a comment

Choose a reason for hiding this comment

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

Looking good. Could you make this a new module in the setting directory? That will improve readability.

@NicolasDP NicolasDP self-assigned this Nov 21, 2019
@NicolasDP NicolasDP added the DO NOT MERGE not to be merged until something else is done label Nov 21, 2019
@NicolasDP
Copy link
Contributor

We cannot use that changes yet as we need to remove the need to use the trusted peers node id first.

impl std::str::FromStr for TrustedPeer {
type Err = String;
fn from_str(s: &str) -> Result<Self, Self::Err> {
let mut split = s.split('@');
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure we need to make an official microformat for this.

.filter_map(|tp| {
tp.address.to_addresses().ok().map(|addrs| {
addrs.into_iter().map(move |addr| TrustedPeer {
id: tp.id.clone(),
Copy link
Contributor

Choose a reason for hiding this comment

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

Umm, do we have provisions elsewhere for the duplicated peer entries?
These are going to overwrite each other in PeerMap. To do it properly, there should be a "happy eyeballs" style async connection routine for a single peer, racing up to two connection trains – one going through a shuffled list of IPv4 addresses, the other through IPv6 – but only to the point where one connects on TCP, then the other needs to be discarded and the protocol handshake with subscriptions should proceed on the winning connection.

Provisions may need to be made in network-grpc to enable two-stage connections.

Copy link
Contributor

Choose a reason for hiding this comment

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

OK, maybe happy eyeballs is a little overkill as there is not much interactive difference in how many milliseconds it takes to establish a connection. So shuffle the list of all addresses for a single peer and go through them with TCP connection attempts until one succeeds, that would do it.

Copy link
Contributor

Choose a reason for hiding this comment

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

Even better perhaps, we could let hyper deal with DNS addresses because we give it an URL to connect to.

Copy link
Contributor

Choose a reason for hiding this comment

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

How much headache would it be to implement DNSSEC signature validation within Jormungandr and WARN if provided FQDN is not signed? Seems (I checked just three) Rust libraries do not support DNSSEC validation, does hyper rely on OS DNS resolver or a Rust library outside of the OS?

Copy link
Contributor

Choose a reason for hiding this comment

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

hyper supports custom resolvers, and previous commits on this branch used trust-dns-resolver which supports DNSSec. @eugene-babichenko @NicolasDP what do you think of re-integrating it back, either in this form or hooking into hyper?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Umm, do we have provisions elsewhere for the duplicated peer entries?

No, and actually this is my main concern about this pull request which I discussed with @NicolasDP. The correct approach is testing IPs until we find a reachable one and then just go for that address. But we must do it right after we got the whole list of addresses, because we also need to feed the node data to poldercast. We can rework poldercast crate a bit though to make it able to accept DNS instead of bare IPs.

Even better perhaps, we could let hyper deal with DNS addresses because we give it an URL to connect to.

If the whole network stuff including gossiping is done via hyper (that's what I can see from the code), I think it's totally fine.

what do you think of re-integrating it back, either in this form or hooking into hyper?

The whole point of the last commit was to remove an additional dependency, but I feel like we will return if want to support DNSSEC. I'm more into hooking that stuff into hyper, just because it sounds way more elegant.

To sum everything up, my approach would be to allow using DNS just everywhere in the code. Let's say, make it a first-class citizen along with the IPs. But this may require some modification of external dependencies, specifically poldercast.

_ => None,
})
.collect(),
Some(AddrComponent::DNS6(fqdn)) => format!("{}:{}", fqdn, port)
Copy link
Contributor

Choose a reason for hiding this comment

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

It's... weird that multiaddr does not support just dns/ which would resolve both A and AAAA records. Which seems to be what's going to happen under the hood anyway, except that you discard the addresses of the wrong type.

Copy link
Contributor

Choose a reason for hiding this comment

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

Converting from multiaddr to an FQDN URL for hyper, as per #1164 (comment), would erase the IP address preference, so I'm not sure what would be more proper here.

Copy link
Contributor

@mzabaluev mzabaluev Nov 22, 2019

Choose a reason for hiding this comment

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

Theoretically, HttpConnector::set_local_address in hyper can be used to restrict connections to IPv4 or IPv6, but I'm not sure it works with hyper's internal resolver.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Either approach requires us to make the whole system treat FQDNs the same way as IPs and probably bring everything to network-grpc (see #1164 (comment)).

}

impl TrustedAddress {
pub fn to_addresses(&self) -> Result<Vec<Address>, AddressError> {
Copy link
Contributor

Choose a reason for hiding this comment

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

Please add a prominent (doc) comment notice that a blocking network resolver roundtrip happens here, so that we remember to avoid calling this in async code.

@mzabaluev
Copy link
Contributor

We cannot use that changes yet as we need to remove the need to use the trusted peers node id first.

We still need some way to identify a node with multiple IP addresses, including the corner cases when we receive its information from gossip with a different, maybe partially overlapping, set of addresses. Any of the old IP addresses may be taken over by other, logically different nodes, so I'm not sure intersecting on any IP address would give you a moral right to put it under the same node entry and reuse the connection.

@mark-stopka
Copy link
Contributor

We cannot use that changes yet as we need to remove the need to use the trusted peers node id first.

We still need some way to identify a node with multiple IP addresses, including the corner cases when we receive its information from gossip with a different, maybe partially overlapping, set of addresses. Any of the old IP addresses may be taken over by other, logically different nodes, so I'm not sure intersecting on any IP address would give you a moral right to put it under the same node entry and reuse the connection.

That's what was good on the initial private key, public key design, now when node_id is just a random string, anybody can replicate someone else's node_id.

Copy link
Contributor

@mzabaluev mzabaluev left a comment

Choose a reason for hiding this comment

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

@mark-stopka We are still debating the correct approach with node IDs and their authentication and whether they are worth having at all.

@eugene-babichenko
Copy link
Contributor Author

closing this in favor of #2193

@NicolasDP NicolasDP deleted the trusted-peers-dns branch May 16, 2020 07:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-jormungandr Area: Issues affecting jörmungandr DO NOT MERGE not to be merged until something else is done enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Trusted peers should accept DNS name
4 participants