change order of configuration

pull/703/head
Jeff Becker 5 years ago
parent 96a4c027d7
commit 4e4c0b85ce
No known key found for this signature in database
GPG Key ID: F357B3B42F6F9B05

@ -764,7 +764,7 @@ namespace llarp
return SaveRC(); return SaveRC();
} }
void bool
Router::fromConfig(Config *conf) Router::fromConfig(Config *conf)
{ {
// Set netid before anything else // Set netid before anything else
@ -784,6 +784,29 @@ namespace llarp
// IWP config // IWP config
m_OutboundPort = conf->iwp_links.outboundPort(); 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()) for(const auto &serverConfig : conf->iwp_links.servers())
{ {
@ -791,18 +814,18 @@ namespace llarp
if(!server->EnsureKeys(transport_keyfile.string().c_str())) if(!server->EnsureKeys(transport_keyfile.string().c_str()))
{ {
llarp::LogError("failed to ensure keyfile ", transport_keyfile); llarp::LogError("failed to ensure keyfile ", transport_keyfile);
return; return false;
} }
const auto &key = std::get< 0 >(serverConfig); const auto &key = std::get< 0 >(serverConfig);
int af = std::get< 1 >(serverConfig); int af = std::get< 1 >(serverConfig);
uint16_t port = std::get< 2 >(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); LogError("failed to bind inbound link on ", key, " port ", port);
return; return false;
} }
LogError("failed to bind inbound link on ", key, " port ", port); AddLink(std::move(server), true);
} }
// set network config // set network config
@ -836,7 +859,7 @@ namespace llarp
if(IsServiceNode()) if(IsServiceNode())
{ {
llarp::LogError("cannot use strict-connect option as service node"); llarp::LogError("cannot use strict-connect option as service node");
return; return false;
} }
llarp::RouterID snode; llarp::RouterID snode;
llarp::PubKey pk; llarp::PubKey pk;
@ -894,13 +917,6 @@ namespace llarp
std::make_unique< FileLogStream >(diskworker(), logfile, 100, true); 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()); netConfig.insert(conf->dns.netConfig.begin(), conf->dns.netConfig.end());
@ -915,7 +931,7 @@ namespace llarp
{ {
llarp::LogWarn("failed to decode bootstrap RC, file='", router, llarp::LogWarn("failed to decode bootstrap RC, file='", router,
"' rc=", rc); "' rc=", rc);
return; return false;
} }
if(rc.Verify(Now())) if(rc.Verify(Now()))
{ {
@ -938,22 +954,7 @@ namespace llarp
} }
} }
} }
return true;
// 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();
}
} }
bool bool

@ -565,7 +565,7 @@ namespace llarp
out.push_back({item.first, item.second}); out.push_back({item.first, item.second});
} }
void bool
fromConfig(Config *conf); fromConfig(Config *conf);
}; };

Loading…
Cancel
Save