mirror of
https://github.com/oxen-io/lokinet.git
synced 2024-11-17 15:25:35 +00:00
use optional
This commit is contained in:
parent
da5af879e9
commit
ecf2685aa3
@ -15,6 +15,7 @@
|
|||||||
#include <util/thread/logic.hpp>
|
#include <util/thread/logic.hpp>
|
||||||
|
|
||||||
#include <functional>
|
#include <functional>
|
||||||
|
#include <absl/types/optional.h>
|
||||||
|
|
||||||
namespace llarp
|
namespace llarp
|
||||||
{
|
{
|
||||||
@ -184,8 +185,7 @@ namespace llarp
|
|||||||
// the actual hop
|
// the actual hop
|
||||||
std::shared_ptr< Hop > hop;
|
std::shared_ptr< Hop > hop;
|
||||||
|
|
||||||
const Addr fromAddr;
|
const absl::optional< llarp::Addr > fromAddr;
|
||||||
const RouterContact fromRC;
|
|
||||||
|
|
||||||
LRCMFrameDecrypt(Context* ctx, Decrypter_ptr dec,
|
LRCMFrameDecrypt(Context* ctx, Decrypter_ptr dec,
|
||||||
const LR_CommitMessage* commit)
|
const LR_CommitMessage* commit)
|
||||||
@ -193,8 +193,9 @@ namespace llarp
|
|||||||
, frames(commit->frames)
|
, frames(commit->frames)
|
||||||
, context(ctx)
|
, context(ctx)
|
||||||
, hop(std::make_shared< Hop >())
|
, hop(std::make_shared< Hop >())
|
||||||
, fromAddr(commit->session->GetRemoteEndpoint())
|
, fromAddr(commit->session->GetRemoteRC().IsPublicRouter()
|
||||||
, fromRC(commit->session->GetRemoteRC())
|
? absl::optional< llarp::Addr >{}
|
||||||
|
: commit->session->GetRemoteEndpoint())
|
||||||
{
|
{
|
||||||
hop->info.downstream = commit->session->GetPubKey();
|
hop->info.downstream = commit->session->GetPubKey();
|
||||||
}
|
}
|
||||||
@ -246,7 +247,7 @@ namespace llarp
|
|||||||
{
|
{
|
||||||
if(self->context->HasTransitHop(self->hop->info))
|
if(self->context->HasTransitHop(self->hop->info))
|
||||||
{
|
{
|
||||||
llarp::LogError("duplicate transit hop", self->hop->info);
|
llarp::LogError("duplicate transit hop ", self->hop->info);
|
||||||
OnForwardLRCMResult(self->context->Router(), self->hop->info.rxID,
|
OnForwardLRCMResult(self->context->Router(), self->hop->info.rxID,
|
||||||
self->hop->info.downstream, self->hop->pathKey,
|
self->hop->info.downstream, self->hop->pathKey,
|
||||||
SendStatus::Congestion);
|
SendStatus::Congestion);
|
||||||
@ -254,13 +255,13 @@ namespace llarp
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(not self->fromRC.IsPublicRouter())
|
if(self->fromAddr.has_value())
|
||||||
{
|
{
|
||||||
// only do ip limiting from non service nodes
|
// only do ip limiting from non service nodes
|
||||||
if(self->context->CheckPathLimitHitByIP(self->fromAddr))
|
if(self->context->CheckPathLimitHitByIP(self->fromAddr.value()))
|
||||||
{
|
{
|
||||||
// we hit a limit so tell it to slow tf down
|
// we hit a limit so tell it to slow tf down
|
||||||
llarp::LogError("client path build limited ", self->hop->info);
|
llarp::LogError("client path build hit limit ", self->hop->info);
|
||||||
OnForwardLRCMResult(self->context->Router(), self->hop->info.rxID,
|
OnForwardLRCMResult(self->context->Router(), self->hop->info.rxID,
|
||||||
self->hop->info.downstream, self->hop->pathKey,
|
self->hop->info.downstream, self->hop->pathKey,
|
||||||
SendStatus::Congestion);
|
SendStatus::Congestion);
|
||||||
|
Loading…
Reference in New Issue
Block a user