Skip to content

Commit f4754b9

Browse files
mzumsandevasild
andcommitted
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 <[email protected]>
1 parent e4d541c commit f4754b9

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/net.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,16 @@ bool GetLocal(CService& addr, const CNode& peer)
164164
LOCK(g_maplocalhost_mutex);
165165
for (const auto& entry : mapLocalHost)
166166
{
167+
// For privacy reasons, don't advertise our privacy-network address
168+
// to other networks and don't advertise our other-network address
169+
// to privacy networks.
170+
const Network our_net{entry.first.GetNetwork()};
171+
const Network peers_net{peer.ConnectedThroughNetwork()};
172+
if (our_net != peers_net &&
173+
(our_net == NET_ONION || our_net == NET_I2P ||
174+
peers_net == NET_ONION || peers_net == NET_I2P)) {
175+
continue;
176+
}
167177
int nScore = entry.second.nScore;
168178
int nReachability = entry.first.GetReachabilityFrom(peer.addr);
169179
if (nReachability > nBestReachability || (nReachability == nBestReachability && nScore > nBestScore))

0 commit comments

Comments
 (0)