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

auto-relay: automatically make reservations on relays as we discover them #4651

Open
thomaseizinger opened this issue Oct 15, 2023 · 8 comments

Comments

@thomaseizinger
Copy link
Contributor

Description

Today, a user of rust-libp2p can make a reservation on a relay by instructing the Swarm to listen_on a relayed address, i.e. one with /p2p-circuit in it.

We should develop a module similar to go-libp2ps AutoRelay that does this automatically as we connect to relays:

  • Upon a new connection, check the supported protocols on that connection for the relay "hop" protocol.
  • Based on some configuration (to be decided), conclude that we should make a new reservation.
  • Emit a ToSwarm::ListenOn command with a constructed /p2p-circuit address for the discovered relay.

Motivation

Give users a module they can drop into their Behaviour that automatically creates reservations as we connect to relays.

Requirements

  1. The number of reservations we make must be bounded by something, i.e. maximum 10. Should probably be configurable.
  2. We may want to make this conditional on our number of external addresses. If we don't have any external addresses, reservations will be useful because it means we are likely behind a NAT.

Open questions

No response

Are you planning to do it yourself in a pull request ?

No

@dariusc93
Copy link
Member

If this is to be automatic, I wonder if we should check the external addresses for any public addresses that isnt a relay circuit (either reported by upnp, autonat or some behaviour emitting the external address event) and either disconnect from the relays (could be configurable to stay connected?), or if the behaviour havent made a reservation to cancel or block any attempts.

@thomaseizinger
Copy link
Contributor Author

If this is to be automatic, I wonder if we should check the external addresses for any public addresses that isnt a relay circuit (either reported by upnp, autonat or some behaviour emitting the external address event) and either disconnect from the relays (could be configurable to stay connected?), or if the behaviour havent made a reservation to cancel or block any attempts.

Yeah, this is what I meant with:

  1. We may want to make this conditional on our number of external addresses. If we don't have any external addresses, reservations will be useful because it means we are likely behind a NAT.

We can easily track how many external address we have using ExternalAddresses. I think it is a good default to free up resources on relays if they are not needed.

@dariusc93
Copy link
Member

I may be interested in tackling this if nobody else does (also as time permits), but just as a question: Should this be apart of the current relay protocol or should this be its own crate?

@thomaseizinger
Copy link
Contributor Author

should this be its own crate?

We can implement this as its own module which I think might be cleaner. There is a fair bit of state tracking involved and the relay code is already quite complex so I think it is best to be separate.

@Techno-Fox
Copy link

I just want to know. Has there been any updates on this?

@dariusc93
Copy link
Member

Hey @Techno-Fox! I did start on it a bit last year but been busy. I may pick up on it in the next few weeks but if you (or anybody else) would like to start on it you are more than welcome :)

@Techno-Fox
Copy link

what did you want to change and or add to your version?

@silkroadnomad
Copy link

I'd need such right now.

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

No branches or pull requests

4 participants