Skip to content

Commit

Permalink
Merge pull request #1387 from jagerman/net-if-default
Browse files Browse the repository at this point in the history
Set default inbound link to best public interface
  • Loading branch information
jagerman authored Oct 3, 2020
2 parents 49907a3 + 753d989 commit b67df3a
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions llarp/config/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit b67df3a

Please sign in to comment.