From 0e888395d65829c722ed77742fc805ccc850b96d Mon Sep 17 00:00:00 2001 From: dr7ana Date: Mon, 11 Dec 2023 13:45:35 -0800 Subject: [PATCH] who cares --- external/oxen-libquic | 2 +- llarp/link/link_manager.cpp | 14 +++++++++++--- llarp/messages/fetch.hpp | 1 + llarp/nodedb.cpp | 3 +-- llarp/nodedb.hpp | 2 +- llarp/router_contact.cpp | 4 ++-- llarp/router_contact.hpp | 1 + llarp/router_contact_remote.cpp | 8 ++++++-- 8 files changed, 24 insertions(+), 11 deletions(-) diff --git a/external/oxen-libquic b/external/oxen-libquic index fdc92554a..ad8904deb 160000 --- a/external/oxen-libquic +++ b/external/oxen-libquic @@ -1 +1 @@ -Subproject commit fdc92554a40414fdcdea1fa1bd84b2c827d21b1c +Subproject commit ad8904debc55f9495667e8571ee5bb963156d54e diff --git a/llarp/link/link_manager.cpp b/llarp/link/link_manager.cpp index 72cea824c..f1dff5b44 100644 --- a/llarp/link/link_manager.cpp +++ b/llarp/link/link_manager.cpp @@ -646,7 +646,6 @@ namespace llarp assert(_router.is_service_node()); log::critical(logcat, "Handling fetch bootstrap fetch request..."); - const auto& rcs = node_db->get_rcs(); RemoteRC remote; size_t quantity; @@ -668,7 +667,16 @@ namespace llarp node_db->put_rc(remote); - auto rc_size = rcs.size(); + auto& bootstraps = node_db->bootstrap_list(); + auto count = bootstraps.size(); + + if (count == 0) + { + log::error(logcat, "No bootstraps locally to send!"); + m.respond(messages::ERROR_RESPONSE, true); + return; + } + auto now = llarp::time_now_ms(); size_t i = 0; @@ -679,7 +687,7 @@ namespace llarp while (i < quantity) { - auto& next_rc = *std::next(rcs.begin(), csrng() % rc_size); + auto& next_rc = bootstraps.next(); if (next_rc.is_expired(now)) continue; diff --git a/llarp/messages/fetch.hpp b/llarp/messages/fetch.hpp index 1d4453810..8981b6dde 100644 --- a/llarp/messages/fetch.hpp +++ b/llarp/messages/fetch.hpp @@ -1,6 +1,7 @@ #pragma once #include "common.hpp" + #include namespace llarp diff --git a/llarp/nodedb.cpp b/llarp/nodedb.cpp index 17c42924d..b67069e47 100644 --- a/llarp/nodedb.cpp +++ b/llarp/nodedb.cpp @@ -671,8 +671,7 @@ namespace llarp _router.link_manager().fetch_bootstrap_rcs( _bootstraps->current(), - BootstrapFetchMessage::serialize( - _router.router_contact, BOOTSTRAP_SOURCE_COUNT), + BootstrapFetchMessage::serialize(_router.router_contact, BOOTSTRAP_SOURCE_COUNT), [this](oxen::quic::message m) mutable { if (not m) { diff --git a/llarp/nodedb.hpp b/llarp/nodedb.hpp index f8e99372a..eb595fec9 100644 --- a/llarp/nodedb.hpp +++ b/llarp/nodedb.hpp @@ -44,7 +44,7 @@ namespace llarp inline constexpr double GOOD_RID_FETCH_THRESHOLD{}; /* Bootstrap Constants */ // the number of rc's we query the bootstrap for - inline constexpr size_t BOOTSTRAP_SOURCE_COUNT{50}; + inline constexpr size_t BOOTSTRAP_SOURCE_COUNT{10}; // the maximum number of fetch requests we make across all bootstraps inline constexpr int MAX_BOOTSTRAP_FETCH_ATTEMPTS{5}; // if all bootstraps fail, router will trigger re-bootstrapping after this cooldown diff --git a/llarp/router_contact.cpp b/llarp/router_contact.cpp index 11aa3341f..dbb57d2da 100644 --- a/llarp/router_contact.cpp +++ b/llarp/router_contact.cpp @@ -63,8 +63,8 @@ namespace llarp auto pubkey = data.require("p"); if (pubkey.size() != 32) - throw std::runtime_error{ - "Invalid RC pubkey: expected 32 bytes, got {}"_format(pubkey.size())}; + throw std::runtime_error{ + "Invalid RC pubkey: expected 32 bytes, got {}"_format(pubkey.size())}; std::memcpy(_router_id.data(), pubkey.data(), 32); // auto pk = data.require("p"); diff --git a/llarp/router_contact.hpp b/llarp/router_contact.hpp index ea7fff249..d8dfd3ae3 100644 --- a/llarp/router_contact.hpp +++ b/llarp/router_contact.hpp @@ -315,6 +315,7 @@ namespace llarp bt_verify(oxenc::bt_dict_consumer& data, bool reject_expired = false) const; explicit RemoteRC(oxenc::bt_dict_consumer btdc); + public: RemoteRC() = default; explicit RemoteRC(std::string_view data) : RemoteRC{oxenc::bt_dict_consumer{data}} diff --git a/llarp/router_contact_remote.cpp b/llarp/router_contact_remote.cpp index 1e9005455..857d2f4a6 100644 --- a/llarp/router_contact_remote.cpp +++ b/llarp/router_contact_remote.cpp @@ -47,8 +47,12 @@ namespace llarp throw std::runtime_error{err}; } - log::error(log::Cat("FIXME"), "ABOUT TO VERIFY THIS: {}, WITH SIG {}, SIGNED BY {}", - oxenc::to_hex(msg), oxenc::to_hex(sig), router_id().ToHex()); + log::error( + log::Cat("FIXME"), + "ABOUT TO VERIFY THIS: {}, WITH SIG {}, SIGNED BY {}", + oxenc::to_hex(msg), + oxenc::to_hex(sig), + router_id().ToHex()); if (not crypto::verify(router_id(), msg, sig)) throw std::runtime_error{"Failed to verify RemoteRC signature"};