llarp::service::OutboundContext

context needed to initiate an outbound hidden service session

#include <outbound_context.hpp>

Inherits from llarp::path::Builder, llarp::service::SendContext, std::enable_shared_from_this< OutboundContext >, llarp::path::PathSet

Public Functions

Name
OutboundContext(const IntroSet & introSet, Endpoint * parent)
~OutboundContext() override
virtual void Tick(llarp_time_t now) override
tick owned paths
virtual void BlacklistSNode(const RouterID ) override
virtual bool ShouldBundleRC() const override
should we bundle RCs in builds?
virtual path::PathSet_ptr GetSelf() override
get a shared_ptr of ourself
virtual std::weak_ptr< path::PathSet > GetWeak() override
get a weak_ptr of ourself
Address Addr() const
virtual bool Stop() override
stop this pathset and mark it as to be removed
bool HandleDataDrop(path::Path_ptr p, const PathID_t & dst, uint64_t s)
virtual void HandlePathDied(path::Path_ptr path) override
a path died now what?
virtual bool ShiftIntroduction(bool rebuild =true) override
update the current selected intro to be a new best introduction return true if we have changed intros
virtual void ShiftIntroRouter(const RouterID remote) override
shift the intro off the current router it is using
virtual void MarkCurrentIntroBad(llarp_time_t now) override
mark the current remote intro as bad
void MarkIntroBad(const Introduction & marked, llarp_time_t now)
bool ReadyToSend() const
return true if we are ready to send
void AddReadyHook(std::function< void(OutboundContext *)> readyHook, llarp_time_t timeout)
virtual void SendPacketToRemote(const llarp_buffer_t & , ProtocolType t) override
for exits
virtual bool ShouldBuildMore(llarp_time_t now) const override
return true if we should build another path
bool Pump(llarp_time_t now)
pump internal state return true to mark as dead
bool IsDone(llarp_time_t now) const
return true if it's safe to remove ourselves
bool CheckPathIsDead(path::Path_ptr p, llarp_time_t dlt)
virtual void AsyncGenIntro(const llarp_buffer_t & payload, ProtocolType t) override
virtual void UpdateIntroSet() override
issues a lookup to find the current intro set of the remote service
virtual void HandlePathBuilt(path::Path_ptr path) override
virtual void HandlePathBuildTimeout(path::Path_ptr path) override
virtual void HandlePathBuildFailedAt(path::Path_ptr path, RouterID hop) override
virtual std::optional< std::vector< RouterContact > > GetHopsForBuild() override
bool HandleHiddenServiceFrame(path::Path_ptr p, const ProtocolFrame & frame)
virtual std::string Name() const override
get the "name" of this pathset
void KeepAlive()
bool ShouldKeepAlive(llarp_time_t now) const
const IntroSet & GetCurrentIntroSet() const
llarp_time_t RTT() const
bool OnIntroSetUpdate(const Address & addr, std::optional< IntroSet > i, const RouterID & endpoint, llarp_time_t , uint64_t relayOrder)

Public Attributes

Name
bool updatingIntroSet
set to true if we are updating the remote introset right now

Additional inherited members

Public Functions inherited from llarp::path::Builder

Name
Builder(AbstractRouter * p_router, size_t numDesiredPaths, size_t numHops)
construct
virtual ~Builder() =default
virtual void ResetInternalState() override
reset all cooldown timers
bool BuildCooldownHit(llarp_time_t now) const
return true if we hit our soft limit for building paths too fast
virtual PathRole GetRoles() const
get roles for this path builder
BuildStats CurrentBuildStats() const
virtual bool IsStopped() const override
return true if we are stopped
virtual bool ShouldRemove() const override
return true if we can and should remove this pathset and underlying resources from its parent context
virtual llarp_time_t Now() const override
get time from event loop
virtual void BuildOne(PathRole roles =ePathRoleAny) override
virtual bool BuildOneAlignedTo(const RouterID endpoint) override
std::optional< std::vector< RouterContact > > GetHopsAlignedToForBuild(RouterID endpoint, const std::set< RouterID > & exclude ={})
virtual void Build(std::vector< RouterContact > hops, PathRole roles =ePathRoleAny) override
manual build on these hops
std::optional< RouterContact > SelectFirstHop(const std::set< RouterID > & exclude ={}) const
pick a first hop
void ManualRebuild(size_t N, PathRole roles =ePathRoleAny)
virtual const SecretKey & GetTunnelEncryptionSecretKey() const

