From 72c0d8443a85fc60be2299fc2cf27ffcb53c84d9 Mon Sep 17 00:00:00 2001 From: orignal Date: Mon, 17 Nov 2014 17:00:30 -0500 Subject: [PATCH] create local destination through API --- api/api.cpp | 28 +++++++++++++++++++++++++++- api/api.h | 6 ++++++ 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/api/api.cpp b/api/api.cpp index 746af0f2..8bf819db 100644 --- a/api/api.cpp +++ b/api/api.cpp @@ -18,7 +18,7 @@ namespace api void InitI2P (int argc, char* argv[]) { - i2p::util::filesystem::SetAppName (argv[0]); + i2p::util::filesystem::SetAppName ("i2papi"); i2p::util::config::OptionParser(argc, argv); i2p::context.Init (); } @@ -53,6 +53,32 @@ namespace api StopLog (); } + + i2p::client::ClientDestination * CreateLocalDestination (const i2p::data::PrivateKeys& keys) + { + auto localDestination = new i2p::client::ClientDestination (keys, true); // public + g_Destinations[localDestination->GetIdentHash ()] = localDestination; + localDestination->Start (); + return localDestination; + } + + i2p::client::ClientDestination * CreateLocalDestination (i2p::data::SigningKeyType sigType) + { + auto localDestination = new i2p::client::ClientDestination (true, sigType); // public + g_Destinations[localDestination->GetIdentHash ()] = localDestination; + localDestination->Start (); + return localDestination; + } + + void DestroyLocalDestination (i2p::client::ClientDestination * dest) + { + if (dest) + { + dest->Stop (); + g_Destinations.erase (dest->GetIdentHash ()); + delete dest; + } + } } } diff --git a/api/api.h b/api/api.h index a4c1b8c2..6e763338 100644 --- a/api/api.h +++ b/api/api.h @@ -1,6 +1,8 @@ #ifndef API_H__ #define API_H__ +#include "Identity.h" + namespace i2p { namespace api @@ -8,6 +10,10 @@ namespace api void InitI2P (int argc, char* argv[]); void StartI2P (); void StopI2P (); + + i2p::client::ClientDestination * CreateLocalDestination (const i2p::data::PrivateKeys& keys); + i2p::client::ClientDestination * CreateLocalDestination (i2p::data::SigningKeyType sigType = i2p::data::SIGNING_KEY_TYPE_DSA_SHA1); + void DestoroyLocalDestination (i2p::client::ClientDestination * dest); } }