Browse Source

check if IP address is valid

pull/14/head
orignal 11 years ago
parent
commit
ddb9a6b477
  1. 2
      NTCPSession.cpp
  2. 2
      NTCPSession.h
  3. 11
      RouterInfo.cpp

2
NTCPSession.cpp

@ -517,7 +517,7 @@ namespace ntcp @@ -517,7 +517,7 @@ namespace ntcp
}
NTCPClient::NTCPClient (boost::asio::io_service& service, boost::asio::ip::address& address,
NTCPClient::NTCPClient (boost::asio::io_service& service, const boost::asio::ip::address& address,
int port, i2p::data::RouterInfo& in_RouterInfo):
NTCPSession (service, in_RouterInfo),
m_Endpoint (address, port)

2
NTCPSession.h

@ -144,7 +144,7 @@ namespace ntcp @@ -144,7 +144,7 @@ namespace ntcp
{
public:
NTCPClient (boost::asio::io_service& service, boost::asio::ip::address& address, int port, i2p::data::RouterInfo& in_RouterInfo);
NTCPClient (boost::asio::io_service& service, const boost::asio::ip::address& address, int port, i2p::data::RouterInfo& in_RouterInfo);
private:

11
RouterInfo.cpp

@ -101,7 +101,16 @@ namespace data @@ -101,7 +101,16 @@ namespace data
r += ReadString (value, s);
s.seekg (1, std::ios_base::cur); r++; // ;
if (!strcmp (key, "host"))
address.host = boost::asio::ip::address::from_string (value);
{
boost::system::error_code ecode;
address.host = boost::asio::ip::address::from_string (value, ecode);
if (ecode)
{
// TODO: we should try to resolve address here
LogPrint ("Unexpected address ", value);
SetUnreachable (true);
}
}
else if (!strcmp (key, "port"))
address.port = boost::lexical_cast<int>(value);
}

Loading…
Cancel
Save