Protected Functions inherited from llarp::path::Builder

Name
virtual bool UrgentBuild(llarp_time_t now) const
bool BuildCooldownHit(RouterID edge) const
return true if we hit our soft limit for building paths too fast on a first hop

Public Attributes inherited from llarp::path::Builder

Name
AbstractRouter *const m_router
SecretKey enckey
size_t numHops
llarp_time_t lastBuild
llarp_time_t buildIntervalLimit

Protected Attributes inherited from llarp::path::Builder

Name
std::atomic< bool > _run
flag for PathSet::Stop()

Public Types inherited from llarp::service::SendContext

Name
using std::shared_ptr< routing::PathTransferMessage > Msg_ptr
using std::pair< Msg_ptr, path::Path_ptr > SendEvent_t

Public Functions inherited from llarp::service::SendContext

Name
SendContext(ServiceInfo ident, const Introduction & intro, path::PathSet * send, Endpoint * ep)
void AsyncEncryptAndSendTo(const llarp_buffer_t & payload, ProtocolType t)
bool Send(std::shared_ptr< ProtocolFrame > f, path::Path_ptr path)
queue send a fully encrypted hidden service frame via a path
void FlushUpstream()
flush upstream traffic when in router thread
void AsyncSendAuth(std::function< void(AuthResult)> replyHandler)

Public Attributes inherited from llarp::service::SendContext

Name
SharedSecret sharedKey
ServiceInfo remoteIdent
Introduction remoteIntro
ConvoTag currentConvoTag
path::PathSet *const m_PathSet
IDataHandler *const m_DataHandler
Endpoint *const m_Endpoint
uint64_t sequenceNo
llarp_time_t lastGoodSend
const llarp_time_t createdAt
llarp_time_t sendTimeout
llarp_time_t connectTimeout
llarp_time_t shiftTimeout
llarp_time_t estimatedRTT
bool markedBad
thread::Queue< SendEvent_t > m_SendQueue
std::function< void(AuthResult)> authResultListener

Protected Types inherited from llarp::path::PathSet

Name
using util::NullMutex Mtx_t
using util::NullLock Lock_t
using std::unordered_map< std::pair< RouterID, PathID_t >, Path_ptr > PathMap_t

Public Functions inherited from llarp::path::PathSet

