diff --git a/src/core/router/context.cc b/src/core/router/context.cc index 7b1481df..c478d996 100644 --- a/src/core/router/context.cc +++ b/src/core/router/context.cc @@ -46,8 +46,6 @@ #include "core/util/mtu.h" #include "core/util/timestamp.h" -#include "version.h" - namespace kovri { namespace core @@ -145,8 +143,7 @@ void RouterContext::Initialize(const boost::program_options::variables_map& map) } // Update RI options (in case RI was older than these version) - router.SetOption(GetTrait(Trait::CoreVersion), I2P_VERSION); - router.SetOption(GetTrait(Trait::RouterVersion), I2P_VERSION); + router.SetDefaultOptions(); // Update context RI m_RouterInfo.Update(router.GetBuffer(), router.GetBufferLen()); diff --git a/src/core/router/info.cc b/src/core/router/info.cc index c50cf95a..095936d3 100644 --- a/src/core/router/info.cc +++ b/src/core/router/info.cc @@ -89,8 +89,7 @@ RouterInfo::RouterInfo( } // Set default options - SetOption(GetTrait(Trait::NetID), std::to_string(I2P_NETWORK_ID)); - SetOption(GetTrait(Trait::RouterVersion), I2P_VERSION); + SetDefaultOptions(); // Set RI buffer + create RI CreateBuffer(keys); @@ -434,6 +433,15 @@ void RouterInfo::ParseRouterInfo(const std::string& router_info) } } +void RouterInfo::SetDefaultOptions() +{ + SetOption(GetTrait(Trait::NetID), std::to_string(I2P_NETWORK_ID)); + SetOption(GetTrait(Trait::RouterVersion), I2P_VERSION); + // TODO(anonimal): implement known lease-sets and known routers. + // We current only set default options when starting/creating RI *before* + // netdb starts. We'll need to ensure the 'known' opts are set *after* netdb starts. +} + void RouterInfo::SetCaps(const std::string& caps) { LOG(debug) << "RouterInfo: " << __func__ << ": setting caps " << caps; @@ -871,7 +879,10 @@ void RouterInfo::CreateRouterInfo( // Write remaining options for (const auto& opt : GetOptions()) - options.WriteKeyPair(opt.first, opt.second); + { + LOG(debug) << "RouterInfo: writing: " << opt.first << "=" << opt.second; + options.WriteKeyPair(opt.first, opt.second); + } // Write size of remaining options std::uint16_t size = htobe16(options.Str().size()); diff --git a/src/core/router/info.h b/src/core/router/info.h index b6058847..29c2b206 100644 --- a/src/core/router/info.h +++ b/src/core/router/info.h @@ -144,7 +144,6 @@ struct RouterInfoTraits // Option-specific RouterVersion, - CoreVersion, LeaseSets, Routers, NetID, @@ -191,9 +190,6 @@ struct RouterInfoTraits case Trait::RouterVersion: return "router.version"; - case Trait::CoreVersion: - return "coreVersion"; - case Trait::LeaseSets: return "netdb.knownLeaseSets"; @@ -625,6 +621,9 @@ class RouterInfo : public RouterInfoTraits, public RoutingDestination m_Options[key] = value; } + /// @brief Set essential (non-caps) default options for new RIs and when updating RIs + void SetDefaultOptions(); + /// @return Mutable RI options std::map& GetOptions() noexcept {