Skip to content

Commit

Permalink
Merge pull request #1649 from oxen-io/dev
Browse files Browse the repository at this point in the history
v0.9.2
  • Loading branch information
majestrate authored May 17, 2021
2 parents 9564e75 + cbb78b5 commit 94376e0
Show file tree
Hide file tree
Showing 6 changed files with 71 additions and 28 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
9 changes: 6 additions & 3 deletions contrib/format.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 changes: 35 additions & 0 deletions contrib/git-hook-pre-push.sh
Original file line number Diff line number Diff line change
@@ -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 ""
25 changes: 17 additions & 8 deletions llarp/handlers/tun.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand All @@ -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});
Expand Down Expand Up @@ -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
{
Expand Down
3 changes: 2 additions & 1 deletion llarp/service/endpoint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
25 changes: 10 additions & 15 deletions llarp/service/outbound_context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ namespace llarp
LogWarn(Name(), " message ", seq, " dropped by endpoint ", p->Endpoint(), " via ", dst);
MarkCurrentIntroBad(Now());
ShiftIntroduction(false);
UpdateIntroSet();
}
return true;
}
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 94376e0

Please sign in to comment.