added i2cp.inboundlimit and i2cp.outboundlimit

This commit is contained in:
orignal 2024-07-28 14:53:46 -04:00
parent ea19d2296c
commit 1410fa5c21
2 changed files with 9 additions and 2 deletions

View File

@ -168,6 +168,8 @@ namespace config {
("i2cp.address", value<std::string>()->default_value("127.0.0.1"), "I2CP listen address")
("i2cp.port", value<uint16_t>()->default_value(7654), "I2CP listen port")
("i2cp.singlethread", value<bool>()->default_value(true), "Destinations run in the I2CP server's thread")
("i2cp.inboundlimit", value<uint32_t>()->default_value(0), "Client inbound limit in KBps to return in BandwidthLimitsMessage. Router's bandwidth by default")
("i2cp.outboundlimit", value<uint32_t>()->default_value(0), "Client outbound limit in KBps to return in BandwidthLimitsMessage. Router's bandwidth by default")
;
options_description i2pcontrol("I2PControl options");

View File

@ -16,6 +16,7 @@
#include "ClientContext.h"
#include "Transports.h"
#include "Signature.h"
#include "Config.h"
#include "I2CP.h"
namespace i2p
@ -1003,8 +1004,12 @@ namespace client
{
uint8_t limits[64];
memset (limits, 0, 64);
htobe32buf (limits, i2p::context.GetBandwidthLimit ()); // inbound
htobe32buf (limits + 4, i2p::context.GetBandwidthLimit ()); // outbound
uint32_t limit; i2p::config::GetOption("i2cp.inboundlimit", limit);
if (!limit) limit = i2p::context.GetBandwidthLimit ();
htobe32buf (limits, limit); // inbound
i2p::config::GetOption("i2cp.outboundlimit", limit);
if (!limit) limit = i2p::context.GetBandwidthLimit ();
htobe32buf (limits + 4, limit); // outbound
SendI2CPMessage (I2CP_BANDWIDTH_LIMITS_MESSAGE, limits, 64);
}