-
Notifications
You must be signed in to change notification settings - Fork 996
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
protocols/relay: Implement circuit relay v2 protocol #2059
Conversation
This commit adds an implementation for the circuit relay v2 protocol to be used as a relay server, i.e. it supports incoming HOP requests and outgoing STOP requests. Future commits will add support for clients, i.e. outgoing HOP requests and incoming STOP requests. The existing circuit relay v1 protocol implementation is moved to protocols/relay/src/v1.
See libp2p/specs#384 for corresponding specification change.
@thomaseizinger @elenaf9 @MarcoPolo if I am not mistaken I addressed all comments. Any other suggestions from your side? |
Unless there are any further suggestions, I will merge here tomorrow. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I took another pass at this, and it looks great! Excited to see this in. I had two comments but they are small nit/question. Feel free to ignore or do in a separate PR.
assert!(pool.run_until(wait_for_dial(&mut client, relay_peer_id))); | ||
|
||
client.listen_on(client_addr.clone()).unwrap(); | ||
pool.run_until(wait_for_reservation( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't exactly check that it resuses the connection right? Should this instead use a modified version of wait_for_reservation
that panics if it tries dialing/connectionestablished?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nicely spotted. Thanks. Fixed with 80a9e76.
} | ||
|
||
self.queued_events.push_back(ProtocolsHandlerEvent::Custom( | ||
Event::OutboundCircuitEstablished { limit }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you still want to push this event if the send_back.send
failed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point. Fixed in b1cb684.
Wow, 232 comments. Definitely a record for me. Thank you all for the help on this effort! The many thorough reviews really show the power of open source. ❤️ |
This commit adds an implementation for the circuit relay v2 protocol to be used as a relay server, i.e. it supports incoming HOP requests and outgoing STOP requests and used as a relay clients, i.e. outgoing HOP requests and incoming STOP requests. The existing circuit relay v1 protocol implementation is moved to protocols/relay/src/v1. Co-authored-by: ronzigelman <[email protected]> Co-authored-by: Marco Munizaga <[email protected]> Co-authored-by: Thomas Eizinger <[email protected]> Co-authored-by: Elena Frank <[email protected]>
This pull request adds an implementation for the circuit relay v2 protocol to be used as a relay server and client, i.e. it supports incoming/outgoing HOP requests and incoming/outgoing STOP requests. The circuit relay v2 protocol is an integral part of Project Flare - bringing NAT / Firewall hole punching to libp2p.
You can find an example in
protocols/relay/examples/relay_v2.rs
and a full relay server implementation in https://github.com/mxinden/rust-libp2p-relay-server.The existing circuit relay v1 protocol implementation is moved to
protocols/relay/src/v1
.