2015-01-07 21:09:59 +03:00
|
|
|
#include "Destination.h"
|
|
|
|
#include "Identity.h"
|
|
|
|
#include "ClientContext.h"
|
|
|
|
#include "I2PService.h"
|
|
|
|
|
|
|
|
|
|
|
|
namespace i2p
|
|
|
|
{
|
|
|
|
namespace client
|
|
|
|
{
|
|
|
|
static const i2p::data::SigningKeyType I2P_SERVICE_DEFAULT_KEY_TYPE = i2p::data::SIGNING_KEY_TYPE_ECDSA_SHA256_P256;
|
|
|
|
|
|
|
|
I2PService::I2PService (ClientDestination * localDestination):
|
|
|
|
m_LocalDestination (localDestination ? localDestination :
|
|
|
|
i2p::client::context.CreateNewLocalDestination (false, I2P_SERVICE_DEFAULT_KEY_TYPE))
|
|
|
|
{
|
|
|
|
}
|
2015-01-07 22:44:24 +03:00
|
|
|
|
2015-01-07 23:15:04 +03:00
|
|
|
I2PService::I2PService (i2p::data::SigningKeyType kt):
|
|
|
|
m_LocalDestination (i2p::client::context.CreateNewLocalDestination (false, kt))
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void I2PService::CreateStream (StreamRequestComplete streamRequestComplete, const std::string& dest, int port) {
|
2015-01-07 22:44:24 +03:00
|
|
|
assert(streamRequestComplete);
|
|
|
|
i2p::data::IdentHash identHash;
|
|
|
|
if (i2p::client::context.GetAddressBook ().GetIdentHash (dest, identHash))
|
2015-01-07 23:15:04 +03:00
|
|
|
m_LocalDestination->CreateStream (streamRequestComplete, identHash, port);
|
2015-01-07 22:44:24 +03:00
|
|
|
else
|
|
|
|
{
|
|
|
|
LogPrint (eLogWarning, "Remote destination ", dest, " not found");
|
|
|
|
streamRequestComplete (nullptr);
|
|
|
|
}
|
|
|
|
}
|
2015-01-07 21:09:59 +03:00
|
|
|
}
|
|
|
|
}
|