mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2026-04-26 17:27:30 +00:00
ignore i2cp.closeIdleTime for tunnels on shared destinations
This commit is contained in:
@@ -39,6 +39,30 @@ namespace client
|
||||
if (m_LocalDestination) m_LocalDestination->Release ();
|
||||
}
|
||||
|
||||
void I2PService::Start ()
|
||||
{
|
||||
if (m_CloseIdleTime)
|
||||
{
|
||||
if (m_LocalDestination && m_LocalDestination->GetRefCounter () <= 1)
|
||||
{
|
||||
if (!m_IdleCheckTimer) m_IdleCheckTimer.reset (new boost::asio::steady_timer(m_LocalDestination->GetService ()));
|
||||
m_LastActivityTime = i2p::util::GetMonotonicMilliseconds ();
|
||||
ScheduleIdleCheckTimer ();
|
||||
}
|
||||
else
|
||||
LogPrint (eLogError, "I2PService: i2cp.closeIdleTime can't be set for ", GetName (), " on shared destination");
|
||||
}
|
||||
}
|
||||
|
||||
void I2PService::Stop ()
|
||||
{
|
||||
if (m_IdleCheckTimer)
|
||||
{
|
||||
m_IdleCheckTimer->cancel ();
|
||||
m_IdleCheckTimer = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void I2PService::ClearHandlers ()
|
||||
{
|
||||
if(m_ConnectTimeout)
|
||||
@@ -58,12 +82,6 @@ namespace client
|
||||
{
|
||||
if (idleTime > 0 && idleTime < I2P_SERVICE_MIN_CLOSE_IDLE_TIME) idleTime = I2P_SERVICE_MIN_CLOSE_IDLE_TIME;
|
||||
m_CloseIdleTime = idleTime;
|
||||
if (m_CloseIdleTime)
|
||||
{
|
||||
if (!m_IdleCheckTimer) m_IdleCheckTimer.reset (new boost::asio::steady_timer(m_LocalDestination->GetService ()));
|
||||
m_LastActivityTime = i2p::util::GetMonotonicMilliseconds ();
|
||||
ScheduleIdleCheckTimer ();
|
||||
}
|
||||
}
|
||||
|
||||
void I2PService::UpdateLastActivityTime ()
|
||||
|
||||
@@ -69,8 +69,8 @@ namespace client
|
||||
void CreateStream(StreamRequestComplete complete, std::shared_ptr<const Address> address, uint16_t port);
|
||||
auto& GetService () { return m_LocalDestination->GetService (); }
|
||||
|
||||
virtual void Start () = 0;
|
||||
virtual void Stop () = 0;
|
||||
virtual void Start ();
|
||||
virtual void Stop ();
|
||||
|
||||
virtual const char* GetName() const { return "Generic I2P Service"; }
|
||||
|
||||
@@ -237,6 +237,7 @@ namespace client
|
||||
virtual ~ServiceAcceptor () { Stop(); }
|
||||
void Start () override
|
||||
{
|
||||
I2PService::Start ();
|
||||
m_Acceptor.reset (new typename Protocol::acceptor (GetService (), m_LocalEndpoint));
|
||||
// update the local end point in case port has been set zero and got updated now
|
||||
m_LocalEndpoint = m_Acceptor->local_endpoint();
|
||||
@@ -251,6 +252,7 @@ namespace client
|
||||
m_Acceptor.reset (nullptr);
|
||||
}
|
||||
ClearHandlers();
|
||||
I2PService::Stop ();
|
||||
}
|
||||
const typename Protocol::endpoint& GetLocalEndpoint () const { return m_LocalEndpoint; };
|
||||
|
||||
|
||||
Reference in New Issue
Block a user