* move host/relay to host/autorelay
* move autorelay wrapper host to package
* support v2 relays in autorelay
* test autorelay with both v1 and v2 relays
* fix test race
* go mod tidy examples/pubsub/chat
static checker complains; sigh.
* refactor reservation refresh loop
* merge background and refresh goroutines
* handle pushes synchronously from reservation refresh failures
* make connmanager tag a package level constant
* dont sleep to wait for identify, use IdentifyWait
* make relay protocol ids package-level constants
* add comment about v1 relays not having reservations
* use errgrp instead of WaitGroup with atomic int
* fix variable capture bug
* go get x/sync
* add circuitv1 protobuf
* add implementation of v1 circuit relay
Intended to be used by standalone daemons and tests
* remove references to go-libp2p-circuit from production code
* update tests to use the in-tree v1 Relay
* use go-log/v2 in relay v1 impl
* use in-tree v1 relay in relay example
* remove go-libp2p-circuit dep from examples go.mod, go mod tidy
* hole punching protocol
* implement the new retry logic (opening a new stream per hole punch)
* rename the holepunch.HolePunchService to holepunch.Service
* remove stream handler when closing
* remove misleading comment from protobuf, add link to spec
* remove unnecessary netNotifiee.HolePunchService
* simplify receiving from the timer channel
* don't defer the closing of the hole punching stream
* only accept hole punch streams from relayed peers
* refactor error logging
* fix incorrect counting of incoming hole punch attempts
* rename HolePunch to DirectConnect
* fix usage of the wait group to close the hole punch service
* use a gc to the garbage collect the holepunch tracer
* check directionality of connection when accepting the hole punch stream
* add comment why we only call Connect once
* move deduplication logic to the holepunch service
Co-authored-by: aarshkshah1992 <aarshkshah1992@gmail.com>
* 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>
Unfortunately, lotus relies on this and we don't have a good alternative
at the moment.
1. The "correct" way to get the status is to subscribe to the
"discoverability" events and read the first event (you're guaranteed to
see a "current status" event). However, this is a bit annoying.
2. Ideally, you'd call host.Addrs() to get the list of "good" addresses.
Unfortunately, we don't feed enough information back into the Host from
AutoNAT for this to be truly useful (yet).
1. Don't write "nil". Not all writers handle this well.
2. Write/read an entire string.
3. Improve debuggability.
4. Move the sleep. We _don't_ need to wait for disconnect notifications.
We _do_ need to wait for the protocol event change to propagate.
fix#7947
move `BasicHost.AutoNat` to a private field (it has no public method and shouldn't be accessed afaik.
Instead add a setter for config that sets it while holding the address mutex to prevent reads of the
field at the same time.
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.
Previously, we'd construct addresses like `/ip4/.../udp/...` instead of
`/ip4/.../udp/.../quic` because we'd use mapped addr (ip + transport + port)
instead of the full external address (ip + transport + port + other
transports...).
* fix: use all interface addresses when we can't find the default route
* fix: don't add advertise unspecified addresses
* fix: resolve addresses before looking up observed addresses
* fix: only advertise global unicast
* fix: filter link-local addresses from advertisement
* test: fix basic host addr tests
Before, we would:
1. Receive a "listen close" event from an event handler, after the teardown started.
2. Try to add a child process to handle the event. This would block because we
were in the teardown.
3. In the teardown, try to unregister the event handler and deadlock
I've now:
* Removed the teardown.
* Switched to a single event loop.
Ideally, we'd remove goprocess entirely. But we'd need to refactor natmgr.
fixes#933
We switched `listenAddrs` from the _interface_ addresses to the raw addresses we
were listening on. Unfortunately, we needed the resolved addresses later in the
function when resolving port mappings.