diff --git a/llarp/config/config.cpp b/llarp/config/config.cpp index 13564ccc3..35115532a 100644 --- a/llarp/config/config.cpp +++ b/llarp/config/config.cpp @@ -182,12 +182,13 @@ namespace llarp return addr; }; - conf.defineOption("dns", "upstream-dns", true, "", [=](std::string arg) { - m_upstreamDNS.push_back(parseAddr(arg)); - }); + conf.defineOption( + "dns", "upstream-dns", false, true, nonstd::nullopt, [=](std::string arg) { + m_upstreamDNS.push_back(parseAddr(arg)); + }); conf.defineOption( - "dns", "bind", false, "", [=](std::string arg) { m_bind = parseAddr(arg); }); + "dns", "bind", false, nonstd::nullopt, [=](std::string arg) { m_bind = parseAddr(arg); }); } LinksConfig::LinkInfo diff --git a/llarp/config/definition.hpp b/llarp/config/definition.hpp index 4990eb2f4..4dad2c969 100644 --- a/llarp/config/definition.hpp +++ b/llarp/config/definition.hpp @@ -2,6 +2,7 @@ #include +#include #include #include #include @@ -122,9 +123,9 @@ namespace llarp if (parsedValues.size()) return parsedValues[0]; else if (not required and not multiValued) - return defaultValue.value(); + return defaultValue; else - return {}; + return nonstd::nullopt; } /// Returns the value at the given index. @@ -223,6 +224,7 @@ namespace llarp { if (multiValued) { + std::cout << name << " has " << parsedValues.size() << " parsedValues" << std::endl; for (const auto& value : parsedValues) { acceptor(value); @@ -230,10 +232,16 @@ namespace llarp } else { + std::cout << name << " is NOT multi-valued" << std::endl; auto maybe = getValue(); - assert(maybe.has_value()); // should be guaranteed by our earlier checks - // TODO: avoid copies here if possible - acceptor(maybe.value()); + if (maybe.has_value()) + { + acceptor(maybe.value()); + } + else + { + assert(not defaultValue.has_value()); // maybe should have a value if defaultValue does + } } } }