diff --git a/Daemon.cpp b/Daemon.cpp index 42a78280..ed0c74d3 100644 --- a/Daemon.cpp +++ b/Daemon.cpp @@ -76,7 +76,15 @@ namespace i2p i2p::context.SetSupportsV6 (i2p::util::config::GetArg("-v6", 0)); i2p::context.SetFloodfill (i2p::util::config::GetArg("-floodfill", 0)); - + auto bandwidth = i2p::util::config::GetArg("-badnwidth", ""); + if (bandwidth.length () > 0) + { + if (bandwidth[0] > 'L') + i2p::context.SetHighBandwidth (); + else + i2p::context.SetLowBandwidth (); + } + LogPrint("CMD parameters:"); for (int i = 0; i < argc; ++i) LogPrint(i, " ", argv[i]); diff --git a/README.md b/README.md index d1b89b8c..5120899c 100644 --- a/README.md +++ b/README.md @@ -74,6 +74,7 @@ Cmdline options * --service= - 1 if uses system folders (/var/run/i2pd.pid, /var/log/i2pd.log, /var/lib/i2pd). * --v6= - 1 if supports communication through ipv6, off by default * --floodfill= - 1 if router is floodfill, off by default +* --bandwidth= - L if bandwidth is limited to 32Kbs/sec, O if not. Always O if floodfill, otherwise L by default. * --httpproxyport= - The port to listen on (HTTP Proxy) * --socksproxyport= - The port to listen on (SOCKS Proxy) * --proxykeys= - optional keys file for proxy's local destination diff --git a/RouterContext.cpp b/RouterContext.cpp index c524486d..e3cd358d 100644 --- a/RouterContext.cpp +++ b/RouterContext.cpp @@ -126,6 +126,24 @@ namespace i2p UpdateRouterInfo (); } + void RouterContext::SetHighBandwidth () + { + if (!m_RouterInfo.IsHighBandwidth ()) + { + m_RouterInfo.SetCaps (m_RouterInfo.GetCaps () | i2p::data::RouterInfo::eHighBandwidth); + UpdateRouterInfo (); + } + } + + void RouterContext::SetLowBandwidth () + { + if (m_RouterInfo.IsHighBandwidth ()) + { + m_RouterInfo.SetCaps (m_RouterInfo.GetCaps () & ~i2p::data::RouterInfo::eHighBandwidth); + UpdateRouterInfo (); + } + } + bool RouterContext::IsUnreachable () const { return m_RouterInfo.GetCaps () & i2p::data::RouterInfo::eUnreachable; diff --git a/RouterContext.h b/RouterContext.h index 483f3feb..7492a4e2 100644 --- a/RouterContext.h +++ b/RouterContext.h @@ -56,6 +56,8 @@ namespace i2p void SetReachable (); bool IsFloodfill () const { return m_IsFloodfill; }; void SetFloodfill (bool floodfill); + void SetHighBandwidth (); + void SetLowBandwidth (); bool AcceptsTunnels () const { return m_AcceptsTunnels; }; void SetAcceptsTunnels (bool acceptsTunnels) { m_AcceptsTunnels = acceptsTunnels; }; bool SupportsV6 () const { return m_RouterInfo.IsV6 (); };