try adding proper limits

pull/768/head
Jeff Becker 5 years ago
parent d6366bc45f
commit 2345dd3239
No known key found for this signature in database
GPG Key ID: F357B3B42F6F9B05

@ -2,6 +2,7 @@ set(LIB_UTIL_SRC
config/config.cpp
config/ini.cpp
constants/defaults.cpp
constants/limits.cpp
constants/link_layer.cpp
constants/path.cpp
constants/proto.cpp

@ -2,6 +2,7 @@
#include <config/ini.hpp>
#include <constants/defaults.hpp>
#include <constants/limits.hpp>
#include <net/net.hpp>
#include <util/fs.hpp>
#include <util/logger.hpp>
@ -501,7 +502,7 @@ llarp_ensure_config(const char *fname, const char *basedir, bool overwrite,
return false;
}
auto &f = optional_f.value();
llarp_generic_ensure_config(f, basepath);
llarp_generic_ensure_config(f, basepath, asRouter);
if(asRouter)
{
llarp_ensure_router_config(f, basepath);
@ -515,7 +516,8 @@ llarp_ensure_config(const char *fname, const char *basedir, bool overwrite,
}
void
llarp_generic_ensure_config(std::ofstream &f, std::string basepath)
llarp_generic_ensure_config(std::ofstream &f, std::string basepath,
bool isRouter)
{
f << "# this configuration was auto generated with 'sane' defaults"
<< std::endl;
@ -536,6 +538,13 @@ llarp_generic_ensure_config(std::ofstream &f, std::string basepath)
f << "# uncomment following line to set router nickname to 'lokinet'"
<< std::endl;
f << "#nickname=lokinet" << std::endl;
const auto limits = isRouter ? llarp::limits::snode : llarp::limits::client;
f << "# maintain min connections to other routers" << std::endl;
f << "min-routers=" << std::to_string(limits.DefaultMinRouters) << std::endl;
f << "# hard limit of routers globally we are connected to at any given time"
<< std::endl;
f << "max-routers=" << std::to_string(limits.DefaultMaxRouters) << std::endl;
f << std::endl << std::endl;
// logging
@ -693,7 +702,7 @@ llarp_ensure_client_config(std::ofstream &f, std::string basepath)
// now do up fname
f << std::endl << std::endl;
f << "# snapps configuration section" << std::endl;
f << "[services]";
f << "[services]" << std::endl;
f << "# uncomment next line to enable a snapp" << std::endl;
f << "#example-snapp=" << snappExample_fpath << std::endl;
f << std::endl << std::endl;

@ -105,7 +105,7 @@ namespace llarp
size_t m_minConnectedRouters = 2;
/// hard upperbound limit on the number of router to router connections
size_t m_maxConnectedRouters = 2000;
size_t m_maxConnectedRouters = 5;
std::string m_netId;
std::string m_nickname;
@ -325,7 +325,8 @@ namespace llarp
} // namespace llarp
void
llarp_generic_ensure_config(std::ofstream& f, std::string basepath);
llarp_generic_ensure_config(std::ofstream& f, std::string basepath,
bool isRouter);
void
llarp_ensure_router_config(std::ofstream& f, std::string basepath);

@ -886,6 +886,14 @@ namespace llarp
EnsureNetConfigDefaultsSane(netConfig);
const auto limits =
IsServiceNode() ? llarp::limits::snode : llarp::limits::client;
minConnectedRouters =
std::max(minConnectedRouters, limits.DefaultMinRouters);
maxConnectedRouters =
std::max(maxConnectedRouters, limits.DefaultMaxRouters);
if(IsServiceNode())
{
// initialize as service node
@ -896,14 +904,12 @@ namespace llarp
}
RouterID us = pubkey();
LogInfo("initalized service node: ", us);
if(minConnectedRouters < 6)
minConnectedRouters = 6;
// relays do not use profiling
routerProfiling().Disable();
}
else
{
maxConnectedRouters = minConnectedRouters + 1;
// we are a client
// regenerate keys and resign rc before everything else
CryptoManager::instance()->identity_keygen(_identity);

Loading…
Cancel
Save