mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-01-22 04:04:16 +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);
|
||||
if (ecode)
|
||||
{
|
||||
// TODO: we should try to resolve address here
|
||||
LogPrint (eLogWarning, "Unexpected address ", value);
|
||||
isValidAddress = false;
|
||||
if (address.transportStyle == eTransportNTCP)
|
||||
{
|
||||
m_SupportedTransports |= eNTCPV4; // TODO:
|
||||
address.addressString = value;
|
||||
}
|
||||
else
|
||||
{
|
||||
// TODO: resolve address for SSU
|
||||
LogPrint (eLogWarning, "Unexpected SSU address ", value);
|
||||
isValidAddress = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -69,7 +69,7 @@ namespace data
|
||||
{
|
||||
TransportStyle transportStyle;
|
||||
boost::asio::ip::address host;
|
||||
char * addressString;
|
||||
std::string addressString;
|
||||
int port, mtu;
|
||||
uint64_t date;
|
||||
uint8_t cost;
|
||||
@ -77,9 +77,6 @@ namespace data
|
||||
Tag<32> key; // intro key for SSU
|
||||
std::vector<Introducer> introducers;
|
||||
|
||||
Address (): addressString (nullptr) {};
|
||||
~Address () { if (addressString) delete[] addressString; };
|
||||
|
||||
bool IsCompatible (const boost::asio::ip::address& other) const
|
||||
{
|
||||
return (host.is_v4 () && other.is_v4 ()) ||
|
||||
|
@ -232,7 +232,7 @@ namespace transport
|
||||
}
|
||||
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);
|
||||
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);
|
||||
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);
|
||||
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,
|
||||
const i2p::data::IdentHash& ident, std::shared_ptr<boost::asio::ip::tcp::resolver> resolver);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user