-
Notifications
You must be signed in to change notification settings - Fork 275
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
*: Address security-protocol-in-multiaddr and relay conflict #359
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -294,6 +294,42 @@ Common failure status codes are: | |
|
||
***Note: implementations _should not_ accept connection initiations over already relayed connections*** | ||
|
||
##### Security protocol selection for the relayed connection | ||
|
||
Instead of negotiating the security protocol in-band, security protocols should | ||
be encapsulated in the multiaddr (see [The multiaddr security component | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here. |
||
section](../addressing/README.md#the-multiaddr-security-component)). A relayed | ||
connection is not an exception. A target advertises the support for a security | ||
protocol for relayed connections by appending | ||
`/p2p-circuit-inner/<security-protocol>` to its relayed multiaddresses. An | ||
initiator may include any set of relayed multiaddr in the `peer` field of | ||
`HopMessage` on type `CONNECT` in which all addresses end with the same | ||
`/p2p-circuit-inner/<security-protocol>`. The initiator is thus signaling to the | ||
target which security protocol, out of all advertised security protocols | ||
by the target, the initiator chose to use on the relayed connection. | ||
|
||
As an example, let's say the target listens for incoming relayed connections via | ||
relay `R1` and relay `R2`. In addition it supports both TLS Noise as security | ||
protocols. It would then advertise the following relayed multiaddresses: | ||
|
||
- `<relay-R1-multiaddr>/p2p-circuit/p2p/QmTarget/p2p-circuit-inner/tls` | ||
- `<relay-R1-multiaddr>/p2p-circuit/p2p/QmTarget/p2p-circuit-inner/noise` | ||
- `<relay-R2-multiaddr>/p2p-circuit/p2p/QmTarget/p2p-circuit-inner/tls` | ||
- `<relay-R2-multiaddr>/p2p-circuit/p2p/QmTarget/p2p-circuit-inner/noise` | ||
|
||
Once the initiator received the above multiaddresses and decides to initiate a | ||
relayed connection to the target, it needs to decide whether it wants to secure | ||
the relayed connection via TLS or Noise. Say it decides for Noise it would then | ||
include the multiaddresses below in it `HopMessage` with type `Connect` in the | ||
`peer` field: | ||
|
||
- `<relay-R1-multiaddr>/p2p-circuit/p2p/QmTarget/p2p-circuit-inner/noise` | ||
- `<relay-R2-multiaddr>/p2p-circuit/p2p/QmTarget/p2p-circuit-inner/noise` | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we say that the relay SHOULD abort the connection if it receives a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I would go by Be strict when sending and tolerant when receiving (RFC 1958). We might have a case in the future where sending a
Sounds good to me. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Second suggestion applied via 7844421. |
||
Note that all addresses sent by the initiator in the `peer` field MUST share the | ||
same security protocol for the relayed connection | ||
(`/p2p-circuit-inner/<security-protocol>`). | ||
|
||
### Stop Protocol | ||
|
||
The Stop protocol governs connection termination between the relay and the target peer; | ||
|
@@ -309,11 +345,13 @@ The relay sends a `StopMessage` with `type = CONNECT` and the following form: | |
``` | ||
StopMessage { | ||
type = CONNECT | ||
peer = Peer { ID = ...} | ||
initiator = Peer { ID = ...} | ||
target = Peer { addrs = ...} | ||
limit = Limit { ...} | ||
} | ||
``` | ||
- the `peer` field contains a `Peer` struct with the peer `ID` of the connection initiator. | ||
- the `initiator` field contains a `Peer` struct with the peer `ID` of the connection initiator. | ||
- the `target` field contains a `Peer` struct with the peer `addrs` of the target that the initiator included in its `HopMessage`. | ||
- the `limit` field, if present, conveys the limits applied to the relayed connection with the semantics described [above](#reservation). | ||
|
||
If the target peer accepts the connection it responds to the relay with a `StopMessage` of `type = STATUS` and `status = OK`: | ||
|
@@ -330,6 +368,21 @@ If the target fails to terminate the connection for some reason, then it respond | |
Common failure status codes are: | ||
- `CONNECTION_FAILED` if the target internally failed to create the relayed connection for some reason. | ||
|
||
#### Security protocol selection for the relayed connection | ||
|
||
A target may advertise support for different security protocols by advertising | ||
multiple multiaddresses with different `/p2p-circuit-inner/<security-protocol>` | ||
suffixes. A target needs some mechanism to determine which of the advertised | ||
security protocols the initiator intends to use to secure an incoming relayed | ||
connection. The target can use the addresses included in the `target` field of | ||
the `StopMessage` to determine which security protocol the initiator chose to | ||
secure the relayed connection. | ||
|
||
Note that all addresses sent by the initiator MUST share the same security | ||
protocol for the relayed connection (`/p2p-circuit-inner/<security-protocol>`). | ||
Thus a target MUST abort the connection attempt (i.e. reset the stream) if it | ||
receives a `CONNECT` with varying security protocols for the relay connection. | ||
|
||
### Reservation Vouchers | ||
|
||
Successful relay slot reservations should come with _Reservation Vouchers_. | ||
|
@@ -383,7 +436,8 @@ message StopMessage { | |
|
||
required Type type = 1; | ||
|
||
optional Peer peer = 2; | ||
optional Peer initiator = 2; | ||
optional Peer target = 5; | ||
optional Limit limit = 3; | ||
|
||
optional Status status = 4; | ||
|
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 we want to make this a prerequisite for circuit v2, or does that clash with our experimental deployment of v2?
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.
That would make Project Flare dependent on security-protocol-in-multiaddr. Given the large number of live libp2p networks, I would prefer to keep the two decoupled to allow flexible roll-outs.
Do you see issues with the decoupled approach @marten-seemann?