This documents the rust-libp2p behaviour when more data than is allowed is transferred over a relayed connection. js-libp2p will take the same approach. go-libp2p may need to be updated.
---------
Co-authored-by: Max Inden <mail@max-inden.de>
Co-authored-by: Prithvi Shahi <50885601+p-shahi@users.noreply.github.com>
The reservation expiration date is specified in seconds so be explicit about that in the spec in the same way we are explicit about the duration limit units.
The Go implementation of the circuit relay v2 implementation treats the
`Reservation::expire` field as `required`:
``` Golang
result := &Reservation{}
result.Expiration = time.Unix(int64(rsvp.GetExpire()), 0)
if result.Expiration.Before(time.Now()) {
return nil, fmt.Errorf("received reservation with expiration date in the past: %s", result.Expiration)
}
```
bfee9f5935/p2p/protocol/circuitv2/client/reservation.go (L88-L92)
Where `rsvp.GetExpire` returns `0` when `Reservation::expire` is not set:
``` Golang
func (m *Reservation) GetExpire() uint64 {
if m != nil && m.Expire != nil {
return *m.Expire
}
return 0
}
```
bfee9f5935/p2p/protocol/circuitv2/pb/circuit.pb.go (L414-L419)
While inexplicable to me why Go treats the non-set case equal to the default
value (`0`), we unfortunately have to take the go implementation as the source
of truth, given that it is already released.
With the above in mind and to prevent confusion for other implementations in
languages which do not treat the non-set case equal to the default value (`0`),
this commit marks the `Reservation::expire` field as `required`.
The `type` field of the DCUtR message definition should not be
`optional`, as a message without a `Type` is useless. Instead it should
be `required`.
See also circuit relay v2 specification using `required` for `type`.
```protobuf
message HopMessage {
enum Type {
RESERVE = 0;
CONNECT = 1;
STATUS = 2;
}
required Type type = 1;
```
```protobuf
message StopMessage {
enum Type {
CONNECT = 0;
STATUS = 1;
}
required Type type = 1;
```
> In this specification, we describe a synchronization protocol for direct
connectivity with hole punching that eschews signaling servers and utilizes
existing relay connections instead.
Co-authored-by: Raúl Kripalani <raul@protocol.ai>
Co-authored-by: Max Inden <mail@max-inden.de>
Co-authored-by: Marten Seemann <martenseemann@gmail.com>
* Specify the Circuit Relay v2 protocol.
* Move README.md specifying the Circuit Relay v1 protocol to circuit-v1.md
Co-authored-by: Max Inden <mail@max-inden.de>
Co-authored-by: raulk <raul@protocol.ai>
* prefixing err codes with HOP/STOP to differentiate dup keys
* typo: srcPeer and destPeer are set in STOP, not STATUS
* relay: add STOP_RELAY_REFUSED and MALFORMED_MESSAGE
* document error codes 390 and 400