Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Track more info for observed addresses #427

Merged
merged 4 commits into from
Oct 1, 2018

Conversation

cannium
Copy link
Contributor

@cannium cannium commented Sep 18, 2018

Fix #416

@cannium cannium force-pushed the track-more-observed-address-info branch from edace18 to cd2f749 Compare September 18, 2018 03:49
@cannium
Copy link
Contributor Author

cannium commented Sep 20, 2018

ping @vyzo @Stebalien for review.
Add internal address and connection direction to observed address info

@vyzo
Copy link
Contributor

vyzo commented Sep 20, 2018

is this actually useful?

@cannium
Copy link
Contributor Author

cannium commented Sep 20, 2018

This patch pave the way for #421, so peers would see less addresses that are actually not reachable.

@Stebalien
Copy link
Member

Stebalien commented Sep 24, 2018

is this actually useful?

Very. Without this, we don't know:

  1. The direction of the mapping. This matters on many NATs.
  2. The actual mapping. That is, which internal address maps to which external address. Currently, we only record our external addresses but we don't actually remember which internal addresses they appear to map to.

@Stebalien
Copy link
Member

I believe the we need to map internal to external to observation. This currently records the first observed internal address (and the first observed direction) but that may not be consistent. That is, I believe we'd want something like:

map[<internal address>]map[<observed/external address>]Observation { SeenBy: map[<peer addr>] {time, direction}}

That way, for each internal address, we can list out all the observed external addresses and figure out where from and how they've been observed.

@cannium
Copy link
Contributor Author

cannium commented Sep 25, 2018

I think an internal address could be observed as multiple external addresses, not the opposite. Say my node is listening on 10.0.0.1:4001, I can configure multiple port mappings for it, so observed address could be 200.0.0.1:5000, 200.0.0.1:6000, etc.

@Stebalien
Copy link
Member

You can get both (technically). These observed addresses include observed addresses from outbound connections. It's possible for two sequential (non-overlapping) connections from different internal ports to end up using the same external port.

@cannium
Copy link
Contributor Author

cannium commented Sep 25, 2018

That's possible, but from my experience, is very rare. A reasonable NAT implementation would avoid port reuse in a very short time, so if two internal ports are mapped to the same external port, it's highly possible that the first connection is considered as closed.

@Stebalien
Copy link
Member

It's also possible for a peer to lie. IMO, that's the real issue here. The only thing we know is the internal address. The external address is just an observation being reported by a peer.

@cannium
Copy link
Contributor Author

cannium commented Sep 26, 2018

That's still a 1:n relationship between internal address and external addresses, the map would be like external address -> internal address, or you mean we should do internal address -> list of external addresses?

@Stebalien
Copy link
Member

The latter. Specifically: internal -> {external -> { observer -> [time, direction] } }. That way, for any port I'm explicitly listening on, I can see which external addresses have been reported. For each external address, I can see who reported them, when, and the connection direction.

- map internal -> []{external -> { observer -> [time, direction] } }
- some cleaning
@cannium cannium force-pushed the track-more-observed-address-info branch from cd2f749 to 96df62b Compare September 26, 2018 08:54
@cannium
Copy link
Contributor Author

cannium commented Sep 26, 2018

I think I misunderstood your intention, updated now. Another idea occurs to me that ObservedAddrSet might be better tracked together with peerstore.

@cannium
Copy link
Contributor Author

cannium commented Sep 28, 2018

Any comments? Still invalid implementation?

Copy link
Member

@Stebalien Stebalien left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two small nits but this otherwise looks like a great improvement!

}
filteredAddrMap[local] = filteredAddrs
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason not to update oas.addrs directly?

p2p/protocol/identify/obsaddr.go Show resolved Hide resolved
@cannium cannium force-pushed the track-more-observed-address-info branch from 1b8e752 to 92ec4b2 Compare September 29, 2018 12:16
@cannium
Copy link
Contributor Author

cannium commented Sep 29, 2018

Re-run CI, tests passed now.

@Stebalien Stebalien merged commit 57ed88e into libp2p:master Oct 1, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants