mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-04-28 11:47:48 +02:00
move RunnableService away from LeaseSetDestination
This commit is contained in:
parent
49810eb153
commit
2d154ee640
7 changed files with 87 additions and 111 deletions
|
@ -24,10 +24,35 @@ namespace client
|
|||
{
|
||||
|
||||
I2CPDestination::I2CPDestination (std::shared_ptr<I2CPSession> owner, std::shared_ptr<const i2p::data::IdentityEx> identity, bool isPublic, const std::map<std::string, std::string>& params):
|
||||
LeaseSetDestination (isPublic, ¶ms), m_Owner (owner), m_Identity (identity)
|
||||
RunnableService ("I2CP"), LeaseSetDestination (GetService (), isPublic, ¶ms),
|
||||
m_Owner (owner), m_Identity (identity)
|
||||
{
|
||||
}
|
||||
|
||||
I2CPDestination::~I2CPDestination ()
|
||||
{
|
||||
if (IsRunning ())
|
||||
Stop ();
|
||||
}
|
||||
|
||||
void I2CPDestination::Start ()
|
||||
{
|
||||
if (!IsRunning ())
|
||||
{
|
||||
LeaseSetDestination::Start ();
|
||||
StartService ();
|
||||
}
|
||||
}
|
||||
|
||||
void I2CPDestination::Stop ()
|
||||
{
|
||||
if (IsRunning ())
|
||||
{
|
||||
LeaseSetDestination::Stop ();
|
||||
StopService ();
|
||||
}
|
||||
}
|
||||
|
||||
void I2CPDestination::SetEncryptionPrivateKey (const uint8_t * key)
|
||||
{
|
||||
memcpy (m_EncryptionPrivateKey, key, 256);
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
#include <thread>
|
||||
#include <map>
|
||||
#include <boost/asio.hpp>
|
||||
#include "util.h"
|
||||
#include "Destination.h"
|
||||
|
||||
namespace i2p
|
||||
|
@ -61,12 +62,16 @@ namespace client
|
|||
const char I2CP_PARAM_MESSAGE_RELIABILITY[] = "i2cp.messageReliability";
|
||||
|
||||
class I2CPSession;
|
||||
class I2CPDestination: public LeaseSetDestination
|
||||
class I2CPDestination: public i2p::util::RunnableService, public LeaseSetDestination
|
||||
{
|
||||
public:
|
||||
|
||||
I2CPDestination (std::shared_ptr<I2CPSession> owner, std::shared_ptr<const i2p::data::IdentityEx> identity, bool isPublic, const std::map<std::string, std::string>& params);
|
||||
|
||||
~I2CPDestination ();
|
||||
|
||||
void Start ();
|
||||
void Stop ();
|
||||
|
||||
void SetEncryptionPrivateKey (const uint8_t * key);
|
||||
void LeaseSetCreated (const uint8_t * buf, size_t len); // called from I2CPSession
|
||||
void LeaseSet2Created (uint8_t storeType, const uint8_t * buf, size_t len); // called from I2CPSession
|
||||
|
|
|
@ -45,29 +45,19 @@ namespace client
|
|||
}
|
||||
|
||||
|
||||
bool MatchedTunnelDestination::Start()
|
||||
void MatchedTunnelDestination::Start()
|
||||
{
|
||||
if(ClientDestination::Start())
|
||||
{
|
||||
m_ResolveTimer = std::make_shared<boost::asio::deadline_timer>(GetService());
|
||||
GetTunnelPool()->SetCustomPeerSelector(this);
|
||||
ResolveCurrentLeaseSet();
|
||||
return true;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
ClientDestination::Start();
|
||||
m_ResolveTimer = std::make_shared<boost::asio::deadline_timer>(GetService());
|
||||
GetTunnelPool()->SetCustomPeerSelector(this);
|
||||
ResolveCurrentLeaseSet();
|
||||
}
|
||||
|
||||
bool MatchedTunnelDestination::Stop()
|
||||
void MatchedTunnelDestination::Stop()
|
||||
{
|
||||
if(ClientDestination::Stop())
|
||||
{
|
||||
if(m_ResolveTimer)
|
||||
m_ResolveTimer->cancel();
|
||||
return true;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
ClientDestination::Stop();
|
||||
if(m_ResolveTimer)
|
||||
m_ResolveTimer->cancel();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -14,8 +14,8 @@ namespace client
|
|||
{
|
||||
public:
|
||||
MatchedTunnelDestination(const i2p::data::PrivateKeys& keys, const std::string & remoteName, const std::map<std::string, std::string> * params = nullptr);
|
||||
bool Start();
|
||||
bool Stop();
|
||||
void Start();
|
||||
void Stop();
|
||||
|
||||
bool SelectPeers(i2p::tunnel::Path & peers, int hops, bool inbound);
|
||||
bool OnBuildResult(const i2p::tunnel::Path & peers, bool inbound, i2p::tunnel::TunnelBuildResult result);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue