start/stop/init through api

pull/113/head
orignal 10 years ago
parent 7cf19f5784
commit 439b8798c9

@ -1,9 +1,58 @@
#include <string>
#include <map>
#include "Log.h"
#include "NetDb.h"
#include "Transports.h"
#include "Tunnel.h"
#include "RouterContext.h"
#include "Identity.h"
#include "Destination.h"
#include "util.h"
#include "api.h"
namespace i2p
{
namespace api
{
static std::map<i2p::data::IdentHash, i2p::client::ClientDestination *> g_Destinations;
void InitI2P (int argc, char* argv[])
{
i2p::util::config::OptionParser(argc, argv);
i2p::context.Init ();
}
void StartI2P ()
{
std::string logfilePath ("libi2pd.log");
StartLog (logfilePath);
i2p::data::netdb.Start();
LogPrint("NetDB started");
i2p::transport::transports.Start();
LogPrint("Transports started");
i2p::tunnel::tunnels.Start();
LogPrint("Tunnels started");
}
void StopI2P ()
{
LogPrint("Shutdown started.");
i2p::tunnel::tunnels.Stop();
LogPrint("Tunnels stoped");
i2p::transport::transports.Stop();
LogPrint("Transports stoped");
i2p::data::netdb.Stop();
LogPrint("NetDB stoped");
for (auto it: g_Destinations)
{
it.second->Stop ();
delete it.second;
}
g_Destinations.clear ();
LogPrint("Local destinations deleted");
StopLog ();
}
}
}

@ -5,6 +5,9 @@ namespace i2p
{
namespace api
{
void InitI2P (int argc, char* argv[]);
void StartI2P ();
void StopI2P ();
}
}

@ -3,21 +3,17 @@
CPP_FILES := ../CryptoConst.cpp ../base64.cpp ../NTCPSession.cpp ../RouterInfo.cpp \
../Transports.cpp ../RouterContext.cpp ../NetDb.cpp ../LeaseSet.cpp Tunnel.cpp \
../TunnelEndpoint.cpp ../TunnelGateway.cpp ../TransitTunnel.cpp ../I2NPProtocol.cpp \
../Log.cpp ../Garlic.cpp ../HTTPServer.cpp ../Streaming.cpp ../Destination.cpp \
../Identity.cpp ../SSU.cpp ../SSUSession.cpp ../SSUData.cpp ../util.cpp ../Reseed.cpp \
../DaemonLinux.cpp ../SSUData.cpp ../aes.cpp ../SOCKS.cpp ../UPnP.cpp ../TunnelPool.cpp \
../HTTPProxy.cpp ../AddressBook.cpp ../I2PTunnel.cpp ../SAM.cpp ../ClientContext.cpp \
../Datagram.cpp api.cpp
../Log.cpp ../Garlic.cpp ../Streaming.cpp ../Destination.cpp ../Identity.cpp \
../SSU.cpp ../SSUSession.cpp ../SSUData.cpp ../util.cpp ../Reseed.cpp ../SSUData.cpp \
../aes.cpp ../TunnelPool.cpp ../AddressBook.cpp ../Datagram.cpp api.cpp
H_FILES := ../CryptoConst.h ../base64.h ../NTCPSession.h ../RouterInfo.h ../Transports.h \
../RouterContext.h ../NetDb.h ../LeaseSet.h ../Tunnel.h ../TunnelEndpoint.h \
../TunnelGateway.h ../TransitTunnel.h ../I2NPProtocol.h ../Log.h ../Garlic.h \
../HTTPServer.h ../Streaming.h ../Destination.h ../Identity.h ../SSU.h ../SSUSession.h \
../SSUData.h ../util.h ../Reseed.h ../DaemonLinux.h ../SSUData.h ../aes.h ../SOCKS.h \
../UPnP.h ../TunnelPool.h ../HTTPProxy.h ../AddressBook.h ../I2PTunnel.h ../version.h \
../Signature.h ../SAM.h ../ClientContext.h ../TransportSession.h ../Datagram.h api.h
../Streaming.h ../Destination.h ../Identity.h ../SSU.h ../SSUSession.h ../SSUData.h \
../util.h ../Reseed.h ../SSUData.h ../aes.h ../TunnelPool.h ../AddressBook.h ../version.h \
../Signature.h ../TransportSession.h ../Datagram.h api.h
OBJECTS = $(addprefix obj/, $(notdir $(CPP_FILES:.cpp=.o)))

Loading…
Cancel
Save