From 0cf5805a7e0eb83b7af58d34d0d1f3ce44db879f Mon Sep 17 00:00:00 2001 From: Jason Rhinelander Date: Mon, 11 Dec 2023 15:56:08 -0400 Subject: [PATCH] DRY duplicated code in RCRemote --- llarp/router_contact_remote.cpp | 24 +----------------------- 1 file changed, 1 insertion(+), 23 deletions(-) diff --git a/llarp/router_contact_remote.cpp b/llarp/router_contact_remote.cpp index 527cfb333..1e9005455 100644 --- a/llarp/router_contact_remote.cpp +++ b/llarp/router_contact_remote.cpp @@ -17,29 +17,7 @@ namespace llarp { bt_load(btdc); - btdc.require_signature("~", [this](ustring_view msg, ustring_view sig) { - if (sig.size() != 64) - throw std::runtime_error{"Invalid signature: not 64 bytes"}; - - if (is_expired(time_now_ms())) - throw std::runtime_error{"Unable to verify expired RemoteRC!"}; - - // TODO: revisit if this is needed; detail from previous implementation - const auto* net = net::Platform::Default_ptr(); - - if (net->IsBogon(addr().in4()) and BLOCK_BOGONS) - { - auto err = "Unable to verify RemoteRC address!"; - log::info(logcat, err); - 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()); - - if (not crypto::verify(router_id(), msg, sig)) - throw std::runtime_error{"Failed to verify RemoteRC signature"}; - }); + bt_verify(btdc, /*reject_expired=*/true); } catch (const std::exception& e) {