From 1410fa5c21db4af763c3de396af127c27d7006ba Mon Sep 17 00:00:00 2001 From: orignal Date: Sun, 28 Jul 2024 14:53:46 -0400 Subject: [PATCH] added i2cp.inboundlimit and i2cp.outboundlimit --- libi2pd/Config.cpp | 2 ++ libi2pd_client/I2CP.cpp | 9 +++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/libi2pd/Config.cpp b/libi2pd/Config.cpp index a819b701..a3fe63c7 100644 --- a/libi2pd/Config.cpp +++ b/libi2pd/Config.cpp @@ -168,6 +168,8 @@ namespace config { ("i2cp.address", value()->default_value("127.0.0.1"), "I2CP listen address") ("i2cp.port", value()->default_value(7654), "I2CP listen port") ("i2cp.singlethread", value()->default_value(true), "Destinations run in the I2CP server's thread") + ("i2cp.inboundlimit", value()->default_value(0), "Client inbound limit in KBps to return in BandwidthLimitsMessage. Router's bandwidth by default") + ("i2cp.outboundlimit", value()->default_value(0), "Client outbound limit in KBps to return in BandwidthLimitsMessage. Router's bandwidth by default") ; options_description i2pcontrol("I2PControl options"); diff --git a/libi2pd_client/I2CP.cpp b/libi2pd_client/I2CP.cpp index 69488a3f..7c59c5c6 100644 --- a/libi2pd_client/I2CP.cpp +++ b/libi2pd_client/I2CP.cpp @@ -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); }