Skip to content

Commit 91f0a7f

Browse files
committed
p2p: add only reachable addresses to addrman
We will not make outgoing connection to peers that are unreachable (e.g. because of -onlynet configuration). Therefore, it makes no sense to add them to addrman in the first place. While this is already the case for addresses received via p2p addr messages, this commit does the same for addresses received from fixed seeds.
1 parent 6dc3084 commit 91f0a7f

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/net.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1635,10 +1635,15 @@ void CConnman::ThreadOpenConnections(const std::vector<std::string> connect)
16351635
}
16361636

16371637
if (add_fixed_seeds_now) {
1638+
std::vector<CAddress> seed_addrs{ConvertSeeds(Params().FixedSeeds())};
1639+
seed_addrs.erase(std::remove_if(seed_addrs.begin(), seed_addrs.end(),
1640+
[](const CAddress& addr) { return !IsReachable(addr); }),
1641+
seed_addrs.end());
16381642
CNetAddr local;
16391643
local.SetInternal("fixedseeds");
1640-
addrman.Add(ConvertSeeds(Params().FixedSeeds()), local);
1644+
addrman.Add(seed_addrs, local);
16411645
add_fixed_seeds = false;
1646+
LogPrintf("Added %d fixed seeds from reachable networks.\n", seed_addrs.size());
16421647
}
16431648
}
16441649

0 commit comments

Comments
 (0)