mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-01-12 22:47:52 +00:00
allow DNS names for SSU
This commit is contained in:
parent
0ef42870e5
commit
bf47df46c9
@ -171,9 +171,8 @@ namespace data
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// TODO: resolve address for SSU
|
m_SupportedTransports |= eSSUV4; // TODO:
|
||||||
LogPrint (eLogWarning, "Unexpected SSU address ", value);
|
address.addressString = value;
|
||||||
isValidAddress = false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -278,7 +278,7 @@ namespace transport
|
|||||||
{
|
{
|
||||||
if (address->addressString.length () > 0) // trying to resolve
|
if (address->addressString.length () > 0) // trying to resolve
|
||||||
{
|
{
|
||||||
LogPrint (eLogInfo, "Resolving ", address->addressString);
|
LogPrint (eLogInfo, "Resolving NTCP ", address->addressString);
|
||||||
NTCPResolve (address->addressString, ident);
|
NTCPResolve (address->addressString, ident);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -304,6 +304,15 @@ namespace transport
|
|||||||
m_SSUServer->CreateSession (peer.router, address->host, address->port);
|
m_SSUServer->CreateSession (peer.router, address->host, address->port);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
else // we don't have address
|
||||||
|
{
|
||||||
|
if (address->addressString.length () > 0) // trying to resolve
|
||||||
|
{
|
||||||
|
LogPrint (eLogInfo, "Resolving SSU ", address->addressString);
|
||||||
|
SSUResolve (address->addressString, ident);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
LogPrint (eLogError, "No NTCP and SSU addresses available");
|
LogPrint (eLogError, "No NTCP and SSU addresses available");
|
||||||
@ -376,6 +385,37 @@ namespace transport
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Transports::SSUResolve (const std::string& addr, const i2p::data::IdentHash& ident)
|
||||||
|
{
|
||||||
|
auto resolver = std::make_shared<boost::asio::ip::tcp::resolver>(m_Service);
|
||||||
|
resolver->async_resolve (boost::asio::ip::tcp::resolver::query (addr, ""),
|
||||||
|
std::bind (&Transports::HandleSSUResolve, this,
|
||||||
|
std::placeholders::_1, std::placeholders::_2, ident, resolver));
|
||||||
|
}
|
||||||
|
|
||||||
|
void Transports::HandleSSUResolve (const boost::system::error_code& ecode, boost::asio::ip::tcp::resolver::iterator it,
|
||||||
|
i2p::data::IdentHash ident, std::shared_ptr<boost::asio::ip::tcp::resolver> resolver)
|
||||||
|
{
|
||||||
|
auto it1 = m_Peers.find (ident);
|
||||||
|
if (it1 != m_Peers.end ())
|
||||||
|
{
|
||||||
|
auto& peer = it1->second;
|
||||||
|
if (!ecode && peer.router)
|
||||||
|
{
|
||||||
|
auto address = (*it).endpoint ().address ();
|
||||||
|
LogPrint (eLogInfo, (*it).host_name (), " has been resolved to ", address);
|
||||||
|
auto addr = peer.router->GetSSUAddress (!context.SupportsV6 ());;
|
||||||
|
if (addr)
|
||||||
|
{
|
||||||
|
m_SSUServer->CreateSession (peer.router, address, addr->port);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
LogPrint (eLogError, "Unable to resolve SSU address: ", ecode.message ());
|
||||||
|
m_Peers.erase (it1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Transports::CloseSession (std::shared_ptr<const i2p::data::RouterInfo> router)
|
void Transports::CloseSession (std::shared_ptr<const i2p::data::RouterInfo> router)
|
||||||
{
|
{
|
||||||
if (!router) return;
|
if (!router) return;
|
||||||
|
@ -114,6 +114,9 @@ namespace transport
|
|||||||
void NTCPResolve (const std::string& addr, const i2p::data::IdentHash& ident);
|
void NTCPResolve (const std::string& addr, const i2p::data::IdentHash& ident);
|
||||||
void HandleNTCPResolve (const boost::system::error_code& ecode, boost::asio::ip::tcp::resolver::iterator it,
|
void HandleNTCPResolve (const boost::system::error_code& ecode, boost::asio::ip::tcp::resolver::iterator it,
|
||||||
i2p::data::IdentHash ident, std::shared_ptr<boost::asio::ip::tcp::resolver> resolver);
|
i2p::data::IdentHash ident, std::shared_ptr<boost::asio::ip::tcp::resolver> resolver);
|
||||||
|
void SSUResolve (const std::string& addr, const i2p::data::IdentHash& ident);
|
||||||
|
void HandleSSUResolve (const boost::system::error_code& ecode, boost::asio::ip::tcp::resolver::iterator it,
|
||||||
|
i2p::data::IdentHash ident, std::shared_ptr<boost::asio::ip::tcp::resolver> resolver);
|
||||||
|
|
||||||
void UpdateBandwidth ();
|
void UpdateBandwidth ();
|
||||||
void DetectExternalIP ();
|
void DetectExternalIP ();
|
||||||
|
Loading…
Reference in New Issue
Block a user