use optional

pull/1014/head
Jeff Becker 4 years ago
parent da5af879e9
commit ecf2685aa3
No known key found for this signature in database
GPG Key ID: F357B3B42F6F9B05

@ -15,6 +15,7 @@
#include <util/thread/logic.hpp>
#include <functional>
#include <absl/types/optional.h>
namespace llarp
{
@ -184,8 +185,7 @@ namespace llarp
// the actual hop
std::shared_ptr< Hop > hop;
const Addr fromAddr;
const RouterContact fromRC;
const absl::optional< llarp::Addr > fromAddr;
LRCMFrameDecrypt(Context* ctx, Decrypter_ptr dec,
const LR_CommitMessage* commit)
@ -193,8 +193,9 @@ namespace llarp
, frames(commit->frames)
, context(ctx)
, hop(std::make_shared< Hop >())
, fromAddr(commit->session->GetRemoteEndpoint())
, fromRC(commit->session->GetRemoteRC())
, fromAddr(commit->session->GetRemoteRC().IsPublicRouter()
? absl::optional< llarp::Addr >{}
: commit->session->GetRemoteEndpoint())
{
hop->info.downstream = commit->session->GetPubKey();
}
@ -246,7 +247,7 @@ namespace llarp
{
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,
self->hop->info.downstream, self->hop->pathKey,
SendStatus::Congestion);
@ -254,13 +255,13 @@ namespace llarp
return;
}
if(not self->fromRC.IsPublicRouter())
if(self->fromAddr.has_value())
{
// 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
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,
self->hop->info.downstream, self->hop->pathKey,
SendStatus::Congestion);

Loading…
Cancel
Save