mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-13 07:28:59 +01:00
net: restrict self-advertisements with privacy networks
Stop advertising 1) our i2p/onion address to peers from other networks 2) Local addresses of non-privacy networks to i2p/onion peers Doing so could lead to fingerprinting ourselves. Co-authored-by: Vasil Dimov <vd@FreeBSD.org>
This commit is contained in:
10
src/net.cpp
10
src/net.cpp
@@ -164,6 +164,16 @@ bool GetLocal(CService& addr, const CNode& peer)
|
|||||||
LOCK(g_maplocalhost_mutex);
|
LOCK(g_maplocalhost_mutex);
|
||||||
for (const auto& entry : mapLocalHost)
|
for (const auto& entry : mapLocalHost)
|
||||||
{
|
{
|
||||||
|
// For privacy reasons, don't advertise our privacy-network address
|
||||||
|
// to other networks and don't advertise our other-network address
|
||||||
|
// to privacy networks.
|
||||||
|
const Network our_net{entry.first.GetNetwork()};
|
||||||
|
const Network peers_net{peer.ConnectedThroughNetwork()};
|
||||||
|
if (our_net != peers_net &&
|
||||||
|
(our_net == NET_ONION || our_net == NET_I2P ||
|
||||||
|
peers_net == NET_ONION || peers_net == NET_I2P)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
int nScore = entry.second.nScore;
|
int nScore = entry.second.nScore;
|
||||||
int nReachability = entry.first.GetReachabilityFrom(peer.addr);
|
int nReachability = entry.first.GetReachabilityFrom(peer.addr);
|
||||||
if (nReachability > nBestReachability || (nReachability == nBestReachability && nScore > nBestScore))
|
if (nReachability > nBestReachability || (nReachability == nBestReachability && nScore > nBestScore))
|
||||||
|
|||||||
Reference in New Issue
Block a user