Commit Graph

214 Commits

Author SHA1 Message Date
Marten Seemann 6a5da01b04 Merge pull request #1075 from coryschwartz/feat/fix-go-vet
fix go vet
2021-04-20 23:57:41 +07:00
Cory Schwartz 628f86c689 fix go vet 2021-04-14 12:27:40 -07: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 69916ed465 Emit event for User's NAT Type i.e. Hard NAT or Easy NAT (#1042)
* emit NAT device type
2021-02-19 15:14:03 +05:30
Aarsh Shah 890f2e86b2 Close peerstore and document Host Close (#1037)
* close peerstore and docs change

* update docs
2021-01-19 10:57:34 +05:30
Steven Allen 024f1af9ae fix: obey new stream timeout 2020-12-08 14:35:58 -08:00
Steven Allen 7a98f28856 feat: update to go-libp2p-core 0.7.0 interface changes
This patch updates go-libp2p for the stream interface changes in go-libp2p-core
0.7.0. This is a _significant_ breaking change to streams and all users should
read https://github.com/libp2p/go-libp2p-core/releases/tag/v0.7.0. In practice,
this change should remove a significant footgun.

TL;DR:

* `Stream.Close` now behaves like `net.TCPConn.Close`.
* There is a new `Stream.CloseWrite` (send an EOF) and `Stream.CloseRead` (close
  for reading), behaving like their counterparts in `net.TCPConn`.
2020-11-11 09:35:37 -08:00
Steven Allen 717d9e7574 fix: use the correct external address when NAT port-mapping
Previously, we'd construct addresses like `/ip4/.../udp/...` instead of
`/ip4/.../udp/.../quic` because we'd use mapped addr (ip + transport + port)
instead of the full external address (ip + transport + port + other
transports...).
2020-08-03 10:29:26 -07:00
sandman d9a4e38ac4 fix to call PublicAddr interface of AutoNat 2020-07-24 10:12:58 +08:00
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
Steven Allen 9cd6aaa9ea Fix address advertisement bugs (#974)
* fix: use all interface addresses when we can't find the default route
* fix: don't add advertise unspecified addresses
* fix: resolve addresses before looking up observed addresses
* fix: only advertise global unicast
* fix: filter link-local addresses from advertisement
* test: fix basic host addr tests
2020-07-07 16:41:45 -07:00
Steven Allen 1180b6fa1e fix(nat): use the right addresses when nat port mapping
We switched `listenAddrs` from the _interface_ addresses to the raw addresses we
were listening on. Unfortunately, we needed the resolved addresses later in the
function when resolving port mappings.
2020-06-09 15:55:15 -07:00
Aarsh Shah 6b34fff392 fixed compilation error (#956) 2020-05-29 19:55:04 +05:30
Aarsh Shah 3a1d20b748 Filter Interface Addresses (#936)
* Filter Host Addresses
2020-05-29 19:46:58 +05:30
Yusef Napora bd9e7b59ce detect listen addr changes in BasicHost 2020-05-19 16:12:56 -04:00
Aarsh Shah a7671efe6b no signed peer records for mocknets (#934)
* Disable generation of Signed peer record for Mockenets.
2020-05-19 13:16:54 +05:30
Aarsh Shah 973933ad7d Remove race between ID, Push & Delta (#907)
* Solve races between Identify, Push and Delta.
2020-05-13 10:50:37 +05:30
Raúl Kripalani d9d18512ca fix a compilation error introduced in 077a818. (#919) 2020-05-12 17:24:58 +01:00
Yusef Napora 077a81814f exchange signed routing records in identify (#747)
*  Exchange signed routing records in identify


Co-authored-by: Aarsh Shah <aarshkshah1992@gmail.com>
2020-04-30 11:06:31 +05:30
Steven Allen bd040ba050 fix: refactor logic for identifying connections
0. NEVER call `peerstore.SetProtocols(p)` (clear the protocol set). Given the
   new identify events, if someone looked in the peerstore at the wrong time, they
   could decide that the peer no longer speaks some protocol.
1. Reliably wait for identify before trying to open a stream. The old logic was
   _really_ racy.
2. Avoids potentially calling identify on the same connection multiple times.
3. Calls identify as early as possible. Previously, we'd invoke identify on
   inbound connections using an event that was only invoked _after_ all `Connected`
   event handlers completed. Now we invoke identify from a `Connected` handler.
2020-04-24 19:05:22 -07:00
Aarsh Shah 615f125342 Remove goprocess from Host (#865)
* remove goprocess from Host
2020-04-06 11:34:45 +05:30
Aarsh Shah e17a6f8bf2 remove lastaddrs as member variable 2020-03-25 00:52:25 +05:30
Aarsh Shah fa575b4d32 changes as per review 2020-03-25 00:35:26 +05:30
Aarsh Shah 82be3ee46f signal address change 2020-03-25 00:10:23 +05:30
Aarsh Shah d49806efc9 emit address change evt 2020-03-20 10:04:13 +05:30
Aarsh Shah ed4646f711 local addr updated event 2020-03-19 19:05:15 +05:30
optman 3f43dfe646 enable non-public address port mapping announcement 2020-01-15 18:38:39 +08:00
Steven Allen 9073eaaf8f fix: demote stream deadline errors to debug logs
Otherwise, we spam an error every time we try to negotiate a protocol on a
closed stream (e.g., when the underlying connection closes on us).
2020-01-03 09:14:43 -08:00
Steven Allen e5d28696f5 feat(host): recursively resolve addresses
We currently only resolve /dnsaddr addresses once. This patch resolves up to 32
dnsaddr addresses per dial.

fixes https://github.com/libp2p/go-libp2p/issues/744
2019-12-16 15:53:51 +01:00
Steven Allen d73a51776e new: allow overriding the user-agent with an option
Instead of using a global variable.

This also:

* Adds an option to the identify service to set the user agent.
* Removes the ability to pass an identify service to NewHost as any reasonable
  Identify service already needs to be constructed with an instance of the host.
2019-08-12 19:13:21 -07:00
Christian Muehlhaeuser 169f2d4139 Avoid unnecessary conversions (#685)
No need to convert these types.
2019-07-22 13:46:15 +01:00
Christian Muehlhaeuser 0603b30056 Make use of time.Until & time.Since (#681)
No need to manually subtract timestamps.
2019-07-22 13:44:47 +01:00
Steven Allen 428d7135a5 doc: ensure nobody tries to add teardown logic to the host close function again 2019-07-04 12:46:17 -07:00
Steven Allen 2f06021e0c fix: use the goprocess for closing
fixes #668
2019-07-04 12:32:01 -07:00
Raúl Kripalani e69d17141c integrate the event bus, handle protocol update events, make identify emit deltas (#659) 2019-06-24 14:44:47 +01:00
Steven Allen 1449765980 basic_host: ensure we close correctly when the context is canceled
As long as we _accept_ a context, we need to obey it.
2019-06-13 11:14:44 -07:00
Raúl Kripalani d87f89314c Consolidate abstractions and core types into go-libp2p-core (#601) 2019-05-26 22:55:46 +01:00
vyzo 3437213b5f close connection manager 2019-05-21 14:03:28 +03:00
vyzo b8616c65b3 use cancelable background context in identify 2019-05-07 21:33:19 +03:00
vyzo f17a4a8667 preallocate map in sameAddrs 2019-04-19 20:03:53 +03:00
vyzo ebc5d16f5d use a map in sameAddrs to avoid quadratic behaviour 2019-04-19 20:03:53 +03:00
vyzo c73f68bdb4 explicit Start method for basic host 2019-04-19 20:03:53 +03:00
vyzo 5845909754 add initialization delay in basic host background task 2019-04-19 20:03:53 +03:00
vyzo 7502fc44c9 add a background task in basic host that periodically pushes identify if needed 2019-04-19 20:03:53 +03:00
vyzo b8a152f593 use a background worker for updating/gcing the observed address set 2019-04-09 12:44:13 +03:00
Steven Allen 3617750071 better nat mapping
1. Update to work with https://github.com/libp2p/go-libp2p-nat/pull/14.
2. Avoid observed addrs when our NAT tells us about external addrs.
3. Ignore bad addrs reported by our NAT. Substitute with observed addrs.
4. Fix https://github.com/libp2p/go-libp2p/issues/428.
2019-03-06 10:56:49 -08:00
Matt Joiner 3b8d83ffdc Resolve addrs with P2P instead of IPFS (#539) 2019-02-16 12:43:11 +11:00
vyzo 5d8988f3ee add comment about the unstable nature of BasicHost.PushIdentify 2018-11-04 10:52:29 +02:00
vyzo a89e74a155 basic host: export AddrsFactory, provide method to push identify 2018-11-04 10:52:29 +02:00
vyzo 0fa1c25479 ping service in basic host 2018-10-19 12:28:58 +03:00