Skip to content

Commit

Permalink
update config file example, add v6 status to windows daemon window, c…
Browse files Browse the repository at this point in the history
…ode cleanup

Signed-off-by: R4SAS <[email protected]>
  • Loading branch information
r4sas committed May 15, 2021
1 parent d299cba commit c359c6e
Show file tree
Hide file tree
Showing 11 changed files with 254 additions and 223 deletions.
42 changes: 32 additions & 10 deletions Win32/Win32App.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,25 +142,47 @@ namespace win32
s << bytes << " Bytes\n";
}

static void PrintMainWindowText (std::stringstream& s)
static void ShowNetworkStatus (std::stringstream& s, RouterStatus status)
{
s << "\n";
s << "Status: ";
switch (i2p::context.GetStatus())
switch (status)
{
case eRouterStatusOK: s << "OK"; break;
case eRouterStatusTesting: s << "Testing"; break;
case eRouterStatusFirewalled: s << "Firewalled"; break;
case eRouterStatusTesting: s << "Test"; break;
case eRouterStatusFirewalled: s << "FW"; break;
case eRouterStatusUnknown: s << "Unk"; break;
case eRouterStatusProxy: s << "Proxy"; break;
case eRouterStatusMesh: s << "Mesh"; break;
case eRouterStatusError:
{
switch (i2p::context.GetError())
s << "Err";
switch (i2p::context.GetError ())
{
case eRouterErrorClockSkew: s << "Clock skew"; break;
default: s << "Error";
case eRouterErrorClockSkew:
s << " - Clock skew";
break;
case eRouterErrorOffline:
s << " - Offline";
break;
case eRouterErrorSymmetricNAT:
s << " - Symmetric NAT";
break;
default: ;
}
break;
}
default: s << "Unknown";
default: s << "Unk";
}
}

