mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-01-22 04:04:16 +00:00
check network status
This commit is contained in:
parent
e21dac21c8
commit
ffa0f0afd9
@ -259,6 +259,9 @@ namespace http {
|
|||||||
case eRouterErrorClockSkew:
|
case eRouterErrorClockSkew:
|
||||||
s << "<br>Clock skew";
|
s << "<br>Clock skew";
|
||||||
break;
|
break;
|
||||||
|
case eRouterErrorOffline:
|
||||||
|
s << "<br>Offline";
|
||||||
|
break;
|
||||||
default: ;
|
default: ;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -125,7 +125,8 @@ namespace data
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!m_IsRunning) break;
|
if (!m_IsRunning) break;
|
||||||
|
if (!i2p::transport::transports.IsOnline ()) continue; // don't manage netdb when offline
|
||||||
|
|
||||||
uint64_t ts = i2p::util::GetSecondsSinceEpoch ();
|
uint64_t ts = i2p::util::GetSecondsSinceEpoch ();
|
||||||
if (ts - lastManageRequest >= 15) // manage requests every 15 seconds
|
if (ts - lastManageRequest >= 15) // manage requests every 15 seconds
|
||||||
{
|
{
|
||||||
|
@ -37,7 +37,8 @@ namespace i2p
|
|||||||
enum RouterError
|
enum RouterError
|
||||||
{
|
{
|
||||||
eRouterErrorNone = 0,
|
eRouterErrorNone = 0,
|
||||||
eRouterErrorClockSkew = 1
|
eRouterErrorClockSkew = 1,
|
||||||
|
eRouterErrorOffline = 2
|
||||||
};
|
};
|
||||||
|
|
||||||
class RouterContext: public i2p::garlic::GarlicDestination
|
class RouterContext: public i2p::garlic::GarlicDestination
|
||||||
|
@ -321,7 +321,8 @@ namespace transport
|
|||||||
|
|
||||||
void Transports::SendMessage (const i2p::data::IdentHash& ident, std::shared_ptr<i2p::I2NPMessage> msg)
|
void Transports::SendMessage (const i2p::data::IdentHash& ident, std::shared_ptr<i2p::I2NPMessage> msg)
|
||||||
{
|
{
|
||||||
SendMessages (ident, std::vector<std::shared_ptr<i2p::I2NPMessage> > {msg });
|
if (m_IsOnline)
|
||||||
|
SendMessages (ident, std::vector<std::shared_ptr<i2p::I2NPMessage> > {msg });
|
||||||
}
|
}
|
||||||
|
|
||||||
void Transports::SendMessages (const i2p::data::IdentHash& ident, const std::vector<std::shared_ptr<i2p::I2NPMessage> >& msgs)
|
void Transports::SendMessages (const i2p::data::IdentHash& ident, const std::vector<std::shared_ptr<i2p::I2NPMessage> >& msgs)
|
||||||
@ -756,5 +757,17 @@ namespace transport
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Transports::SetOnline (bool online)
|
||||||
|
{
|
||||||
|
if (m_IsOnline != online)
|
||||||
|
{
|
||||||
|
m_IsOnline = online;
|
||||||
|
if (online)
|
||||||
|
PeerTest ();
|
||||||
|
else
|
||||||
|
i2p::context.SetError (eRouterErrorOffline);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -94,7 +94,7 @@ namespace transport
|
|||||||
bool IsBoundNTCP2() const { return m_NTCP2Server != nullptr; }
|
bool IsBoundNTCP2() const { return m_NTCP2Server != nullptr; }
|
||||||
|
|
||||||
bool IsOnline() const { return m_IsOnline; };
|
bool IsOnline() const { return m_IsOnline; };
|
||||||
void SetOnline (bool online) { m_IsOnline = online; };
|
void SetOnline (bool online);
|
||||||
|
|
||||||
boost::asio::io_service& GetService () { return *m_Service; };
|
boost::asio::io_service& GetService () { return *m_Service; };
|
||||||
std::shared_ptr<i2p::crypto::DHKeys> GetNextDHKeysPair ();
|
std::shared_ptr<i2p::crypto::DHKeys> GetNextDHKeysPair ();
|
||||||
@ -151,7 +151,8 @@ namespace transport
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
bool m_IsOnline, m_IsRunning, m_IsNAT;
|
volatile bool m_IsOnline;
|
||||||
|
bool m_IsRunning, m_IsNAT;
|
||||||
std::thread * m_Thread;
|
std::thread * m_Thread;
|
||||||
boost::asio::io_service * m_Service;
|
boost::asio::io_service * m_Service;
|
||||||
boost::asio::io_service::work * m_Work;
|
boost::asio::io_service::work * m_Work;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user