Commit Graph

105 Commits

Author SHA1 Message Date
Marco Munizaga 46986fcdbf Remove assertion that assumes a certain CI network environment
The number of interfaces attached to the CI is unknown to this test. We
shouldn't assert on a specific count.

Co-Authored-By: gammazero <11790789+gammazero@users.noreply.github.com>
2026-01-26 17:22:51 -05:00
sukun 31f527dc87 basichost: fix lint error 2025-10-02 19:56:02 +05:30
sukun 3e69227598 basichost: move EvtLocalAddrsChanged to addrs_manager (#3355) 2025-09-30 16:20:38 +05:30
cargoedit c8e06bb688 refactor: replace context.WithCancel with t.Context
Signed-off-by: cargoedit <cargoedit@outlook.com>
2025-09-18 12:25:40 -07:00
sukun 90b841260e basichost: move observed address manager to basichost (#3332) 2025-08-18 12:16:16 -07:00
sukun 26a5710d35 basichost: fix deadlock with addrs_manager (#3348) 2025-07-30 17:08:12 +05:30
Piotr Galar 335c75a398 Merge branch 'master' into uci-golangci-lint 2025-06-11 10:42:45 +01:00
galargh 50f065b4df chore: fix revive issues 2025-06-11 10:00:47 +01:00
sukun fb1d9512e8 basichost: use autonatv2 to verify reachability (#3231)
This introduces addrsReachabilityTracker that tracks reachability on
a set of addresses. It probes reachability for addresses periodically
and has an exponential backoff in case there are too many errors
or we don't have any valid autonatv2 peer.

There's no smartness in the address selection logic currently. We just
test all provided addresses. It also doesn't use the addresses provided
by `AddrsFactory`, so currently there's no way to get a user provided
address tested for reachability, something that would be a problem for
dns addresses. I intend to introduce an alternative to
`AddrsFactory`, something like, `AnnounceAddrs(addrs []ma.Multiaddr)`
that's just appended to the set of addresses that we have, and check
reachability for those addresses.

There's only one method exposed in the BasicHost right now that's
`ReachableAddrs() []ma.Multiadd`r that returns the host's reachable
addrs. Users can also use the event `EvtHostReachableAddrsChanged`
to be notified when any addrs reachability changes.
2025-06-03 17:13:56 +05:30
sukun 5e6f217d84 addrsmanager: extract out addressing logic from basichost (#3075)
Benchmark for AllAddrs:

```
goos: linux
goarch: amd64
pkg: github.com/libp2p/go-libp2p
cpu: AMD Ryzen 7 7840U w/ Radeon  780M Graphics
BenchmarkAllAddrs-16               16737            122245 ns/op           21240 B/op        218 allocs/op
```
after:
```
goos: linux
goarch: amd64
pkg: github.com/libp2p/go-libp2p
cpu: AMD Ryzen 7 7840U w/ Radeon  780M Graphics
BenchmarkAllAddrs-16            11103236               105.7 ns/op           192 B/op          1 allocs/op
```
2025-02-27 22:24:57 +05:30
Marco Munizaga 785181fbb8 chore: Update go-multiaddr to v0.15 (#3145) 2025-02-24 14:21:47 -08:00
Marco Munizaga c31f093851 fix: basichost: Use NegotiationTimeout as fallback timeout for NewStream (#3020) 2024-11-04 09:42:44 -08:00
sukun c2556325d5 basichost: ensure no duplicates in Addrs output (#2980) 2024-10-03 10:43:59 +05:30
sukun 8a11b7c8e4 basic_host: close swarm on Close (#2916)
Using the `BasicHost` constructor transfers the ownership of the swarm.
This is similar to how using `libp2p.New` transfers the ownership of
user provided config options like `ResourceManager`, all of which are
closed on `host.Close`
2024-08-15 18:18:35 +05:30
Marco Munizaga 0cc0b2fba7 ObsAddrManager: Infer external addresses for transports that share the same listening address. (#2892)
* Remove this hack, the new observed address manager just works

* Infer addresses that share the same local thin waist

* Use Interface listen address as well
2024-08-01 16:05:04 -07:00
sukun 6861cecb3c identify: refactor observed address manager to do address mapping at thin waist(IP+TCP/UDP) layer (#2793)
* refactor observed address manager to do mapping at thin waist layer

---------

Co-authored-by: Marco Munizaga <git@marcopolo.io>

* restrict output message size, add top level option to disable address
discovery

* Comment nit

* Increase maxPeerRecordSize

---------

Co-authored-by: Marco Munizaga <git@marcopolo.io>
2024-05-15 20:17:25 -07:00
dozyio e3b0a86e86 chore: testify fix got, expected transpositions (#2666)
* chore: testify lint fixes

* chore: revert t.error replacements

* chore: revert errNotWebSocketAddress

---------

Co-authored-by: Sukun <sukunrt@gmail.com>
2024-02-14 14:35:19 +05:30
Jorropo 676a35f59b tests: add a CertHashes testcase in TestInferWebtransportAddrsFromQuic (#2495)
Also do not sort the test cases twice.
2023-08-16 09:22:51 -07:00
Hlib Kanunnikov e5334ed296 basichost / blankhost: wrap errors (#2331) 2023-06-27 11:21:32 -07:00
Marten Seemann 0f9ad8c242 revert "feat:add contexts to all peerstore methods (#2312)" (#2328) 2023-06-03 16:55:08 +03:00
Prem Chaitanya Prathi 8864d1c33e feat:add contexts to all peerstore methods (#2312) 2023-06-03 02:24:50 -07:00
Marco Munizaga e89814c520 swarm: Dedup addresses to dial (#2322)
* Dedup addresses to dial

Co-authored-by: Aayush Rajasekaran <arajasek94@gmail.com>

* Move DedupAddrs test

* Typo

---------

Co-authored-by: Aayush Rajasekaran <arajasek94@gmail.com>
2023-06-02 13:26:28 -07:00
Marco Munizaga fbf11bc5c0 Infer public webtransport addrs from quic-v1 addrs. (#2251)
* Infer external webtransport addrs from external quic addrs

* Infer external webtransport addrs from external quic addrs is now pure

* Remove ConnManager method

* Nits

* Dedupe addrs

* Revert "Dedupe addrs"

This reverts commit b63155f4a3997d7adfebc337d0262defca329c15.

* Assume input is deduped
2023-04-12 14:44:48 -07:00
Marten Seemann 7dc3b81a0a basichost: don't allocate when deduplicating multiaddrs (#2206)
* basichost: don't allocate when deduplicating multiaddrs

* fix sort.Slice less comparison

Co-authored-by: Marco Munizaga <git@marcopolo.io>

* interop: don't send loopback addrs

---------

Co-authored-by: Marco Munizaga <git@marcopolo.io>
2023-04-12 11:51:01 -07:00
Marten Seemann 0119e9a2b6 basichost: remove stray print statement in test (#2249) 2023-04-08 11:31:10 -07:00
Marco Munizaga 3b3f8baf93 correctly handle WebTransport addresses without certhashes (#2239)
* Add helpers to transform webtransport multiaddrs in AddrsFactory

* Remove unused line

* PR nits

* Add wrapper around AddrsFactory to fill in missing certhash

* PR nits

* Handle WebTransport multiaddrs in observed addr manager

* Remove unneccessary change

* Remove unused func

* Use SplitLast

* Add comment

* Clone multiaddr before splitting last

* Revert "Clone multiaddr before splitting last"

This reverts commit f168a8e8b6.

* Wait for certmanager to be instantiated

* Copy addrs slice before modifying

* Fix stalled test
2023-04-05 23:45:54 -07:00
Marco Munizaga 5330570d1c identify: Fix IdentifyWait when Connected events happen out of order (#2173)
* Add test case

* Id works even if Connected notifications happen out of order

* Add IsClosed shim

* Call basichost `.Start()` for all tests
2023-03-06 19:55:47 -08:00
Marco Munizaga 29785d22b3 basic_host: Fix flaky tests (#2136) 2023-02-24 09:53:42 -08:00
Marco Munizaga 32f2f25529 Revert mistaken "Bump timeout"
This reverts commit f00c9507c3.
2023-02-17 23:04:59 +00:00
Marco Munizaga f00c9507c3 Bump timeout 2023-02-17 23:00:49 +00:00
Marten Seemann 235f25b487 identify: refactor sending of Identify pushes (#1984)
* identify: cache the snapshot

* identify: refactor sending of Identify pushes

* identify: fix concurrency when sending pushes

* identify: fix timestamp handling

* identify: remove unneeded pushSemaphore

* identify: improve logging

* identify: use a sequence number instead of a timestamp

* identify: start with an empty snapshot

* identify: wait until we've actually finished setting up
2023-02-08 14:44:33 -08:00
Sukun 6b9c11680e consistently use protocol.ID instead of strings (#2004)
* Change PeerStore interface to use protocol.ID

This reduces the string to protocol.ID translations happening
at various places in the code

* Fix misc cases of protocol.ID conversion

* Merge multistream changes

* Use protocol.ID in network.ConnectionState

* don't update examples

* fix error message tests

* merge new go-multistream changes

* update test-plans go mod

* change transport back to string
2023-01-27 01:39:59 -08:00
Marten Seemann aa1f32484a identify: remove support for Identify Delta 2023-01-07 14:41:27 +13:00
Marco Munizaga f654b4bd69 Add Resolver interface to transport (#1719)
* 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>
2022-09-13 09:36:26 -07:00
Marten Seemann 4623690009 switch from github.com/libp2p/go-libp2p-core to core 2022-08-17 17:13:02 +03:00
Marten Seemann 40727b1b00 switch from github.com/libp2p/go-eventbus to p2p/host/eventbus 2022-08-17 12:20:25 +03:00
Marten Seemann 6631bfb011 basichost: remove usage of MultistreamServerMatcher in test (#1680) 2022-08-17 02:08:40 -07:00
web3-bot eff72c4afa sync: update CI config files (#1678)
* 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>
2022-08-17 01:05:51 -07:00
Marten Seemann d8c4f163a3 chore: use the new multiaddr.Contains function (#1618) 2022-06-28 01:35:22 -07:00
Marco Munizaga 3517eae205 autonat: fix flaky TestAutoNATPrivate (#1581)
* Use expectEvent and scale duration for CI

* Use 3 seconds
2022-06-02 02:44:02 -07:00
Marten Seemann fd697bb605 basichost: fix flaky TestSignedPeerRecordWithNoListenAddrs (#1559) 2022-06-01 04:10:41 -07:00
Marten Seemann 5c218cf55e basichost: fix flaky TestSignedPeerRecordWithNoListenAddrs (#1488) 2022-05-16 11:50:39 -07:00
Marten Seemann 3effab121a switch from github.com/libp2p/go-libp2p-swarm to p2p/net/swarm 2022-04-21 13:35:04 +01:00
Andrew Gillis e8d3df92f7 Resolve addresses when creating a new stream (#1342)
* 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
2022-03-31 02:45:20 -07:00
Marten Seemann 741348ec9c update import paths to use p2p/host/autonat 2021-12-22 13:26:20 +04:00
Marten Seemann bf0203c6d3 fix flaky BasicHost tests 2021-09-26 16:00:50 +01:00
Marten Seemann b7bee3855c remove the context from the libp2p and from the Host contructor 2021-09-18 14:06:56 +02:00
Marten Seemann 29da01af70 update go-libp2p-core to v0.10.0 2021-09-17 18:50:15 +02:00
Marten Seemann 2d07a0d973 chore: update go-libp2p-autonat to v0.5.0 2021-08-30 10:57:52 +01:00
Marten Seemann 82a43f7abd remove deprecated basichost.New constructor 2021-08-16 16:49:28 +02:00