-
Notifications
You must be signed in to change notification settings - Fork 951
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
Merged
Merged
Changes from all commits
Commits
Show all changes
129 commits
Select commit
Hold shift + click to select a range
3bd6602
protocols/relay: Implement circuit relay v2 protocol
mxinden 125e3c3
misc/multistream-select: Ignore simultaneous open 'iamclient'
mxinden 4281bd5
protocols/relay: Ensure connections of HOP connect are kept alive
mxinden 778512d
protocols/relay: Improve documentation
mxinden dfe1285
protocols/relay: Implement v2 client logic
mxinden ca19fe4
Merge branch 'libp2p/master' into relay-v2
mxinden 59c8741
protocols/relay: Handle dial failure
mxinden 54cc9db
protocols/relay: Reuse connection
mxinden 8e7b6a0
protocols/relay: Rename Connection to RelayedConnection
mxinden a1589cc
protocols/relay: Update transport doc examples
mxinden 4af855e
protocols/relay: Pass relay addr to transport
mxinden 8934664
protocols/relay: Implement inbound stop denial
mxinden 79fd6be
protocols/relay: Renew reservations
mxinden 0ed3153
protocols/relay: Handle invalid expiration in the past
mxinden 1318636
protocols/relay: Handle in and outbound failure
mxinden 5df655e
protocols/relay: Implement client handler keep alive
mxinden 643ffb0
protocols/relay: Handle handler listener closed channel
mxinden 570980d
protocols/relay: Handle handler to listener failure
mxinden 037a398
protocols/relay: Return all new listener addresses
mxinden 806fd93
protocols/relay/v2: Update to latest protobuf definition
mxinden 5b170d7
Merge branch 'libp2p/master' into relay-v2
mxinden 1723e92
Revert "misc/multistream-select: Ignore simultaneous open 'iamclient'"
mxinden cfcb810
Merge branch 'libp2p/master' into relay-v2
mxinden ea53ad7
protocols/relay/v2: Report back to transport
mxinden 599aa09
protocols/relay/v2: Disconnect when stop protocol not supported
mxinden 0b8d54c
protocols/relay/v2: Document max_duration not exceed u32::MAX
mxinden 3082efb
protocols/relay/v2: Don't append p2p-circuit as relay
mxinden 5f073c6
protocols/relay/v2: Implement rate limiter
mxinden fdacc1b
protocols/relay/v2: Document caveats on rate limiter with high volume
mxinden 93f0979
protocols/relay: Prevent possible false positive in quickcheck
mxinden 334ffc6
protocols/relay: Reword Prost error message
mxinden 8803bd0
protocols/relay: Allow users to specify generic rate limiters
mxinden c51f9e2
protocols/relay: Move rate limiting logic into module
mxinden 8777d70
protocols/relay: Prevent reservation and connection over relayed conn
mxinden 4e5f99d
protocols/relay: Add circuit src rate limiting
mxinden d55a5b9
protocols/relay/v2: Simplify example
mxinden e5f63bc
protocols/relay: Add myself to authors
mxinden f8d0047
protocols/relay: Use thiserror
mxinden 55dd0a2
protocols/relay/v2: Set rate limits
mxinden 7e11439
Merge branch 'libp2p/master' into relay-v2
mxinden 126f971
protocols/relay: Use wasm_timer::Instant
mxinden 75f5616
protocols/relay/v2: Apply clippy suggestions
mxinden 6dc961a
protocols/relay: Fix intra doc link
mxinden 2ef7050
Merge branch 'libp2p/master' into relay-v2
mxinden b07257d
Merge branch 'libp2p/master' into relay-v2
mxinden 31f8424
protocols/relay: Fix clippy warnings
mxinden 8dc98bf
Merge branch 'libp2p/master' into relay-v2
mxinden cfa459d
Merge branch 'libp2p/master' into relay-v2
mxinden 7e51e54
Merge branch 'libp2p/master' into relay-v2
mxinden 832f069
Merge branch 'libp2p/master' into relay-v2
mxinden 2c79813
misc/metrics: Add basic instrumentation for libp2p-relay
mxinden fa82385
Merge branch 'libp2p/master' into relay-v2
mxinden d51fa72
protocols/relay: Return NetworkBehaviourAction::NotifyHandler right away
mxinden c742335
protocols/relay: Run rust fmt
mxinden 0780206
Merge branch 'master' into relay-v2
mxinden 69b2fc1
protocols/relay/src/v2/relay: Accept mutable config
mxinden 580f668
protocols/relay/examples: Structure command line args
r-zig 7c9f3bc
protocols/relay/src/v2/client: Return NetworkBehaviourAction on Liste…
mxinden ad79422
Refactor suggestion
MarcoPolo 517075d
protocols/relay/src/v2/client/handler: Check status of lend out subst…
mxinden da7f5e4
protocols/relay/src/v2/client: Use void::Void for drop_notifer
mxinden 45163df
protocols/relay/src/v2/client/handler: Log dropped oneshot Sender to …
mxinden 1d20392
protocols/relay/src/v2/client/handler: Await send call to transport l…
mxinden 395f43a
protocols/relay/src/v2/client/handler: Remove unnecessary boxing
mxinden 2de96d6
Merge branch 'libp2p/master' into relay-v2
mxinden c0c0880
protocols/relay/src/v2/client: Extend unreacheable! text
mxinden 746c75e
protocols/relay/src/v2/: Document pending_error and send_error_futs
mxinden 08d6637
protocols/relay/src/v2: Use OrTransport
mxinden bfd92a1
protocols/relay/src/v2: Fix typo
mxinden a60ffba
protocols/relay/src/v2: Renew reservation after 3/4 of expiration
mxinden 1123952
protocols/relay/v2: Use AcceptReservationReqBuilder concept
mxinden 1af928a
protocols/relay: Capitalize I in NoAddressesInReservation
mxinden a9d9b41
misc/metrics: Derive Debug for event types
mxinden a8f21ae
protocols/relay/src/v2/client/handler: Consistent mpsc and oneshot im…
mxinden daa0686
protocols/relay/src/v2/client/transport: Loop on from_behaviour
mxinden 8856fde
protocols/relay: Fix intra doc link
mxinden a1fad8c
protocols/relay/: Allow large enum variant
mxinden 5d9f95a
protocols/relay/src/v2/client/transport: Remove destination address
mxinden eaab34e
protocols/relay/src/v2: Don't override NetworkBehaviour methods with …
mxinden 26aaa6e
protocols/relay/src/v2/client: Pass event at handler initialization
mxinden 49a6327
protocols/relay/src/v2: Use lent instead of lend
mxinden 2e4e743
protocols/relay/v2: Use Renewing instead of Renewal
mxinden bce3ba0
protocols/relay/src/v2/client: Introduce Reservation::None
thomaseizinger 01e12f7
protocols/relay/src/v2: Fix intra doc link
mxinden b1646f4
Merge branch 'libp2p/master' into relay-v2
mxinden 912d314
protocols/relay/src/v2/client/handler: Inject event at creation time
mxinden dbfe25b
protocols/relay/src/v2/client/handler: Refactor Reservation::poll
MarcoPolo c09861b
protocols/relay/src/v2/client/handler.rs: Fix typo
mxinden 5afa13b
protocols/relay/src/v2/client/transport.rs: Make doc examples consistent
mxinden 9a0f886
protocols/relay/src/v2: Stress required usage of other Transport
mxinden a15bf3d
protocols/relay/src/v2/protocol/inbound_stop.rs: Remove src_peer_id p…
mxinden 7b2eeb5
protocols/relay/src/v2/relay/handler: Remove wrong unused variable as…
mxinden 8e6ce38
protocols/relay/src/v2/client: Garbage collect unconnected nodes
mxinden 451d86c
protocols/relay/src/v2: Prevent nested relay on incoming relayed conn
mxinden a0750ef
protocols/relay/tests/v2: Test new reservation replacing old
mxinden 4b90626
protocols/relay/src/v2: Close listener when channel from behaviour dr…
mxinden 45f7e21
protocols/relay/src/v2: Expose connection limit via OutEvent
mxinden 1b5cb8e
protocols/relay/v2: Use Option::transpose
mxinden 2f5b8e6
protocols/relay/src/v2: Rework outbound_hop error types
mxinden a056b4b
protocols/relay/src/v2/client: Queue Event and not Action
mxinden 7a4cf0a
protocols/relay/src/v2/client: Remove loop in NetworkBehaviour::poll
mxinden ed79c72
protocols/relay/src/v2/client/: Refactor parse_relayed_multiaddr
mxinden 0b6aca3
protocols/relay/src/v2: Use ready! in RelayListener as Stream
mxinden 0e17512
protocols/relay/src/v2: Remove unnecessary else
mxinden be9b94e
protocols/relay/src/v2/protocol: Use Vec::with_capacity
mxinden b9eb0f0
protocols/relay/src/v2: Separate error paths and happy path
mxinden 93691a8
protocols/relay/src/v2/copy_future.rs: Add unit tests
mxinden 0cdb1b6
protocols/relay/src/v2/relay: Remove unnecessary unwrap_or
mxinden b68f5a2
Merge remote-tracking branch 'libp2p/master' into relay-v2
mxinden 040909e
protocols/relay/src/v2: Use ConnectedPoint::is_relayed
mxinden d5ee477
protocols/relay/src/v2: Make reservation expiration required
mxinden 3627610
protocols/relay/src/v2: Refactor inbound_stop error handling
mxinden 9a4ad18
protocols/relay/src/v2: Refactor outbound_stop error handling
mxinden 2aa6e94
protocols/relay/src/v2: Refactor inbound_hop error handling
mxinden 6916384
misc/metrics/src/relay: Update to error handling refactoring
mxinden 8aa3867
Separate control flow as much as possible
thomaseizinger ca5aaed
protocols/relay/src/v2: Implement max_reservations_per_peer
mxinden 48f7f68
protocols/relay/src/v2: Implement max_circuits_per_peer
mxinden 58daa47
protocols/relay/src/v2: Deny duplicate reservation denial
mxinden 00c98d5
Merge branch 'libp2p/master' into relay-v2
mxinden 14e7912
Merge branch 'mxinden/relay-v2' into relay-v2-refactor-error
mxinden 3f8e772
protocols/relay/src/v2: Use DummyProtocolsHandler on relayed connection
mxinden b6dbf82
Merge branch 'libp2p/master' into relay-v2
mxinden 80a9e76
protocols/relay/tests/v2: Use wait_for_dial to ensure connection reuse
mxinden b1cb684
protocols/relay/: Only emit CircuitEstablished when transport notified
mxinden 4212777
Merge branch 'libp2p/master' into relay-v2
mxinden 00dbcc8
protocols/relay-src/v2: Fix Rust fmt complaint
mxinden 56ce0a3
Merge branch 'master' into relay-v2
mxinden ab619c9
Merge branch 'master' into relay-v2
mxinden File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
// Copyright 2021 Protocol Labs. | ||
// | ||
// Permission is hereby granted, free of charge, to any person obtaining a | ||
// copy of this software and associated documentation files (the "Software"), | ||
// to deal in the Software without restriction, including without limitation | ||
// the rights to use, copy, modify, merge, publish, distribute, sublicense, | ||
// and/or sell copies of the Software, and to permit persons to whom the | ||
// Software is furnished to do so, subject to the following conditions: | ||
// | ||
// The above copyright notice and this permission notice shall be included in | ||
// all copies or substantial portions of the Software. | ||
// | ||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS | ||
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | ||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | ||
// DEALINGS IN THE SOFTWARE. | ||
|
||
use open_metrics_client::encoding::text::Encode; | ||
use open_metrics_client::metrics::counter::Counter; | ||
use open_metrics_client::metrics::family::Family; | ||
use open_metrics_client::registry::Registry; | ||
|
||
pub struct Metrics { | ||
events: Family<EventLabels, Counter>, | ||
} | ||
|
||
impl Metrics { | ||
pub fn new(registry: &mut Registry) -> Self { | ||
let sub_registry = registry.sub_registry_with_prefix("relay"); | ||
|
||
let events = Family::default(); | ||
sub_registry.register( | ||
"events", | ||
"Events emitted by the relay NetworkBehaviour", | ||
Box::new(events.clone()), | ||
); | ||
|
||
Self { events } | ||
} | ||
} | ||
|
||
#[derive(Debug, Clone, Hash, PartialEq, Eq, Encode)] | ||
struct EventLabels { | ||
event: EventType, | ||
} | ||
|
||
#[derive(Debug, Clone, Hash, PartialEq, Eq, Encode)] | ||
enum EventType { | ||
ReservationReqAccepted, | ||
ReservationReqAcceptFailed, | ||
ReservationReqDenied, | ||
ReservationReqDenyFailed, | ||
ReservationTimedOut, | ||
CircuitReqReceiveFailed, | ||
CircuitReqDenied, | ||
CircuitReqDenyFailed, | ||
CircuitReqOutboundConnectFailed, | ||
CircuitReqAccepted, | ||
CircuitReqAcceptFailed, | ||
CircuitClosed, | ||
} | ||
|
||
impl From<&libp2p_relay::v2::relay::Event> for EventType { | ||
fn from(event: &libp2p_relay::v2::relay::Event) -> Self { | ||
match event { | ||
libp2p_relay::v2::relay::Event::ReservationReqAccepted { .. } => { | ||
EventType::ReservationReqAccepted | ||
} | ||
libp2p_relay::v2::relay::Event::ReservationReqAcceptFailed { .. } => { | ||
EventType::ReservationReqAcceptFailed | ||
} | ||
libp2p_relay::v2::relay::Event::ReservationReqDenied { .. } => { | ||
EventType::ReservationReqDenied | ||
} | ||
libp2p_relay::v2::relay::Event::ReservationReqDenyFailed { .. } => { | ||
EventType::ReservationReqDenyFailed | ||
} | ||
libp2p_relay::v2::relay::Event::ReservationTimedOut { .. } => { | ||
EventType::ReservationTimedOut | ||
} | ||
libp2p_relay::v2::relay::Event::CircuitReqReceiveFailed { .. } => { | ||
EventType::CircuitReqReceiveFailed | ||
} | ||
libp2p_relay::v2::relay::Event::CircuitReqDenied { .. } => EventType::CircuitReqDenied, | ||
libp2p_relay::v2::relay::Event::CircuitReqOutboundConnectFailed { .. } => { | ||
EventType::CircuitReqOutboundConnectFailed | ||
} | ||
libp2p_relay::v2::relay::Event::CircuitReqDenyFailed { .. } => { | ||
EventType::CircuitReqDenyFailed | ||
} | ||
libp2p_relay::v2::relay::Event::CircuitReqAccepted { .. } => { | ||
EventType::CircuitReqAccepted | ||
} | ||
libp2p_relay::v2::relay::Event::CircuitReqAcceptFailed { .. } => { | ||
EventType::CircuitReqAcceptFailed | ||
} | ||
libp2p_relay::v2::relay::Event::CircuitClosed { .. } => EventType::CircuitClosed, | ||
} | ||
} | ||
} | ||
|
||
impl super::Recorder<libp2p_relay::v2::relay::Event> for super::Metrics { | ||
fn record(&self, event: &libp2p_relay::v2::relay::Event) { | ||
self.relay | ||
.events | ||
.get_or_create(&EventLabels { | ||
event: event.into(), | ||
}) | ||
.inc(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,152 @@ | ||
// Copyright 2020 Parity Technologies (UK) Ltd. | ||
// Copyright 2021 Protocol Labs. | ||
// | ||
// Permission is hereby granted, free of charge, to any person obtaining a | ||
// copy of this software and associated documentation files (the "Software"), | ||
// to deal in the Software without restriction, including without limitation | ||
// the rights to use, copy, modify, merge, publish, distribute, sublicense, | ||
// and/or sell copies of the Software, and to permit persons to whom the | ||
// Software is furnished to do so, subject to the following conditions: | ||
// | ||
// The above copyright notice and this permission notice shall be included in | ||
// all copies or substantial portions of the Software. | ||
// | ||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS | ||
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | ||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | ||
// DEALINGS IN THE SOFTWARE. | ||
|
||
use futures::executor::block_on; | ||
use futures::stream::StreamExt; | ||
use libp2p::core::upgrade; | ||
use libp2p::identify::{Identify, IdentifyConfig, IdentifyEvent}; | ||
use libp2p::multiaddr::Protocol; | ||
use libp2p::ping::{Ping, PingConfig, PingEvent}; | ||
use libp2p::relay::v2::relay::{self, Relay}; | ||
use libp2p::swarm::{Swarm, SwarmEvent}; | ||
use libp2p::tcp::TcpConfig; | ||
use libp2p::Transport; | ||
use libp2p::{identity, NetworkBehaviour, PeerId}; | ||
use libp2p::{noise, Multiaddr}; | ||
use std::error::Error; | ||
use std::net::{Ipv4Addr, Ipv6Addr}; | ||
use structopt::StructOpt; | ||
|
||
fn main() -> Result<(), Box<dyn Error>> { | ||
env_logger::init(); | ||
|
||
let opt = Opt::from_args(); | ||
println!("opt: {:?}", opt); | ||
|
||
// Create a static known PeerId based on given secret | ||
let local_key: identity::Keypair = generate_ed25519(opt.secret_key_seed); | ||
let local_peer_id = PeerId::from(local_key.public()); | ||
println!("Local peer id: {:?}", local_peer_id); | ||
|
||
let tcp_transport = TcpConfig::new(); | ||
|
||
let noise_keys = noise::Keypair::<noise::X25519Spec>::new() | ||
.into_authentic(&local_key) | ||
.expect("Signing libp2p-noise static DH keypair failed."); | ||
|
||
let transport = tcp_transport | ||
.upgrade(upgrade::Version::V1) | ||
.authenticate(noise::NoiseConfig::xx(noise_keys).into_authenticated()) | ||
.multiplex(libp2p_yamux::YamuxConfig::default()) | ||
.boxed(); | ||
|
||
let behaviour = Behaviour { | ||
relay: Relay::new(local_peer_id, Default::default()), | ||
ping: Ping::new(PingConfig::new()), | ||
identify: Identify::new(IdentifyConfig::new( | ||
"/TODO/0.0.1".to_string(), | ||
local_key.public(), | ||
)), | ||
}; | ||
|
||
let mut swarm = Swarm::new(transport, behaviour, local_peer_id); | ||
|
||
// Listen on all interfaces | ||
let listen_addr = Multiaddr::empty() | ||
.with(match opt.use_ipv6 { | ||
Some(true) => Protocol::from(Ipv6Addr::UNSPECIFIED), | ||
_ => Protocol::from(Ipv4Addr::UNSPECIFIED), | ||
}) | ||
.with(Protocol::Tcp(opt.port)); | ||
swarm.listen_on(listen_addr)?; | ||
|
||
block_on(async { | ||
loop { | ||
match swarm.next().await.expect("Infinite Stream.") { | ||
SwarmEvent::Behaviour(Event::Relay(event)) => { | ||
println!("{:?}", event) | ||
} | ||
SwarmEvent::NewListenAddr { address, .. } => { | ||
println!("Listening on {:?}", address); | ||
} | ||
_ => {} | ||
} | ||
} | ||
}) | ||
} | ||
|
||
#[derive(NetworkBehaviour)] | ||
#[behaviour(out_event = "Event", event_process = false)] | ||
struct Behaviour { | ||
relay: Relay, | ||
ping: Ping, | ||
identify: Identify, | ||
} | ||
|
||
#[derive(Debug)] | ||
enum Event { | ||
Ping(PingEvent), | ||
Identify(IdentifyEvent), | ||
Relay(relay::Event), | ||
} | ||
|
||
impl From<PingEvent> for Event { | ||
fn from(e: PingEvent) -> Self { | ||
Event::Ping(e) | ||
} | ||
} | ||
|
||
impl From<IdentifyEvent> for Event { | ||
fn from(e: IdentifyEvent) -> Self { | ||
Event::Identify(e) | ||
} | ||
} | ||
|
||
impl From<relay::Event> for Event { | ||
fn from(e: relay::Event) -> Self { | ||
Event::Relay(e) | ||
} | ||
} | ||
|
||
fn generate_ed25519(secret_key_seed: u8) -> identity::Keypair { | ||
let mut bytes = [0u8; 32]; | ||
bytes[0] = secret_key_seed; | ||
|
||
let secret_key = identity::ed25519::SecretKey::from_bytes(&mut bytes) | ||
.expect("this returns `Err` only if the length is wrong; the length is correct; qed"); | ||
identity::Keypair::Ed25519(secret_key.into()) | ||
} | ||
|
||
#[derive(Debug, StructOpt)] | ||
#[structopt(name = "libp2p relay")] | ||
struct Opt { | ||
/// Determine if the relay listen on ipv6 or ipv4 loopback address. the default is ipv4 | ||
#[structopt(long)] | ||
use_ipv6: Option<bool>, | ||
|
||
/// Fixed value to generate deterministic peer id | ||
#[structopt(long)] | ||
secret_key_seed: u8, | ||
|
||
/// The port used to listen on all interfaces | ||
#[structopt(long)] | ||
port: u16, | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
no transport wrapper anymore? 👍
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.
The relay client and server in the
v2
implementation are split. This is the server side only. The server does not require a transport wrapper.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.
What is a transport wrapper? Looking at the examples gives me no clues
Edit:
To answer my question, the transport wrapper for the client side of the circuit v2 would be here: https://github.com/libp2p/rust-libp2p/blob/580f6688fd675c698ca918d44808915fa9bda914/protocols/relay/src/v2/client/transport.rs
It wraps the given transport and gives it the ability to do extra stuff. For example, a tcp_transport wouldn't know how to dial another client over a circuit V2 connection, but the wrapped transport adds this ability. It basically sees if the address to dial (or listen on) includes a relay portioned, if it does it does something specific to circuitV2 otherwise it defers to the inner transport.