Name
PathSet(size_t numDesiredPaths)
construct @params numDesiredPaths the number of paths to maintain
virtual void BuildOne(PathRole roles =ePathRoleAny) =0
virtual void Build(std::vector< RouterContact > hops, PathRole roles =ePathRoleAny) =0
manual build on these hops
size_t NumPathsExistingAt(llarp_time_t futureTime) const
count the number of paths that will exist at this timestamp in future
virtual void PathBuildStarted(Path_ptr path)
bool GetNewestIntro(service::Introduction & intro) const
void AddPath(Path_ptr path)
Path_ptr GetByUpstream(RouterID remote, PathID_t rxid) const
void ExpirePaths(llarp_time_t now, AbstractRouter * router)
size_t NumInStatus(PathStatus st) const
get the number of paths in this status
size_t AvailablePaths(PathRole role) const
get the number of paths that match the role that are available
virtual llarp_time_t Now() const =0
get time from event loop
virtual bool IsStopped() const =0
return true if we are stopped
virtual bool ShouldRemove() const =0
return true if we can and should remove this pathset and underlying resources from its parent context
virtual bool ShouldBuildMoreForRoles(llarp_time_t now, PathRole roles) const
return true if we need another path with the given path roles
virtual size_t MinRequiredForRoles(PathRole roles) const
return the minimum number of paths we want for given roles
virtual bool ShouldPublishDescriptors(llarp_time_t now) const
return true if we should publish a new hidden service descriptor
virtual bool HandleGotIntroMessage(std::shared_ptr< const dht::GotIntroMessage > )
override me in subtype
virtual bool HandleGotRouterMessage(std::shared_ptr< const dht::GotRouterMessage > )
override me in subtype
virtual bool HandleGotNameMessage(std::shared_ptr< const dht::GotNameMessage > )
override me in subtype
virtual routing::IMessageHandler * GetDHTHandler()
Path_ptr GetEstablishedPathClosestTo(RouterID router, std::unordered_set< RouterID > excluding ={}, PathRole roles =ePathRoleAny) const
Path_ptr PickEstablishedPath(PathRole roles =ePathRoleAny) const
Path_ptr PickRandomEstablishedPath(PathRole roles =ePathRoleAny) const
Path_ptr GetPathByRouter(RouterID router, PathRole roles =ePathRoleAny) const
Path_ptr GetNewestPathByRouter(RouterID router, PathRole roles =ePathRoleAny) const
Path_ptr GetRandomPathByRouter(RouterID router, PathRole roles =ePathRoleAny) const
Path_ptr GetPathByID(PathID_t id) const
Path_ptr GetByEndpointWithID(RouterID router, PathID_t id) const
std::optional< std::set< service::Introduction > > GetCurrentIntroductionsWithFilter(std::function< bool(const service::Introduction &)> filter) const
virtual bool PublishIntroSet(const service::EncryptedIntroSet & , AbstractRouter * )
virtual void ResetInternalState() =0
reset all cooldown timers
virtual bool BuildOneAlignedTo(const RouterID endpoint) =0
void ForEachPath(std::function< void(const Path_ptr &)> visit) const
void UpstreamFlush(AbstractRouter * r)
void DownstreamFlush(AbstractRouter * r)

Protected Functions inherited from llarp::path::PathSet

Name
void TickPaths(AbstractRouter * r)

Public Attributes inherited from llarp::path::PathSet

Name
constexpr size_t max_paths
maximum number of paths a path set can maintain
size_t numDesiredPaths

Protected Attributes inherited from llarp::path::PathSet

Name
BuildStats m_BuildStats
Mtx_t m_PathsMutex
PathMap_t m_Paths

Public Functions Documentation

function OutboundContext

OutboundContext(
    const IntroSet & introSet,
    Endpoint * parent
)

function ~OutboundContext

~OutboundContext() override

function Tick

virtual void Tick(
    llarp_time_t now
) override

tick owned paths

Reimplements: llarp::path::Builder::Tick

function BlacklistSNode

inline virtual void BlacklistSNode(
    const RouterID 
) override

Reimplements: llarp::path::PathSet::BlacklistSNode

function ShouldBundleRC

virtual bool ShouldBundleRC() const override

should we bundle RCs in builds?

Reimplements: llarp::path::Builder::ShouldBundleRC

function GetSelf

inline virtual path::PathSet_ptr GetSelf() override

get a shared_ptr of ourself

Reimplements: llarp::path::PathSet::GetSelf

function GetWeak

inline virtual std::weak_ptr< path::PathSet > GetWeak() override

get a weak_ptr of ourself

Reimplements: llarp::path::PathSet::GetWeak

function Addr

Address Addr() const

function Stop

virtual bool Stop() override

stop this pathset and mark it as to be removed

Reimplements: llarp::path::Builder::Stop

function HandleDataDrop

bool HandleDataDrop(
    path::Path_ptr p,
    const PathID_t & dst,
    uint64_t s
)

function HandlePathDied

virtual void HandlePathDied(
    path::Path_ptr path
) override

