diff --git a/src/core/router/context.cc b/src/core/router/context.cc index 810ba78a..06d54f7b 100644 --- a/src/core/router/context.cc +++ b/src/core/router/context.cc @@ -88,9 +88,9 @@ void RouterContext::NewRouterInfo() { routerInfo.AddSSUAddress(m_Host, m_Port, routerInfo.GetIdentHash()); routerInfo.AddNTCPAddress(m_Host, m_Port); routerInfo.SetCaps( - core::RouterInfo::Caps::Reachable | - core::RouterInfo::Caps::SSUTesting | - core::RouterInfo::Caps::SSUIntroducer); + core::RouterInfo::Cap::Reachable | + core::RouterInfo::Cap::SSUTesting | + core::RouterInfo::Cap::SSUIntroducer); routerInfo.SetProperty("netId", I2P_NETWORK_ID); routerInfo.SetProperty("router.version", I2P_VERSION); routerInfo.CreateBuffer(m_Keys); @@ -156,10 +156,10 @@ void RouterContext::SetFloodfill( m_IsFloodfill = floodfill; if (floodfill) { m_RouterInfo.SetCaps( - m_RouterInfo.GetCaps() | core::RouterInfo::Caps::Floodfill); + m_RouterInfo.GetCaps() | core::RouterInfo::Cap::Floodfill); } else { m_RouterInfo.SetCaps( - m_RouterInfo.GetCaps() & ~core::RouterInfo::Caps::Floodfill); + m_RouterInfo.GetCaps() & ~core::RouterInfo::Cap::Floodfill); // we don't publish number of routers and leaseset for non-floodfill m_RouterInfo.DeleteProperty(ROUTER_INFO_PROPERTY_LEASESETS); m_RouterInfo.DeleteProperty(ROUTER_INFO_PROPERTY_ROUTERS); @@ -168,29 +168,29 @@ void RouterContext::SetFloodfill( } void RouterContext::SetHighBandwidth() { - if (!m_RouterInfo.IsHighBandwidth()) { - m_RouterInfo.SetCaps( - m_RouterInfo.GetCaps() | core::RouterInfo::Caps::HighBandwidth); + auto cap = core::RouterInfo::Cap::HighBandwidth; + if (!m_RouterInfo.HasCap(cap)) { + m_RouterInfo.SetCaps(m_RouterInfo.GetCaps() | cap); UpdateRouterInfo(); } } void RouterContext::SetLowBandwidth() { - if (m_RouterInfo.IsHighBandwidth()) { - m_RouterInfo.SetCaps( - m_RouterInfo.GetCaps() & ~core::RouterInfo::Caps::HighBandwidth); + auto cap = core::RouterInfo::Cap::HighBandwidth; + if (m_RouterInfo.HasCap(cap)) { + m_RouterInfo.SetCaps(m_RouterInfo.GetCaps() & ~cap); UpdateRouterInfo(); } } bool RouterContext::IsUnreachable() const { - return m_RouterInfo.GetCaps() & core::RouterInfo::Caps::Unreachable; + return m_RouterInfo.GetCaps() & core::RouterInfo::Cap::Unreachable; } void RouterContext::SetUnreachable() { // set caps m_RouterInfo.SetCaps( // LU, B - core::RouterInfo::Caps::Unreachable | core::RouterInfo::Caps::SSUTesting); + core::RouterInfo::Cap::Unreachable | core::RouterInfo::Cap::SSUTesting); // remove NTCP address RemoveTransport(core::RouterInfo::Transport::NTCP); // delete previous introducers @@ -203,11 +203,11 @@ void RouterContext::SetUnreachable() { void RouterContext::SetReachable() { // update caps std::uint8_t caps = m_RouterInfo.GetCaps(); - caps &= ~core::RouterInfo::Caps::Unreachable; - caps |= core::RouterInfo::Caps::Reachable; - caps |= core::RouterInfo::Caps::SSUIntroducer; + caps &= ~core::RouterInfo::Cap::Unreachable; + caps |= core::RouterInfo::Cap::Reachable; + caps |= core::RouterInfo::Cap::SSUIntroducer; if (m_IsFloodfill) - caps |= core::RouterInfo::Caps::Floodfill; + caps |= core::RouterInfo::Cap::Floodfill; m_RouterInfo.SetCaps(caps); // insert NTCP back @@ -254,8 +254,8 @@ void RouterContext::SetSupportsSSU(bool supportsSSU) { RemoveTransport(core::RouterInfo::Transport::SSU); // Remove SSU-related flags m_RouterInfo.SetCaps(m_RouterInfo.GetCaps() - & ~core::RouterInfo::Caps::SSUTesting - & ~core::RouterInfo::Caps::SSUIntroducer); + & ~core::RouterInfo::Cap::SSUTesting + & ~core::RouterInfo::Cap::SSUIntroducer); UpdateRouterInfo(); } diff --git a/src/core/router/info.cc b/src/core/router/info.cc index 74b915f7..631756c5 100644 --- a/src/core/router/info.cc +++ b/src/core/router/info.cc @@ -366,7 +366,7 @@ void RouterInfo::ParseRouterInfo(const std::string& router_info) value.c_str(), value.size(), address.key, 32); break; case Trait::Caps: - ExtractCaps(value.c_str()); + SetCaps(value); break; default: // Test for introducers @@ -450,7 +450,7 @@ void RouterInfo::ParseRouterInfo(const std::string& router_info) // Set capabilities // TODO(anonimal): review setter implementation if (key == GetTrait(Trait::Caps)) - ExtractCaps(value.c_str()); + SetCaps(value); } // Router *should* be unreachable @@ -463,69 +463,78 @@ void RouterInfo::ParseRouterInfo(const std::string& router_info) } } -// TODO(anonimal): refactor + rename as setter -void RouterInfo::ExtractCaps( - const char* value) { - const char* cap = value; - while (*cap) { - switch (GetTrait(*cap)) { - case CapsFlag::Floodfill: - m_Caps |= Caps::Floodfill; - break; - case CapsFlag::UnlimitedBandwidth: - m_Caps |= Caps::UnlimitedBandwidth; - break; - case CapsFlag::HighBandwidth1: - case CapsFlag::HighBandwidth2: - case CapsFlag::HighBandwidth3: - case CapsFlag::HighBandwidth4: - m_Caps |= Caps::HighBandwidth; - break; - case CapsFlag::Hidden: - m_Caps |= Caps::Hidden; - break; - case CapsFlag::Reachable: - m_Caps |= Caps::Reachable; - break; - case CapsFlag::Unreachable: - m_Caps |= Caps::Unreachable; - break; - case CapsFlag::SSUTesting: - m_Caps |= Caps::SSUTesting; - break; - case CapsFlag::SSUIntroducer: - m_Caps |= Caps::SSUIntroducer; - break; - default: {} +void RouterInfo::SetCaps(const std::string& caps) +{ + LOG(debug) << "RouterInfo: " << __func__ << ": setting caps " << caps; + for (const auto& cap : caps) + { + switch (GetTrait(cap)) + { + case CapFlag::Floodfill: + m_Caps |= Cap::Floodfill; + break; + case CapFlag::UnlimitedBandwidth: + m_Caps |= Cap::UnlimitedBandwidth; + break; + case CapFlag::HighBandwidth1: + case CapFlag::HighBandwidth2: + case CapFlag::HighBandwidth3: + case CapFlag::HighBandwidth4: + m_Caps |= Cap::HighBandwidth; + break; + case CapFlag::LowBandwidth1: + case CapFlag::LowBandwidth2: + // TODO(anonimal): implement! + break; + case CapFlag::Hidden: + m_Caps |= Cap::Hidden; + break; + case CapFlag::Reachable: + m_Caps |= Cap::Reachable; + break; + case CapFlag::Unreachable: + m_Caps |= Cap::Unreachable; + break; + case CapFlag::SSUTesting: + m_Caps |= Cap::SSUTesting; + break; + case CapFlag::SSUIntroducer: + m_Caps |= Cap::SSUIntroducer; + break; + case CapFlag::Unknown: + default: + { + LOG(error) << "RouterInfo: " << __func__ + << ": ignoring unknown cap " << cap; + } + } } - cap++; - } } void RouterInfo::UpdateCapsProperty() { std::string caps; - if (m_Caps & Caps::Floodfill) + if (m_Caps & Cap::Floodfill) { - caps += GetTrait(CapsFlag::HighBandwidth4); // highest bandwidth - caps += GetTrait(CapsFlag::Floodfill); + caps += GetTrait(CapFlag::HighBandwidth4); // highest bandwidth + caps += GetTrait(CapFlag::Floodfill); } else { - caps += (m_Caps & Caps::HighBandwidth) - ? GetTrait(CapsFlag::HighBandwidth3) - : GetTrait(CapsFlag::LowBandwidth2); + caps += (m_Caps & Cap::HighBandwidth) + ? GetTrait(CapFlag::HighBandwidth3) + : GetTrait(CapFlag::LowBandwidth2); } - if (m_Caps & Caps::Hidden) - caps += GetTrait(CapsFlag::Hidden); + if (m_Caps & Cap::Hidden) + caps += GetTrait(CapFlag::Hidden); - if (m_Caps & Caps::Reachable) - caps += GetTrait(CapsFlag::Reachable); + if (m_Caps & Cap::Reachable) + caps += GetTrait(CapFlag::Reachable); - if (m_Caps & Caps::Unreachable) - caps += GetTrait(CapsFlag::Unreachable); + if (m_Caps & Cap::Unreachable) + caps += GetTrait(CapFlag::Unreachable); SetProperty("caps", caps); } @@ -583,12 +592,12 @@ void RouterInfo::CreateRouterInfo( { router_info.WriteByteAndString(GetTrait(Trait::SSU)); - // Get SSU capabilities + // Get/Set SSU capabilities flags std::string caps; - if (IsPeerTesting()) - caps += GetTrait(CapsFlag::SSUTesting); - if (IsIntroducer()) - caps += GetTrait(CapsFlag::SSUIntroducer); + if (HasCap(Cap::SSUTesting)) + caps += GetTrait(CapFlag::SSUTesting); + if (HasCap(Cap::SSUIntroducer)) + caps += GetTrait(CapFlag::SSUIntroducer); // Write SSU capabilities options.WriteKeyPair(GetTrait(Trait::Caps), caps); @@ -770,8 +779,8 @@ void RouterInfo::AddSSUAddress( m_Addresses.push_back(addr); m_SupportedTransports |= addr.host.is_v6() ? SupportedTransport::SSUv6 : SupportedTransport::SSUv4; - m_Caps |= Caps::SSUTesting; - m_Caps |= Caps::SSUIntroducer; + m_Caps |= Cap::SSUTesting; + m_Caps |= Cap::SSUIntroducer; } bool RouterInfo::AddIntroducer( @@ -818,14 +827,6 @@ void RouterInfo::SetCaps( UpdateCapsProperty(); } -// TODO(anonimal): refactor this setter, it should be simpler -void RouterInfo::SetCaps( - const char* caps) { - SetProperty("caps", caps); - m_Caps = 0; - ExtractCaps(caps); -} - void RouterInfo::SetProperty( const std::string& key, const std::string& value) { @@ -837,10 +838,6 @@ void RouterInfo::DeleteProperty( m_Options.erase(key); } -bool RouterInfo::IsFloodfill() const { - return m_Caps & Caps::Floodfill; -} - bool RouterInfo::IsNTCP( bool v4only) const { if (v4only) @@ -896,7 +893,7 @@ void RouterInfo::DisableV6() { } bool RouterInfo::UsesIntroducer() const { - return m_Caps & Caps::Unreachable; // non-reachable + return HasCap(Cap::Unreachable); // Router is unreachable, must use introducer } const RouterInfo::Address* RouterInfo::GetNTCPAddress( @@ -947,10 +944,10 @@ const std::string RouterInfo::GetDescription(const std::string& tabs) const for (const auto& opt : m_Options) ss << tabs << "\t\t[" << opt.first << "] : [" << opt.second << "]" << std::endl; ss << tabs << "\tSSU Caps: [" - << (IsPeerTesting() ? GetTrait(CapsFlag::SSUTesting) - : GetTrait(CapsFlag::Unknown)) - << (IsIntroducer() ? GetTrait(CapsFlag::SSUIntroducer) - : GetTrait(CapsFlag::Unknown)) + << (HasCap(Cap::SSUTesting) ? GetTrait(CapFlag::SSUTesting) + : GetTrait(CapFlag::Unknown)) + << (HasCap(Cap::SSUIntroducer) ? GetTrait(CapFlag::SSUIntroducer) + : GetTrait(CapFlag::Unknown)) << "]" << std::endl; ss << tabs << "\tAddresses(" << m_Addresses.size() << "): " << std::endl; for (const auto& address : m_Addresses) diff --git a/src/core/router/info.h b/src/core/router/info.h index 5ce80f61..8472af35 100644 --- a/src/core/router/info.h +++ b/src/core/router/info.h @@ -74,9 +74,9 @@ class RouterInfo : public RoutingDestination { SSUv6 = 0x08, }; - /// @enum Caps + /// @enum Cap /// @brief RI capabilities - enum Caps : std::uint8_t + enum Cap : std::uint8_t { Floodfill = 0x01, UnlimitedBandwidth = 0x02, @@ -88,9 +88,9 @@ class RouterInfo : public RoutingDestination { Unreachable = 0x80, }; - /// @enum CapsFlag + /// @enum CapFlag /// @brief Flags used for RI capabilities - enum struct CapsFlag : std::uint8_t + enum struct CapFlag : std::uint8_t { Floodfill, Hidden, @@ -110,50 +110,50 @@ class RouterInfo : public RoutingDestination { /// @return Char flag of given enumerated caps flag /// @param flag Flag enum used for caps char flag - char GetTrait(CapsFlag flag) const noexcept + char GetTrait(CapFlag flag) const noexcept { switch (flag) { - case CapsFlag::Floodfill: + case CapFlag::Floodfill: return 'f'; // Floodfill - case CapsFlag::Hidden: + case CapFlag::Hidden: return 'H'; // Hidden - case CapsFlag::Reachable: + case CapFlag::Reachable: return 'R'; // Reachable - case CapsFlag::Unreachable: + case CapFlag::Unreachable: return 'U'; // Unreachable - case CapsFlag::LowBandwidth1: + case CapFlag::LowBandwidth1: return 'K'; // Under 12 KBps shared bandwidth - case CapsFlag::LowBandwidth2: + case CapFlag::LowBandwidth2: return 'L'; // 12 - 48 KBps shared bandwidth - case CapsFlag::HighBandwidth1: + case CapFlag::HighBandwidth1: return 'M'; // 48 - 64 KBps shared bandwidth - case CapsFlag::HighBandwidth2: + case CapFlag::HighBandwidth2: return 'N'; // 64 - 128 KBps shared bandwidth - case CapsFlag::HighBandwidth3: + case CapFlag::HighBandwidth3: return 'O'; // 128 - 256 KBps shared bandwidth - case CapsFlag::HighBandwidth4: + case CapFlag::HighBandwidth4: return 'P'; // 256 - 2000 KBps shared bandwidth - case CapsFlag::UnlimitedBandwidth: + case CapFlag::UnlimitedBandwidth: return 'X'; // Over 2000 KBps shared bandwidth - case CapsFlag::SSUTesting: + case CapFlag::SSUTesting: return 'B'; // Willing and able to participate in peer tests (as Bob or Charlie) - case CapsFlag::SSUIntroducer: + case CapFlag::SSUIntroducer: return 'C'; // Willing and able to serve as an introducer (serving as Bob for an otherwise unreachable Alice) - case CapsFlag::Unknown: + case CapFlag::Unknown: default: return ' '; // TODO(anonimal): review } @@ -161,49 +161,49 @@ class RouterInfo : public RoutingDestination { /// @return Enumerated caps flag /// @param value Char value of potential caps flag given - CapsFlag GetTrait(const char& value) const noexcept + CapFlag GetTrait(const char& value) const noexcept { - if (value == GetTrait(CapsFlag::Floodfill)) - return CapsFlag::Floodfill; + if (value == GetTrait(CapFlag::Floodfill)) + return CapFlag::Floodfill; - else if (value == GetTrait(CapsFlag::Hidden)) - return CapsFlag::Hidden; + else if (value == GetTrait(CapFlag::Hidden)) + return CapFlag::Hidden; - else if (value == GetTrait(CapsFlag::Reachable)) - return CapsFlag::Reachable; + else if (value == GetTrait(CapFlag::Reachable)) + return CapFlag::Reachable; - else if (value == GetTrait(CapsFlag::Unreachable)) - return CapsFlag::Unreachable; + else if (value == GetTrait(CapFlag::Unreachable)) + return CapFlag::Unreachable; - else if (value == GetTrait(CapsFlag::LowBandwidth1)) - return CapsFlag::LowBandwidth1; + else if (value == GetTrait(CapFlag::LowBandwidth1)) + return CapFlag::LowBandwidth1; - else if (value == GetTrait(CapsFlag::LowBandwidth2)) - return CapsFlag::LowBandwidth2; + else if (value == GetTrait(CapFlag::LowBandwidth2)) + return CapFlag::LowBandwidth2; - else if (value == GetTrait(CapsFlag::HighBandwidth1)) - return CapsFlag::HighBandwidth1; + else if (value == GetTrait(CapFlag::HighBandwidth1)) + return CapFlag::HighBandwidth1; - else if (value == GetTrait(CapsFlag::HighBandwidth2)) - return CapsFlag::HighBandwidth2; + else if (value == GetTrait(CapFlag::HighBandwidth2)) + return CapFlag::HighBandwidth2; - else if (value == GetTrait(CapsFlag::HighBandwidth3)) - return CapsFlag::HighBandwidth3; + else if (value == GetTrait(CapFlag::HighBandwidth3)) + return CapFlag::HighBandwidth3; - else if (value == GetTrait(CapsFlag::HighBandwidth4)) - return CapsFlag::HighBandwidth4; + else if (value == GetTrait(CapFlag::HighBandwidth4)) + return CapFlag::HighBandwidth4; - else if (value == GetTrait(CapsFlag::UnlimitedBandwidth)) - return CapsFlag::UnlimitedBandwidth; + else if (value == GetTrait(CapFlag::UnlimitedBandwidth)) + return CapFlag::UnlimitedBandwidth; - else if (value == GetTrait(CapsFlag::SSUTesting)) - return CapsFlag::SSUTesting; + else if (value == GetTrait(CapFlag::SSUTesting)) + return CapFlag::SSUTesting; - else if (value == GetTrait(CapsFlag::SSUIntroducer)) - return CapsFlag::SSUIntroducer; + else if (value == GetTrait(CapFlag::SSUIntroducer)) + return CapFlag::SSUIntroducer; else - return CapsFlag::Unknown; // TODO(anonimal): review + return CapFlag::Unknown; // TODO(anonimal): review } struct Introducer { @@ -445,8 +445,6 @@ class RouterInfo : public RoutingDestination { m_Options.clear(); } - bool IsFloodfill() const; - bool IsNTCP( bool v4only = true) const; @@ -466,20 +464,11 @@ class RouterInfo : public RoutingDestination { bool UsesIntroducer() const; - bool IsIntroducer() const { - return m_Caps & Caps::SSUIntroducer; - } - - bool IsPeerTesting() const { - return m_Caps & Caps::SSUTesting; - } - - bool IsHidden() const { - return m_Caps & Caps::Hidden; - } - - bool IsHighBandwidth() const { - return m_Caps & Caps::HighBandwidth; + bool HasCap(Cap cap) const + { + bool has_cap = m_Caps & cap; + LOG(debug) << "RouterInfo: " << __func__ << ": " << has_cap; + return has_cap; } std::uint8_t GetCaps() const { @@ -489,9 +478,6 @@ class RouterInfo : public RoutingDestination { void SetCaps( std::uint8_t caps); - void SetCaps( - const char* caps); - void SetUnreachable(bool unreachable) { m_IsUnreachable = unreachable; } @@ -555,6 +541,7 @@ class RouterInfo : public RoutingDestination { return m_Options; } + // TODO(anonimal): really?... bool IsDestination() const { return false; } @@ -583,8 +570,7 @@ class RouterInfo : public RoutingDestination { core::StringStream& router_info, const PrivateKeys& private_keys); - void ExtractCaps( - const char* value); + void SetCaps(const std::string& caps); const Address* GetAddress( Transport s, diff --git a/src/core/router/net_db/impl.cc b/src/core/router/net_db/impl.cc index 99080c81..127ba686 100644 --- a/src/core/router/net_db/impl.cc +++ b/src/core/router/net_db/impl.cc @@ -215,7 +215,7 @@ void NetDb::AddRouterInfo( std::unique_lock l(m_RouterInfosMutex); m_RouterInfos[r->GetIdentHash()] = r; } - if (r->IsFloodfill()) { + if (r->HasCap(RouterInfo::Cap::Floodfill)) { std::unique_lock l(m_FloodfillsMutex); m_Floodfills.push_back(r); } @@ -351,7 +351,7 @@ bool NetDb::Load() router->DeleteBuffer(); router->ClearProperties(); // properties are not used for regular routers m_RouterInfos.insert(std::make_pair(router->GetIdentHash(), router)); - if (router->IsFloodfill()) + if (router->HasCap(RouterInfo::Cap::Floodfill)) m_Floodfills.push_back(router); num_routers++; } @@ -451,7 +451,7 @@ void NetDb::SaveUpdated() { if (is_removed) deleted_count++; // delete from floodfills list - if (it.second->IsFloodfill()) { + if (it.second->HasCap(RouterInfo::Cap::Floodfill)) { std::unique_lock l(m_FloodfillsMutex); m_Floodfills.remove(it.second); } @@ -867,10 +867,11 @@ void NetDb::Publish() { } } +// TODO(anonimal): refactor these getters into fewer functions std::shared_ptr NetDb::GetRandomRouter() const { return GetRandomRouter( [](std::shared_ptr router)->bool { - return !router->IsHidden(); + return !router->HasCap(RouterInfo::Cap::Hidden); }); } @@ -878,7 +879,7 @@ std::shared_ptr NetDb::GetRandomRouter( std::shared_ptr compatible_with) const { return GetRandomRouter( [compatible_with](std::shared_ptr router)->bool { - return !router->IsHidden() && router != compatible_with && + return !router->HasCap(RouterInfo::Cap::Hidden) && router != compatible_with && router->IsCompatible(*compatible_with); }); } @@ -886,14 +887,14 @@ std::shared_ptr NetDb::GetRandomRouter( std::shared_ptr NetDb::GetRandomPeerTestRouter() const { return GetRandomRouter( [](std::shared_ptr router)->bool { - return !router->IsHidden() && router->IsPeerTesting(); + return !router->HasCap(RouterInfo::Cap::Hidden) && router->HasCap(RouterInfo::Cap::SSUTesting); }); } std::shared_ptr NetDb::GetRandomIntroducer() const { return GetRandomRouter( [](std::shared_ptr router)->bool { - return !router->IsHidden() && router->IsIntroducer(); + return !router->HasCap(RouterInfo::Cap::Hidden) && router->HasCap(RouterInfo::Cap::SSUIntroducer); }); } @@ -901,10 +902,10 @@ std::shared_ptr NetDb::GetHighBandwidthRandomRouter( std::shared_ptr compatible_with) const { return GetRandomRouter( [compatible_with](std::shared_ptr router)->bool { - return !router->IsHidden() && + return !router->HasCap(RouterInfo::Cap::Hidden) && router != compatible_with && router->IsCompatible(*compatible_with) && - (router->GetCaps() & RouterInfo::Caps::HighBandwidth); + (router->GetCaps() & RouterInfo::Cap::HighBandwidth); }); } @@ -1014,7 +1015,7 @@ std::shared_ptr NetDb::GetClosestNonFloodfill( min_metric.SetMax(); // must be called from NetDb thread only for (auto it : m_RouterInfos) { - if (!it.second->IsFloodfill()) { + if (!it.second->HasCap(RouterInfo::Cap::Floodfill)) { XORMetric m = dest_key ^ it.first; if (m < min_metric && !excluded.count(it.first)) { min_metric = m; diff --git a/src/core/router/transports/impl.cc b/src/core/router/transports/impl.cc index 546cdfbc..2737f40a 100644 --- a/src/core/router/transports/impl.cc +++ b/src/core/router/transports/impl.cc @@ -270,7 +270,7 @@ bool Transports::IsBandwidthExceeded() const { LOG(debug) << "Transports: bandwidth has been exceeded"; return true; } - if (kovri::context.GetRouterInfo().IsHighBandwidth()) + if (kovri::context.GetRouterInfo().HasCap(RouterInfo::Cap::HighBandwidth)) LOG(debug) << "Transports: bandwidth has not been exceeded"; return false; } diff --git a/src/core/router/transports/ssu/session.cc b/src/core/router/transports/ssu/session.cc index 67a73ae4..36c0d177 100644 --- a/src/core/router/transports/ssu/session.cc +++ b/src/core/router/transports/ssu/session.cc @@ -477,7 +477,7 @@ void SSUSession::SendSessionCreated( s.Insert (htobe16(address->port)); // our port std::uint32_t relay_tag = 0; - if (kovri::context.GetRouterInfo().IsIntroducer()) { + if (kovri::context.GetRouterInfo().HasCap(RouterInfo::Cap::SSUIntroducer)) { relay_tag = kovri::core::Rand(); if (!relay_tag) relay_tag = 1; @@ -1408,7 +1408,7 @@ void SSUSession::Established() { // send database store m_Data.Send(CreateDatabaseStoreMsg()); transports.PeerConnected(shared_from_this()); - if (m_PeerTest && (m_RemoteRouter && m_RemoteRouter->IsPeerTesting())) + if (m_PeerTest && (m_RemoteRouter && m_RemoteRouter->HasCap(RouterInfo::Cap::SSUTesting))) SendPeerTest(); ScheduleTermination(); }