Browse Source

Merge pull request #725 from majestrate/fix-722

don't add multiple router addresses when specifying ifname4/6
pull/729/head
orignal 8 years ago committed by GitHub
parent
commit
a8061003dd
  1. 21
      RouterContext.cpp

21
RouterContext.cpp

@ -53,6 +53,8 @@ namespace i2p
bool ipv6; i2p::config::GetOption("ipv6", ipv6); bool ipv6; i2p::config::GetOption("ipv6", ipv6);
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 ifname6; i2p::config::GetOption("ifname6", ifname6);
if (ipv4) if (ipv4)
{ {
std::string host = "127.0.0.1"; std::string host = "127.0.0.1";
@ -61,6 +63,10 @@ namespace i2p
else if (!nat && !ifname.empty()) else if (!nat && !ifname.empty())
/* bind to interface, we have no NAT so set external address too */ /* bind to interface, we have no NAT so set external address too */
host = i2p::util::net::GetInterfaceAddress(ifname, false).to_string(); // v4 host = i2p::util::net::GetInterfaceAddress(ifname, false).to_string(); // v4
if(ifname4.size())
host = i2p::util::net::GetInterfaceAddress(ifname4, false).to_string();
routerInfo.AddSSUAddress (host.c_str(), port, routerInfo.GetIdentHash ()); routerInfo.AddSSUAddress (host.c_str(), port, routerInfo.GetIdentHash ());
routerInfo.AddNTCPAddress (host.c_str(), port); routerInfo.AddNTCPAddress (host.c_str(), port);
} }
@ -71,21 +77,10 @@ namespace i2p
i2p::config::GetOption("host", host); i2p::config::GetOption("host", host);
else if (!ifname.empty()) else if (!ifname.empty())
host = i2p::util::net::GetInterfaceAddress(ifname, true).to_string(); // v6 host = i2p::util::net::GetInterfaceAddress(ifname, true).to_string(); // v6
routerInfo.AddSSUAddress (host.c_str(), port, routerInfo.GetIdentHash ());
routerInfo.AddNTCPAddress (host.c_str(), port);
}
std::string ifname4; i2p::config::GetOption("ifname4", ifname4);
if(ifname4.size())
{
std::string host = i2p::util::net::GetInterfaceAddress(ifname4, false).to_string();
routerInfo.AddSSUAddress (host.c_str(), port, routerInfo.GetIdentHash());
routerInfo.AddNTCPAddress (host.c_str(), port);
}
std::string ifname6; i2p::config::GetOption("ifname6", ifname6);
if(ifname6.size()) if(ifname6.size())
{ host = i2p::util::net::GetInterfaceAddress(ifname6, true).to_string();
std::string host = i2p::util::net::GetInterfaceAddress(ifname6, true).to_string();
routerInfo.AddSSUAddress (host.c_str(), port, routerInfo.GetIdentHash ()); routerInfo.AddSSUAddress (host.c_str(), port, routerInfo.GetIdentHash ());
routerInfo.AddNTCPAddress (host.c_str(), port); routerInfo.AddNTCPAddress (host.c_str(), port);
} }

Loading…
Cancel
Save