a path died now what?

Reimplements: llarp::path::PathSet::HandlePathDied

function ShiftIntroduction

virtual bool ShiftIntroduction(
    bool rebuild =true
) override

update the current selected intro to be a new best introduction return true if we have changed intros

Reimplements: llarp::service::SendContext::ShiftIntroduction

function ShiftIntroRouter

virtual void ShiftIntroRouter(
    const RouterID remote
) override

shift the intro off the current router it is using

Reimplements: llarp::service::SendContext::ShiftIntroRouter

function MarkCurrentIntroBad

virtual void MarkCurrentIntroBad(
    llarp_time_t now
) override

mark the current remote intro as bad

Reimplements: llarp::service::SendContext::MarkCurrentIntroBad

function MarkIntroBad

void MarkIntroBad(
    const Introduction & marked,
    llarp_time_t now
)

function ReadyToSend

bool ReadyToSend() const

return true if we are ready to send

function AddReadyHook

void AddReadyHook(
    std::function< void(OutboundContext *)> readyHook,
    llarp_time_t timeout
)

function SendPacketToRemote

virtual void SendPacketToRemote(
    const llarp_buffer_t & ,
    ProtocolType t
) override

for exits

Reimplements: llarp::path::PathSet::SendPacketToRemote

function ShouldBuildMore

virtual bool ShouldBuildMore(
    llarp_time_t now
) const override

return true if we should build another path

Reimplements: llarp::path::Builder::ShouldBuildMore

function Pump

bool Pump(
    llarp_time_t now
)

pump internal state return true to mark as dead

function IsDone

bool IsDone(
    llarp_time_t now
) const

return true if it's safe to remove ourselves

function CheckPathIsDead

bool CheckPathIsDead(
    path::Path_ptr p,
    llarp_time_t dlt
)

function AsyncGenIntro

virtual void AsyncGenIntro(
    const llarp_buffer_t & payload,
    ProtocolType t
) override

Reimplements: llarp::service::SendContext::AsyncGenIntro

function UpdateIntroSet

virtual void UpdateIntroSet() override

issues a lookup to find the current intro set of the remote service

Reimplements: llarp::service::SendContext::UpdateIntroSet

function HandlePathBuilt

virtual void HandlePathBuilt(
    path::Path_ptr path
) override

Reimplements: llarp::path::Builder::HandlePathBuilt

function HandlePathBuildTimeout

virtual void HandlePathBuildTimeout(
    path::Path_ptr path
) override

Reimplements: llarp::path::Builder::HandlePathBuildTimeout

function HandlePathBuildFailedAt

virtual void HandlePathBuildFailedAt(
    path::Path_ptr path,
    RouterID hop
) override

Reimplements: llarp::path::Builder::HandlePathBuildFailedAt

function GetHopsForBuild

virtual std::optional< std::vector< RouterContact > > GetHopsForBuild() override

Reimplements: llarp::path::Builder::GetHopsForBuild

function HandleHiddenServiceFrame

bool HandleHiddenServiceFrame(
    path::Path_ptr p,
    const ProtocolFrame & frame
)

function Name

virtual std::string Name() const override

get the "name" of this pathset

Reimplements: llarp::path::PathSet::Name

function KeepAlive

void KeepAlive()

function ShouldKeepAlive

bool ShouldKeepAlive(
    llarp_time_t now
) const

function GetCurrentIntroSet

inline const IntroSet & GetCurrentIntroSet() const

function RTT

llarp_time_t RTT() const

function OnIntroSetUpdate

bool OnIntroSetUpdate(
    const Address & addr,
    std::optional< IntroSet > i,
    const RouterID & endpoint,
    llarp_time_t ,
    uint64_t relayOrder
)

Public Attributes Documentation

variable updatingIntroSet

bool updatingIntroSet;

set to true if we are updating the remote introset right now


Updated on 2026-01-10 at 22:49:45 +0000