Skip to content
New issue

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

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

Already on GitHub? # to your account

STUN support #26

Merged
merged 5 commits into from
Jun 4, 2021
Merged

STUN support #26

merged 5 commits into from
Jun 4, 2021

Conversation

carver
Copy link
Collaborator

@carver carver commented May 27, 2021

Closes #23

  • Bind against 0.0.0.0 instead of loopback: Binding to 127.0.0.1 prevents messages from properly sending to a non-loopback address
  • Use external STUN server to populate IP & port in the initial ENR
  • If STUN check fails, pick a local IP addr for the ENR. That way, you can use the encoded ENR immediately from another (local network) peer

@carver carver changed the title Stun support STUN support May 28, 2021
Copy link
Member

@g-r-a-n-t g-r-a-n-t left a comment

Choose a reason for hiding this comment

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

just linked a few helpful functions

@carver carver force-pushed the stun-support branch 2 times, most recently from ecd3be7 to 6b6ecad Compare May 28, 2021 22:41
@carver
Copy link
Collaborator Author

carver commented May 28, 2021

@SamWilsn would you mind taking a look at this too?

Cargo.toml Outdated
@@ -14,12 +14,14 @@ env_logger = "0.8.2"
eth2_ssz = "0.1.2"
eth2_ssz_derive = "0.1.0"
futures = "0.3.13"
get_if_addrs = "0.5.3"
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm worried that this hasn't been updated in some time. Some alternatives might be heim or interfaces. I think heim is more mature.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I got stuck on getting async working with heim. If you feel like pairing with me to fix it, that would be cool. Otherwise, I've got an implementation with interfaces ready to go in c2a564c.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm fine with interfaces if you are, but I'm okay with pairing too. I think you'll want to do something like:

use futures_util::stream::TryStreamExt;

let ifaces: Result<Vec<_>, _> = heim::net::nic().try_collect().await;

I'd actually have to sit down and give it a go though.

@carver carver force-pushed the stun-support branch 2 times, most recently from 51222da to cf3e942 Compare June 2, 2021 00:18
carver added 5 commits June 4, 2021 13:20
Binding to 127.0.0.1 prevents messages from properly sending to a
non-loopback address.
This makes it easier to connect two peers locally if global connection
is unavailable.
get_if_addrs is probably abandoned, based on lack of changes for more
than 3 years.
@carver carver merged commit b11bfff into master Jun 4, 2021
@carver carver deleted the stun-support branch June 4, 2021 20:41
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Use STUN server to speed up the external socket address discovery
3 participants