Merge pull request #1647 from majestrate/stability-fix-2021-05-15

last minute fixes
pull/1649/head
Jeff 3 years ago committed by GitHub
commit 22481f8d68
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -933,7 +933,6 @@ namespace llarp
PathAlignmentTimeout());
return;
}
bool rewriteAddrs = true;
std::variant<service::Address, RouterID> to;
service::ProtocolType type;
if (m_SNodes.at(itr->second))
@ -950,7 +949,8 @@ namespace llarp
// prepare packet for insertion into network
// this includes clearing IP addresses, recalculating checksums, etc
if (rewriteAddrs)
// this does not happen for exits because the point is they don't rewrite addresses
if (type != service::ProtocolType::Exit)
{
if (pkt.IsV4())
pkt.UpdateIPv4Address({0}, {0});
@ -1059,22 +1059,31 @@ namespace llarp
src = pkt.srcv6();
}
// find what exit we think this should be for
service::Address fromAddr{};
if (const auto* ptr = std::get_if<service::Address>(&addr))
{
fromAddr = *ptr;
}
else // don't allow snode
return false;
const auto mapped = m_ExitMap.FindAllEntries(src);
bool allow = false;
for (const auto& [range, exitAddr] : mapped)
{
if ((range.BogonRange() and range.Contains(src)) or not IsBogon(src))
{
// this range is either not a bogon or is a bogon we are explicitly allowing
if (const auto* ptr = std::get_if<service::Address>(&addr))
{
// allow if this address matches the endpoint we think it should be
allow = exitAddr == *ptr;
}
// allow if this address matches the endpoint we think it should be
allow = exitAddr == fromAddr;
break;
}
}
if (not allow)
{
var::visit(
[&](auto&& address) { LogWarn(Name(), " does not allow ", src, " from ", address); },
addr);
return false;
}
}
else
{

@ -1083,9 +1083,10 @@ namespace llarp
PutReplyIntroFor(msg->tag, path->intro);
Introduction intro;
intro.pathID = from;
intro.router = PubKey(path->Endpoint());
intro.router = PubKey{path->Endpoint()};
intro.expiresAt = std::min(path->ExpireTime(), msg->introReply.expiresAt);
PutIntroFor(msg->tag, intro);
ConvoTagRX(msg->tag);
return ProcessDataMessage(msg);
}

@ -369,6 +369,12 @@ namespace llarp
});
}
if (lastGoodSend > 0s and now >= lastGoodSend + (sendTimeout / 2))
{
// send a keep alive to keep this session alive
KeepAlive();
}
// if we are dead return true so we are removed
return lastGoodSend > 0s ? (now >= lastGoodSend && now - lastGoodSend > sendTimeout)
: (now >= createdAt && now - createdAt > connectTimeout);

Loading…
Cancel
Save