static void PrintMainWindowText (std::stringstream& s)
{
s << "\n";
s << "Status: ";
ShowNetworkStatus (s, i2p::context.GetStatus ());
if (i2p::context.SupportsV6 ())
{
s << " / ";
ShowNetworkStatus (s, i2p::context.GetStatusV6 ());
}
s << "; ";
s << "Success Rate: " << i2p::tunnel::tunnels.GetTunnelCreationSuccessRate() << "%\n";
Expand Down
54 changes: 30 additions & 24 deletions contrib/i2pd.conf
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,30 @@
## Write full CLF-formatted date and time to log (default: write only time)
# logclftime = true

## Daemon mode. Router will go to background after start
## Daemon mode. Router will go to background after start. Ignored on Windows
# daemon = true

## Specify a family, router belongs to (default - none)
# family =

## External IP address to listen for connections
## Network interface to bind to
## Updates address4/6 options if they are not set
# ifname =
## You can specify different interfaces for IPv4 and IPv6
# ifname4 =
# ifname6 =

## Local address to bind transport sockets to
## Overrides host option if:
## For ipv4: if ipv4 = true and nat = false

This comment has been minimized.

Copy link
@LLE8

LLE8 May 16, 2021

Кажется опцию 'nat' давно выбросили?

This comment has been minimized.

Copy link
@r4sas

r4sas May 17, 2021

Author Member

Нет, она еще существует, но практически не используется. В следующем релизе план выкинуть окончательно.

This comment has been minimized.

Copy link
@LLE8

LLE8 May 20, 2021

А на что она влияет и как? Значение по умолчанию true? На типичном VDS где никакого nat-а вроде бы не должно быть, она тоже true по умолчанию?

This comment has been minimized.

Copy link
@r4sas

r4sas May 21, 2021

Author Member

Если память не изменяет, оно включает определение доступности узла через peertest.

## For ipv6: if 'host' is not set or ipv4 = true
# address4 =
# address6 =

## External IPv4 or IPv6 address to listen for connections
## By default i2pd sets IP automatically
## Sets published NTCP2v4/SSUv4 address to 'host' value if nat = true

This comment has been minimized.

Copy link
@LLE8

LLE8 May 16, 2021

Кажется опцию 'nat' давно выбросили?

## Sets published NTCP2v6/SSUv6 address to 'host' value if ipv4 = false
# host = 1.2.3.4

## Port to listen for connections
Expand All @@ -55,17 +71,6 @@ ipv4 = true
## Enable communication through ipv6
ipv6 = false

## Network interface to bind to
# ifname =
## You can specify different interfaces for IPv4 and IPv6
# ifname4 =
# ifname6 =

## Enable NTCP transport (default = true)
# ntcp = true
## If you run i2pd behind a proxy server, you can only use NTCP transport with ntcpproxy option
## Should be http://address:port or socks://address:port
# ntcpproxy = http://127.0.0.1:8118
## Enable SSU transport (default = true)
# ssu = true

Expand All @@ -82,6 +87,7 @@ ipv6 = false
# notransit = true

## Router will be floodfill
## Note: that mode uses much more network connections and CPU!
# floodfill = true

[http]
Expand All @@ -93,7 +99,7 @@ address = 127.0.0.1
port = 7070
## Path to web console, default "/"
# webroot = /
## Uncomment following lines to enable Web Console authentication
## Uncomment following lines to enable Web Console authentication
# auth = true
# user = i2pd
# pass = changeme
Expand Down Expand Up @@ -170,11 +176,11 @@ enabled = true
# name = I2Pd

[meshnets]
## Enable connectivity over the Yggdrasil network
## Enable connectivity over the Yggdrasil network
# yggdrasil = false
## You can bind address from your Yggdrasil subnet 300::/64
## The address must first be added to the network interface
# yggaddress =
## The address must first be added to the network interface
# yggaddress =

[reseed]
## Options for bootstrapping into I2P network, aka reseeding
Expand Down Expand Up @@ -207,13 +213,13 @@ verify = true
[limits]
## Maximum active transit sessions (default:2500)
# transittunnels = 2500
## Limit number of open file descriptors (0 - use system limit)
## Limit number of open file descriptors (0 - use system limit)
# openfiles = 0
## Maximum size of corefile in Kb (0 - use system limit)
## Maximum size of corefile in Kb (0 - use system limit)
# coresize = 0
## Threshold to start probabalistic backoff with ntcp sessions (0 - use system limit)
## Threshold to start probabalistic backoff with ntcp sessions (0 - use system limit)
# ntcpsoft = 0
## Maximum number of ntcp sessions (0 - use system limit)
## Maximum number of ntcp sessions (0 - use system limit)
# ntcphard = 0

[trust]
Expand All @@ -222,13 +228,13 @@ verify = true
## Make direct I2P connections only to routers in specified Family.
# family = MyFamily
## Make direct I2P connections only to routers specified here. Comma separated list of base64 identities.
# routers =
# routers =
## Should we hide our router from other routers? false by default
# hidden = true

[exploratory]
## Exploratory tunnels settings with default values
# inbound.length = 2
# inbound.length = 2
# inbound.quantity = 3
# outbound.length = 2
# outbound.quantity = 3
Expand All @@ -237,7 +243,7 @@ verify = true
## Save peer profiles on disk (default: true)
# profiles = true
## Save full addresses on disk (default: true)
# addressbook = true
# addressbook = true

[cpuext]
## Use CPU AES-NI instructions set when work with cryptography when available (default: true)
Expand Down
26 changes: 13 additions & 13 deletions daemon/Daemon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,32 +142,32 @@ namespace util
i2p::context.SetNetID (netID);
i2p::context.Init ();

bool ipv6; i2p::config::GetOption("ipv6", ipv6);
bool ipv4; i2p::config::GetOption("ipv4", ipv4);
bool ipv6; i2p::config::GetOption("ipv6", ipv6);
bool ipv4; i2p::config::GetOption("ipv4", ipv4);
#ifdef MESHNET
// manual override for meshnet
ipv4 = false;
ipv6 = true;
#endif
// ifname -> address
std::string ifname; i2p::config::GetOption("ifname", ifname);
std::string ifname; i2p::config::GetOption("ifname", ifname);
if (ipv4 && i2p::config::IsDefault ("address4"))
{
std::string ifname4; i2p::config::GetOption("ifname4", ifname4);
if (!ifname4.empty ())
i2p::config::SetOption ("address4", i2p::util::net::GetInterfaceAddress(ifname4, false).to_string ()); // v4
else if (!ifname.empty ())
i2p::config::SetOption ("address4", i2p::util::net::GetInterfaceAddress(ifname, false).to_string ()); // v4
}
i2p::config::SetOption ("address4", i2p::util::net::GetInterfaceAddress(ifname, false).to_string ()); // v4
}
if (ipv6 && i2p::config::IsDefault ("address6"))
{
std::string ifname6; i2p::config::GetOption("ifname6", ifname6);
if (!ifname6.empty ())
i2p::config::SetOption ("address6", i2p::util::net::GetInterfaceAddress(ifname6, true).to_string ()); // v6
else if (!ifname.empty ())
i2p::config::SetOption ("address6", i2p::util::net::GetInterfaceAddress(ifname, true).to_string ()); // v6
}
}

