mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-01-22 21:37:17 +01:00
select compatible resolved address for server tunnel
This commit is contained in:
parent
fc29911ffd
commit
797f5eb714
|
@ -605,7 +605,40 @@ namespace client
|
||||||
{
|
{
|
||||||
if (!ecode)
|
if (!ecode)
|
||||||
{
|
{
|
||||||
auto addr = (*it).endpoint ().address ();
|
bool found = false;
|
||||||
|
boost::asio::ip::tcp::resolver::iterator end;
|
||||||
|
boost::asio::ip::tcp::endpoint ep;
|
||||||
|
while (it != end)
|
||||||
|
{
|
||||||
|
ep = *it;
|
||||||
|
if (!ep.address ().is_unspecified ())
|
||||||
|
{
|
||||||
|
if (ep.address ().is_v4 ())
|
||||||
|
{
|
||||||
|
if (!m_LocalAddress || m_LocalAddress->is_v4 ()) // look for ipv4 if not specified
|
||||||
|
found = true;
|
||||||
|
}
|
||||||
|
else if (ep.address ().is_v6 ())
|
||||||
|
{
|
||||||
|
if (i2p::util::net::IsYggdrasilAddress (ep.address ()))
|
||||||
|
{
|
||||||
|
if (m_LocalAddress && i2p::util::net::IsYggdrasilAddress (*m_LocalAddress))
|
||||||
|
found = true;
|
||||||
|
}
|
||||||
|
else if (m_LocalAddress && m_LocalAddress->is_v6 ())
|
||||||
|
found = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (found) break;
|
||||||
|
it++;
|
||||||
|
}
|
||||||
|
if (!found)
|
||||||
|
{
|
||||||
|
LogPrint (eLogError, "I2PTunnel: Unable to reslove to compatible address");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto addr = ep.address ();
|
||||||
LogPrint (eLogInfo, "I2PTunnel: server tunnel ", (*it).host_name (), " has been resolved to ", addr);
|
LogPrint (eLogInfo, "I2PTunnel: server tunnel ", (*it).host_name (), " has been resolved to ", addr);
|
||||||
m_Endpoint.address (addr);
|
m_Endpoint.address (addr);
|
||||||
Accept ();
|
Accept ();
|
||||||
|
|
Loading…
Reference in a new issue