1
1
Fork 0
mirror of https://github.com/oxen-io/lokinet synced 2023-12-14 06:53:00 +01:00

Merge pull request #815 from majestrate/logging-cleanip

reduce logging and make format
This commit is contained in:
Jeff 2019-09-09 08:23:00 -04:00 committed by GitHub
commit b9c130d576
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 41 additions and 11 deletions

View file

@ -102,7 +102,7 @@ llarp_ev_add_tun(struct llarp_ev_loop *loop, struct llarp_tun_io *tun)
{
LogError("invalid ifname on tun: ", tun->ifname);
return false;
}
}
#if !defined(_WIN32)
return loop->tun_listen(tun);
#else

View file

@ -733,11 +733,6 @@ namespace llarp
m_Exit->QueueUpstreamTraffic(std::move(pkt),
llarp::routing::ExitPadSize);
}
else
{
llarp::LogWarn(Name(), " has no endpoint for ", dst);
llarp::DumpBuffer(pkt.ConstBuffer());
}
return;
}
if(m_SNodes.at(itr->second))

View file

@ -870,10 +870,10 @@ namespace llarp
net::IPPacket::ExpandV4(xntohl(ifmask))});
}
});
// try 10.x.0.0/16
byte_t oct = 0;
while(oct < 255)
{
// TODO: check for range inbetween these
const huint32_t loaddr = ipaddr_ipv4_bits(10, oct, 0, 1);
const huint32_t hiaddr = ipaddr_ipv4_bits(10, oct, 255, 255);
bool hit = false;
@ -885,6 +885,38 @@ namespace llarp
return loaddr.ToString() + "/16";
++oct;
}
// try 192.168.x.0/24
oct = 0;
while(oct < 255)
{
const huint32_t loaddr = ipaddr_ipv4_bits(192, 168, oct, 1);
const huint32_t hiaddr = ipaddr_ipv4_bits(192, 168, oct, 255);
bool hit = false;
for(const auto& range : currentRanges)
{
hit = hit || range.ContainsV4(loaddr) || range.ContainsV4(hiaddr);
}
if(!hit)
return loaddr.ToString() + "/24";
}
// try 172.16.x.0/24
oct = 0;
while(oct < 255)
{
const huint32_t loaddr = ipaddr_ipv4_bits(172, 16, oct, 1);
const huint32_t hiaddr = ipaddr_ipv4_bits(172, 16, oct, 255);
bool hit = false;
for(const auto& range : currentRanges)
{
hit = hit || range.ContainsV4(loaddr) || range.ContainsV4(hiaddr);
}
if(!hit)
return loaddr.ToString() + "/24";
++oct;
}
LogError(
"cannot autodetect any free ip ranges on your system for use, please "
"configure this manually");
return "";
}

View file

@ -356,7 +356,8 @@ namespace llarp
Router::FromConfig(Config *conf)
{
// Set netid before anything else
if(!conf->router.netId().empty() && strcmp(conf->router.netId().c_str(), Version::LLARP_NET_ID))
if(!conf->router.netId().empty()
&& strcmp(conf->router.netId().c_str(), Version::LLARP_NET_ID))
{
const auto &netid = conf->router.netId();
llarp::LogWarn("!!!! you have manually set netid to be '", netid,
@ -803,7 +804,9 @@ namespace llarp
auto found = netConfig.find(itr->first);
if(found == netConfig.end() || found->second.empty())
{
netConfig.emplace(itr->first, itr->second());
auto val = itr->second();
if(!val.empty())
netConfig.emplace(itr->first, std::move(val));
}
++itr;
}
@ -1174,7 +1177,7 @@ namespace llarp
}
else
{
LogWarn("Message failed sending to ", remote);
LogDebug("Message failed sending to ", remote);
}
}
} // namespace llarp

View file

@ -250,7 +250,7 @@ namespace llarp
bool
RouterContact::IsExpired(llarp_time_t now) const
{
(void) now;
(void)now;
return false;
// return Age(now) >= Lifetime;
}