MCPcopy Create free account
hub / github.com/PurpleI2P/i2pd / GetIncomingToken

Method GetIncomingToken

libi2pd/SSU2.cpp:1266–1282  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1264 }
1265
1266 uint64_t SSU2Server::GetIncomingToken (const boost::asio::ip::udp::endpoint& ep)
1267 {
1268 auto ts = i2p::util::GetSecondsSinceEpoch ();
1269 auto it = m_IncomingTokens.find (ep);
1270 if (it != m_IncomingTokens.end ())
1271 {
1272 if (ts + SSU2_TOKEN_EXPIRATION_THRESHOLD <= it->second.second)
1273 return it->second.first;
1274 else // token expired
1275 m_IncomingTokens.erase (it);
1276 }
1277 uint64_t token;
1278 RAND_bytes ((uint8_t *)&token, 8);
1279 if (!token) token = 1; // token can't be zero
1280 m_IncomingTokens.try_emplace (ep, token, uint32_t(ts + SSU2_TOKEN_EXPIRATION_TIMEOUT));
1281 return token;
1282 }
1283
1284 std::pair<uint64_t, uint32_t> SSU2Server::NewIncomingToken (const boost::asio::ip::udp::endpoint& ep)
1285 {

Callers 3

ProcessSessionRequestMethod · 0.80
SendRetryMethod · 0.80
HandleRelayIntroMethod · 0.80

Calls 1

GetSecondsSinceEpochFunction · 0.85

Tested by

no test coverage detected