mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2026-10-20 10:12:31 +00:00
don't persisted DHT for transient destination if dhtfile is not specified
This commit is contained in:
@@ -289,12 +289,7 @@ namespace client
|
||||
bool ClientContext::LoadPrivateKeys (i2p::data::PrivateKeys& keys, std::string_view filename,
|
||||
i2p::data::SigningKeyType sigType, i2p::data::CryptoKeyType cryptoType)
|
||||
{
|
||||
#if __cplusplus >= 202002L // C++20
|
||||
if (filename.starts_with ("transient"))
|
||||
#else
|
||||
std::string_view transient("transient");
|
||||
if (!filename.compare (0, transient.length (), transient)) // starts with transient
|
||||
#endif
|
||||
{
|
||||
keys = i2p::data::PrivateKeys::CreateRandomKeys (sigType, cryptoType, true);
|
||||
LogPrint (eLogInfo, "Clients: New transient keys address ", m_AddressBook.ToAddress(keys.GetPublic ()->GetIdentHash ()), " created");
|
||||
@@ -1050,6 +1045,11 @@ namespace client
|
||||
bool dht = section.second.get<bool> (TORRENTS_TUNNEL_DHT, true);
|
||||
std::string dhtFileName = section.second.get<std::string> (TORRENTS_TUNNEL_DHT_FILE, "");
|
||||
bool web = section.second.get<bool> (TORRENTS_TUNNEL_WEB, true);
|
||||
if (dhtFileName.empty () && keys.starts_with ("transient"))
|
||||
{
|
||||
// finename with zero in first byte means non persistent
|
||||
dhtFileName.resize (1); dhtFileName[0] = '\x00';
|
||||
}
|
||||
|
||||
// I2CP
|
||||
i2p::util::Mapping options;
|
||||
|
||||
@@ -378,7 +378,8 @@ namespace torrents
|
||||
m_DHTFileName = dest->GetIdentHash ().ToBase32 () + ".dht";
|
||||
}
|
||||
if (m_DHTFileName.empty ()) m_DHTFileName = "nodest.dht";
|
||||
Load (GetDHTFilePath (m_DHTFileName));
|
||||
if (m_DHTFileName[0]) // first byte zero means non persistent
|
||||
Load (GetDHTFilePath (m_DHTFileName));
|
||||
ScheduleDHTUpdateCheck ();
|
||||
ScheduleDHTExpirationCheck ();
|
||||
ScheduleDHTSendPingCheck ();
|
||||
@@ -391,7 +392,8 @@ namespace torrents
|
||||
m_DHTExpirationCheckTimer.cancel ();
|
||||
m_DHTSendPingCheckTimer.cancel ();
|
||||
m_DHTQueryExpirationCheckTimer.cancel ();
|
||||
Save (GetDHTFilePath (m_DHTFileName));
|
||||
if (m_DHTFileName[0]) // first byte zero means non persistent
|
||||
Save (GetDHTFilePath (m_DHTFileName));
|
||||
}
|
||||
|
||||
std::filesystem::path TorrentsDHT::GetDHTFilePath (std::string_view filename) const
|
||||
|
||||
Reference in New Issue
Block a user