Browse Source

resolve address for NTCP

pull/150/head
orignal 10 years ago
parent
commit
bf7b53a2a6
  1. 14
      RouterInfo.cpp
  2. 5
      RouterInfo.h
  3. 4
      Transports.cpp
  4. 2
      Transports.h

14
RouterInfo.cpp

@ -150,9 +150,17 @@ namespace data @@ -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
{

5
RouterInfo.h

@ -69,7 +69,7 @@ namespace data @@ -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 @@ -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 ()) ||

4
Transports.cpp

@ -232,7 +232,7 @@ namespace transport @@ -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 @@ -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),

2
Transports.h

@ -94,7 +94,7 @@ namespace transport @@ -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…
Cancel
Save