Merge branch 'PurpleI2P:openssl' into ui

This commit is contained in:
dr|z3d 2021-08-14 01:20:59 +00:00 committed by GitHub
commit 98eadf6f78
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 45 additions and 2 deletions

View file

@ -555,7 +555,10 @@ namespace net
static const std::vector< std::pair<boost::asio::ip::address_v6::bytes_type, boost::asio::ip::address_v6::bytes_type> > reservedIPv6Ranges {
address_pair_v6("2001:db8::", "2001:db8:ffff:ffff:ffff:ffff:ffff:ffff"),
address_pair_v6("fc00::", "fdff:ffff:ffff:ffff:ffff:ffff:ffff:ffff"),
address_pair_v6("fe80::", "febf:ffff:ffff:ffff:ffff:ffff:ffff:ffff")
address_pair_v6("fe80::", "febf:ffff:ffff:ffff:ffff:ffff:ffff:ffff"),
address_pair_v6("ff00::", "ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff"),
address_pair_v6("::", "::"),
address_pair_v6("::1", "::1")
};
boost::asio::ip::address_v6::bytes_type ipv6_address = host.to_v6 ().to_bytes ();

View file

@ -605,7 +605,47 @@ namespace client
{
if (!ecode)
{
auto addr = (*it).endpoint ().address ();
bool found = false;
boost::asio::ip::tcp::endpoint ep;
if (m_LocalAddress)
{
boost::asio::ip::tcp::resolver::iterator end;
while (it != end)
{
ep = *it;
if (!ep.address ().is_unspecified ())
{
if (ep.address ().is_v4 ())
{
if (m_LocalAddress->is_v4 ()) found = true;
}
else if (ep.address ().is_v6 ())
{
if (i2p::util::net::IsYggdrasilAddress (ep.address ()))
{
if (i2p::util::net::IsYggdrasilAddress (*m_LocalAddress))
found = true;
}
else if (m_LocalAddress->is_v6 ())
found = true;
}
}
if (found) break;
it++;
}
}
else
{
found = true;
ep = *it; // first available
}
if (!found)
{
LogPrint (eLogError, "I2PTunnel: Unable to resolve to compatible address");
return;
}
auto addr = ep.address ();
LogPrint (eLogInfo, "I2PTunnel: server tunnel ", (*it).host_name (), " has been resolved to ", addr);
m_Endpoint.address (addr);
Accept ();