don't persisted DHT for transient destination if dhtfile is not specified

This commit is contained in:
orignal
2026-10-16 11:30:38 -04:00
parent 95ef8d1692
commit 4ea6acd4f7
2 changed files with 9 additions and 7 deletions
+5 -5
View File
@@ -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;
+4 -2
View File
@@ -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