bool ygg; i2p::config::GetOption("meshnets.yggdrasil", ygg);
boost::asio::ip::address_v6 yggaddr;
if (ygg)
Expand Down Expand Up @@ -210,10 +210,10 @@ namespace util
{
bool published; i2p::config::GetOption("ntcp2.published", published);
if (published)
{
{
std::string ntcp2proxy; i2p::config::GetOption("ntcp2.proxy", ntcp2proxy);
if (!ntcp2proxy.empty ()) published = false;
}
}
if (published)
{
uint16_t ntcp2port; i2p::config::GetOption("ntcp2.port", ntcp2port);
Expand All @@ -232,12 +232,12 @@ namespace util
}
if (ygg)
{
i2p::context.PublishNTCP2Address (port, true, false, false, true);
i2p::context.PublishNTCP2Address (port, true, false, false, true);
i2p::context.UpdateNTCP2V6Address (yggaddr);
if (!ipv4 && !ipv6)
i2p::context.SetStatus (eRouterStatusMesh);
}
i2p::context.SetStatus (eRouterStatusMesh);
}

bool transit; i2p::config::GetOption("notransit", transit);
i2p::context.SetAcceptsTunnels (!transit);
uint16_t transitTunnels; i2p::config::GetOption("limits.transittunnels", transitTunnels);
Expand Down
22 changes: 11 additions & 11 deletions daemon/HTTPServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -265,15 +265,15 @@ namespace http {
break;
case eRouterErrorSymmetricNAT:
s << " - Symmetric NAT";
break;
break;
default: ;
}
break;
}
default: s << "Unknown";
}
}
}

void ShowStatus (std::stringstream& s, bool includeHiddenContent, i2p::http::OutputFormatEnum outputFormat)
{
s << "<b>Uptime:</b> ";
Expand All @@ -287,7 +287,7 @@ namespace http {
s << "<b>Network status 6:</b> ";
ShowNetworkStatus (s, i2p::context.GetStatusV6 ());
s << "<br>\r\n";
}
}
#if ((!defined(WIN32) && !defined(QT_GUI_LIB) && !defined(ANDROID)) || defined(ANDROID_BINARY))
if (auto remains = Daemon.gracefulShutdownInterval) {
s << "<b>Stopping in:</b> ";
Expand Down Expand Up @@ -1276,14 +1276,14 @@ namespace http {
ident.FromBase32 (b32);
auto dest = i2p::client::context.FindLocalDestination (ident);

if (dest)
if (dest)
{
std::size_t pos;
pos = name.find (".i2p");
if (pos == (name.length () - 4))
if (pos == (name.length () - 4))
{
pos = name.find (".b32.i2p");
if (pos == std::string::npos)
if (pos == std::string::npos)
{
auto signatureLen = dest->GetIdentity ()->GetSignatureLen ();
uint8_t * signature = new uint8_t[signatureLen];
Expand All @@ -1303,13 +1303,13 @@ namespace http {
"</form>\r\n<br>\r\n";
delete[] signature;
delete[] sig;
}
else
}
else
s << "<b>ERROR</b>:&nbsp;Domain can't end with .b32.i2p\r\n<br>\r\n<br>\r\n";
}
}
else
s << "<b>ERROR</b>:&nbsp;Domain must end with .i2p\r\n<br>\r\n<br>\r\n";
}
}
else
s << "<b>ERROR</b>:&nbsp;Such destination is not found\r\n<br>\r\n<br>\r\n";

Expand Down
4 changes: 4 additions & 0 deletions daemon/I2PControl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
#include <sstream>
#include <openssl/x509.h>
#include <openssl/pem.h>

// Use global placeholders from boost introduced when local_time.hpp is loaded
#define BOOST_BIND_GLOBAL_PLACEHOLDERS

