Network discovery: store the remote address of the peer after finishing a successful handshake #2900
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What's in this pull request?
Previously we used the
remote_addr
directly from thehandle_pending_inbound_connection
to check if it's banned. However this will never work correctly because it also containsMultiaddr
protocol parts like/tcp/{random port}
and others. Since a new connection always gets opened on a new port you have a differentMultiaddr
on each connection thus never find a bannedMultiaddr
.This PR adds storing a remote address in the
PeerContactMeta
that only contains aip4
,ip6
,dns4
ordns6
part of aMultiaddr
that can be used to correctly verify if IP or hostname is banned.Lastly this PR solves the problem of banning observed peer addresses, which could lead to banning
127.0.0.1
. Fixes #2896.