mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-01-22 08:14:15 +00:00
shared transient addresses
This commit is contained in:
parent
e50abbb250
commit
6fec92c012
@ -253,7 +253,8 @@ namespace client
|
|||||||
bool ClientContext::LoadPrivateKeys (i2p::data::PrivateKeys& keys, const std::string& filename,
|
bool ClientContext::LoadPrivateKeys (i2p::data::PrivateKeys& keys, const std::string& filename,
|
||||||
i2p::data::SigningKeyType sigType, i2p::data::CryptoKeyType cryptoType)
|
i2p::data::SigningKeyType sigType, i2p::data::CryptoKeyType cryptoType)
|
||||||
{
|
{
|
||||||
if (filename == "transient")
|
static const std::string transient("transient");
|
||||||
|
if (!filename.compare (0, transient.length (), transient)) // starts with transient
|
||||||
{
|
{
|
||||||
keys = i2p::data::PrivateKeys::CreateRandomKeys (sigType, cryptoType);
|
keys = i2p::data::PrivateKeys::CreateRandomKeys (sigType, cryptoType);
|
||||||
LogPrint (eLogInfo, "Clients: New transient keys address ", m_AddressBook.ToAddress(keys.GetPublic ()->GetIdentHash ()), " created");
|
LogPrint (eLogInfo, "Clients: New transient keys address ", m_AddressBook.ToAddress(keys.GetPublic ()->GetIdentHash ()), " created");
|
||||||
@ -533,6 +534,7 @@ namespace client
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::map<std::string, std::shared_ptr<ClientDestination> > destinations; // keys -> destination
|
||||||
for (auto& section: pt)
|
for (auto& section: pt)
|
||||||
{
|
{
|
||||||
std::string name = section.first;
|
std::string name = section.first;
|
||||||
@ -564,18 +566,25 @@ namespace client
|
|||||||
std::shared_ptr<ClientDestination> localDestination = nullptr;
|
std::shared_ptr<ClientDestination> localDestination = nullptr;
|
||||||
if (keys.length () > 0)
|
if (keys.length () > 0)
|
||||||
{
|
{
|
||||||
i2p::data::PrivateKeys k;
|
auto it = destinations.find (keys);
|
||||||
if(LoadPrivateKeys (k, keys, sigType, cryptoType))
|
if (it != destinations.end ())
|
||||||
{
|
localDestination = it->second;
|
||||||
localDestination = FindLocalDestination (k.GetPublic ()->GetIdentHash ());
|
else
|
||||||
if (!localDestination)
|
{
|
||||||
|
i2p::data::PrivateKeys k;
|
||||||
|
if(LoadPrivateKeys (k, keys, sigType, cryptoType))
|
||||||
{
|
{
|
||||||
if(matchTunnels)
|
localDestination = FindLocalDestination (k.GetPublic ()->GetIdentHash ());
|
||||||
localDestination = CreateNewMatchedTunnelDestination(k, dest, &options);
|
if (!localDestination)
|
||||||
else
|
{
|
||||||
localDestination = CreateNewLocalDestination (k, type == I2P_TUNNELS_SECTION_TYPE_UDPCLIENT, &options);
|
if(matchTunnels)
|
||||||
|
localDestination = CreateNewMatchedTunnelDestination(k, dest, &options);
|
||||||
|
else
|
||||||
|
localDestination = CreateNewLocalDestination (k, type == I2P_TUNNELS_SECTION_TYPE_UDPCLIENT, &options);
|
||||||
|
destinations[keys] = localDestination;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type == I2P_TUNNELS_SECTION_TYPE_UDPCLIENT) {
|
if (type == I2P_TUNNELS_SECTION_TYPE_UDPCLIENT) {
|
||||||
@ -679,12 +688,21 @@ namespace client
|
|||||||
ReadI2CPOptions (section, options);
|
ReadI2CPOptions (section, options);
|
||||||
|
|
||||||
std::shared_ptr<ClientDestination> localDestination = nullptr;
|
std::shared_ptr<ClientDestination> localDestination = nullptr;
|
||||||
i2p::data::PrivateKeys k;
|
auto it = destinations.find (keys);
|
||||||
if(!LoadPrivateKeys (k, keys, sigType, cryptoType))
|
if (it != destinations.end ())
|
||||||
continue;
|
localDestination = it->second;
|
||||||
localDestination = FindLocalDestination (k.GetPublic ()->GetIdentHash ());
|
else
|
||||||
if (!localDestination)
|
{
|
||||||
localDestination = CreateNewLocalDestination (k, true, &options);
|
i2p::data::PrivateKeys k;
|
||||||
|
if(!LoadPrivateKeys (k, keys, sigType, cryptoType))
|
||||||
|
continue;
|
||||||
|
localDestination = FindLocalDestination (k.GetPublic ()->GetIdentHash ());
|
||||||
|
if (!localDestination)
|
||||||
|
{
|
||||||
|
localDestination = CreateNewLocalDestination (k, true, &options);
|
||||||
|
destinations[keys] = localDestination;
|
||||||
|
}
|
||||||
|
}
|
||||||
if (type == I2P_TUNNELS_SECTION_TYPE_UDPSERVER)
|
if (type == I2P_TUNNELS_SECTION_TYPE_UDPSERVER)
|
||||||
{
|
{
|
||||||
// udp server tunnel
|
// udp server tunnel
|
||||||
|
Loading…
x
Reference in New Issue
Block a user