Commit Graph

574 Commits

Author SHA1 Message Date
vyzo 0d8a1852cf make tag value fixed, tagged in first circuit, untagged in last. 2021-09-21 13:37:41 +03:00
vyzo 369df59523 fix tag increment 2021-09-21 13:37:41 +03:00
vyzo 3df061d90e tag relay hops in relay implementations 2021-09-21 13:37:40 +03:00
vyzo d1e26810a0
Add standalone implementation of v1 Relay (#1186)
* add circuitv1 protobuf

* add implementation of v1 circuit relay

Intended to be used by standalone daemons and tests

* remove references to go-libp2p-circuit from production code

* update tests to use the in-tree v1 Relay

* use go-log/v2 in relay v1 impl

* use in-tree v1 relay in relay example

* remove go-libp2p-circuit dep from examples go.mod, go mod tidy
2021-09-20 00:29:42 -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 a5f982ff01
Merge pull request #1185 from libp2p/circuit-shutdown
don't use a context to shut down the circuitv2
2021-09-17 18:23:41 +02:00
Marten Seemann 729386c495 don't use a context to shut down the circuitv2 2021-09-17 11:37:28 +02:00
Steven Allen 2c69c99b23 fix: remove v1 go-log dep 2021-09-15 20:01:07 +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 3c25b386d9 merge branch 'hole-punching' 2021-09-08 18:23:13 +01: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 0797df7cbc
Merge pull request #1175 from libp2p/id-service-shutdown
don't use a context for closing the ObservedAddrManager
2021-09-07 14:30:40 +01:00
Marten Seemann 964880b872
Merge pull request #1174 from libp2p/circuitv2
move the circuit v2 code here
2021-09-07 14:24:30 +01:00
Marten Seemann 9342776c9c allow concurrent calls to Close and SetTTL in the ObservedAddrManager 2021-09-07 13:48:07 +01:00
Marten Seemann b25e0b1274 stop using jbenet/go-cienv 2021-09-05 19:12:58 +01:00
Marten Seemann 2cf1c457d5 don't use a context for closing the ObservedAddrManager 2021-09-05 18:30:11 +01:00
Marten Seemann 07dbdf262f remove unnecessary sync.Once from the identify service 2021-09-05 18:07:10 +01:00
Marten Seemann 2d07a0d973 chore: update go-libp2p-autonat to v0.5.0 2021-08-30 10:57:52 +01:00
Steven Allen fd4d2a47e2
Merge pull request #1172 from libp2p/fix-flaky-obsaddr-test
fix flaky TestObsAddrSet test
2021-08-27 12:37:55 -07:00
Marten Seemann 6e75f7e767 fix flaky TestObsAddrSet test 2021-08-27 11:26:10 +01:00
Marten Seemann a507d12bd4 clean up messy defer logic in IDService.sendIdentifyResp 2021-08-27 09:52:08 +01:00
Marten Seemann ec3c9cbf49
implement the new mDNS spec, move the old mDNS implementation (#1161)
* move the current mdns discovery implementation to discovery_legacy

* use libp2p/zeroconf for mDNS discovery

* rename the discovery package to mdns

* don't store the context

* use a wait group for clean shutdown of the mdns resolver

* add comment about port numbers

* move the mdns packages p2p/discovery
2021-08-18 09:15:56 -07:00
Marten Seemann 82a43f7abd remove deprecated basichost.New constructor 2021-08-16 16:49:28 +02:00
Marten Seemann c67489ddf2 base limits on reservations issued (#132)
* base limits on reservations issued

* switch default reservation limits per peer and per IP

* don't export the constructor for relay.constraints

* panic when reading from crypto/rand fails

* optimize IP-based reservation lookup

* use lists instead of maps to save reservations

* save expiry timestamp in reservations

* use slices instead of linked lists for reservations

* remove unused rand in constraints
2021-08-05 19:13:49 +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
Steven Allen d38694b8cd
Merge pull request #1136 from libp2p/fix/deprecated
fix: remove deprecated call
2021-07-22 15:43:40 -07:00
Steven Allen 38eb9a71cd fix: remove deprecated call 2021-07-22 15:39:35 -07:00
Marten Seemann 25d36cdd05 remove deprecated identify.ClientVersion 2021-07-22 21:49:25 +02:00
Marten Seemann 7a72c33aef remove rollback logic when writing reservation fails 2021-07-06 12:34:47 -07:00
Marten Seemann b44b6de1b8 remove unneeded handleReserve function parameter 2021-07-06 11:51:21 -07:00
vyzo 7872bd5a44 p2p-circuit v2 (#125)
* v2 client scaffolding

* gomod: go-libp2p-core and go-libp2p-transport-upgrader feature dependencies

* Conn implements network.ConnStat

* add reservation stub

* utilities

* dial scaffolding and v1 compat dialing

* stream handling scaffolding and v1 incoming connection handling

* implement hop tagging

* export timeout variables

* v2 protobuf

* v2 client protocol implementation

* implement Reserve

* go get go-libp2p-swarm@feat/transient-conns

* implement client.New

* rework pb status codes

* client responds with UNEXPECTED_MESSAGE when it's actually an unexpected message

* relay scaffolding, reservation implementation

* implement relaying

* implement missing details

* add options for resources/limit

* gc idle conn counts

* fix clown shoes in cancellation check

* end to end relay test

* untag peers with expired reservations

* add time limit test

* better debug log for accepted conns

* add data limit test

* add v2-v1 compatibility tests

* godocs

* add WithACL relay option

* only return public relay addrs in reservation record

* remove the refresh restriction madness

* set default limit Data to 128K

* fix typo in AllowReserve godoc

* fix some small issues

- remove context from constructor
- remove stream handler when closing the host
- remove the awkward cancellation check from handleStream

* fix tests

* address review comments

- Add deadline for Reserve calls
- Add deadline for dials
- Add some comments for things that confuse aarsh.

* humor aarsh and add initializers for slices

* comment nitpicks

* fix bug in slice pre-allocations

* add deadline to connectV1

* make Relay.Close thread-safe

* untag peers with reservations when closing the relay

* gomod: get go-libp2p-asn-util

* add IP/ASN reservation constraints

* gomod: update deps

* fix e2e test

* increase default limit duration to 2min

* update protocol for vouched relay addrs; provide absolute expiration time instead of TTL

* update for reservation changes

* add voucher to the reservation pb

* TODO about reservation vouchers

* deduplicate protocol ID definitions between relay and client

* add reservation vouchers

* emit and consume reservation vouchers

* improve limit data test

* deduplicate concurrent relay dials to the samke peer

* improve dialer deduplication

* add a short timeout to dialing the relay in order to aid deduplication

* gomod: fix go1.16 madness

* spec compliance: don't include p2p-circuit in reservation addrs

* spec compliance: refuse reservation and connection attempts over relayed connections

* test shim: add empty file in test directory

* spec compliance: update protobuf

* spec compliance: use libp2p envelopes for reservation vouchers

* fix staticcheck

Co-authored-by: Marten Seemann <martenseemann@gmail.com>
2021-09-02 20:25:16 +01: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
Jakub Sztandera d82385ef70
Deterministic lock order
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
2021-06-07 20:45:07 +02:00
Jakub Sztandera 79cc9a4bae
Fix race in adding connections to connsByPeer
Side A could already be running Identify with side B before B had the
connection in the connsByPeer, this lead to Connectedness returning
NotConnected and Identify failing.

Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
2021-06-07 18:49:09 +02:00
Steven Allen a26ef70657
Merge pull request #1103 from libp2p/speedup-mock-test
speed up the mock tests
2021-05-18 10:19:22 -07:00
Marten Seemann a2b8ed16f8 speed up the mock tests 2021-05-18 09:03:37 -07:00
Marten Seemann 2603aac445 remove slow ObservedAddrManager test that doesn't test anything 2021-05-17 20:02:04 -07:00
Steven Allen b7e0282037 test: rewrite backpressure test
We just want to make sure we don't keep writing forever if the other
side isn't reading.
2021-05-04 22:09:47 -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 c7902333be test: deflake TestProtoDowngrade
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.
2021-04-30 17:30:36 -07:00
Steven Allen a6747e5b72 test: deflake tests 2021-04-29 22:20:44 -07:00
web3-bot 218f33bc62 run gofmt -s 2021-04-29 21:35:37 +00:00
Steven Allen 2ad02f79b2 chore: update to go-log v2 2021-04-29 14:15:17 -07:00
Steven Allen 2a72777ef9 fix: address review feedback 2021-04-29 14:13:54 -07:00
Cory Schwartz 12753d3795 advertise util 2021-04-29 14:12:47 -07:00