Browse Source

fixed bandwidth logic

pull/358/head
orignal 9 years ago
parent
commit
8de15c9d0d
  1. 4
      Config.cpp
  2. 32
      Daemon.cpp

4
Config.cpp

@ -114,13 +114,13 @@ namespace config { @@ -114,13 +114,13 @@ namespace config {
("logfile", value<std::string>()->default_value(""), "Path to logfile (stdout if not set, autodetect if daemon)")
("loglevel", value<std::string>()->default_value("info"), "Set the minimal level of log messages (debug, info, warn, error)")
("host", value<std::string>()->default_value(""), "External IP (deprecated)")
("port", value<uint16_t>()->default_value(4567), "Port to listen for incoming connections")
("port", value<uint16_t>()->default_value(0), "Port to listen for incoming connections")
("ipv6", value<bool>()->zero_tokens()->default_value(false), "Enable communication through ipv6")
("daemon", value<bool>()->zero_tokens()->default_value(false), "Router will go to background after start")
("service", value<bool>()->zero_tokens()->default_value(false), "Router will use system folders like '/var/lib/i2pd'")
("notransit", value<bool>()->zero_tokens()->default_value(false), "Router will not forward transit traffic")
("floodfill", value<bool>()->zero_tokens()->default_value(false), "Router will try to become floodfill")
("bandwidth", value<char>()->default_value('O'), "Bandwidth limiting: L - 32kbps, O - 256Kbps, P - unlimited (ignored if floodfill)")
("bandwidth", value<char>()->default_value('-'), "Bandwidth limiting: L - 32kbps, O - 256Kbps, P - unlimited")
;
options_description httpserver("HTTP Server options");

32
Daemon.cpp

@ -86,11 +86,15 @@ namespace i2p @@ -86,11 +86,15 @@ namespace i2p
isLogging = true;
uint16_t port; i2p::config::GetOption("port", port);
if (port)
{
LogPrint(eLogInfo, "Daemon: accepting incoming connections at port ", port);
i2p::context.UpdatePort (port);
}
std::string host; i2p::config::GetOption("host", host);
if (host != "") {
if (host != "")
{
LogPrint(eLogInfo, "Daemon: address for incoming connections is ", host);
i2p::context.UpdateAddress (boost::asio::ip::address::from_string (host));
}
@ -103,18 +107,28 @@ namespace i2p @@ -103,18 +107,28 @@ namespace i2p
bool isFloodfill; i2p::config::GetOption("floodfill", isFloodfill);
char bandwidth; i2p::config::GetOption("bandwidth", bandwidth);
if (isFloodfill) {
LogPrint(eLogInfo, "Daemon: router will be floodfill, bandwidth set to 'extra'");
if (isFloodfill)
{
LogPrint(eLogInfo, "Daemon: router will be floodfill");
i2p::context.SetFloodfill (true);
i2p::context.SetExtraBandwidth ();
} else if (bandwidth != '-') {
}
if (bandwidth != '-')
{
LogPrint(eLogInfo, "Daemon: bandwidth set to ", bandwidth);
switch (bandwidth) {
case 'P' : i2p::context.SetExtraBandwidth (); break;
case 'L' : i2p::context.SetHighBandwidth (); break;
default : i2p::context.SetLowBandwidth (); break;
if (bandwidth > 'O')
i2p::context.SetExtraBandwidth ();
else if (bandwidth > 'L')
i2p::context.SetHighBandwidth ();
else
i2p::context.SetLowBandwidth ();
}
else if (isFloodfill)
{
LogPrint(eLogInfo, "Daemon: floodfill bandwidth set to 'extra'");
i2p::context.SetExtraBandwidth ();
}
else
i2p::context.SetLowBandwidth ();
return true;
}

Loading…
Cancel
Save