* Add Resolver interface to transport
* Move resolve test to swarm_dial_test
* Use proper peer id in test
* Only import go-multiaddr once
* Cleanup
* Use SNI in websocket
* Update go-multiaddr
* Update p2p/net/swarm/swarm.go
Co-authored-by: Marten Seemann <martenseemann@gmail.com>
* PR comments on websocket.go
* Use unresolved/resolved map
* Set sni
* Refactor websocket multiaddr parsing code, add server test
* Delete superflous helpers
* Update callsites
* Fix typo in p2p/transport/websocket/websocket.go
Co-authored-by: Marten Seemann <martenseemann@gmail.com>
* Configure protocolVersion for Identify protocol
Allows the protocolVersion field of the Idenfity protocol to be
configured on the host. The current value is fixed for what appears to
be for backwards compatibility with IPFS which makes it difficult for
non-IPFS protocols to use the library.
References:
- https://github.com/libp2p/go-libp2p/issues/714
- https://github.com/libp2p/go-libp2p/pull/1137
- 6855ab943b/protocols/identify/src/identify.rs (L125-L127)
* Fix protocol version assignment
Fix an issue where the protocolVersion string for the Identify protocol
was wrongly being assigned the agentVersion string.
* Delete trailing whitespace
* bump go.mod to Go 1.18 and run go fix
* bump go.mod to Go 1.18 and run go fix
* bump go.mod to Go 1.18 and run go fix
* bump go.mod to Go 1.18 and run go fix
* run gofmt -s
* update .github/workflows/go-test.yml
* update .github/workflows/go-check.yml
* stop using the deprecated io/ioutil package
Co-authored-by: web3-bot <web3-bot@users.noreply.github.com>
Co-authored-by: Marten Seemann <martenseemann@gmail.com>
When a host is closed, it should close its resource manager. Otherwise, goroutines are leaked.
Generally this is not a problem when a host exists for the life of a program, but can be a problem if hosts are created and closed.
* Resolve addresses when creating a new stream
BasicHost.NewStream will try to establish a connection if one doesn't already exist. This will fail if the hosts addresses have not yet been resolved. This PR resolves the hosts addresses before creating the stream and possible new connection.
Fixes#1302
* Changes from review comments
* 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>
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.