Browse Source

start/stop/init through api

pull/113/head
orignal 10 years ago
parent
commit
439b8798c9
  1. 49
      api/api.cpp
  2. 3
      api/api.h
  3. 16
      api/filelist.mk

49
api/api.cpp

@ -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" #include "api.h"
namespace i2p namespace i2p
{ {
namespace api 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 ();
}
} }
} }

3
api/api.h

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

16
api/filelist.mk

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

Loading…
Cancel
Save