mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-01-23 17:34:21 +00:00
convert ifname* params to address*
This commit is contained in:
parent
09dadd7e01
commit
5f93dc72fd
@ -144,6 +144,25 @@ namespace util
|
|||||||
ipv4 = false;
|
ipv4 = false;
|
||||||
ipv6 = true;
|
ipv6 = true;
|
||||||
#endif
|
#endif
|
||||||
|
// ifname -> address
|
||||||
|
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
|
||||||
|
}
|
||||||
|
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);
|
bool ygg; i2p::config::GetOption("meshnets.yggdrasil", ygg);
|
||||||
boost::asio::ip::address_v6 yggaddr;
|
boost::asio::ip::address_v6 yggaddr;
|
||||||
if (ygg)
|
if (ygg)
|
||||||
|
@ -76,9 +76,6 @@ namespace i2p
|
|||||||
bool ntcp2; i2p::config::GetOption("ntcp2.enabled", ntcp2);
|
bool ntcp2; i2p::config::GetOption("ntcp2.enabled", ntcp2);
|
||||||
bool ygg; i2p::config::GetOption("meshnets.yggdrasil", ygg);
|
bool ygg; i2p::config::GetOption("meshnets.yggdrasil", ygg);
|
||||||
bool nat; i2p::config::GetOption("nat", nat);
|
bool nat; i2p::config::GetOption("nat", nat);
|
||||||
std::string ifname; i2p::config::GetOption("ifname", ifname);
|
|
||||||
std::string ifname4; i2p::config::GetOption("ifname4", ifname4);
|
|
||||||
std::string ifname6; i2p::config::GetOption("ifname6", ifname6);
|
|
||||||
|
|
||||||
if ((ntcp2 || ygg) && !m_NTCP2Keys)
|
if ((ntcp2 || ygg) && !m_NTCP2Keys)
|
||||||
NewNTCP2Keys ();
|
NewNTCP2Keys ();
|
||||||
@ -98,12 +95,13 @@ namespace i2p
|
|||||||
std::string host = "127.0.0.1";
|
std::string host = "127.0.0.1";
|
||||||
if (!i2p::config::IsDefault("host"))
|
if (!i2p::config::IsDefault("host"))
|
||||||
i2p::config::GetOption("host", host);
|
i2p::config::GetOption("host", host);
|
||||||
else if (!nat && !ifname.empty())
|
else if (!nat)
|
||||||
/* bind to interface, we have no NAT so set external address too */
|
{
|
||||||
host = i2p::util::net::GetInterfaceAddress(ifname, false).to_string(); // v4
|
// we have no NAT so set external address from local address
|
||||||
if(ifname4.size())
|
std::string address4; i2p::config::GetOption("address4", address4);
|
||||||
host = i2p::util::net::GetInterfaceAddress(ifname4, false).to_string();
|
if (!address4.empty ()) host = address4;
|
||||||
|
}
|
||||||
|
|
||||||
if (ntcp2)
|
if (ntcp2)
|
||||||
{
|
{
|
||||||
if (ntcp2Published)
|
if (ntcp2Published)
|
||||||
@ -125,10 +123,11 @@ namespace i2p
|
|||||||
std::string host = "::1";
|
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
|
||||||
host = i2p::util::net::GetInterfaceAddress(ifname, true).to_string(); // v6
|
{
|
||||||
if(ifname6.size())
|
std::string address6; i2p::config::GetOption("address6", address6);
|
||||||
host = i2p::util::net::GetInterfaceAddress(ifname6, true).to_string();
|
if (!address6.empty ()) host = address6;
|
||||||
|
}
|
||||||
|
|
||||||
if (ntcp2)
|
if (ntcp2)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user