mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-02-01 22:34:13 +00:00
resolve address for NTCP
This commit is contained in:
parent
07c6f2a20b
commit
bf7b53a2a6
@ -150,9 +150,17 @@ namespace data
|
|||||||
address.host = boost::asio::ip::address::from_string (value, ecode);
|
address.host = boost::asio::ip::address::from_string (value, ecode);
|
||||||
if (ecode)
|
if (ecode)
|
||||||
{
|
{
|
||||||
// TODO: we should try to resolve address here
|
if (address.transportStyle == eTransportNTCP)
|
||||||
LogPrint (eLogWarning, "Unexpected address ", value);
|
{
|
||||||
isValidAddress = false;
|
m_SupportedTransports |= eNTCPV4; // TODO:
|
||||||
|
address.addressString = value;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// TODO: resolve address for SSU
|
||||||
|
LogPrint (eLogWarning, "Unexpected SSU address ", value);
|
||||||
|
isValidAddress = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -69,7 +69,7 @@ namespace data
|
|||||||
{
|
{
|
||||||
TransportStyle transportStyle;
|
TransportStyle transportStyle;
|
||||||
boost::asio::ip::address host;
|
boost::asio::ip::address host;
|
||||||
char * addressString;
|
std::string addressString;
|
||||||
int port, mtu;
|
int port, mtu;
|
||||||
uint64_t date;
|
uint64_t date;
|
||||||
uint8_t cost;
|
uint8_t cost;
|
||||||
@ -77,9 +77,6 @@ namespace data
|
|||||||
Tag<32> key; // intro key for SSU
|
Tag<32> key; // intro key for SSU
|
||||||
std::vector<Introducer> introducers;
|
std::vector<Introducer> introducers;
|
||||||
|
|
||||||
Address (): addressString (nullptr) {};
|
|
||||||
~Address () { if (addressString) delete[] addressString; };
|
|
||||||
|
|
||||||
bool IsCompatible (const boost::asio::ip::address& other) const
|
bool IsCompatible (const boost::asio::ip::address& other) const
|
||||||
{
|
{
|
||||||
return (host.is_v4 () && other.is_v4 ()) ||
|
return (host.is_v4 () && other.is_v4 ()) ||
|
||||||
|
@ -232,7 +232,7 @@ namespace transport
|
|||||||
}
|
}
|
||||||
else // we don't have address
|
else // we don't have address
|
||||||
{
|
{
|
||||||
if (address->addressString) // trying to resolve
|
if (address->addressString.length () > 0) // trying to resolve
|
||||||
{
|
{
|
||||||
LogPrint (eLogInfo, "Resolving ", address->addressString);
|
LogPrint (eLogInfo, "Resolving ", address->addressString);
|
||||||
NTCPResolve (address->addressString, ident);
|
NTCPResolve (address->addressString, ident);
|
||||||
@ -287,7 +287,7 @@ namespace transport
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Transports::NTCPResolve (const char * addr, const i2p::data::IdentHash& ident)
|
void Transports::NTCPResolve (const std::string& addr, const i2p::data::IdentHash& ident)
|
||||||
{
|
{
|
||||||
auto resolver = std::make_shared<boost::asio::ip::tcp::resolver>(m_Service);
|
auto resolver = std::make_shared<boost::asio::ip::tcp::resolver>(m_Service);
|
||||||
resolver->async_resolve (boost::asio::ip::tcp::resolver::query (addr),
|
resolver->async_resolve (boost::asio::ip::tcp::resolver::query (addr),
|
||||||
|
@ -94,7 +94,7 @@ namespace transport
|
|||||||
void PostCloseSession (std::shared_ptr<const i2p::data::RouterInfo> router);
|
void PostCloseSession (std::shared_ptr<const i2p::data::RouterInfo> router);
|
||||||
bool ConnectToPeer (const i2p::data::IdentHash& ident, Peer& peer);
|
bool ConnectToPeer (const i2p::data::IdentHash& ident, Peer& peer);
|
||||||
|
|
||||||
void NTCPResolve (const char * 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,
|
||||||
const i2p::data::IdentHash& ident, std::shared_ptr<boost::asio::ip::tcp::resolver> resolver);
|
const i2p::data::IdentHash& ident, std::shared_ptr<boost::asio::ip::tcp::resolver> resolver);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user