mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-01-22 08:14:15 +00:00
don't accept tunnels if bandwidth is exceeded
This commit is contained in:
parent
b693d13144
commit
47c3d5ed23
@ -281,7 +281,8 @@ namespace i2p
|
|||||||
i2p::crypto::ElGamalDecrypt (i2p::context.GetEncryptionPrivateKey (), record + BUILD_REQUEST_RECORD_ENCRYPTED_OFFSET, clearText);
|
i2p::crypto::ElGamalDecrypt (i2p::context.GetEncryptionPrivateKey (), record + BUILD_REQUEST_RECORD_ENCRYPTED_OFFSET, clearText);
|
||||||
// replace record to reply
|
// replace record to reply
|
||||||
if (i2p::context.AcceptsTunnels () &&
|
if (i2p::context.AcceptsTunnels () &&
|
||||||
i2p::tunnel::tunnels.GetTransitTunnels ().size () <= MAX_NUM_TRANSIT_TUNNELS)
|
i2p::tunnel::tunnels.GetTransitTunnels ().size () <= MAX_NUM_TRANSIT_TUNNELS &&
|
||||||
|
!i2p::transport::transports.IsBandwidthExceeded ())
|
||||||
{
|
{
|
||||||
i2p::tunnel::TransitTunnel * transitTunnel =
|
i2p::tunnel::TransitTunnel * transitTunnel =
|
||||||
i2p::tunnel::CreateTransitTunnel (
|
i2p::tunnel::CreateTransitTunnel (
|
||||||
|
@ -917,7 +917,7 @@ namespace data
|
|||||||
[compatibleWith](std::shared_ptr<const RouterInfo> router)->bool
|
[compatibleWith](std::shared_ptr<const RouterInfo> router)->bool
|
||||||
{
|
{
|
||||||
return !router->IsHidden () && router != compatibleWith &&
|
return !router->IsHidden () && router != compatibleWith &&
|
||||||
router->IsCompatible (*compatibleWith) && (router->GetCaps () & RouterInfo::eHighBandwidth);
|
router->IsCompatible (*compatibleWith) && router->IsHighBandwidth ();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -118,6 +118,7 @@ namespace data
|
|||||||
bool IsIntroducer () const { return m_Caps & eSSUIntroducer; };
|
bool IsIntroducer () const { return m_Caps & eSSUIntroducer; };
|
||||||
bool IsPeerTesting () const { return m_Caps & eSSUTesting; };
|
bool IsPeerTesting () const { return m_Caps & eSSUTesting; };
|
||||||
bool IsHidden () const { return m_Caps & eHidden; };
|
bool IsHidden () const { return m_Caps & eHidden; };
|
||||||
|
bool IsHighBandwidth () const { return m_Caps & RouterInfo::eHighBandwidth; };
|
||||||
|
|
||||||
uint8_t GetCaps () const { return m_Caps; };
|
uint8_t GetCaps () const { return m_Caps; };
|
||||||
void SetCaps (uint8_t caps);
|
void SetCaps (uint8_t caps);
|
||||||
|
@ -199,6 +199,11 @@ namespace transport
|
|||||||
m_LastOutBandwidthUpdateBytes = m_TotalSentBytes;
|
m_LastOutBandwidthUpdateBytes = m_TotalSentBytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Transports::IsBandwidthExceeded () const
|
||||||
|
{
|
||||||
|
if (i2p::context.GetRouterInfo ().IsHighBandwidth ()) return false;
|
||||||
|
return std::max (m_InBandwidth, m_OutBandwidth) > LOW_BANDWIDTH_LIMIT;
|
||||||
|
}
|
||||||
|
|
||||||
void Transports::SendMessage (const i2p::data::IdentHash& ident, i2p::I2NPMessage * msg)
|
void Transports::SendMessage (const i2p::data::IdentHash& ident, i2p::I2NPMessage * msg)
|
||||||
{
|
{
|
||||||
|
@ -68,6 +68,7 @@ namespace transport
|
|||||||
};
|
};
|
||||||
|
|
||||||
const size_t SESSION_CREATION_TIMEOUT = 10; // in seconds
|
const size_t SESSION_CREATION_TIMEOUT = 10; // in seconds
|
||||||
|
const uint32_t LOW_BANDWIDTH_LIMIT = 32*1024; // 32KBs
|
||||||
class Transports
|
class Transports
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -96,6 +97,7 @@ namespace transport
|
|||||||
uint64_t GetTotalReceivedBytes () const { return m_TotalReceivedBytes; };
|
uint64_t GetTotalReceivedBytes () const { return m_TotalReceivedBytes; };
|
||||||
uint32_t GetInBandwidth () const { return m_InBandwidth; }; // bytes per second
|
uint32_t GetInBandwidth () const { return m_InBandwidth; }; // bytes per second
|
||||||
uint32_t GetOutBandwidth () const { return m_OutBandwidth; }; // bytes per second
|
uint32_t GetOutBandwidth () const { return m_OutBandwidth; }; // bytes per second
|
||||||
|
bool IsBandwidthExceeded () const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user