From 0ca3fb5af05ebac35068111a0df37991b8eff9ea Mon Sep 17 00:00:00 2001 From: orignal Date: Sat, 16 Jan 2016 15:36:30 -0500 Subject: [PATCH] specify and check netId --- NetDb.cpp | 19 +++++++++++-------- RouterContext.cpp | 2 +- RouterInfo.cpp | 7 +++++++ version.h | 1 + 4 files changed, 20 insertions(+), 9 deletions(-) diff --git a/NetDb.cpp b/NetDb.cpp index d0b6da26..b9d5a130 100644 --- a/NetDb.cpp +++ b/NetDb.cpp @@ -168,16 +168,19 @@ namespace data } else { - LogPrint (eLogInfo, "NetDb: RouterInfo added: ", ident.ToBase32()); r = std::make_shared (buf, len); + if (!r->IsUnreachable ()) { - std::unique_lock l(m_RouterInfosMutex); - m_RouterInfos[r->GetIdentHash ()] = r; - } - if (r->IsFloodfill ()) - { - std::unique_lock l(m_FloodfillsMutex); - m_Floodfills.push_back (r); + LogPrint (eLogInfo, "NetDb: RouterInfo added: ", ident.ToBase32()); + { + std::unique_lock l(m_RouterInfosMutex); + m_RouterInfos[r->GetIdentHash ()] = r; + } + if (r->IsFloodfill ()) + { + std::unique_lock l(m_FloodfillsMutex); + m_Floodfills.push_back (r); + } } } // take care about requested destination diff --git a/RouterContext.cpp b/RouterContext.cpp index 3117c85a..7d35ccf1 100644 --- a/RouterContext.cpp +++ b/RouterContext.cpp @@ -51,7 +51,7 @@ namespace i2p routerInfo.SetCaps (i2p::data::RouterInfo::eReachable | i2p::data::RouterInfo::eSSUTesting | i2p::data::RouterInfo::eSSUIntroducer); // LR, BC routerInfo.SetProperty ("coreVersion", I2P_VERSION); - routerInfo.SetProperty ("netId", "2"); + routerInfo.SetProperty ("netId", std::to_string (I2PD_NET_ID)); routerInfo.SetProperty ("router.version", I2P_VERSION); routerInfo.SetProperty ("stat_uptime", "90m"); routerInfo.CreateBuffer (m_Keys); diff --git a/RouterInfo.cpp b/RouterInfo.cpp index 53ab7aa3..8f2b7bfe 100644 --- a/RouterInfo.cpp +++ b/RouterInfo.cpp @@ -3,6 +3,7 @@ #include "I2PEndian.h" #include #include +#include "version.h" #include "Crypto.h" #include "Base.h" #include "Timestamp.h" @@ -243,6 +244,12 @@ namespace data // extract caps if (!strcmp (key, "caps")) ExtractCaps (value); + // check netId + if (!strcmp (key, "netId") && atoi (value) != I2PD_NET_ID) + { + LogPrint (eLogError, "Unexpected netid=", value); + m_IsUnreachable = true; + } } if (!m_SupportedTransports || !m_Addresses.size() || (UsesIntroducer () && !introducers)) diff --git a/version.h b/version.h index 8b93f1af..8fea069c 100644 --- a/version.h +++ b/version.h @@ -12,6 +12,7 @@ #define I2PD_VERSION_PATCH 0 #define I2PD_VERSION MAKE_VERSION(I2PD_VERSION_MAJOR, I2PD_VERSION_MINOR, I2PD_VERSION_MICRO) #define VERSION I2PD_VERSION +#define I2PD_NET_ID 2 #define I2P_VERSION_MAJOR 0 #define I2P_VERSION_MINOR 9