mirror of
https://github.com/oxen-io/lokinet.git
synced 2024-11-11 07:10:36 +00:00
commit
94376e0da0
@ -16,7 +16,7 @@ if(CCACHE_PROGRAM)
|
||||
endif()
|
||||
|
||||
project(lokinet
|
||||
VERSION 0.9.1
|
||||
VERSION 0.9.2
|
||||
DESCRIPTION "lokinet - IP packet onion router"
|
||||
LANGUAGES C CXX)
|
||||
|
||||
|
@ -16,6 +16,9 @@ if [ $? -ne 0 ]; then
|
||||
fi
|
||||
fi
|
||||
|
||||
# TODO: readlink -e is a GNU-ism
|
||||
cd "$(readlink -e $(dirname $0)/../)"
|
||||
$binary -i $(find jni daemon llarp include pybind | grep -E '\.[hc](pp)?$') &> /dev/null
|
||||
cd "$(dirname $0)/../"
|
||||
if [ "$1" = "verify" ] ; then
|
||||
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());
|
||||
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,23 +1059,32 @@ 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 = exitAddr == fromAddr;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (not allow)
|
||||
{
|
||||
var::visit(
|
||||
[&](auto&& address) { LogWarn(Name(), " does not allow ", src, " from ", address); },
|
||||
addr);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// snapp traffic
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -47,6 +47,7 @@ namespace llarp
|
||||
LogWarn(Name(), " message ", seq, " dropped by endpoint ", p->Endpoint(), " via ", dst);
|
||||
MarkCurrentIntroBad(Now());
|
||||
ShiftIntroduction(false);
|
||||
UpdateIntroSet();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@ -347,26 +348,20 @@ namespace llarp
|
||||
|
||||
if (ReadyToSend() and m_ReadyHook)
|
||||
{
|
||||
KeepAlive();
|
||||
const auto path = GetPathByRouter(remoteIntro.router);
|
||||
if (not path)
|
||||
{
|
||||
LogWarn(Name(), " ready but no path to ", remoteIntro.router, " ???");
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
const auto rtt = (path->intro.latency + remoteIntro.latency) * 2;
|
||||
m_router->loop()->call_later(
|
||||
rtt, [rtt, self = shared_from_this(), hook = std::move(m_ReadyHook)]() {
|
||||
LogInfo(
|
||||
self->Name(),
|
||||
" is ready, RTT is measured as ",
|
||||
self->estimatedRTT,
|
||||
" approximated as ",
|
||||
rtt,
|
||||
" delta=",
|
||||
rtt - self->estimatedRTT);
|
||||
hook(self.get());
|
||||
});
|
||||
m_ReadyHook(this);
|
||||
m_ReadyHook = nullptr;
|
||||
}
|
||||
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user