Commit Graph

214 Commits

Author SHA1 Message Date
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 1f7b0d2add transport integration tests: add tests for resource manager (#2285)
* Remove duplicate `SetProtocol` call

* Don't log if transport ErrListenerClosed

* Close the conn scope in webtransport dial

* Mock resource scope span

* Add transport rcmgr integration test

* PR nits

* Fix flakiness

* Threadsafe way of waiting for all streams

* Expand comment
2023-06-01 01:19:31 -07:00
Marten Seemann b456165430 webtransport: only add cert hashes if we already started listening (#2271) 2023-05-05 11:09:12 -07:00
Marten Seemann 4ee60e39d0 move more of the NAT mapping logging to the NAT manager 2023-04-14 14:31:24 +02:00
Marten Seemann 1ad214650c nat: replace alloc-heavy nat.Mapping with explicit GetMapping method 2023-04-14 14:31:21 +02: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
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 0d7e852b0a basichost: prevent duplicate dials (#2196) 2023-03-16 19:27:07 -07:00
Sukun bfc6fc30de relay service: add metrics (#2154)
* relay service: add metrics

Metrics Added:

ReservationRequest: Opened, Closed, Renewed
ReservationRequestResponseStatus
ReservationRejectionReason

ConnectionRequest: Opened, Closed
ConnectionRequestResponseStatus
ConnectionRejectionReason
ConnectionDuration

BytesTransferred

RelayStatus

* add dashboard and changelog

* bugfix

* add metrics tests

* address review comments

* rename dashboard

* address review comments

* change label to rolling avg
2023-03-07 01:26:37 -08:00
Sukun c738a48d02 autonat: don't use autonat for address discovery (#2148)
* dont use autonat for address discovery

* dont increase timeout
2023-02-27 13:04:21 -08:00
Marten Seemann 581a015412 swarm: emit PeerConnectedness event from swarm instead of from hosts (#1574)
* pass an event bus to the swarm constructor

* make the eventbus parameter a required swarm constructor parameter

* emit Connectedness notifications from the swarm

* remove peer connectedness watchers from hosts

* swarm: emit connectedness events when holding the mutex
2023-02-24 19:49:51 -08:00
Sukun a491074d89 metrics: add options to disable metrics and to set Prometheus registerer (#2116)
* provided a WithRegisterer option for metrics

* provide a libp2p.Option to setup metrics
2023-02-20 22:48:17 -08:00
Marten Seemann 5f8fe94f90 identify: add some basic metrics (#2069) 2023-02-09 16:33:35 +11: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 3598171505 eventbus: add metrics (#2038)
* add events emitted metric to eventbus

* properly export grafana dashboard

* Add eventbus subscriber and notification time metrics

* expose name in subscription

* use atomic.AddInt64 for backwards compatibility

* make metrics optin

* update dashboard json

* follow options constructor pattern for eventbus

* remove unused type

* Review comments

* remove event name

* remove whitespace diff

* address review changes. remove notification time

* fix subscribers count

* make subscriber queue state timeline

* allow custom registerer. Make queue length gauge

* eventbus: remove package version from subscriber metrics

* eventbus: minor dashboard tweaks

---------

Co-authored-by: Marten Seemann <martenseemann@gmail.com>
2023-02-04 14:13:30 -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 cbb0761f1a basichost: improve protocol negotiation debug message (#1846) 2022-10-31 20:31:43 +00: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
  - https://github.com/libp2p/rust-libp2p/blob/6855ab943bd7427a2135b46ad3d08f48fbf10872/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
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
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 f656048800 switch from github.com/libp2p/go-libp2p-nat to p2p/net/nat 2022-05-20 12:37:09 +02:00
Marten Seemann 9aab068808 update go-multistream, stop using deprecated NegotiateLazy (#1417)
* update go-multistream, stop using deprecated NegotiateLazy

* remove mock net test case TestStreamsStress
2022-04-22 07:57:23 -07:00
Andrew Gillis 7a7eb8ba32 Close resource manager when host closes (#1343)
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.
2022-04-18 14:38:08 -07: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
vyzo df2301ba95 use the resource manager in libp2p bundled services, initialize default one 2022-01-18 12:27:07 +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 161f1c73fd remove direct dependency on libp2p/go-addr-util 2022-01-03 12:47:46 +04:00
Marten Seemann 741348ec9c update import paths to use p2p/host/autonat 2021-12-22 13:26:20 +04:00
Marten Seemann a4e2a94e7b move the peerstoremanager to the host 2021-12-10 12:47:36 +04:00
Marten Seemann 0f76f17417 reduce the default stream protocol negotiation timeout (#1254) 2021-12-07 21:10:17 -08:00
Marten Seemann 1464cc7073 convert the IDService to an interface 2021-11-16 14:40:41 +04:00
Marten Seemann e1335f6274 emit the EvtPeerConnectednessChanged event 2021-10-25 16:00:29 +02:00
Marten Seemann 0aeef559d0 add an option to start the relay v2 2021-09-27 14:18:18 +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 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
Marten Seemann 82a43f7abd remove deprecated basichost.New constructor 2021-08-16 16:49:28 +02:00
Steven Allen 989fba5d32 Merge pull request #1147 from lthibault/enhancement/stateful-addr-events
Make BasicHost.evtLocalAddrsUpdated event emitter stateful.
2021-08-03 17:04:18 -07:00
godcong 99c48cfe99 fix(basic_host): stream not closed when context done 2021-08-03 22:20:39 +08:00
Louis Thibault fbcfca7ac3 Make BasicHost.evtLocalAddrsUpdated event emitter stateful. 2021-08-02 10:16:19 -04:00
Marten Seemann 25d36cdd05 remove deprecated identify.ClientVersion 2021-07-22 21:49:25 +02:00
Steven Allen 219a23aa99 fix(basic_host): process address filters even when not listening
That way, `Addrs` and the addresses emitted on the event bus are always
consistent.
2021-06-29 20:46:32 -07:00
snyh cc409ae169 perf/basic_host: Don't handle address change if we hasn't anyone 2021-06-29 20:31:54 -07:00
Steven Allen e482b45c66 fix: re-expose AutoNAT service on BasicHost
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).
2021-05-04 20:21:22 -07:00
Steven Allen 2ad02f79b2 chore: update to go-log v2 2021-04-29 14:15:17 -07:00
Cory Schwartz 04a93f4080 static check fixes 2021-04-29 14:08:24 -07:00