mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-02-24 04:37:37 +01:00
Don't do peertest if nat=false
This commit is contained in:
parent
0b560fdd27
commit
9de617172f
2 changed files with 15 additions and 6 deletions
|
@ -110,7 +110,7 @@ namespace transport
|
||||||
Transports transports;
|
Transports transports;
|
||||||
|
|
||||||
Transports::Transports ():
|
Transports::Transports ():
|
||||||
m_IsOnline (true), m_IsRunning (false), m_Thread (nullptr), m_Service (nullptr),
|
m_IsOnline (true), m_IsRunning (false), m_IsNAT (true), m_Thread (nullptr), m_Service (nullptr),
|
||||||
m_Work (nullptr), m_PeerCleanupTimer (nullptr), m_PeerTestTimer (nullptr),
|
m_Work (nullptr), m_PeerCleanupTimer (nullptr), m_PeerTestTimer (nullptr),
|
||||||
m_NTCPServer (nullptr), m_SSUServer (nullptr), m_DHKeysPairSupplier (5), // 5 pre-generated keys
|
m_NTCPServer (nullptr), m_SSUServer (nullptr), m_DHKeysPairSupplier (5), // 5 pre-generated keys
|
||||||
m_TotalSentBytes(0), m_TotalReceivedBytes(0), m_TotalTransitTransmittedBytes (0),
|
m_TotalSentBytes(0), m_TotalReceivedBytes(0), m_TotalTransitTransmittedBytes (0),
|
||||||
|
@ -142,6 +142,9 @@ namespace transport
|
||||||
m_PeerTestTimer = new boost::asio::deadline_timer (*m_Service);
|
m_PeerTestTimer = new boost::asio::deadline_timer (*m_Service);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool nat; i2p::config::GetOption("nat", nat);
|
||||||
|
SetNAT (nat);
|
||||||
|
|
||||||
m_DHKeysPairSupplier.Start ();
|
m_DHKeysPairSupplier.Start ();
|
||||||
m_IsRunning = true;
|
m_IsRunning = true;
|
||||||
m_Thread = new std::thread (std::bind (&Transports::Run, this));
|
m_Thread = new std::thread (std::bind (&Transports::Run, this));
|
||||||
|
@ -221,9 +224,13 @@ namespace transport
|
||||||
}
|
}
|
||||||
m_PeerCleanupTimer->expires_from_now (boost::posix_time::seconds(5*SESSION_CREATION_TIMEOUT));
|
m_PeerCleanupTimer->expires_from_now (boost::posix_time::seconds(5*SESSION_CREATION_TIMEOUT));
|
||||||
m_PeerCleanupTimer->async_wait (std::bind (&Transports::HandlePeerCleanupTimer, this, std::placeholders::_1));
|
m_PeerCleanupTimer->async_wait (std::bind (&Transports::HandlePeerCleanupTimer, this, std::placeholders::_1));
|
||||||
|
|
||||||
|
if (IsNAT())
|
||||||
|
{
|
||||||
m_PeerTestTimer->expires_from_now (boost::posix_time::minutes(PEER_TEST_INTERVAL));
|
m_PeerTestTimer->expires_from_now (boost::posix_time::minutes(PEER_TEST_INTERVAL));
|
||||||
m_PeerTestTimer->async_wait (std::bind (&Transports::HandlePeerTestTimer, this, std::placeholders::_1));
|
m_PeerTestTimer->async_wait (std::bind (&Transports::HandlePeerTestTimer, this, std::placeholders::_1));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Transports::Stop ()
|
void Transports::Stop ()
|
||||||
{
|
{
|
||||||
|
@ -605,9 +612,8 @@ namespace transport
|
||||||
}
|
}
|
||||||
if (m_SSUServer)
|
if (m_SSUServer)
|
||||||
{
|
{
|
||||||
bool nat; i2p::config::GetOption("nat", nat);
|
|
||||||
bool isv4 = i2p::context.SupportsV4 ();
|
bool isv4 = i2p::context.SupportsV4 ();
|
||||||
if (nat && isv4)
|
if (IsNAT() && isv4)
|
||||||
i2p::context.SetStatus (eRouterStatusTesting);
|
i2p::context.SetStatus (eRouterStatusTesting);
|
||||||
for (int i = 0; i < 5; i++)
|
for (int i = 0; i < 5; i++)
|
||||||
{
|
{
|
||||||
|
|
|
@ -84,6 +84,9 @@ namespace transport
|
||||||
bool IsOnline() const { return m_IsOnline; };
|
bool IsOnline() const { return m_IsOnline; };
|
||||||
void SetOnline (bool online) { m_IsOnline = online; };
|
void SetOnline (bool online) { m_IsOnline = online; };
|
||||||
|
|
||||||
|
bool IsNAT() const { return m_IsNAT; };
|
||||||
|
void SetNAT (bool nat) { m_IsNAT = nat; };
|
||||||
|
|
||||||
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 ();
|
||||||
void ReuseDHKeysPair (std::shared_ptr<i2p::crypto::DHKeys> pair);
|
void ReuseDHKeysPair (std::shared_ptr<i2p::crypto::DHKeys> pair);
|
||||||
|
@ -146,7 +149,7 @@ namespace transport
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
bool m_IsOnline, m_IsRunning;
|
bool m_IsOnline, 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…
Add table
Reference in a new issue