#include <boost/lexical_cast.hpp>
#include <boost/date_time/local_time/local_time.hpp>
#include <boost/date_time/posix_time/posix_time.hpp>
Expand Down
14 changes: 7 additions & 7 deletions libi2pd/Config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,11 @@ namespace config {
("floodfill", bool_switch()->default_value(false), "Router will be floodfill (default: disabled)")
("bandwidth", value<std::string>()->default_value(""), "Bandwidth limit: integer in KBps or letters: L (32), O (256), P (2048), X (>9000)")
("share", value<int>()->default_value(100), "Limit of transit traffic from max bandwidth in percents. (default: 100)")
("ntcp", bool_switch()->default_value(false), "Ignored. Always false")
("ntcp", bool_switch()->default_value(false), "Deprecated option. Always false")
("ssu", bool_switch()->default_value(true), "Enable SSU transport (default: enabled)")
("ntcpproxy", value<std::string>()->default_value(""), "Ignored")
("ntcpproxy", value<std::string>()->default_value(""), "Deprecated option")
#ifdef _WIN32
("svcctl", value<std::string>()->default_value(""), "Ignored")
("svcctl", value<std::string>()->default_value(""), "Deprecated option")
("insomnia", bool_switch()->default_value(false), "Prevent system from sleeping (default: disabled)")
("close", value<std::string>()->default_value("ask"), "Action on close: minimize, exit, ask")
#endif
Expand All @@ -77,9 +77,9 @@ namespace config {
("limits.coresize", value<uint32_t>()->default_value(0), "Maximum size of corefile in Kb (0 - use system limit)")
("limits.openfiles", value<uint16_t>()->default_value(0), "Maximum number of open files (0 - use system default)")
("limits.transittunnels", value<uint16_t>()->default_value(2500), "Maximum active transit sessions (default:2500)")
("limits.ntcpsoft", value<uint16_t>()->default_value(0), "Threshold to start probabilistic backoff with ntcp sessions (default: use system limit)")
("limits.ntcphard", value<uint16_t>()->default_value(0), "Maximum number of ntcp sessions (default: use system limit)")
("limits.ntcpthreads", value<uint16_t>()->default_value(1), "Maximum number of threads used by NTCP DH worker (default: 1)")
("limits.ntcpsoft", value<uint16_t>()->default_value(0), "Deprecated option")
("limits.ntcphard", value<uint16_t>()->default_value(0), "Deprecated option")
("limits.ntcpthreads", value<uint16_t>()->default_value(1), "Deprecated option")
;

options_description httpserver("HTTP Server options");
Expand Down Expand Up @@ -281,7 +281,7 @@ namespace config {

options_description meshnets("Meshnet transports options");
meshnets.add_options()
("meshnets.yggdrasil", bool_switch()->default_value(false), "Support transports through the Yggdrasil (deafult: false)")
("meshnets.yggdrasil", bool_switch()->default_value(false), "Support transports through the Yggdrasil (default: false)")
("meshnets.yggaddress", value<std::string>()->default_value(""), "Yggdrasil address to publish")
;

Expand Down
5 changes: 2 additions & 3 deletions libi2pd/Destination.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,7 @@ namespace client
// schedule verification
m_PublishVerificationTimer.expires_from_now (boost::posix_time::seconds(PUBLISH_VERIFICATION_TIMEOUT));
m_PublishVerificationTimer.async_wait (std::bind (&LeaseSetDestination::HandlePublishVerificationTimer,
shared_from_this (), std::placeholders::_1));
shared_from_this (), std::placeholders::_1));
}
else
i2p::garlic::GarlicDestination::HandleDeliveryStatusMessage (msgID);
Expand Down Expand Up @@ -592,8 +592,7 @@ namespace client
// assume it successive and try to verify
m_PublishVerificationTimer.expires_from_now (boost::posix_time::seconds(PUBLISH_VERIFICATION_TIMEOUT));
m_PublishVerificationTimer.async_wait (std::bind (&LeaseSetDestination::HandlePublishVerificationTimer,
shared_from_this (), std::placeholders::_1));

shared_from_this (), std::placeholders::_1));
}
}
}
Expand Down
Loading

0 comments on commit c359c6e

Please sign in to comment.