diff --git a/libi2pd_client/ClientContext.cpp b/libi2pd_client/ClientContext.cpp index 55e4f388..13b1c873 100644 --- a/libi2pd_client/ClientContext.cpp +++ b/libi2pd_client/ClientContext.cpp @@ -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 (TORRENTS_TUNNEL_DHT, true); std::string dhtFileName = section.second.get (TORRENTS_TUNNEL_DHT_FILE, ""); bool web = section.second.get (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; diff --git a/libi2pd_client/TorrentsDHT.cpp b/libi2pd_client/TorrentsDHT.cpp index ea104cf1..9a85eaeb 100644 --- a/libi2pd_client/TorrentsDHT.cpp +++ b/libi2pd_client/TorrentsDHT.cpp @@ -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