From e06c2e45020b022cfa72228bfe6aa4fd451fb019 Mon Sep 17 00:00:00 2001 From: Stephen Shelton Date: Tue, 31 Mar 2020 09:01:55 -0600 Subject: [PATCH] Check that [router]min-connections <= [router]max --- llarp/config/config.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/llarp/config/config.cpp b/llarp/config/config.cpp index 9b7b4cc47..dc8348d2f 100644 --- a/llarp/config/config.cpp +++ b/llarp/config/config.cpp @@ -79,11 +79,6 @@ namespace llarp m_maxConnectedRouters = arg; }); - // additional check that min <= max - // TODO: where can we perform this check now? - // if (m_minConnectedRouters > m_maxConnectedRouters) - // throw std::invalid_argument("[router]:min-connections must be less than [router]:max-connections"); - conf.defineOption("router", "nickname", false, m_nickname, AssignmentAcceptor(m_nickname)); @@ -443,7 +438,12 @@ namespace llarp } }); - // TODO: hand parsed data to conf, pull out values + conf.acceptAllOptions(); + + // TODO: better way to support inter-option constraints + if (router.m_maxConnectedRouters < router.m_minConnectedRouters) + throw std::invalid_argument("[router]:min-connections must be <= [router]:max-connections"); + return true; } catch(const std::exception& e)