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

Method CreateToken

daemon/HTTPServer.cpp:1325–1340  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1323 std::map<uint32_t, uint32_t> HTTPConnection::m_Tokens;
1324
1325 uint32_t HTTPConnection::CreateToken ()
1326 {
1327 uint32_t token;
1328 RAND_bytes ((uint8_t *)&token, 4);
1329 token &= 0x7FFFFFFF; // clear first bit
1330 auto ts = i2p::util::GetSecondsSinceEpoch ();
1331 for (auto it = m_Tokens.begin (); it != m_Tokens.end (); )
1332 {
1333 if (ts > it->second + TOKEN_EXPIRATION_TIMEOUT)
1334 it = m_Tokens.erase (it);
1335 else
1336 ++it;
1337 }
1338 m_Tokens[token] = ts;
1339 return token;
1340 }
1341
1342 void HTTPConnection::HandlePage (const HTTPReq& req, HTTPRes& res, std::stringstream& s)
1343 {

Callers

nothing calls this directly

Calls 1

GetSecondsSinceEpochFunction · 0.85

Tested by

no test coverage detected