who cares

pull/2232/head
dr7ana 6 months ago
parent f00137adeb
commit 0e888395d6

@ -1 +1 @@
Subproject commit fdc92554a40414fdcdea1fa1bd84b2c827d21b1c Subproject commit ad8904debc55f9495667e8571ee5bb963156d54e

@ -646,7 +646,6 @@ namespace llarp
assert(_router.is_service_node()); assert(_router.is_service_node());
log::critical(logcat, "Handling fetch bootstrap fetch request..."); log::critical(logcat, "Handling fetch bootstrap fetch request...");
const auto& rcs = node_db->get_rcs();
RemoteRC remote; RemoteRC remote;
size_t quantity; size_t quantity;
@ -668,7 +667,16 @@ namespace llarp
node_db->put_rc(remote); 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(); auto now = llarp::time_now_ms();
size_t i = 0; size_t i = 0;
@ -679,7 +687,7 @@ namespace llarp
while (i < quantity) while (i < quantity)
{ {
auto& next_rc = *std::next(rcs.begin(), csrng() % rc_size); auto& next_rc = bootstraps.next();
if (next_rc.is_expired(now)) if (next_rc.is_expired(now))
continue; continue;

@ -1,6 +1,7 @@
#pragma once #pragma once
#include "common.hpp" #include "common.hpp"
#include <llarp/util/logging/buffer.hpp> #include <llarp/util/logging/buffer.hpp>
namespace llarp namespace llarp

@ -671,8 +671,7 @@ namespace llarp
_router.link_manager().fetch_bootstrap_rcs( _router.link_manager().fetch_bootstrap_rcs(
_bootstraps->current(), _bootstraps->current(),
BootstrapFetchMessage::serialize( BootstrapFetchMessage::serialize(_router.router_contact, BOOTSTRAP_SOURCE_COUNT),
_router.router_contact, BOOTSTRAP_SOURCE_COUNT),
[this](oxen::quic::message m) mutable { [this](oxen::quic::message m) mutable {
if (not m) if (not m)
{ {

@ -44,7 +44,7 @@ namespace llarp
inline constexpr double GOOD_RID_FETCH_THRESHOLD{}; inline constexpr double GOOD_RID_FETCH_THRESHOLD{};
/* Bootstrap Constants */ /* Bootstrap Constants */
// the number of rc's we query the bootstrap for // 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 // the maximum number of fetch requests we make across all bootstraps
inline constexpr int MAX_BOOTSTRAP_FETCH_ATTEMPTS{5}; inline constexpr int MAX_BOOTSTRAP_FETCH_ATTEMPTS{5};
// if all bootstraps fail, router will trigger re-bootstrapping after this cooldown // if all bootstraps fail, router will trigger re-bootstrapping after this cooldown

@ -63,8 +63,8 @@ namespace llarp
auto pubkey = data.require<std::string_view>("p"); auto pubkey = data.require<std::string_view>("p");
if (pubkey.size() != 32) if (pubkey.size() != 32)
throw std::runtime_error{ throw std::runtime_error{
"Invalid RC pubkey: expected 32 bytes, got {}"_format(pubkey.size())}; "Invalid RC pubkey: expected 32 bytes, got {}"_format(pubkey.size())};
std::memcpy(_router_id.data(), pubkey.data(), 32); std::memcpy(_router_id.data(), pubkey.data(), 32);
// auto pk = data.require<std::string_view>("p"); // auto pk = data.require<std::string_view>("p");

@ -315,6 +315,7 @@ namespace llarp
bt_verify(oxenc::bt_dict_consumer& data, bool reject_expired = false) const; bt_verify(oxenc::bt_dict_consumer& data, bool reject_expired = false) const;
explicit RemoteRC(oxenc::bt_dict_consumer btdc); explicit RemoteRC(oxenc::bt_dict_consumer btdc);
public: public:
RemoteRC() = default; RemoteRC() = default;
explicit RemoteRC(std::string_view data) : RemoteRC{oxenc::bt_dict_consumer{data}} explicit RemoteRC(std::string_view data) : RemoteRC{oxenc::bt_dict_consumer{data}}

@ -47,8 +47,12 @@ namespace llarp
throw std::runtime_error{err}; throw std::runtime_error{err};
} }
log::error(log::Cat("FIXME"), "ABOUT TO VERIFY THIS: {}, WITH SIG {}, SIGNED BY {}", log::error(
oxenc::to_hex(msg), oxenc::to_hex(sig), router_id().ToHex()); 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)) if (not crypto::verify(router_id(), msg, sig))
throw std::runtime_error{"Failed to verify RemoteRC signature"}; throw std::runtime_error{"Failed to verify RemoteRC signature"};

Loading…
Cancel
Save