mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-04-28 11:47:48 +02:00
generate new token with longer expiration time
This commit is contained in:
parent
079f7e515c
commit
67252b90b3
4 changed files with 21 additions and 9 deletions
|
@ -582,16 +582,25 @@ namespace transport
|
|||
return 0;
|
||||
}
|
||||
|
||||
std::pair<uint64_t, uint32_t> SSU2Server::GetIncomingToken (const boost::asio::ip::udp::endpoint& ep)
|
||||
uint64_t SSU2Server::GetIncomingToken (const boost::asio::ip::udp::endpoint& ep)
|
||||
{
|
||||
auto it = m_IncomingTokens.find (ep);
|
||||
if (it != m_IncomingTokens.end ())
|
||||
return it->second;
|
||||
return it->second.first;
|
||||
uint64_t token;
|
||||
RAND_bytes ((uint8_t *)&token, 8);
|
||||
auto ret = std::make_pair (token, i2p::util::GetSecondsSinceEpoch () + SSU2_TOKEN_EXPIRATION_TIMEOUT);
|
||||
m_IncomingTokens.emplace (ep, std::make_pair (token, i2p::util::GetSecondsSinceEpoch () + SSU2_TOKEN_EXPIRATION_TIMEOUT));
|
||||
return token;
|
||||
}
|
||||
|
||||
std::pair<uint64_t, uint32_t> SSU2Server::NewIncomingToken (const boost::asio::ip::udp::endpoint& ep)
|
||||
{
|
||||
m_IncomingTokens.erase (ep); // drop previous
|
||||
uint64_t token;
|
||||
RAND_bytes ((uint8_t *)&token, 8);
|
||||
auto ret = std::make_pair (token, i2p::util::GetSecondsSinceEpoch () + SSU2_NEXT_TOKEN_EXPIRATION_TIMEOUT);
|
||||
m_IncomingTokens.emplace (ep, ret);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue