feat: specify a DERP region for the peer you are trying to connect to#1222
Conversation
|
I think I would choose b. If we don't know the DERP region in our config we might still be able to connect directly to it, it may not even need holepunching at all. If we do not have any direct address and can not reach the peer's home derp server [0] then we'd have to return either a [0] Also, I think not knowing the derp server in our own config might be equivalent to the lightly broader "can not reach that derp server" which we also have to handle anyway. |
|
I think we should require at least a derp region or a UDP address, if neither is provided we don't have any chance of connecting and should fail fast. |
Okay, so if we have no UDP addresses, and no derp server OR if that derp server is not one we have in configuration we error. (no UDP && ( no DERP || unknown DERP )) -> error However, once we attempt to dial in the I'm going to move forward on this PR with the following scenarios in mind:
|
1c1cbfd to
8c6c051
Compare
|
I can't believe I did this, but I added a lock 😢 😢 😢 Now that If there is a strong feeling about this, PLEASE FEEL FREE TO CHANGE IT BACK. EDIT: |
my_derp and add_known_addrs|
Okay, I need to put this down for the night, but the Otherwise everything is implemented. You can test your ping to the DERP regions using: You can explicitly fetch via DERP only by passing in a derp region ID using the And you can also see that providing a region is essential if you are trying to hole punch by explicitly putting in the "wrong" region when you attempt to |
| /// Hostname of the default Derp. | ||
| pub const DEFAULT_DERP_HOSTNAME: &str = "derp.iroh.network"; | ||
| /// Hostname of the default NA Derp. | ||
| pub const DEFAULT_NA_DERP_HOSTNAME: &str = "derp.iroh.network"; |
There was a problem hiding this comment.
@Arqu can we get this to be sth like na1. or similar?
|
At @ramfox's request I've run the test suite on windows, and run provide from a windows machine to a mac. While running the test suite I received two "allow this to happen" requests from the windows firewall, which I said yes to. Test suite passed, transfer worked. |
Add `my_derp` (so we can display our own home derp) and adjust `add_known_addrs` to include a `region_id` in the `MagicEndpoint`. Adjusts the `region_id` to be `Option<u16>` in the `hp` code, allowing for `None` if we do not have a derp home region Allows a region id of `0` to be valid
connects to each region in specified in the configuration and reports either the latency of that region or an error
965a70b to
b960db3
Compare
b960db3 to
6ed4527
Compare
f972366 to
6ed4527
Compare
comment out multiple `test_mesh_network` runs until further investigation
dignifiedquire
left a comment
There was a problem hiding this comment.
Generally looks good to me, except the dialing restrictions, we should figure those out to make sure things still work.
| self.outstanding_tasks.hairpin = true; | ||
| if !self.hairpin_actor.has_started() { | ||
| self.hairpin_actor.start_check(*addr); | ||
| self.outstanding_tasks.hairpin = true; |
There was a problem hiding this comment.
I guess booleans were too simple to keep track of this state. 😞 I knew I wasn't quite happy with how this state was tracked.
Good call on pushing that state into the actor client. I like it so much I'd go even further and try and get rid of self.outstanding_tasks entirely in favour of tracking the state in the tasks themselves. But that's for another PR.
|
|
||
| A peer may be connected to multiple regions, but it will advertise its home region as the one best used to hole-punch or relay packets through. | ||
|
|
||
| When attempting to connect to another peer, it is not required to pass in that peer’s DERP region, but if the other peer is behind a NAT, the only way to attempt to hole punch directly through to it is by passing down a DERP region. It is also possible that the DERP region that the remote Iroh peer is connected to is one that you have no dialing information about. However, that is unlikely to happen if you use the default regions and nodes we have specified here. These also exist as defaults in the code. |
There was a problem hiding this comment.
This is difficult to understand... but I have no suggestions on how to improve it 😅
I think what you're trying to say is that for any direct connection establishment knowing the peer's home derp region is not needed. But if you need holepunching then you need to be aware of the peer's home derp server?
| stun_only: false, | ||
| stun_port: 3478, | ||
| ipv4: UseIpv4::Some(std::net::Ipv4Addr::new(35, 175, 99, 113)), | ||
| ipv6: UseIpv6::TryDns, |
There was a problem hiding this comment.
I wonder how we'll notice to update the docs when we change this config format.
(I only do so because I just broke things by making a change to this format)
| addr: "[::]:443".parse().unwrap(), | ||
| stun_port: DEFAULT_DERP_STUN_PORT, | ||
| hostname: DEFAULT_DERP_HOSTNAME.into(), | ||
| hostname: NA_DERP_HOSTNAME.into(), |
There was a problem hiding this comment.
lol, i read this as "Not Available derp hostname" initially...
| /// Probe indicating the presence of port mapping protocols on the LAN. | ||
| pub portmap_probe: Option<portmapper::ProbeOutput>, | ||
| /// or 0 for unknown | ||
| /// `0` for unknown |
There was a problem hiding this comment.
also would love to turn this into an option
…#1222) * pass down a `derp_region` when we connect to a peer: add `my_derp` (so we can display our own home derp) and adjust `add_known_addrs` to include a `region_id` in the `MagicEndpoint`. * add `iroh doctor derp-regions` command: connects to each region in specified in the configuration and reports either the latency of that region or an error * update cli commands to include a `derp_region` where necessary * add derp region docs * pr review fixes * fix: stable sorting for regions * fix hairpin bug causing probe to never finish * comment out multiple `test_mesh_network` runs until further investigation on flakeyness * upgrade yanked dependency --------- Co-authored-by: dignifiedquire <me@dignifiedquire.com>
Description
closes #1221
closes #1073
Notes & open questions
what happens if the peer you want to talk to is in a region you do not understand?
Hi, I've been going back and forth a few times with this. Can I get some feedback.
Now that we have multiple derp regions, it's possible that the regions you have configured are NOT the region that the node you are trying to communicate is in.
So, how should we handle the case where we cannot connect to that specific derp region?
a) When we add a peer to our address book, the derp region is required (along with the PublicKey & ALPNs), and we check our DERP configuration. If we don't have that derp region in our configuration, we fail when we attempt to add that peer to our address book. In this case, we won't ever attempt to dial the peer if no DERP region is provided or the DERP region provided does not exist in our configuration, even if we have a valid UDP connection
b) We do not require a derp region when you add a peer to the address book and we don't check if any derp region provided exists in our configuration. If no UDP address nor DERP region exists when we go to connect, we log a warning, but fail silently. Whatever timeouts exist on QUIC will timeout when no connection can be made. If you don't have logging, you will not understand why this failed.
c) You are not required to provide a DERP region, but if you DO, we will fail if that derp region does not exist in our configuration. The implication here is that if you have provided a DERP region, you expect hole punching to occur, and it is an error if you cannot attempt to hole punch in the current conditions. If you do NOT provide a derp region, you are accepting that hole punching is not possible or you have some outside information that the UDP addresses are accessible.
This last one seems like the best option to me & it's how I am planning to continue with the PR, but would love some feedback.
region 0Currently,region_id1 is expected to be NA, andregion_id2 is expected to be EU. This is currently only documented here: https://www.notion.so/number-zero/Derp-Regions-a63c309839e64d9ab19c23778a7b9c37We also have a bit of a testing problem. Since the region_ids should be standardized, it seems we should leave the id 0 as a testing id.impl From<Url> for DerpMapNow that it is we have the possibility of multiple regions, we can no longer assume the default region id for any given
Url, so we can no longer implementFromonDerpMapforUrlChange checklist