mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-01-22 04:04:16 +00:00
meshnets.yggaddress added
This commit is contained in:
parent
bfb1380dd2
commit
ace80c29e7
@ -148,11 +148,24 @@ namespace i2p
|
|||||||
boost::asio::ip::address_v6 yggaddr;
|
boost::asio::ip::address_v6 yggaddr;
|
||||||
if (ygg)
|
if (ygg)
|
||||||
{
|
{
|
||||||
yggaddr = i2p::util::net::GetYggdrasilAddress ();
|
std::string yggaddress; i2p::config::GetOption ("meshnets.yggaddress", yggaddress);
|
||||||
if (yggaddr.is_unspecified ())
|
if (!yggaddress.empty ())
|
||||||
{
|
{
|
||||||
LogPrint(eLogWarning, "Daemon: Yggdrasil is not running. Disabled");
|
yggaddr = boost::asio::ip::address_v6::from_string (yggaddress);
|
||||||
ygg = false;
|
if (yggaddr.is_unspecified () || i2p::util::net::GetMTU (yggaddr) != 0xFFFF) // ygg's MTU is always 65535
|
||||||
|
{
|
||||||
|
LogPrint(eLogWarning, "Daemon: Can't find Yggdrasil address ", yggaddress);
|
||||||
|
ygg = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
yggaddr = i2p::util::net::GetYggdrasilAddress ();
|
||||||
|
if (yggaddr.is_unspecified ())
|
||||||
|
{
|
||||||
|
LogPrint(eLogWarning, "Daemon: Yggdrasil is not running. Disabled");
|
||||||
|
ygg = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -279,6 +279,7 @@ namespace config {
|
|||||||
options_description meshnets("Meshnet transports options");
|
options_description meshnets("Meshnet transports options");
|
||||||
meshnets.add_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 (deafult: false)")
|
||||||
|
("meshnets.yggaddress", value<std::string>()->default_value(""), "Yggdrasil address to publish")
|
||||||
;
|
;
|
||||||
|
|
||||||
m_OptionsDesc
|
m_OptionsDesc
|
||||||
|
@ -980,7 +980,8 @@ namespace data
|
|||||||
return GetAddress (
|
return GetAddress (
|
||||||
[](std::shared_ptr<const RouterInfo::Address> address)->bool
|
[](std::shared_ptr<const RouterInfo::Address> address)->bool
|
||||||
{
|
{
|
||||||
return address->IsPublishedNTCP2 () && address->host.is_v6 ();
|
return address->IsPublishedNTCP2 () && address->host.is_v6 () &&
|
||||||
|
!i2p::util::net::IsYggdrasilAddress (address->host);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -461,7 +461,7 @@ namespace net
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IsInReservedRange (const boost::asio::ip::address& host, bool checkYggdrasil)
|
bool IsInReservedRange (const boost::asio::ip::address& host)
|
||||||
{
|
{
|
||||||
// https://en.wikipedia.org/wiki/Reserved_IP_addresses
|
// https://en.wikipedia.org/wiki/Reserved_IP_addresses
|
||||||
if(host.is_v4())
|
if(host.is_v4())
|
||||||
@ -502,7 +502,7 @@ namespace net
|
|||||||
if (ipv6_address >= it.first && ipv6_address <= it.second)
|
if (ipv6_address >= it.first && ipv6_address <= it.second)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (checkYggdrasil && IsYggdrasilAddress (ipv6_address.data ())) // yggdrasil?
|
if (IsYggdrasilAddress (ipv6_address.data ())) // yggdrasil?
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -189,7 +189,7 @@ namespace util
|
|||||||
int GetMTU (const boost::asio::ip::address& localAddress);
|
int GetMTU (const boost::asio::ip::address& localAddress);
|
||||||
const boost::asio::ip::address GetInterfaceAddress (const std::string & ifname, bool ipv6=false);
|
const boost::asio::ip::address GetInterfaceAddress (const std::string & ifname, bool ipv6=false);
|
||||||
boost::asio::ip::address_v6 GetYggdrasilAddress ();
|
boost::asio::ip::address_v6 GetYggdrasilAddress ();
|
||||||
bool IsInReservedRange (const boost::asio::ip::address& host, bool checkYggdrasil = true);
|
bool IsInReservedRange (const boost::asio::ip::address& host);
|
||||||
bool IsYggdrasilAddress (const boost::asio::ip::address& addr);
|
bool IsYggdrasilAddress (const boost::asio::ip::address& addr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user