|
|
@ -415,9 +415,10 @@ namespace transport |
|
|
|
auto r = netdb.FindRouter (ident); |
|
|
|
auto r = netdb.FindRouter (ident); |
|
|
|
if (r && (r->IsUnreachable () || !r->IsReachableFrom (i2p::context.GetRouterInfo ()))) return; // router found but non-reachable
|
|
|
|
if (r && (r->IsUnreachable () || !r->IsReachableFrom (i2p::context.GetRouterInfo ()))) return; // router found but non-reachable
|
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
auto ts = i2p::util::GetSecondsSinceEpoch (); |
|
|
|
std::unique_lock<std::mutex> l(m_PeersMutex); |
|
|
|
std::unique_lock<std::mutex> l(m_PeersMutex); |
|
|
|
it = m_Peers.insert (std::pair<i2p::data::IdentHash, Peer>(ident, { 0, r, {}, |
|
|
|
it = m_Peers.insert (std::pair<i2p::data::IdentHash, Peer>(ident, { 0, r, {}, |
|
|
|
i2p::util::GetSecondsSinceEpoch (), {} })).first; |
|
|
|
ts, ts + PEER_ROUTER_INFO_UPDATE_INTERVAL, {} })).first; |
|
|
|
} |
|
|
|
} |
|
|
|
connected = ConnectToPeer (ident, it->second); |
|
|
|
connected = ConnectToPeer (ident, it->second); |
|
|
|
} |
|
|
|
} |
|
|
@ -753,8 +754,10 @@ namespace transport |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
session->SendI2NPMessages ({ CreateDatabaseStoreMsg () }); // send DatabaseStore
|
|
|
|
session->SendI2NPMessages ({ CreateDatabaseStoreMsg () }); // send DatabaseStore
|
|
|
|
|
|
|
|
auto ts = i2p::util::GetSecondsSinceEpoch (); |
|
|
|
std::unique_lock<std::mutex> l(m_PeersMutex); |
|
|
|
std::unique_lock<std::mutex> l(m_PeersMutex); |
|
|
|
m_Peers.insert (std::make_pair (ident, Peer{ 0, nullptr, { session }, i2p::util::GetSecondsSinceEpoch (), {} })); |
|
|
|
m_Peers.insert (std::make_pair (ident, Peer{ 0, nullptr, { session }, |
|
|
|
|
|
|
|
ts, ts + PEER_ROUTER_INFO_UPDATE_INTERVAL, {} })); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
@ -815,8 +818,18 @@ namespace transport |
|
|
|
it = m_Peers.erase (it); |
|
|
|
it = m_Peers.erase (it); |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
else |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if (ts > it->second.nextRouterInfoUpdateTime) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
auto session = it->second.sessions.front (); |
|
|
|
|
|
|
|
if (session) |
|
|
|
|
|
|
|
session->SendLocalRouterInfo (true); |
|
|
|
|
|
|
|
it->second.nextRouterInfoUpdateTime = ts + PEER_ROUTER_INFO_UPDATE_INTERVAL + |
|
|
|
|
|
|
|
rand () % PEER_ROUTER_INFO_UPDATE_INTERVAL_VARIANCE; |
|
|
|
|
|
|
|
} |
|
|
|
++it; |
|
|
|
++it; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
UpdateBandwidth (); // TODO: use separate timer(s) for it
|
|
|
|
UpdateBandwidth (); // TODO: use separate timer(s) for it
|
|
|
|
bool ipv4Testing = i2p::context.GetStatus () == eRouterStatusTesting; |
|
|
|
bool ipv4Testing = i2p::context.GetStatus () == eRouterStatusTesting; |
|
|
|
bool ipv6Testing = i2p::context.GetStatusV6 () == eRouterStatusTesting; |
|
|
|
bool ipv6Testing = i2p::context.GetStatusV6 () == eRouterStatusTesting; |
|
|
|