mirror of
https://github.com/oxen-io/lokinet.git
synced 2024-11-19 09:25:28 +00:00
Merge remote-tracking branch 'origin/stable' into debian/sid
This commit is contained in:
commit
cab99c1a13
@ -16,7 +16,7 @@ if(CCACHE_PROGRAM)
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
project(lokinet
|
project(lokinet
|
||||||
VERSION 0.9.1
|
VERSION 0.9.2
|
||||||
DESCRIPTION "lokinet - IP packet onion router"
|
DESCRIPTION "lokinet - IP packet onion router"
|
||||||
LANGUAGES C CXX)
|
LANGUAGES C CXX)
|
||||||
|
|
||||||
|
@ -16,6 +16,9 @@ if [ $? -ne 0 ]; then
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# TODO: readlink -e is a GNU-ism
|
cd "$(dirname $0)/../"
|
||||||
cd "$(readlink -e $(dirname $0)/../)"
|
if [ "$1" = "verify" ] ; then
|
||||||
$binary -i $(find jni daemon llarp include pybind | grep -E '\.[hc](pp)?$') &> /dev/null
|
exit $($binary --output-replacements-xml $(find jni daemon llarp include pybind | grep -E '\.[hc](pp)?$' | grep -v '\#') | grep '</replacement>' | wc -l)
|
||||||
|
else
|
||||||
|
$binary -i $(find jni daemon llarp include pybind | grep -E '\.[hc](pp)?$' | grep -v '\#') &> /dev/null
|
||||||
|
fi
|
||||||
|
35
contrib/git-hook-pre-push.sh
Executable file
35
contrib/git-hook-pre-push.sh
Executable file
@ -0,0 +1,35 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
#
|
||||||
|
# pre-push hook for git
|
||||||
|
# this script is probably overkill for most contributors
|
||||||
|
#
|
||||||
|
# "i use this to prevent foot cannons caused by commiting broken code"
|
||||||
|
#
|
||||||
|
# ~ jeff (lokinet author and crazy person)
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# to use this as a git hook do this in the root of the repo:
|
||||||
|
#
|
||||||
|
# cp contrib/git-hook-pre-push.sh .git/hooks/pre-push
|
||||||
|
#
|
||||||
|
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
cd "$(dirname $0)/../.."
|
||||||
|
echo "check format..."
|
||||||
|
./contrib/format.sh verify
|
||||||
|
echo "format is gucci af fam"
|
||||||
|
|
||||||
|
echo "remove old test build directory..."
|
||||||
|
rm -rf build-git-hook
|
||||||
|
mkdir build-git-hook
|
||||||
|
echo "configuring test build jizz..."
|
||||||
|
cmake -S . -B build-git-hook -DWITH_LTO=OFF -DWITH_HIVE=ON -G Ninja
|
||||||
|
echo "ensure this shit compiles..."
|
||||||
|
ninja -C build-git-hook all
|
||||||
|
echo "ensure unit tests aren't fucked..."
|
||||||
|
ninja -C build-git-hook check
|
||||||
|
|
||||||
|
echo "we gud UmU"
|
||||||
|
echo ""
|
@ -933,7 +933,6 @@ namespace llarp
|
|||||||
PathAlignmentTimeout());
|
PathAlignmentTimeout());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
bool rewriteAddrs = true;
|
|
||||||
std::variant<service::Address, RouterID> to;
|
std::variant<service::Address, RouterID> to;
|
||||||
service::ProtocolType type;
|
service::ProtocolType type;
|
||||||
if (m_SNodes.at(itr->second))
|
if (m_SNodes.at(itr->second))
|
||||||
@ -950,7 +949,8 @@ namespace llarp
|
|||||||
|
|
||||||
// prepare packet for insertion into network
|
// prepare packet for insertion into network
|
||||||
// this includes clearing IP addresses, recalculating checksums, etc
|
// 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())
|
if (pkt.IsV4())
|
||||||
pkt.UpdateIPv4Address({0}, {0});
|
pkt.UpdateIPv4Address({0}, {0});
|
||||||
@ -1059,22 +1059,31 @@ namespace llarp
|
|||||||
src = pkt.srcv6();
|
src = pkt.srcv6();
|
||||||
}
|
}
|
||||||
// find what exit we think this should be for
|
// 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);
|
const auto mapped = m_ExitMap.FindAllEntries(src);
|
||||||
bool allow = false;
|
bool allow = false;
|
||||||
for (const auto& [range, exitAddr] : mapped)
|
for (const auto& [range, exitAddr] : mapped)
|
||||||
{
|
{
|
||||||
if ((range.BogonRange() and range.Contains(src)) or not IsBogon(src))
|
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
|
// allow if this address matches the endpoint we think it should be
|
||||||
if (const auto* ptr = std::get_if<service::Address>(&addr))
|
allow = exitAddr == fromAddr;
|
||||||
{
|
break;
|
||||||
// allow if this address matches the endpoint we think it should be
|
|
||||||
allow = exitAddr == *ptr;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (not allow)
|
if (not allow)
|
||||||
|
{
|
||||||
|
var::visit(
|
||||||
|
[&](auto&& address) { LogWarn(Name(), " does not allow ", src, " from ", address); },
|
||||||
|
addr);
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -1083,9 +1083,10 @@ namespace llarp
|
|||||||
PutReplyIntroFor(msg->tag, path->intro);
|
PutReplyIntroFor(msg->tag, path->intro);
|
||||||
Introduction intro;
|
Introduction intro;
|
||||||
intro.pathID = from;
|
intro.pathID = from;
|
||||||
intro.router = PubKey(path->Endpoint());
|
intro.router = PubKey{path->Endpoint()};
|
||||||
intro.expiresAt = std::min(path->ExpireTime(), msg->introReply.expiresAt);
|
intro.expiresAt = std::min(path->ExpireTime(), msg->introReply.expiresAt);
|
||||||
PutIntroFor(msg->tag, intro);
|
PutIntroFor(msg->tag, intro);
|
||||||
|
ConvoTagRX(msg->tag);
|
||||||
return ProcessDataMessage(msg);
|
return ProcessDataMessage(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,6 +47,7 @@ namespace llarp
|
|||||||
LogWarn(Name(), " message ", seq, " dropped by endpoint ", p->Endpoint(), " via ", dst);
|
LogWarn(Name(), " message ", seq, " dropped by endpoint ", p->Endpoint(), " via ", dst);
|
||||||
MarkCurrentIntroBad(Now());
|
MarkCurrentIntroBad(Now());
|
||||||
ShiftIntroduction(false);
|
ShiftIntroduction(false);
|
||||||
|
UpdateIntroSet();
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -347,26 +348,20 @@ namespace llarp
|
|||||||
|
|
||||||
if (ReadyToSend() and m_ReadyHook)
|
if (ReadyToSend() and m_ReadyHook)
|
||||||
{
|
{
|
||||||
KeepAlive();
|
|
||||||
const auto path = GetPathByRouter(remoteIntro.router);
|
const auto path = GetPathByRouter(remoteIntro.router);
|
||||||
if (not path)
|
if (not path)
|
||||||
{
|
{
|
||||||
LogWarn(Name(), " ready but no path to ", remoteIntro.router, " ???");
|
LogWarn(Name(), " ready but no path to ", remoteIntro.router, " ???");
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
const auto rtt = (path->intro.latency + remoteIntro.latency) * 2;
|
m_ReadyHook(this);
|
||||||
m_router->loop()->call_later(
|
m_ReadyHook = nullptr;
|
||||||
rtt, [rtt, self = shared_from_this(), hook = std::move(m_ReadyHook)]() {
|
}
|
||||||
LogInfo(
|
|
||||||
self->Name(),
|
if (lastGoodSend > 0s and now >= lastGoodSend + (sendTimeout / 2))
|
||||||
" is ready, RTT is measured as ",
|
{
|
||||||
self->estimatedRTT,
|
// send a keep alive to keep this session alive
|
||||||
" approximated as ",
|
KeepAlive();
|
||||||
rtt,
|
|
||||||
" delta=",
|
|
||||||
rtt - self->estimatedRTT);
|
|
||||||
hook(self.get());
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// if we are dead return true so we are removed
|
// if we are dead return true so we are removed
|
||||||
|
Loading…
Reference in New Issue
Block a user