pull/230/head
Ryan Tharp 6 years ago
commit 0be2edaff7

@ -151,7 +151,6 @@ llarp_ev_add_tun(struct llarp_ev_loop *loop, struct llarp_tun_io *tun)
if(strcmp(tun->ifaddr, "") == 0 || strcmp(tun->ifaddr, "auto"))
{
std::string ifaddr = llarp::findFreePrivateRange();
std::string addr;
auto pos = ifaddr.find("/");
if(pos == std::string::npos)
{
@ -171,13 +170,14 @@ llarp_ev_add_tun(struct llarp_ev_loop *loop, struct llarp_tun_io *tun)
return false;
}
tun->netmask = num;
addr = ifaddr.substr(0, pos);
strcpy(tun->ifaddr, addr.c_str());
const std::string addr = ifaddr.substr(0, pos);
std::copy_n(addr.begin(), std::min(sizeof(tun->ifaddr), addr.size()), tun->ifaddr);
llarp::LogInfo("IfAddr autodetect: ", tun->ifaddr, "/", tun->netmask);
}
if(strcmp(tun->ifname, "") == 0 || strcmp(tun->ifname, "auto"))
{
strcpy(tun->ifname, llarp::findFreeLokiTunIfName().c_str());
std::string ifname = llarp::findFreeLokiTunIfName();
std::copy_n(ifname.begin(), std::min(sizeof(tun->ifname), ifname.size()), tun->ifname);
llarp::LogInfo("IfName autodetect: ", tun->ifname);
}
llarp::LogDebug("Tun Interface will use the following settings:");

@ -1182,10 +1182,10 @@ namespace llarp
if(hiddenServiceContext.hasEndpoints())
{
llarp::LogInfo("Auto mode detected and we have endpoints");
netConfig.emplace(std::make_pair("enabled", "false"));
netConfig.emplace("enabled", "false");
return false;
}
netConfig.emplace(std::make_pair("enabled", "true"));
netConfig.emplace("enabled", "true");
}
// ev.cpp llarp_ev_add_tun now handles this
/*
@ -1388,6 +1388,7 @@ namespace llarp
Router::CreateDefaultHiddenService()
{
// fallback defaults
// To NeuroScr: why run findFree* here instead of in tun.cpp?
static const std::unordered_map< std::string,
std::function< std::string(void) > >
netConfigDefaults = {

@ -298,14 +298,17 @@ namespace llarp
// construct
service.reset(itr->second(conf.first, m_Router));
// if ephemeral, then we need to regen key
// if privkey file, then set it and load it
if(keyfile != "")
{
llarp::LogInfo("Found keyfile, prestarting endpoint");
service->SetOption("keyfile", keyfile);
// load keyfile, so we have the correct name for logging
service->LoadKeyFile(); // only start endpoint not tun
llarp::LogInfo("Endpoint prestarted");
}
llarp::LogInfo("Establishing endpoint identity");
service->LoadKeyFile(); // only start endpoint not tun
// now Name() will be correct
}
// configure
for(const auto &option : conf.second)

@ -507,7 +507,8 @@ namespace llarp
bool
Endpoint::Start()
{
this->LoadKeyFile();
// how can I tell if a m_Identity isn't loaded?
//this->LoadKeyFile();
if(!m_DataHandler)
{
m_DataHandler = this;

Loading…
Cancel
Save