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

DCUtR #4

Merged
merged 141 commits into from
Nov 25, 2021
Merged

DCUtR #4

merged 141 commits into from
Nov 25, 2021

Conversation

canewsin
Copy link

No description provided.

mxinden added 30 commits April 26, 2021 17:47
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.
From the multistream-select 1.0 simultaneous open protocol extension
specification:

> In order to support direct connections through NATs with hole
punching, we need to account for simultaneous open. In such cases, there
is no single initiator and responder, but instead both peers act as
initiators. This breaks protocol negotiation in multistream-select,
which assumes a single initator.

> This draft proposes a simple extension to the multistream protocol
negotiation in order to select a single initator when both peers are
acting as such.

See libp2p/specs#196 for details.

This commit implements the above specification, available via
`Version::V1SimOpen`.
@canewsin canewsin merged commit b6a8622 into decentnetwork:dcutr Nov 25, 2021
canewsin added a commit that referenced this pull request Dec 6, 2021
* DCUtR (#4)

* protocols/relay: Implement circuit relay v2 protocol

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.

* misc/multistream-select: Ignore simultaneous open 'iamclient'

* protocols/relay: Ensure connections of HOP connect are kept alive

* protocols/relay: Improve documentation

* misc/multistream-select: Implement simultaneous open extension

From the multistream-select 1.0 simultaneous open protocol extension
specification:

> In order to support direct connections through NATs with hole
punching, we need to account for simultaneous open. In such cases, there
is no single initiator and responder, but instead both peers act as
initiators. This breaks protocol negotiation in multistream-select,
which assumes a single initator.

> This draft proposes a simple extension to the multistream protocol
negotiation in order to select a single initator when both peers are
acting as such.

See libp2p/specs#196 for details.

This commit implements the above specification, available via
`Version::V1SimOpen`.

* protocols/relay: Implement v2 client logic

* protocols/relay: Handle dial failure

* protocols/relay: Reuse connection

* protocols/relay: Rename Connection to RelayedConnection

* protocols/relay: Update transport doc examples

* protocols/relay: Pass relay addr to transport

* protocols/relay: Implement inbound stop denial

* protocols/relay: Renew reservations

* protocols/relay: Handle invalid expiration in the past

* protocols/relay: Handle in and outbound failure

* protocols/relay: Implement client handler keep alive

* protocols/relay: Handle handler listener closed channel

* protocols/relay: Handle handler to listener failure

* protocols/relay: Return all new listener addresses

* protocols/dcutr: Implement Direct Connection Upgrade through Relay

* protocols/dcutr: Carry observed addresses in Connect

* protocols/dcutr: Reply to Syn

* protocols/dcutr: Dial as initiator

* core/: Integrate Simultaneous Open extension

* protocols/relay/v2: Update to latest protobuf definition

* protocols/dcutr/examples: Add client

* Revert "misc/multistream-select: Ignore simultaneous open 'iamclient'"

This reverts commit 125e3c3.

* core/src/transport/upgrade: Make DialFuture aware of SimOpenRole

* core/src/transport: Use Transport::and_then for Authenticated::apply

* core/: Clean type structure

* core/: Enforce upgrade version at compile time

* misc/multistream-select: Document V1SimOpen

* *: Rename V1SimOpen to V1SimultaneousOpen

* misc/multistream-select: Document SimOpenRole

* *: Rename SimOpenRole to Role

* misc/multistream-select: Document reponder role process

* misc/multistream-select: Bump version and add changelog entry

* core/CHANGELOG: Add entry

* core/src/upgrade: Assert Initiator when not using SimOpen

* core/upgrade/apply: Document different versions

* misc/multistream-select: Derive Eq for Role

* *: Fix documentation links

* misc/multistream-select: Fix doc link

* src/lib: Call upgrade without Version

* protocols/relay/v2: Report back to transport

* protocols/relay/v2: Disconnect when stop protocol not supported

* protocols/relay/v2: Document max_duration not exceed u32::MAX

* protocols/relay/v2: Don't append p2p-circuit as relay

* protocols/relay/v2: Implement rate limiter

* protocols/relay/v2: Document caveats on rate limiter with high volume

* protocols/relay: Prevent possible false positive in quickcheck

* protocols/relay: Reword Prost error message

* protocols/relay: Allow users to specify generic rate limiters

* protocols/relay: Move rate limiting logic into module

* protocols/relay: Prevent reservation and connection over relayed conn

* protocols/relay: Add circuit src rate limiting

* protocols/relay/v2: Simplify example

* protocols/relay: Add myself to authors

* protocols/relay: Use thiserror

* protocols/relay/v2: Set rate limits

* protocols/relay: Use wasm_timer::Instant

* protocols/relay/v2: Apply clippy suggestions

* protocols/relay: Fix intra doc link

* protocols/dcutr/tests: Fix connect test

* protocols/dcutr: Run cargo fix

* protocols/dcutr: Attempt direct connection upgrade as listener only

* protocols/dcutr: Emit event when attempting direct connection upgrade

* protocols/dcutr: Emit event when remote initiates direct connection up

* protocols/relay: Fix clippy warnings

* protocols/dcutr: Extend with TODOs

* swarm/src/behaviour: Update DialAddress doc comment

With 45f07bf `Network::dial` accepts a
`Multiaddr` with a `PeerId`. With that in mind the doc comment on
`NetworkBehaviourAction::DialAddress` is outdated.

* swarm/src/protocols_handler: Add EitherHandler

Add implementation of a ProtocolsHandler that represents either of two
ProtocolsHandler implementations.

* protocols/dcutr: Deny upgrades on non-relayed connections

* protocols/dcutr: Properly expect size of data container

* protocols/dcutr: Enforce maximum message size on incoming msgs

* *: Format with rustfmt

* protocols/dcutr: Tell handler what it is going to be used for

* misc/metrics: Add basic instrumentation for libp2p-relay

* protocols/dcutr: Report successful connection upgrade

* protocols/dcutr/examples: Use structopts

* protocols/dcutr: Do not panic on connection closing

* protocols/relay: Return NetworkBehaviourAction::NotifyHandler right away

* protocols/dcutr/src/behaviour: Do not send relayed addresses

* protocols/dcutr/examples: Log on info level

* protocols/relay: Run rust fmt

* protocols/relay/src/v2/relay: Accept mutable config

* misc/multistream-select/src/protocol.rs: Fix typo

* protocols/dcutr/build: Run rust fmt

* protocols/dcutr/src/behaviour: Remove outdated comment

* misc/multistream-select: Supress needless collect warning

* protocols/dcutr/: Do not attempt upgrade if direct connection exists

* protocols/dcutr/src/handler: Remove DirectConnection Prototype variant

* protocols/dcutr: Deny incoming substreams as dialer

* protocols/dcutr/src/handler: Split into relayed and direct

* protocols/dcutr: Don't abbreviate negotiated with neg

* protocols/dcutr/src/protocol: Use correct protocol name

* protocols/dcutr/src/message.proto: Make type field required

* protocols/dcutr/src/protocol: Use thiserror

* protocols/dcutr/src/handler/relayed: Refine keep alive handling

* protocols/dcutr/src/protocol: Split into outbound and inbound

* protocols/dcutr/src/handler/relayed: Handle stream upgrade errors

Co-authored-by: Max Inden <mail@max-inden.de>

* z

Co-authored-by: Max Inden <mail@max-inden.de>
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

Successfully merging this pull request may close these issues.

2 participants