From 3b6953badcb9b69bd14eb67d76f638a63b40bc32 Mon Sep 17 00:00:00 2001 From: Thomas Winget Date: Mon, 24 Oct 2022 21:58:32 -0400 Subject: [PATCH] clarify strict-connect usage and enforce minimum of 2 nodes --- llarp/config/config.cpp | 4 ++-- llarp/router/router.cpp | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/llarp/config/config.cpp b/llarp/config/config.cpp index 9f8f41397..7572b34bb 100644 --- a/llarp/config/config.cpp +++ b/llarp/config/config.cpp @@ -300,9 +300,9 @@ namespace llarp throw std::invalid_argument{"duplicate strict connect snode: " + value}; }, Comment{ - "Public key of a router which will act as a pinned first-hop. This may be used to", + "Public keys of routers which will act as pinned first-hops. This may be used to", "provide a trusted router (consider that you are not fully anonymous with your", - "first hop).", + "first hop). This REQUIRES two or more nodes to be specified.", }); conf.defineOption( diff --git a/llarp/router/router.cpp b/llarp/router/router.cpp index 00d357eb7..5214d75a3 100644 --- a/llarp/router/router.cpp +++ b/llarp/router/router.cpp @@ -653,14 +653,15 @@ namespace llarp auto& networkConfig = conf.network; /// build a set of strictConnectPubkeys ( - /// TODO: make this consistent with config -- do we support multiple strict connections - // or not? std::unordered_set strictConnectPubkeys; if (not networkConfig.m_strictConnect.empty()) { const auto& val = networkConfig.m_strictConnect; if (IsServiceNode()) throw std::runtime_error("cannot use strict-connect option as service node"); + if (val.size() < 2) + throw std::runtime_error( + "Must specify more than one strict-connect router if using strict-connect"); strictConnectPubkeys.insert(val.begin(), val.end()); }