check if our external IP is valid

This commit is contained in:
orignal 2021-04-16 19:31:49 -04:00
parent 74d0c04314
commit 5edb256990

View file

@ -296,10 +296,18 @@ namespace transport
if (s.Verify (m_RemoteIdentity, payload)) if (s.Verify (m_RemoteIdentity, payload))
{ {
LogPrint (eLogInfo, "SSU: Our external address is ", ourIP.to_string (), ":", ourPort); LogPrint (eLogInfo, "SSU: Our external address is ", ourIP.to_string (), ":", ourPort);
if (!i2p::util::net::IsInReservedRange (ourIP))
{
i2p::context.UpdateAddress (ourIP); i2p::context.UpdateAddress (ourIP);
SendSessionConfirmed (y, ourAddressAndPort, addressAndPortLen); SendSessionConfirmed (y, ourAddressAndPort, addressAndPortLen);
} }
else else
{
LogPrint (eLogError, "SSU: Wrong external address ", ourIP.to_string ());
Failed ();
}
}
else
{ {
LogPrint (eLogError, "SSU: message 'created' signature verification failed"); LogPrint (eLogError, "SSU: message 'created' signature verification failed");
Failed (); Failed ();
@ -682,7 +690,10 @@ namespace transport
if (!ourSize) return; if (!ourSize) return;
buf += ourSize; len -= ourSize; buf += ourSize; len -= ourSize;
LogPrint (eLogInfo, "SSU: Our external address is ", ourIP.to_string (), ":", ourPort); LogPrint (eLogInfo, "SSU: Our external address is ", ourIP.to_string (), ":", ourPort);
if (!i2p::util::net::IsInReservedRange (ourIP))
i2p::context.UpdateAddress (ourIP); i2p::context.UpdateAddress (ourIP);
else
LogPrint (eLogWarning, "SSU: Wrong external address ", ourIP.to_string ());
if (ourIP.is_v4 ()) if (ourIP.is_v4 ())
{ {
if (ourPort != m_Server.GetPort ()) if (ourPort != m_Server.GetPort ())