From 753d989f7c779d93112810a5d21090804bc9dddc Mon Sep 17 00:00:00 2001 From: Jason Rhinelander Date: Fri, 2 Oct 2020 23:07:56 -0300 Subject: [PATCH] Set default inbound link to best public interface Fixes default config not working. --- llarp/config/config.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/llarp/config/config.cpp b/llarp/config/config.cpp index 6f5af4807..d108438fc 100644 --- a/llarp/config/config.cpp +++ b/llarp/config/config.cpp @@ -27,12 +27,13 @@ namespace llarp constexpr int DefaultMinConnectionsForClient = 4; constexpr int DefaultMaxConnectionsForClient = 6; + constexpr int DefaultPublicPort = 1090; + void RouterConfig::defineConfigOptions(ConfigDefinition& conf, const ConfigGenParameters& params) { constexpr int DefaultJobQueueSize = 1024 * 8; constexpr auto DefaultNetId = "lokinet"; - constexpr int DefaultPublicPort = 1090; constexpr int DefaultWorkerThreads = 1; constexpr int DefaultNetThreads = 1; constexpr bool DefaultBlockBogons = true; @@ -443,8 +444,19 @@ namespace llarp m_OutboundLink = LinkInfoFromINIValues("*", arg); }); + if (std::string best_if; GetBestNetIF(best_if)) + m_InboundLinks.push_back(LinkInfoFromINIValues(best_if, std::to_string(DefaultPublicPort))); + conf.addUndeclaredHandler( - "bind", [&](std::string_view, std::string_view name, std::string_view value) { + "bind", + [&, defaulted = true]( + std::string_view, std::string_view name, std::string_view value) mutable { + if (defaulted) + { + m_InboundLinks.clear(); // Clear the default + defaulted = false; + } + LinkInfo info = LinkInfoFromINIValues(name, value); if (info.port <= 0)