aboutsummaryrefslogtreecommitdiff
path: root/src/net.cpp
diff options
context:
space:
mode:
authordergoegge <n.goeggi@gmail.com>2022-04-12 13:47:48 +0200
committerdergoegge <n.goeggi@gmail.com>2022-06-02 19:03:54 +0200
commit3382905befd23364989d941038bf7b1530fea0dc (patch)
tree0d71c5bdfd79007deb8623d6c15c3989f8ed5300 /src/net.cpp
parentf10e80b6e4fbc151abbf1c20fbdcc3581d3688f0 (diff)
downloadbitcoin-3382905befd23364989d941038bf7b1530fea0dc.tar.xz
[net] Seed addr cache randomizer with port from binding address
Diffstat (limited to 'src/net.cpp')
-rw-r--r--src/net.cpp3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/net.cpp b/src/net.cpp
index e8c131b5b0..3820ee1fd0 100644
--- a/src/net.cpp
+++ b/src/net.cpp
@@ -2801,6 +2801,9 @@ std::vector<CAddress> CConnman::GetAddresses(CNode& requestor, size_t max_addres
uint64_t cache_id = GetDeterministicRandomizer(RANDOMIZER_ID_ADDRCACHE)
.Write(requestor.ConnectedThroughNetwork())
.Write(local_socket_bytes.data(), local_socket_bytes.size())
+ // For outbound connections, the port of the bound address is randomly
+ // assigned by the OS and would therefore not be useful for seeding.
+ .Write(requestor.IsInboundConn() ? requestor.addrBind.GetPort() : 0)
.Finalize();
const auto current_time = GetTime<std::chrono::microseconds>();
auto r = m_addr_response_caches.emplace(cache_id, CachedAddrResponse{});