mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-15 12:51:00 +02:00
Cache responses to addr requests
Prevents a spy from scraping victim's AddrMan by reconnecting and re-requesting addrs.
This commit is contained in:
parent
7cc0e8101f
commit
acd6135b43
3 changed files with 43 additions and 1 deletions
11
src/net.cpp
11
src/net.cpp
|
|
@ -2539,6 +2539,17 @@ std::vector<CAddress> CConnman::GetAddresses()
|
|||
return addresses;
|
||||
}
|
||||
|
||||
std::vector<CAddress> CConnman::GetAddresses(Network requestor_network)
|
||||
{
|
||||
const auto current_time = GetTime<std::chrono::microseconds>();
|
||||
if (m_addr_response_caches.find(requestor_network) == m_addr_response_caches.end() ||
|
||||
m_addr_response_caches[requestor_network].m_update_addr_response < current_time) {
|
||||
m_addr_response_caches[requestor_network].m_addrs_response_cache = GetAddresses();
|
||||
m_addr_response_caches[requestor_network].m_update_addr_response = current_time + std::chrono::hours(21) + GetRandMillis(std::chrono::hours(6));
|
||||
}
|
||||
return m_addr_response_caches[requestor_network].m_addrs_response_cache;
|
||||
}
|
||||
|
||||
bool CConnman::AddNode(const std::string& strNode)
|
||||
{
|
||||
LOCK(cs_vAddedNodes);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue