Merge remote-tracking branch 'origin/master' into ipv6-tun

pull/686/head
Jeff Becker 5 years ago
commit 9a2ffb85e6
No known key found for this signature in database
GPG Key ID: F357B3B42F6F9B05

@ -24,6 +24,7 @@ namespace llarp
if(val.size() <= NetID::size())
{
m_netId.assign(val.begin(), val.end());
LogInfo("setting netid to '", val, "'");
}
else
{
@ -55,22 +56,27 @@ namespace llarp
m_nickname.assign(val.begin(), val.end());
// set logger name here
LogContext::Instance().nodeName = nickname();
LogInfo("nickname set");
}
if(key == "encryption-privkey")
{
m_encryptionKeyfile.assign(val.begin(), val.end());
LogDebug("encryption key set to ", m_encryptionKeyfile);
}
if(key == "contact-file")
{
m_ourRcFile.assign(val.begin(), val.end());
LogDebug("rc file set to ", m_ourRcFile);
}
if(key == "transport-privkey")
{
m_transportKeyfile.assign(val.begin(), val.end());
LogDebug("transport key set to ", m_transportKeyfile);
}
if((key == "identity-privkey" || key == "ident-privkey"))
{
m_identKeyfile.assign(val.begin(), val.end());
LogDebug("identity key set to ", m_identKeyfile);
}
if(key == "public-address" || key == "public-ip")
{
@ -99,16 +105,26 @@ namespace llarp
m_workerThreads = atoi(std::string(val).c_str());
if(m_workerThreads <= 0)
{
LogWarn("worker threads invalid value: '", val, "' defaulting to 1");
m_workerThreads = 1;
}
else
{
LogDebug("set to use ", m_workerThreads, " worker threads");
}
}
if(key == "net-threads")
{
m_numNetThreads = atoi(std::string(val).c_str());
if(m_numNetThreads <= 0)
{
LogWarn("net threads invalid value: '", val, "' defaulting to 1");
m_numNetThreads = 1;
}
else
{
LogDebug("set to use ", m_numNetThreads, " net threads");
}
}
}

@ -110,16 +110,16 @@ namespace llarp
std::string m_netId;
std::string m_nickname;
fs::path m_encryptionKeyfile = "encryption.key";
std::string m_encryptionKeyfile = "encryption.key";
// path to write our self signed rc to
fs::path m_ourRcFile = "rc.signed";
std::string m_ourRcFile = "rc.signed";
// transient iwp encryption key
fs::path m_transportKeyfile = "transport.key";
std::string m_transportKeyfile = "transport.key";
// long term identity key
fs::path m_identKeyfile = "identity.key";
std::string m_identKeyfile = "identity.key";
bool m_publicOverride = false;
struct sockaddr_in m_ip4addr;
@ -132,10 +132,10 @@ namespace llarp
// clang-format off
size_t minConnectedRouters() const { return fromEnv(m_minConnectedRouters, "MIN_CONNECTED_ROUTERS"); }
size_t maxConnectedRouters() const { return fromEnv(m_maxConnectedRouters, "MAX_CONNECTED_ROUTERS"); }
fs::path encryptionKeyfile() const { return fromEnv(m_encryptionKeyfile, "ENCRYPTION_KEYFILE"); }
fs::path ourRcFile() const { return fromEnv(m_ourRcFile, "OUR_RC_FILE"); }
fs::path transportKeyfile() const { return fromEnv(m_transportKeyfile, "TRANSPORT_KEYFILE"); }
fs::path identKeyfile() const { return fromEnv(m_identKeyfile, "IDENT_KEYFILE"); }
std::string encryptionKeyfile() const { return fromEnv(m_encryptionKeyfile, "ENCRYPTION_KEYFILE"); }
std::string ourRcFile() const { return fromEnv(m_ourRcFile, "OUR_RC_FILE"); }
std::string transportKeyfile() const { return fromEnv(m_transportKeyfile, "TRANSPORT_KEYFILE"); }
std::string identKeyfile() const { return fromEnv(m_identKeyfile, "IDENT_KEYFILE"); }
std::string netId() const { return fromEnv(m_netId, "NETID"); }
std::string nickname() const { return fromEnv(m_nickname, "NICKNAME"); }
bool publicOverride() const { return fromEnv(m_publicOverride, "PUBLIC_OVERRIDE"); }

