mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-04-24 09:56:35 +02:00
fix ipv6 fallback address
This commit is contained in:
parent
ece140f18c
commit
73921b1024
2 changed files with 38 additions and 36 deletions
|
@ -51,13 +51,13 @@ namespace i2p
|
||||||
port = rand () % (30777 - 9111) + 9111; // I2P network ports range
|
port = rand () % (30777 - 9111) + 9111; // I2P network ports range
|
||||||
if (port == 9150) port = 9151; // Tor browser
|
if (port == 9150) port = 9151; // Tor browser
|
||||||
}
|
}
|
||||||
bool ipv4; i2p::config::GetOption("ipv4", ipv4);
|
bool ipv4; i2p::config::GetOption("ipv4", ipv4);
|
||||||
bool ipv6; i2p::config::GetOption("ipv6", ipv6);
|
bool ipv6; i2p::config::GetOption("ipv6", ipv6);
|
||||||
bool ssu; i2p::config::GetOption("ssu", ssu);
|
bool ssu; i2p::config::GetOption("ssu", ssu);
|
||||||
bool ntcp; i2p::config::GetOption("ntcp", ntcp);
|
bool ntcp; i2p::config::GetOption("ntcp", ntcp);
|
||||||
bool ntcp2; i2p::config::GetOption("ntcp2.enabled", ntcp2);
|
bool ntcp2; i2p::config::GetOption("ntcp2.enabled", ntcp2);
|
||||||
bool nat; i2p::config::GetOption("nat", nat);
|
bool nat; i2p::config::GetOption("nat", nat);
|
||||||
std::string ifname; i2p::config::GetOption("ifname", ifname);
|
std::string ifname; i2p::config::GetOption("ifname", ifname);
|
||||||
std::string ifname4; i2p::config::GetOption("ifname4", ifname4);
|
std::string ifname4; i2p::config::GetOption("ifname4", ifname4);
|
||||||
std::string ifname6; i2p::config::GetOption("ifname6", ifname6);
|
std::string ifname6; i2p::config::GetOption("ifname6", ifname6);
|
||||||
if (ipv4)
|
if (ipv4)
|
||||||
|
@ -79,7 +79,7 @@ namespace i2p
|
||||||
}
|
}
|
||||||
if (ipv6)
|
if (ipv6)
|
||||||
{
|
{
|
||||||
std::string host = "::";
|
std::string host = "::1";
|
||||||
if (!i2p::config::IsDefault("host") && !ipv4) // override if v6 only
|
if (!i2p::config::IsDefault("host") && !ipv4) // override if v6 only
|
||||||
i2p::config::GetOption("host", host);
|
i2p::config::GetOption("host", host);
|
||||||
else if (!ifname.empty())
|
else if (!ifname.empty())
|
||||||
|
@ -113,7 +113,6 @@ namespace i2p
|
||||||
PublishNTCP2Address (port, true);
|
PublishNTCP2Address (port, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void RouterContext::UpdateRouterInfo ()
|
void RouterContext::UpdateRouterInfo ()
|
||||||
|
|
|
@ -295,7 +295,10 @@ namespace net
|
||||||
{
|
{
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
LogPrint(eLogError, "NetIface: cannot get address by interface name, not implemented on WIN32");
|
LogPrint(eLogError, "NetIface: cannot get address by interface name, not implemented on WIN32");
|
||||||
return boost::asio::ip::address::from_string("127.0.0.1");
|
if(ipv6)
|
||||||
|
return boost::asio::ip::address::from_string("::1");
|
||||||
|
else
|
||||||
|
return boost::asio::ip::address::from_string("127.0.0.1");
|
||||||
#else
|
#else
|
||||||
int af = (ipv6 ? AF_INET6 : AF_INET);
|
int af = (ipv6 ? AF_INET6 : AF_INET);
|
||||||
ifaddrs * addrs = nullptr;
|
ifaddrs * addrs = nullptr;
|
||||||
|
@ -327,7 +330,7 @@ namespace net
|
||||||
std::string fallback;
|
std::string fallback;
|
||||||
if(ipv6)
|
if(ipv6)
|
||||||
{
|
{
|
||||||
fallback = "::";
|
fallback = "::1";
|
||||||
LogPrint(eLogWarning, "NetIface: cannot find ipv6 address for interface ", ifname);
|
LogPrint(eLogWarning, "NetIface: cannot find ipv6 address for interface ", ifname);
|
||||||
} else {
|
} else {
|
||||||
fallback = "127.0.0.1";
|
fallback = "127.0.0.1";
|
||||||
|
|
Loading…
Add table
Reference in a new issue