mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-01-22 04:04:16 +00:00
check if IP address is valid
This commit is contained in:
parent
2d428fd090
commit
ddb9a6b477
@ -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):
|
int port, i2p::data::RouterInfo& in_RouterInfo):
|
||||||
NTCPSession (service, in_RouterInfo),
|
NTCPSession (service, in_RouterInfo),
|
||||||
m_Endpoint (address, port)
|
m_Endpoint (address, port)
|
||||||
|
@ -144,7 +144,7 @@ namespace ntcp
|
|||||||
{
|
{
|
||||||
public:
|
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:
|
private:
|
||||||
|
|
||||||
|
@ -101,7 +101,16 @@ namespace data
|
|||||||
r += ReadString (value, s);
|
r += ReadString (value, s);
|
||||||
s.seekg (1, std::ios_base::cur); r++; // ;
|
s.seekg (1, std::ios_base::cur); r++; // ;
|
||||||
if (!strcmp (key, "host"))
|
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"))
|
else if (!strcmp (key, "port"))
|
||||||
address.port = boost::lexical_cast<int>(value);
|
address.port = boost::lexical_cast<int>(value);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user