* base limits on reservations issued
* switch default reservation limits per peer and per IP
* don't export the constructor for relay.constraints
* panic when reading from crypto/rand fails
* optimize IP-based reservation lookup
* use lists instead of maps to save reservations
* save expiry timestamp in reservations
* use slices instead of linked lists for reservations
* remove unused rand in constraints
* v2 client scaffolding
* gomod: go-libp2p-core and go-libp2p-transport-upgrader feature dependencies
* Conn implements network.ConnStat
* add reservation stub
* utilities
* dial scaffolding and v1 compat dialing
* stream handling scaffolding and v1 incoming connection handling
* implement hop tagging
* export timeout variables
* v2 protobuf
* v2 client protocol implementation
* implement Reserve
* go get go-libp2p-swarm@feat/transient-conns
* implement client.New
* rework pb status codes
* client responds with UNEXPECTED_MESSAGE when it's actually an unexpected message
* relay scaffolding, reservation implementation
* implement relaying
* implement missing details
* add options for resources/limit
* gc idle conn counts
* fix clown shoes in cancellation check
* end to end relay test
* untag peers with expired reservations
* add time limit test
* better debug log for accepted conns
* add data limit test
* add v2-v1 compatibility tests
* godocs
* add WithACL relay option
* only return public relay addrs in reservation record
* remove the refresh restriction madness
* set default limit Data to 128K
* fix typo in AllowReserve godoc
* fix some small issues
- remove context from constructor
- remove stream handler when closing the host
- remove the awkward cancellation check from handleStream
* fix tests
* address review comments
- Add deadline for Reserve calls
- Add deadline for dials
- Add some comments for things that confuse aarsh.
* humor aarsh and add initializers for slices
* comment nitpicks
* fix bug in slice pre-allocations
* add deadline to connectV1
* make Relay.Close thread-safe
* untag peers with reservations when closing the relay
* gomod: get go-libp2p-asn-util
* add IP/ASN reservation constraints
* gomod: update deps
* fix e2e test
* increase default limit duration to 2min
* update protocol for vouched relay addrs; provide absolute expiration time instead of TTL
* update for reservation changes
* add voucher to the reservation pb
* TODO about reservation vouchers
* deduplicate protocol ID definitions between relay and client
* add reservation vouchers
* emit and consume reservation vouchers
* improve limit data test
* deduplicate concurrent relay dials to the samke peer
* improve dialer deduplication
* add a short timeout to dialing the relay in order to aid deduplication
* gomod: fix go1.16 madness
* spec compliance: don't include p2p-circuit in reservation addrs
* spec compliance: refuse reservation and connection attempts over relayed connections
* test shim: add empty file in test directory
* spec compliance: update protobuf
* spec compliance: use libp2p envelopes for reservation vouchers
* fix staticcheck
Co-authored-by: Marten Seemann <martenseemann@gmail.com>
This patch updates go-libp2p for the stream interface changes in go-libp2p-core
0.7.0. This is a _significant_ breaking change to streams and all users should
read https://github.com/libp2p/go-libp2p-core/releases/tag/v0.7.0. In practice,
this change should remove a significant footgun.
TL;DR:
* `Stream.Close` now behaves like `net.TCPConn.Close`.
* There is a new `Stream.CloseWrite` (send an EOF) and `Stream.CloseRead` (close
for reading), behaving like their counterparts in `net.TCPConn`.
1. Fix tests on go 1.15 by avoiding `string(i)`.
2. Fix the autorelay test by making relays announce fake "public" addresses. I'm
not sure how this worked before.
Alternative to #963. Instead of using atomics, this patch ensures that all state
changes are performed on the main thread. It also:
* Threads the context through explicitly to make sure fields changed by the main
thread are never read by the handler goroutines. This isn't strictly necessary
but it makes it easier to reason about.
* Uses a callback to signal "on done". There may be cleaner ways to do this (I
hate callbacks), but this nicely decouples the peer handler from the main loop.
fixes#963
Previously, we'd keep addresses discovered through the DHT for up to 2
minutes (temporary TTL) and previously seen addresses (recently connected) for
up to 10 minutes (the TTL).
1. Make sure to downgrade both connected and recently connected addresses to the
"temporary" ttl before adding new addresses.
2. Finally, downgrade addresses with the temporary TTL to 0.
This could be more efficient with a better peerstore abstraction, but this is
better than nothing.
In #917, we started dropping additional address observations if we had multiple
for the same transport set. However, on further consideration, this isn't quite
correct. We _want_ to keep additional observations for multiple IP addresses.
The real issue is many observations for different ports.
So this patch simply changes the key with which we group observations from
"address protocols" to "address without the port" (well, with the port set to
0).