@ -464,7 +464,8 @@ namespace llarp
bool
Router::Configure(Config *conf)
{
fromConfig(conf);
if(!FromConfig(conf))
return false;
if(!InitOutboundLinks())
return false;
@ -766,8 +767,8 @@ namespace llarp
return SaveRC();
}
void
Router::fromConfig(Config *conf)
bool
Router::FromConfig(Config *conf)
{
// Set netid before anything else
if(!conf->router.netId().empty())
@ -786,6 +787,29 @@ namespace llarp
// IWP config
m_OutboundPort = conf->iwp_links.outboundPort();
// Router config
_rc.SetNick(conf->router.nickname());
maxConnectedRouters = conf->router.maxConnectedRouters();
minConnectedRouters = conf->router.minConnectedRouters();
encryption_keyfile = conf->router.encryptionKeyfile();
our_rc_file = conf->router.ourRcFile();
transport_keyfile = conf->router.transportKeyfile();
addrInfo = conf->router.addrInfo();
publicOverride = conf->router.publicOverride();
ip4addr = conf->router.ip4addr();
// Lokid Config
usingSNSeed = conf->lokid.usingSNSeed;
ident_keyfile = conf->lokid.ident_keyfile;
whitelistRouters = conf->lokid.whitelistRouters;
lokidRPCAddr = conf->lokid.lokidRPCAddr;
lokidRPCUser = conf->lokid.lokidRPCUser;
lokidRPCPassword = conf->lokid.lokidRPCPassword;
if(!usingSNSeed)
{
ident_keyfile = conf->router.identKeyfile();
}
for(const auto &serverConfig : conf->iwp_links.servers())
{
@ -793,18 +817,18 @@ namespace llarp
if(!server->EnsureKeys(transport_keyfile.string().c_str()))
{
llarp::LogError("failed to ensure keyfile ", transport_keyfile);
return;
return false;
}
const auto &key = std::get< 0 >(serverConfig);
int af = std::get< 1 >(serverConfig);
uint16_t port = std::get< 2 >(serverConfig);
if(server->Configure(netloop(), key, af, port))
if(!server->Configure(netloop(), key, af, port))
{
AddLink(std::move(server), true);
return;
LogError("failed to bind inbound link on ", key, " port ", port);
return false;
}
LogError("failed to bind inbound link on ", key, " port ", port);
AddLink(std::move(server), true);
}
// set network config
@ -838,7 +862,7 @@ namespace llarp
if(IsServiceNode())
{
llarp::LogError("cannot use strict-connect option as service node");
return;
return false;
}
llarp::RouterID snode;
llarp::PubKey pk;
@ -896,13 +920,6 @@ namespace llarp
std::make_unique< FileLogStream >(diskworker(), logfile, 100, true);
}
// Lokid Config
usingSNSeed = conf->lokid.usingSNSeed;
ident_keyfile = conf->lokid.ident_keyfile;
whitelistRouters = conf->lokid.whitelistRouters;
lokidRPCAddr = conf->lokid.lokidRPCAddr;
lokidRPCUser = conf->lokid.lokidRPCUser;
lokidRPCPassword = conf->lokid.lokidRPCPassword;
netConfig.insert(conf->dns.netConfig.begin(), conf->dns.netConfig.end());
@ -917,7 +934,7 @@ namespace llarp
{
llarp::LogWarn("failed to decode bootstrap RC, file='", router,
"' rc=", rc);
return;
return false;
}
if(rc.Verify(Now()))
{
@ -940,22 +957,7 @@ namespace llarp
}
}
}
// Router config
_rc.SetNick(conf->router.nickname());
maxConnectedRouters = conf->router.maxConnectedRouters();
minConnectedRouters = conf->router.minConnectedRouters();
encryption_keyfile = conf->router.encryptionKeyfile();
our_rc_file = conf->router.ourRcFile();
transport_keyfile = conf->router.transportKeyfile();
addrInfo = conf->router.addrInfo();
publicOverride = conf->router.publicOverride();
ip4addr = conf->router.ip4addr();
if(!usingSNSeed)
{
ident_keyfile = conf->router.identKeyfile();
}
return true;
}
bool

@ -562,8 +562,8 @@ namespace llarp
out.push_back({item.first, item.second});
}
void
fromConfig(Config *conf);
bool
FromConfig(Config *conf);
};
} // namespace llarp

@ -66,7 +66,7 @@ namespace cpp17
void
path::swap(path& p)
{
s.swap(p.s);
std::swap(p.s, s);
}
std::string

@ -83,9 +83,7 @@ public:
template< typename Source >
path& assign(const Source& source)
{
path t(source);
swap(t);
s = string_type(source);
return *this;
}
@ -95,9 +93,7 @@ public:
Iterator last
)
{
path t(first, last);
swap(t);
s = string_type(first, last);
return *this;
}

Loading…
Cancel
Save