From 5edb2569907a9a8bd880f93907e500ade61d811c Mon Sep 17 00:00:00 2001 From: orignal Date: Fri, 16 Apr 2021 19:31:49 -0400 Subject: [PATCH] check if our external IP is valid --- libi2pd/SSUSession.cpp | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/libi2pd/SSUSession.cpp b/libi2pd/SSUSession.cpp index c135ae1d..19ccd1ce 100644 --- a/libi2pd/SSUSession.cpp +++ b/libi2pd/SSUSession.cpp @@ -296,8 +296,16 @@ namespace transport if (s.Verify (m_RemoteIdentity, payload)) { LogPrint (eLogInfo, "SSU: Our external address is ", ourIP.to_string (), ":", ourPort); - i2p::context.UpdateAddress (ourIP); - SendSessionConfirmed (y, ourAddressAndPort, addressAndPortLen); + if (!i2p::util::net::IsInReservedRange (ourIP)) + { + i2p::context.UpdateAddress (ourIP); + SendSessionConfirmed (y, ourAddressAndPort, addressAndPortLen); + } + else + { + LogPrint (eLogError, "SSU: Wrong external address ", ourIP.to_string ()); + Failed (); + } } else { @@ -682,7 +690,10 @@ namespace transport if (!ourSize) return; buf += ourSize; len -= ourSize; LogPrint (eLogInfo, "SSU: Our external address is ", ourIP.to_string (), ":", ourPort); - i2p::context.UpdateAddress (ourIP); + if (!i2p::util::net::IsInReservedRange (ourIP)) + i2p::context.UpdateAddress (ourIP); + else + LogPrint (eLogWarning, "SSU: Wrong external address ", ourIP.to_string ()); if (ourIP.is_v4 ()) { if (ourPort != m_Server.GetPort ())