Skip to content
This repository has been archived by the owner on Sep 1, 2022. It is now read-only.

Commit

Permalink
Core: default RI opts setter + remove deprecation
Browse files Browse the repository at this point in the history
- coreVersion option was removed in 0.9.24
- adds RI options debug logging
  • Loading branch information
anonimal committed Nov 18, 2017
1 parent 872c70e commit 771340f
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 11 deletions.
5 changes: 1 addition & 4 deletions src/core/router/context.cc
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@
#include "core/util/mtu.h"
#include "core/util/timestamp.h"

#include "version.h"

namespace kovri
{
namespace core
Expand Down Expand Up @@ -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());
Expand Down
17 changes: 14 additions & 3 deletions src/core/router/info.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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());
Expand Down
7 changes: 3 additions & 4 deletions src/core/router/info.h
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,6 @@ struct RouterInfoTraits

// Option-specific
RouterVersion,
CoreVersion,
LeaseSets,
Routers,
NetID,
Expand Down Expand Up @@ -191,9 +190,6 @@ struct RouterInfoTraits
case Trait::RouterVersion:
return "router.version";

case Trait::CoreVersion:
return "coreVersion";

case Trait::LeaseSets:
return "netdb.knownLeaseSets";

Expand Down Expand Up @@ -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<std::string, std::string>& GetOptions() noexcept
{
Expand Down

0 comments on commit 771340f

Please sign in to comment.