ignore i2cp.closeIdleTime for tunnels on shared destinations

This commit is contained in:
orignal
2026-04-15 18:39:28 -04:00
parent bdb1432015
commit eee36175e6
2 changed files with 28 additions and 8 deletions

View File

@@ -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 ()

View File

@@ -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; };