Commit Graph

85 Commits

Author SHA1 Message Date
Marten Seemann 3919359872
swarm: add a basic metrics tracer (#1973)
* swarm: add very basic metrics for opening and closing connections

* swarm: use a sync.Pool to make metrics collection allocation-free

* swarm: introduce a MetricsTracer interface

* swarm: add the transport to the dial error metric

* swarm: add Grafana dashboard

* swarm: use the prometheus namespace option
2023-01-26 16:18:55 -08: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 d72d35c025 add an integration test for the ordering of security protocols 2022-11-22 10:46:32 +13:00
Marten Seemann 1ecf340f51 config: respect the user's security protocol preference order 2022-11-22 10:46:32 +13:00
Marten Seemann e2a246d5b6 upgrader: absorb SSMuxer into the upgrader 2022-11-20 18:30:00 +13:00
Marten Seemann 133f002117 config: supply the host ID to fx
This is needed to construct the insecure transport.
2022-11-17 12:03:28 +13:00
Marten Seemann 04a43b13a9
upgrader: absorb the muxer_multistream.Transport into the upgrader (#1885) 2022-11-16 14:09:21 -08:00
Marten Seemann d0704fdc7e config: forward fx output to the logger 2022-11-10 10:09:50 +00:00
Marten Seemann 479dbb93c4 restrict the Muxer option to already constructed network.Multiplexers 2022-11-10 10:09:47 +00:00
Marten Seemann cbe50095f3 config: use fx to construct security transports 2022-11-10 10:09:45 +00:00
Marten Seemann f7c8c0247b config: use fx to construct the transport upgrader 2022-11-10 10:09:38 +00:00
Marten Seemann 30e59560d3 upgrader: simplify the constructor 2022-11-10 10:07:17 +00:00
Marten Seemann 1367a62d52 use fx dependency injection to construct transports 2022-11-10 10:07:15 +00:00
julian88110 ebd000db1e
tls: use ALPN to negotiate the stream multiplexer (#1772)
* Muxer selection in TLS handshake first cut

* Clean up some part of the code

* Change earlydata to ConnectionState for security connection.

* resolve merging conflicts

* Add stubs for noise

* clean up code

* Switch over to passing muxers to security transport constructors

* Address feedback points

* Update p2p/net/upgrader/upgrader.go

Co-authored-by: Marten Seemann <martenseemann@gmail.com>

* clean up accidental checked file.

* Review points round 2

* Address some go nit points

* Update tls transport test to address review points

Co-authored-by: Marten Seemann <martenseemann@gmail.com>
2022-10-07 10:34:58 -07: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
Tshaka Eric Lekholoane fcf408c65d
identify: make the protocol version configurable (#1724)
* 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
2022-09-02 01:11:41 -07:00
Steven Allen 0efe1e5093
feat: inject DNS resolver (#1607) 2022-08-22 04:04:56 -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 ab634d2ba1 switch from github.com/libp2p/go-libp2p-peerstore to p2p/host/peerstore 2022-08-15 12:29:16 +03:00
Marten Seemann 9dc18edc26 switch from github.com/libp2p/go-libp2p-transport-upgrader to p2p/net/upgrader 2022-04-27 01:46:40 +02:00
Marten Seemann 3effab121a switch from github.com/libp2p/go-libp2p-swarm to p2p/net/swarm 2022-04-21 13:35:04 +01:00
Marten Seemann fc2c34e045 switch from github.com/libp2p/go-libp2p-blankhost to p2p/host/blank 2022-04-19 14:41:06 +01:00
Marten Seemann 7e767cbc22 correctly handle static relays 2022-03-31 11:31:05 +01:00
Marten Seemann 29fd1022a4 implement relay discovery in autorelay 2022-03-31 11:29:41 +01:00
vyzo df2301ba95 use the resource manager in libp2p bundled services, initialize default one 2022-01-18 12:27:07 +04:00
Marten Seemann 5f9c4075aa add a ResourceManager option 2022-01-18 12:25:32 +04:00
Marten Seemann 4268804809 make go-libp2p build when using the resource manager dependencies 2022-01-18 12:25:31 +04:00
Marten Seemann 4269c5f7b2 stop using go-libp2p-discovery 2022-01-16 15:32:30 +04:00
Marten Seemann d24f4f20f8 add an option for the swarm dial timeout 2022-01-04 13:37:21 +04:00
Marten Seemann 0f0cc4e4a0 use the transport.Upgrader interface 2022-01-04 13:20:59 +04:00
Marten Seemann 741348ec9c update import paths to use p2p/host/autonat 2021-12-22 13:26:20 +04:00
Marten Seemann 4141cac6f9 pass static relays to EnableAutoRelay 2021-11-14 15:33:59 +04:00
Marten Seemann e024655a40 introduce options to configure the AutoRelay 2021-11-14 14:56:47 +04:00
Gus Eggert 7a35d0df97
feat: plumb through peerstore context changes (#1237) 2021-11-12 13:43:02 -05:00
Marten Seemann 0aeef559d0 add an option to start the relay v2 2021-09-27 14:18:18 +01:00
vyzo 22b62cfd65
autorelay support for circuitv2 relays (#1198)
* 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
2021-09-25 05:47:39 -07: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 729386c495 don't use a context to shut down the circuitv2 2021-09-17 11:37:28 +02:00
Marten Seemann f3acea0d61 don't use the context to shut down the relay 2021-09-10 11:30:27 +01:00
vyzo 79d995404c
Use circuitv2 code (#1183)
* move circuitv2 to p2p/protocol

* update circuitv2 imports

* RIP circuit v2; use circuitv2

* fix autorelay test

* fix holepunch test

* fix relay example
2021-09-10 02:43:58 -07:00
Marten Seemann 8206fcda76
signalling for hole punching (#1168)
* 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>
2021-09-08 09:41:48 -07:00
Marten Seemann 2d07a0d973 chore: update go-libp2p-autonat to v0.5.0 2021-08-30 10:57:52 +01:00
Steven Allen 2ad02f79b2 chore: update to go-log v2 2021-04-29 14:15:17 -07:00
vyzo b313b4af98 option for custom dns resolver 2021-04-12 12:42:56 +03:00
Will Scott c2c5918483
fix autonat race
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.
2021-02-26 23:21:36 -08: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
sandman a55891f71b add AutoNat PublicAddr when host can be dialed but not get public addr by net.InterfaceAddrs() 2020-07-23 15:19:47 +08:00
Aarsh Shah 887f2c40cf
implement connection gating at the top level (#881) 2020-05-15 17:31:03 +01:00
Will Scott c08993b4e8
switch bool to enum 2020-04-13 10:23:22 -07:00