This commit documents the DHT client mode, keeping routing tables clear
of clients (laptops), while still allowing clients to utilize the
functionality of the DHT.
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;
```
On PUT_VALUE the Golang implementation expects `key` on `Message` to
equal `key` on `Record` when handling a request (see [go-1]). This patch
updates the specification accordingly.
[go-1]: 7724838e46/handlers.go (L151-L164)
> 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>
Previous versions of this specification required connections to be
closed on version mismatch. This requirement is revoked to allow
interoperability between protocol families / networks.
* Remove `id` field from `Unregister` message
All connections in libp2p are authenticated. As such, we don't have
to include the PeerId in the `Unregister` message. We only allow
peers to unregister themselves and therefore, this `id` would always
be equal to the one we are learn from the authentication layer. Having
to compare those and ensure they are equal is an unnecessary error
path.
To be backwards-compatible with existing deployments of the rendezvous
protocol, the field is only commented out. If this record ever gets
extended, the next field should use id `3`.
* Clarify absence of `UNREGISTER` response