Commit Graph

498 Commits

Author SHA1 Message Date
Cyril Fougeray 16d314cf30 Deduplicating code when parsing ipv4/ipv6 address; from the comment on the PR 2020-08-20 18:36:07 +02:00
Cyril Fougeray 3fa37a3452 Added parsing of IPv6 addresses for incomming mDNS requests 2020-08-11 15:04:54 +02:00
Will 7cfc4e645e
Bump Autonat version & validate fixed call loop in `.Addrs` (#988)
* add test for host address with attached autonat
* bump autonat release
2020-08-03 14:33:21 -04: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
Raúl Kripalani a5786f0415
upgrade deps + interoperable uvarint delimited writer/reader. (#985) 2020-07-30 12:42:57 +01: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 6a3b138a57
Merge pull request #971 from libp2p/fix/close-deadlock
fix: avoid a close deadlock in the natmanager
2020-06-23 10:21:59 -07:00
Steven Allen 72770db2f6 fix: avoid a close deadlock in the natmanager
Before, we would:

1. Receive a "listen close" event from an event handler, after the teardown started.
2. Try to add a child process to handle the event. This would block because we
were in the teardown.
3. In the teardown, try to unregister the event handler and deadlock

I've now:

* Removed the teardown.
* Switched to a single event loop.

Ideally, we'd remove goprocess entirely. But we'd need to refactor natmgr.

fixes #933
2020-06-22 16:33:19 -07:00
Raúl Kripalani 985120b6f9
upgrade swarm; add ID() on mock conns and streams. (#970) 2020-06-16 19:45:28 +01: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
Steven Allen 34e67e019e Fix peer handler race
Alternative to #963. Instead of using atomics, this patch ensures that all state
changes are performed on the main thread. It also:

* Threads the context through explicitly to make sure fields changed by the main
thread are never read by the handler goroutines. This isn't strictly necessary
but it makes it easier to reason about.
* Uses a callback to signal "on done". There may be cleaner ways to do this (I
hate callbacks), but this nicely decouples the peer handler from the main loop.

fixes #963
2020-06-05 10:20:28 -07:00
Steven Allen 5ae0888629 fix(id): document observation struct 2020-06-04 14:57:07 -07:00
Steven Allen a03403fa64 fix: optimize numInbound count
We call this _very_ frequently when computing our local addresses.
2020-06-04 14:55:17 -07:00
Steven Allen 1e4ce46ca7 test(id): fix nits 2020-06-04 14:55:17 -07:00
Steven Allen 1dd7a8c4d4 fix: count observations with at least one inbound connection as inbound
We prefer addresses from inbound connections. We don't want outbound connections
to hide these perfectly good addresses.
2020-06-04 14:55:13 -07:00
Steven Allen 6ca83309d2 fix(mocknet): set inbound/outbound on the right link 2020-06-04 14:55:13 -07:00
Steven Allen a0813d7292 fix: make address observation types private
We don't use and/or expose these anyways. Making them private makes it easier to
reason about their state.
2020-06-04 14:55:10 -07:00
Steven Allen b22add866a fix: remove more field
We no longer need it now that we keep reading till the stream closes.
2020-06-03 15:41:08 -07:00
Aarsh Shah 513e13d0d2 changes as per review 2020-06-03 15:27:03 -07:00
Aarsh Shah c4a1e220ac test large push msgs 2020-06-03 15:27:02 -07:00
Aarsh Shah 60b52f10ae more protocol strings 2020-06-03 15:27:02 -07:00
Aarsh Shah 1b36fd8697 first draft 2020-06-03 15:27:01 -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
Steven Allen 294ba3dfac
Merge pull request #953 from libp2p/fix/remove-addresses-immediately
fix: remove old addresses in identify immediately
2020-05-27 19:14:33 -07:00
Steven Allen be70fa2460 test: fix test for immediately forgetting addresses 2020-05-27 16:58:53 -07:00
Steven Allen 59062c6d6d fix: remove old addresses in identify immediately
Previously, we'd keep addresses discovered through the DHT for up to 2
minutes (temporary TTL) and previously seen addresses (recently connected) for
up to 10 minutes (the TTL).

1. Make sure to downgrade both connected and recently connected addresses to the
"temporary" ttl before adding new addresses.
2. Finally, downgrade addresses with the temporary TTL to 0.

This could be more efficient with a better peerstore abstraction, but this is
better than nothing.
2020-05-27 16:22:39 -07:00
Aarsh Shah 0dd65a5998
fix flaky test (#952)
Fix flaky TestIdentifyPushOnAddrChange
2020-05-21 12:02:29 +05:30
Steven Allen 6ef5f5dacf fix: group observations by zeroing port
In #917, we started dropping additional address observations if we had multiple
for the same transport set. However, on further consideration, this isn't quite
correct. We _want_ to keep additional observations for multiple IP addresses.
The real issue is many observations for different ports.

So this patch simply changes the key with which we group observations from
"address protocols" to "address without the port" (well, with the port set to
0).
2020-05-20 12:13:25 -07:00
Aarsh Shah ba118a4d14 create subscriber first 2020-05-20 15:10:04 +05:30
Aarsh Shah 79ead33e32
Filter observed addresses (#917)
* filter observed addrs
2020-05-20 11:39:45 +05:30
Steven Allen 01da330ef2 fix: don't try to marshal a nil record
fixes #939
2020-05-19 18:15:33 -07:00
Steven Allen aa60461752
Merge pull request #941 from libp2p/test/peer-records-no-listen-addrs
add test to demo missing peer records after listen
2020-05-19 18:10:57 -07:00
Steven Allen e3a983a355 fix: don't leak a goroutine if a peer connects and immediately disconnects 2020-05-19 13:37:52 -07:00
Yusef Napora 82c11bce2a sleep longer in test 2020-05-19 16:15:28 -04:00
Yusef Napora bd9e7b59ce detect listen addr changes in BasicHost 2020-05-19 16:12:56 -04:00
Yusef Napora 3364dccbbf make test fail to demonstrate issue 2020-05-19 14:38:25 -04:00
Yusef Napora 0d6e02e95b add test to demo missing peer records after listen 2020-05-19 14:20:24 -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
Steven Allen b42ba0faf3
various identify fixes and nits (#922)
* various identify fixes and nits

Co-authored-by: Aarsh Shah <aarshkshah1992@gmail.com>
2020-05-14 17:24:10 +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 84b923c7bf fix: address code review 2020-04-24 23:54:07 -07:00
Steven Allen 06d9fc7987 fix: keep observed addrs alive as long as their associated connections are alive
Otherwise, if we're not creating new connections, we'll eventually forget them.

Up until now, this wasn't _too_ much of an issue because our peers would still
remember our addresses. However, we now _tell_ our connected peers when our
addresses change. That means we'll tell our peers to forget where we are,
preventing anyone from finding us.
2020-04-24 22:55:16 -07:00
Steven Allen d3b7b3b907 test: fix a flaky test 2020-04-24 19:33:19 -07:00
Aarsh Shah 3d676b688c skip test local addr filtering 2020-04-24 19:05:23 -07:00
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