Commit Graph

55 Commits

Author SHA1 Message Date
sukun f96852745c chore: update quic-go to v0.57.1 (#3439) 2025-12-12 01:36:21 +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
Marco Munizaga b3f1e66e26 feat(network): Add Conn.As
ConnAs works in a similar way to errors.As. It allows a user to cut
through the interface layers and extract a specific type of connection
if available.

This serves as a sort of escape hatch to allow users to leverage some
connection specific feature without having to support that feature for
all connections. Getting RTT information is one example.

It also allows us, within the library, to get specific types of
connections out of the interface box. This would have been useful in the
recent changes in tcpreuse. See
https://github.com/libp2p/go-libp2p/pull/3181 and
https://github.com/libp2p/go-libp2p/pull/3142.

Getting access to the underlying type can lead to hard to debug issues.
For example, if a user mutates connection state on the underlying type,
hooks that relied on only mutating that state from the wrapped
connection would never be called.

It is up to the user to ensure they are using this safely.
2025-09-08 14:11:08 -07:00
Marco Munizaga da810a1764 feat: Migrate to log/slog (#3364) 2025-08-25 14:00:01 -07:00
sukun 26a5710d35 basichost: fix deadlock with addrs_manager (#3348) 2025-07-30 17:08:12 +05:30
galargh 50f065b4df chore: fix revive issues 2025-06-11 10:00:47 +01:00
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
sukun 914331ba90 autorelay: send addresses on eventbus; dont wrap address factory (#3071) 2025-02-18 18:36:17 +05:30
Marco Munizaga 9584246e7d feat: Implement Custom TCP Dialers (#3166) 2025-02-03 14:24:28 -08:00
sukun ca611f1c4e tcpreuse: error on using tcpreuse with pnet (#3129)
Co-authored-by: Marco Munizaga <git@marcopolo.io>
2025-01-10 13:14:35 -05:00
Adin Schmahmann 5a47a90938 feat(tcpreuse): add options for sharing TCP listeners amongst TCP, WS and WSS transports (#2984)
Allows the same socket to be shared amongst TCP,WS,WSS transports.

---------

Co-authored-by: sukun <sukunrt@gmail.com>
Co-authored-by: Marco Munizaga <git@marcopolo.io>
2024-11-04 09:41:32 -08:00
Marco Munizaga e8b6685edb fix: swarm: refactor address resolution (#2990)
* Remove unused resolver in basic host

* Refactor Swarm.resolveAddrs

Refactors how DNS Address resolution works.

* lint

* Move MultiaddrDNSResolver interface to core

* Reserve output space for addresses left to resolve

* feat: core/transport: Add SkipResolver interface (#2989)

* Rebase on top of resolveAddrs refactor

* Add comments

* Sanitize address inputs when returning a reservation message (#3006)
2024-10-16 12:20:21 -07:00
Marco Munizaga 65bc28b80f fix: QUIC/Webtransport Transports now will prefer their owned listeners for dialing out (#2936) 2024-08-28 13:16:39 -07:00
Marco Munizaga 6c12e2237a ci: Out of the tarpit (#2923)
* Lint fixes

* Use latest go version for go-check

Fixes nil pointer issue in staticcheck

* Add test_analysis helper script

* Use custom go-test-template

* Add some tests to the test_analysis script

* Always upload test_results db

* Attempt to fix test on windows

* Better if statement

* Try to fix flaky test

* Disable caching setup-go on Windows

* Better if statement

* Tweak

* Always upload summary and artifact

* Close db

* No extra newline
2024-08-20 11:13:32 -07:00
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 db41da3b26 feat: WebRTC reuse QUIC conn (#2889)
* feat: WebRTC reuse QUIC conn

* Fix transport constructor in test

* Move provide to where the transports are
2024-08-01 07:36:46 -07:00
sukun cb81b3e48c webrtc: remove experimental tag, enable by default (#2887) 2024-07-31 16:57:32 +05:30
sukun f80d18f24c config: fix AddrFactory for AutoNAT (#2868)
---------

Co-authored-by: Marco Munizaga <git@marcopolo.io>
2024-07-31 16:56:32 +05:30
sukun 87c435512c autonatv2: implement autonatv2 spec (#2469) 2024-06-21 14:55:22 +05:30
sukun 9f854e2a7c config: fix Insecure security constructor (#2810) 2024-05-23 19:52:22 +05:30
Marco Munizaga 62ebf06cb6 rcmgr: Backwards compatibility if you wrap default impl (#2805) 2024-05-23 19:50:31 +05:30
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
Marco Munizaga 86a6720a62 autonat: Clean up after close (#2749)
* Clean up after autonat

* Close
2024-03-27 20:14:32 -07:00
Marten Seemann 9d149fa3cb use Fx to start and stop the host, swarm, autorelay and quicreuse (#2118)
* config: refactor AutoNAT construction into separate method

* config: use a lifecycle hook to start listening on swarm addresses

* use Fx to construct the host

* add a test for constructing a routed host

* use Fx hooks to start the host

* config: use Fx lifecycle hooks to start AutoRelay and for PeerRouting

* basichost: don't close the swarm

The swarm is not constructed by the basic host, thus is shouldn't be
closed by it.

* config: use Fx hook to close the quicreuse connection manager

* test for goroutine leaks when starting/stopping fx

To do this, I've had to move a few leaky tests into a separate package.
I've filed a bug for the AutoNAT issue (#2743) but the "error on
startup" issue is going to require some pretty invasive changes (we need
to construct _then_ start).

* go fmt

* Ignore one more top function

* Typo

* Ignore any not top

---------

Co-authored-by: Sukun <sukunrt@gmail.com>
Co-authored-by: Steven Allen <steven@stebalien.com>
Co-authored-by: Marco Munizaga <git@marcopolo.io>
2024-03-21 10:18:34 -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
Marco Munizaga 9edef5a939 quic: drop support for QUIC draft-29 (#2487) 2023-08-15 18:15:02 -07:00
Marten Seemann b456165430 webtransport: only add cert hashes if we already started listening (#2271) 2023-05-05 11:09:12 -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
Marten Seemann f73205096f quic / webtransport: make it possible to listen on the same address / port (#1905)
* quic: add an integration test for QUIC version support

* quic: refactor the stateless reset test

* quic: simplify the interface of the noreuseConn

DecreaseCount now closes the underlying UDP conn, so that callers don't
need to pay attention if they're dealing with a reuseConn or a
noreuseConn.

* implement a quicreuse to manage QUIC connections

* quicreuse: introduce options

* config: construct the quicreuse.ConnManager using fx

* webtransport: use the quicreuse

* add integration test for QUIC and WebTranport sharing the same UDP addr

* Handle errors in accept loop goroutine

* Add comment

* Remove todo

* Rename mutexes

* Cleanup extra close

* Only log on err

* Use webtransport-go 0.4.0

* Fix expected error

Co-authored-by: Marco Munizaga <git@marcopolo.io>
2022-11-28 15:55:38 -08:00
Marten Seemann b90b74f3a5 check the options passed to transport constructor match 2022-11-10 12:42:10 +00:00
Marten Seemann 7d0b6ba933 refactor the transport constructor code to remove TransportWithOptions 2022-11-10 10:09:48 +00:00
Marten Seemann cbe50095f3 config: use fx to construct security transports 2022-11-10 10:09:45 +00:00
Marten Seemann 8df365bf45 add default listen addresses for QUIC (#1615) 2022-08-22 08:06:10 -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 2b69671cb9 remove flaky TestTcpSimultaneousConnect (#1425) 2022-04-22 09:19:32 -07:00
Marten Seemann dfc3a3f24a switch from github.com/libp2p/go-tcp-transport to p2p/transport/tcp 2022-04-22 14:48:25 +01:00
Marten Seemann 4268804809 make go-libp2p build when using the resource manager dependencies 2022-01-18 12:25:31 +04:00
Marten Seemann 0f0cc4e4a0 use the transport.Upgrader interface 2022-01-04 13:20:59 +04:00
Marten Seemann d01b892679 update go-libp2p-swarm to v0.7.0 2021-10-19 10:39:32 +02:00
Marten Seemann b7bee3855c remove the context from the libp2p and from the Host contructor 2021-09-18 14:06:56 +02:00
Aarsh Shah c575ec40e1 Finish and Test the simultaneous connect problem in libp2p peers (#1041)
* Implement support for SimOpen.
2021-02-17 13:36:40 +05:30
Steven Allen 46b58740de fix: fix connection gater in transport constructor 2020-05-20 11:09:00 -07:00
Steven Allen 1359013f39 fix: set the private key when constructing the autonat service
Otherwise, it the node fails to build.
2020-03-24 16:49:24 -07:00
Raúl Kripalani d87f89314c Consolidate abstractions and core types into go-libp2p-core (#601) 2019-05-26 22:55:46 +01:00
Steven Allen 262b35f272 chore: improve nil option tests 2019-04-17 18:05:08 -07:00
Steven Allen cff9cb577c constructor: allow nil options
This can make it significantly easier to configure libp2p with optional options.
2019-04-17 17:08:50 -07:00
vyzo 0600392e23 enable relay by default in New 2018-09-28 11:30:45 +03:00
Steven Allen a36d383413 add tests for NoTransports and NoListen 2018-08-21 14:40:18 -07:00
Abhishek Upperwal 9e952be412 modified regex for ipv6 2018-07-28 02:48:09 +05:30
Abhishek Upperwal ecf27b599f strict DefaultListenAddrs test w/ regex 2018-07-28 02:08:45 +05:30