Skip to content
This repository has been archived by the owner on May 11, 2022. It is now read-only.

Early rescan when all network connections closed #39

Closed
wants to merge 1 commit into from

Conversation

willscott
Copy link
Contributor

Partially address #34

@Stebalien
Copy link
Member

What's the motivation for this change?

@willscott
Copy link
Contributor Author

The real event of 'network change' that should reset autonat is likely to be an approximation - mostly because the underlying host won't always or reliably know that the network environment has changed.

Some options:

  • We could poll net.InterfaceAddrs() to see if local addresses have changed from DHCP.
  • We could try platform specific methods like netlink sockets to try to get notified of network changes as the OS understands them.

The heuristic here is that if your network gets disconnected or switched, your existing connections will all time out / close. If you find yourself with no active connections (and you expect to generally be maintaining at least some connections in a passive state) that's an indication that you probably should have less confidence in your previous externally visible address remaining the same.

@Stebalien
Copy link
Member

Stebalien commented Feb 11, 2020

Got it. My concern here is that, when we disconnect from all peers, we likely have no internet so this will likely fail. Then, when we start connecting to new peers, we won't take any additional actions.

The correct way to do this would be to listen for the EvtLocalAddressesUpdated event (defined in go-libp2p-core) from the libp2p event bus (host.EventBus()).

Unfortunately..., it doesn't look like we've hooked that up. However, I'd just go ahead and do that anyways (i.e., use events) then file an issue in go-libp2p about adding address change detection to the swarm host.

@Stebalien
Copy link
Member

We could poll net.InterfaceAddrs() to see if local addresses have changed from DHCP.

We actually do this (effectively) in "BasicHost" (defined in go-libp2p).

@raulk
Copy link
Member

raulk commented Feb 11, 2020

The hooking up of the “local addrs updated” event in the host is here: libp2p/go-libp2p#747

@aarshkshah1992
Copy link
Collaborator

aarshkshah1992 commented Feb 26, 2020

@willscott This PR can be closed as I think you plan to address this change by consuming the EvtLocalAddressesUpdated event here.

@willscott willscott closed this Feb 26, 2020
@willscott willscott deleted the feat/network-change branch February 26, 2020 15:37
willscott added a commit that referenced this pull request Mar 13, 2020
* limits addresses for a peer (at most 4 chosen) - fix #39
* clears addresses before dialing back - fix #38
* global rate limit of 30 responses per (1 - 1.25 min) - fix #36
* only dial back on the source IP - fix #32
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants