Browse Source

fixed bandwidth logic

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

4
Config.cpp

@ -114,13 +114,13 @@ namespace config {
("logfile", value<std::string>()->default_value(""), "Path to logfile (stdout if not set, autodetect if daemon)") ("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)") ("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)") ("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") ("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") ("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'") ("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") ("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") ("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"); options_description httpserver("HTTP Server options");

38
Daemon.cpp

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

Loading…
Cancel
Save