---
title: llarp::AbstractRouter

---

# llarp::AbstractRouter





Inherits from std::enable_shared_from_this< AbstractRouter >

Inherited by [llarp::Router](Classes/structllarp_1_1Router.md)

## Public Functions

|                | Name           |
| -------------- | -------------- |
| virtual | **[~AbstractRouter](Classes/structllarp_1_1AbstractRouter.md#function-~abstractrouter)**() =default |
| virtual bool | **[HandleRecvLinkMessageBuffer](Classes/structllarp_1_1AbstractRouter.md#function-handlerecvlinkmessagebuffer)**([ILinkSession](Classes/structllarp_1_1ILinkSession.md) * from, const [llarp_buffer_t](Classes/structllarp__buffer__t.md) & msg) =0 |
| virtual const [net::Platform](Classes/classllarp_1_1net_1_1Platform.md) & | **[Net](Classes/structllarp_1_1AbstractRouter.md#function-net)**() const =0 |
| virtual const LMQ_ptr & | **[lmq](Classes/structllarp_1_1AbstractRouter.md#function-lmq)**() const =0 |
| virtual [vpn::Platform](Classes/classllarp_1_1vpn_1_1Platform.md) * | **[GetVPNPlatform](Classes/structllarp_1_1AbstractRouter.md#function-getvpnplatform)**() const =0 |
| virtual const std::shared_ptr< [rpc::LokidRpcClient](Classes/structllarp_1_1rpc_1_1LokidRpcClient.md) > & | **[RpcClient](Classes/structllarp_1_1AbstractRouter.md#function-rpcclient)**() const =0 |
| virtual [llarp_dht_context](Classes/structllarp__dht__context.md) * | **[dht](Classes/structllarp_1_1AbstractRouter.md#function-dht)**() const =0 |
| virtual const std::shared_ptr< [NodeDB](Classes/classllarp_1_1NodeDB.md) > & | **[nodedb](Classes/structllarp_1_1AbstractRouter.md#function-nodedb)**() const =0 |
| virtual const [path::PathContext](Classes/structllarp_1_1path_1_1PathContext.md) & | **[pathContext](Classes/structllarp_1_1AbstractRouter.md#function-pathcontext)**() const =0 |
| virtual [path::PathContext](Classes/structllarp_1_1path_1_1PathContext.md) & | **[pathContext](Classes/structllarp_1_1AbstractRouter.md#function-pathcontext)**() =0 |
| virtual const [RouterContact](Classes/structllarp_1_1RouterContact.md) & | **[rc](Classes/structllarp_1_1AbstractRouter.md#function-rc)**() const =0 |
| virtual void | **[ModifyOurRC](Classes/structllarp_1_1AbstractRouter.md#function-modifyourrc)**(std::function< std::optional< [RouterContact](Classes/structllarp_1_1RouterContact.md) >([RouterContact](Classes/structllarp_1_1RouterContact.md))> modify) =0<br>modify our rc modify returns nullopt if unmodified otherwise it returns the new rc to be sigend and published out  |
| virtual [exit::Context](Classes/structllarp_1_1exit_1_1Context.md) & | **[exitContext](Classes/structllarp_1_1AbstractRouter.md#function-exitcontext)**() =0 |
| virtual const std::shared_ptr< [KeyManager](Classes/structllarp_1_1KeyManager.md) > & | **[keyManager](Classes/structllarp_1_1AbstractRouter.md#function-keymanager)**() const =0 |
| virtual const [SecretKey](Classes/structllarp_1_1SecretKey.md) & | **[identity](Classes/structllarp_1_1AbstractRouter.md#function-identity)**() const =0 |
| virtual const [SecretKey](Classes/structllarp_1_1SecretKey.md) & | **[encryption](Classes/structllarp_1_1AbstractRouter.md#function-encryption)**() const =0 |
| virtual [Profiling](Classes/structllarp_1_1Profiling.md) & | **[routerProfiling](Classes/structllarp_1_1AbstractRouter.md#function-routerprofiling)**() =0 |
| virtual const EventLoop_ptr & | **[loop](Classes/structllarp_1_1AbstractRouter.md#function-loop)**() const =0 |
| virtual void | **[QueueWork](Classes/structllarp_1_1AbstractRouter.md#function-queuework)**(std::function< void(void)> ) =0<br>call function in crypto worker  |
| virtual void | **[QueueDiskIO](Classes/structllarp_1_1AbstractRouter.md#function-queuediskio)**(std::function< void(void)> ) =0<br>call function in disk io thread  |
| virtual std::shared_ptr< [Config](Classes/structllarp_1_1Config.md) > | **[GetConfig](Classes/structllarp_1_1AbstractRouter.md#function-getconfig)**() const |
| virtual [service::Context](Classes/structllarp_1_1service_1_1Context.md) & | **[hiddenServiceContext](Classes/structllarp_1_1AbstractRouter.md#function-hiddenservicecontext)**() =0 |
| virtual const [service::Context](Classes/structllarp_1_1service_1_1Context.md) & | **[hiddenServiceContext](Classes/structllarp_1_1AbstractRouter.md#function-hiddenservicecontext)**() const =0 |
| virtual [IOutboundMessageHandler](Classes/structllarp_1_1IOutboundMessageHandler.md) & | **[outboundMessageHandler](Classes/structllarp_1_1AbstractRouter.md#function-outboundmessagehandler)**() =0 |
| virtual [IOutboundSessionMaker](Classes/structllarp_1_1IOutboundSessionMaker.md) & | **[outboundSessionMaker](Classes/structllarp_1_1AbstractRouter.md#function-outboundsessionmaker)**() =0 |
| virtual [ILinkManager](Classes/structllarp_1_1ILinkManager.md) & | **[linkManager](Classes/structllarp_1_1AbstractRouter.md#function-linkmanager)**() =0 |
| virtual const std::shared_ptr< [RoutePoker](Classes/structllarp_1_1RoutePoker.md) > & | **[routePoker](Classes/structllarp_1_1AbstractRouter.md#function-routepoker)**() const =0 |
| virtual [I_RCLookupHandler](Classes/structllarp_1_1I__RCLookupHandler.md) & | **[rcLookupHandler](Classes/structllarp_1_1AbstractRouter.md#function-rclookuphandler)**() =0 |
| virtual std::shared_ptr< [PeerDb](Classes/structllarp_1_1PeerDb.md) > | **[peerDb](Classes/structllarp_1_1AbstractRouter.md#function-peerdb)**() =0 |
| virtual bool | **[Sign](Classes/structllarp_1_1AbstractRouter.md#function-sign)**([Signature](Classes/structllarp_1_1Signature.md) & sig, const [llarp_buffer_t](Classes/structllarp__buffer__t.md) & buf) const =0 |
| virtual bool | **[Configure](Classes/structllarp_1_1AbstractRouter.md#function-configure)**(std::shared_ptr< [Config](Classes/structllarp_1_1Config.md) > conf, bool isSNode, std::shared_ptr< [NodeDB](Classes/classllarp_1_1NodeDB.md) > nodedb) =0 |
| virtual bool | **[IsServiceNode](Classes/structllarp_1_1AbstractRouter.md#function-isservicenode)**() const =0 |
| virtual std::optional< std::string > | **[OxendErrorState](Classes/structllarp_1_1AbstractRouter.md#function-oxenderrorstate)**() const =0<br>Called to determine if we're in a bad state (which gets reported to our oxend) that should prevent uptime proofs from going out to the network (so that the error state gets noticed).  |
| virtual bool | **[StartRpcServer](Classes/structllarp_1_1AbstractRouter.md#function-startrpcserver)**() =0 |
| virtual bool | **[Run](Classes/structllarp_1_1AbstractRouter.md#function-run)**() =0 |
| virtual bool | **[IsRunning](Classes/structllarp_1_1AbstractRouter.md#function-isrunning)**() const =0 |
| virtual bool | **[LooksAlive](Classes/structllarp_1_1AbstractRouter.md#function-looksalive)**() const =0 |
| virtual void | **[Stop](Classes/structllarp_1_1AbstractRouter.md#function-stop)**() =0<br>stop running the router logic gracefully  |
| virtual void | **[Freeze](Classes/structllarp_1_1AbstractRouter.md#function-freeze)**() =0<br>indicate we are about to sleep for a while  |
| virtual void | **[Thaw](Classes/structllarp_1_1AbstractRouter.md#function-thaw)**() =0<br>thaw from long sleep or network changed event  |
| virtual void | **[Die](Classes/structllarp_1_1AbstractRouter.md#function-die)**() =0<br>non gracefully stop the router  |
| virtual void | **[TriggerPump](Classes/structllarp_1_1AbstractRouter.md#function-triggerpump)**() =0<br>Trigger a pump of low level links. Idempotent.  |
| virtual bool | **[IsBootstrapNode](Classes/structllarp_1_1AbstractRouter.md#function-isbootstrapnode)**([RouterID](Classes/structllarp_1_1RouterID.md) r) const =0 |
| virtual const byte_t * | **[pubkey](Classes/structllarp_1_1AbstractRouter.md#function-pubkey)**() const =0 |
| virtual std::optional< std::variant< nuint32_t, nuint128_t > > | **[OurPublicIP](Classes/structllarp_1_1AbstractRouter.md#function-ourpublicip)**() const =0<br>get what our real public ip is if we can know it  |
| virtual void | **[ConnectToRandomRouters](Classes/structllarp_1_1AbstractRouter.md#function-connecttorandomrouters)**(int N) =0<br>connect to N random routers  |
| virtual bool | **[TryConnectAsync](Classes/structllarp_1_1AbstractRouter.md#function-tryconnectasync)**([RouterContact](Classes/structllarp_1_1RouterContact.md) rc, uint16_t tries) =0 |
| virtual void | **[SessionClosed](Classes/structllarp_1_1AbstractRouter.md#function-sessionclosed)**([RouterID](Classes/structllarp_1_1RouterID.md) remote) =0<br>called by link when a remote session has no more sessions open  |
| virtual llarp_time_t | **[Now](Classes/structllarp_1_1AbstractRouter.md#function-now)**() const =0<br>returns system clock milliseconds since epoch  |
| virtual llarp_time_t | **[Uptime](Classes/structllarp_1_1AbstractRouter.md#function-uptime)**() const =0<br>returns milliseconds since started  |
| virtual bool | **[GetRandomGoodRouter](Classes/structllarp_1_1AbstractRouter.md#function-getrandomgoodrouter)**([RouterID](Classes/structllarp_1_1RouterID.md) & r) =0 |
| virtual bool | **[SendToOrQueue](Classes/structllarp_1_1AbstractRouter.md#function-sendtoorqueue)**(const [RouterID](Classes/structllarp_1_1RouterID.md) & remote, const [ILinkMessage](Classes/structllarp_1_1ILinkMessage.md) & msg, SendStatusHandler handler =nullptr) =0 |
| virtual void | **[PersistSessionUntil](Classes/structllarp_1_1AbstractRouter.md#function-persistsessionuntil)**(const [RouterID](Classes/structllarp_1_1RouterID.md) & remote, llarp_time_t until) =0 |
| virtual bool | **[ParseRoutingMessageBuffer](Classes/structllarp_1_1AbstractRouter.md#function-parseroutingmessagebuffer)**(const [llarp_buffer_t](Classes/structllarp__buffer__t.md) & buf, [routing::IMessageHandler](Classes/structllarp_1_1routing_1_1IMessageHandler.md) * h, const [PathID_t](Classes/structllarp_1_1PathID__t.md) & rxid) =0 |
| virtual size_t | **[NumberOfConnectedRouters](Classes/structllarp_1_1AbstractRouter.md#function-numberofconnectedrouters)**() const =0<br>count the number of service nodes we are connected to  |
| virtual size_t | **[NumberOfConnectedClients](Classes/structllarp_1_1AbstractRouter.md#function-numberofconnectedclients)**() const =0<br>count the number of clients that are connected to us  |
| virtual bool | **[GetRandomConnectedRouter](Classes/structllarp_1_1AbstractRouter.md#function-getrandomconnectedrouter)**([RouterContact](Classes/structllarp_1_1RouterContact.md) & result) const =0 |
| virtual void | **[HandleDHTLookupForExplore](Classes/structllarp_1_1AbstractRouter.md#function-handledhtlookupforexplore)**([RouterID](Classes/structllarp_1_1RouterID.md) remote, const std::vector< [RouterContact](Classes/structllarp_1_1RouterContact.md) > & results) =0 |
| virtual void | **[SetDownHook](Classes/structllarp_1_1AbstractRouter.md#function-setdownhook)**(std::function< void(void)> ) |
| virtual void | **[LookupRouter](Classes/structllarp_1_1AbstractRouter.md#function-lookuprouter)**([RouterID](Classes/structllarp_1_1RouterID.md) remote, RouterLookupHandler resultHandler) =0<br>lookup router by pubkey if we are a service node this is done direct otherwise it's done via path  |
| virtual bool | **[CheckRenegotiateValid](Classes/structllarp_1_1AbstractRouter.md#function-checkrenegotiatevalid)**([RouterContact](Classes/structllarp_1_1RouterContact.md) newRc, [RouterContact](Classes/structllarp_1_1RouterContact.md) oldRC) =0<br>check if newRc matches oldRC and update local rc for this remote contact if valid returns true on valid and updated returns false otherwise  |
| virtual void | **[SetRouterWhitelist](Classes/structllarp_1_1AbstractRouter.md#function-setrouterwhitelist)**(const std::vector< [RouterID](Classes/structllarp_1_1RouterID.md) > & whitelist, const std::vector< [RouterID](Classes/structllarp_1_1RouterID.md) > & greylist, const std::vector< [RouterID](Classes/structllarp_1_1RouterID.md) > & unfundedlist) =0<br>set router's service node whitelist  |
| virtual std::unordered_set< [RouterID](Classes/structllarp_1_1RouterID.md) > | **[GetRouterWhitelist](Classes/structllarp_1_1AbstractRouter.md#function-getrouterwhitelist)**() const =0 |
| virtual void | **[ForEachPeer](Classes/structllarp_1_1AbstractRouter.md#function-foreachpeer)**(std::function< void(const [ILinkSession](Classes/structllarp_1_1ILinkSession.md) *, bool)> visit, bool randomize) const =0<br>visit each connected link session  |
| virtual bool | **[SessionToRouterAllowed](Classes/structllarp_1_1AbstractRouter.md#function-sessiontorouterallowed)**(const [RouterID](Classes/structllarp_1_1RouterID.md) & router) const =0 |
| virtual bool | **[PathToRouterAllowed](Classes/structllarp_1_1AbstractRouter.md#function-pathtorouterallowed)**(const [RouterID](Classes/structllarp_1_1RouterID.md) & router) const =0 |
| virtual bool | **[HasClientExit](Classes/structllarp_1_1AbstractRouter.md#function-hasclientexit)**() const<br>return true if we have an exit as a client  |
| virtual [path::BuildLimiter](Classes/classllarp_1_1path_1_1BuildLimiter.md) & | **[pathBuildLimiter](Classes/structllarp_1_1AbstractRouter.md#function-pathbuildlimiter)**() =0 |
| virtual bool | **[HasSessionTo](Classes/structllarp_1_1AbstractRouter.md#function-hassessionto)**(const [RouterID](Classes/structllarp_1_1RouterID.md) & router) const =0<br>return true if we have at least 1 session to this router in either direction  |
| virtual uint32_t | **[NextPathBuildNumber](Classes/structllarp_1_1AbstractRouter.md#function-nextpathbuildnumber)**() =0 |
| virtual std::string | **[ShortName](Classes/structllarp_1_1AbstractRouter.md#function-shortname)**() const =0 |
| virtual util::StatusObject | **[ExtractStatus](Classes/structllarp_1_1AbstractRouter.md#function-extractstatus)**() const =0 |
| virtual util::StatusObject | **[ExtractSummaryStatus](Classes/structllarp_1_1AbstractRouter.md#function-extractsummarystatus)**() const =0 |
| virtual void | **[GossipRCIfNeeded](Classes/structllarp_1_1AbstractRouter.md#function-gossiprcifneeded)**(const [RouterContact](Classes/structllarp_1_1RouterContact.md) rc) =0<br>gossip an rc if required  |
| template <class EventType ,class... Params\> <br>void | **[NotifyRouterEvent](Classes/structllarp_1_1AbstractRouter.md#function-notifyrouterevent)**(] Params &&... args) const<br>Templated convenience function to generate a RouterHive event and delegate to non-templated (and overridable) function for handling.  |
| virtual int | **[OutboundUDPSocket](Classes/structllarp_1_1AbstractRouter.md#function-outboundudpsocket)**() const |

## Protected Functions

|                | Name           |
| -------------- | -------------- |
| virtual void | **[HandleRouterEvent](Classes/structllarp_1_1AbstractRouter.md#function-handlerouterevent)**(tooling::RouterEventPtr event) const =0<br>Virtual function to handle RouterEvent.  |

## Public Functions Documentation

### function ~AbstractRouter

```cpp
virtual ~AbstractRouter() =default
```


### function HandleRecvLinkMessageBuffer

```cpp
virtual bool HandleRecvLinkMessageBuffer(
    ILinkSession * from,
    const llarp_buffer_t & msg
) =0
```


**Reimplemented by**: [llarp::Router::HandleRecvLinkMessageBuffer](Classes/structllarp_1_1Router.md#function-handlerecvlinkmessagebuffer)


### function Net

```cpp
virtual const net::Platform & Net() const =0
```


**Reimplemented by**: [llarp::Router::Net](Classes/structllarp_1_1Router.md#function-net)


### function lmq

```cpp
virtual const LMQ_ptr & lmq() const =0
```


**Reimplemented by**: [llarp::Router::lmq](Classes/structllarp_1_1Router.md#function-lmq)


### function GetVPNPlatform

```cpp
virtual vpn::Platform * GetVPNPlatform() const =0
```


**Reimplemented by**: [llarp::Router::GetVPNPlatform](Classes/structllarp_1_1Router.md#function-getvpnplatform)


### function RpcClient

```cpp
virtual const std::shared_ptr< rpc::LokidRpcClient > & RpcClient() const =0
```


**Reimplemented by**: [llarp::Router::RpcClient](Classes/structllarp_1_1Router.md#function-rpcclient)


### function dht

```cpp
virtual llarp_dht_context * dht() const =0
```


**Reimplemented by**: [llarp::Router::dht](Classes/structllarp_1_1Router.md#function-dht)


### function nodedb

```cpp
virtual const std::shared_ptr< NodeDB > & nodedb() const =0
```


**Reimplemented by**: [llarp::Router::nodedb](Classes/structllarp_1_1Router.md#function-nodedb)


### function pathContext

```cpp
virtual const path::PathContext & pathContext() const =0
```


**Reimplemented by**: [llarp::Router::pathContext](Classes/structllarp_1_1Router.md#function-pathcontext)


### function pathContext

```cpp
virtual path::PathContext & pathContext() =0
```


**Reimplemented by**: [llarp::Router::pathContext](Classes/structllarp_1_1Router.md#function-pathcontext)


### function rc

```cpp
virtual const RouterContact & rc() const =0
```


**Reimplemented by**: [llarp::Router::rc](Classes/structllarp_1_1Router.md#function-rc)


### function ModifyOurRC

```cpp
virtual void ModifyOurRC(
    std::function< std::optional< RouterContact >(RouterContact)> modify
) =0
```

modify our rc modify returns nullopt if unmodified otherwise it returns the new rc to be sigend and published out 

**Reimplemented by**: [llarp::Router::ModifyOurRC](Classes/structllarp_1_1Router.md#function-modifyourrc)


### function exitContext

```cpp
virtual exit::Context & exitContext() =0
```


**Reimplemented by**: [llarp::Router::exitContext](Classes/structllarp_1_1Router.md#function-exitcontext)


### function keyManager

```cpp
virtual const std::shared_ptr< KeyManager > & keyManager() const =0
```


**Reimplemented by**: [llarp::Router::keyManager](Classes/structllarp_1_1Router.md#function-keymanager)


### function identity

```cpp
virtual const SecretKey & identity() const =0
```


**Reimplemented by**: [llarp::Router::identity](Classes/structllarp_1_1Router.md#function-identity)


### function encryption

```cpp
virtual const SecretKey & encryption() const =0
```


**Reimplemented by**: [llarp::Router::encryption](Classes/structllarp_1_1Router.md#function-encryption)


### function routerProfiling

```cpp
virtual Profiling & routerProfiling() =0
```


**Reimplemented by**: [llarp::Router::routerProfiling](Classes/structllarp_1_1Router.md#function-routerprofiling)


### function loop

```cpp
virtual const EventLoop_ptr & loop() const =0
```


**Reimplemented by**: [llarp::Router::loop](Classes/structllarp_1_1Router.md#function-loop)


### function QueueWork

```cpp
virtual void QueueWork(
    std::function< void(void)> 
) =0
```

call function in crypto worker 

**Reimplemented by**: [llarp::Router::QueueWork](Classes/structllarp_1_1Router.md#function-queuework)


### function QueueDiskIO

```cpp
virtual void QueueDiskIO(
    std::function< void(void)> 
) =0
```

call function in disk io thread 

**Reimplemented by**: [llarp::Router::QueueDiskIO](Classes/structllarp_1_1Router.md#function-queuediskio)


### function GetConfig

```cpp
inline virtual std::shared_ptr< Config > GetConfig() const
```


**Reimplemented by**: [llarp::Router::GetConfig](Classes/structllarp_1_1Router.md#function-getconfig)


### function hiddenServiceContext

```cpp
virtual service::Context & hiddenServiceContext() =0
```


**Reimplemented by**: [llarp::Router::hiddenServiceContext](Classes/structllarp_1_1Router.md#function-hiddenservicecontext)


### function hiddenServiceContext

```cpp
virtual const service::Context & hiddenServiceContext() const =0
```


**Reimplemented by**: [llarp::Router::hiddenServiceContext](Classes/structllarp_1_1Router.md#function-hiddenservicecontext)


### function outboundMessageHandler

```cpp
virtual IOutboundMessageHandler & outboundMessageHandler() =0
```


**Reimplemented by**: [llarp::Router::outboundMessageHandler](Classes/structllarp_1_1Router.md#function-outboundmessagehandler)


### function outboundSessionMaker

```cpp
virtual IOutboundSessionMaker & outboundSessionMaker() =0
```


**Reimplemented by**: [llarp::Router::outboundSessionMaker](Classes/structllarp_1_1Router.md#function-outboundsessionmaker)


### function linkManager

```cpp
virtual ILinkManager & linkManager() =0
```


**Reimplemented by**: [llarp::Router::linkManager](Classes/structllarp_1_1Router.md#function-linkmanager)


### function routePoker

```cpp
virtual const std::shared_ptr< RoutePoker > & routePoker() const =0
```


**Reimplemented by**: [llarp::Router::routePoker](Classes/structllarp_1_1Router.md#function-routepoker)


### function rcLookupHandler

```cpp
virtual I_RCLookupHandler & rcLookupHandler() =0
```


**Reimplemented by**: [llarp::Router::rcLookupHandler](Classes/structllarp_1_1Router.md#function-rclookuphandler)


### function peerDb

```cpp
virtual std::shared_ptr< PeerDb > peerDb() =0
```


**Reimplemented by**: [llarp::Router::peerDb](Classes/structllarp_1_1Router.md#function-peerdb)


### function Sign

```cpp
virtual bool Sign(
    Signature & sig,
    const llarp_buffer_t & buf
) const =0
```


**Reimplemented by**: [llarp::Router::Sign](Classes/structllarp_1_1Router.md#function-sign)


### function Configure

```cpp
virtual bool Configure(
    std::shared_ptr< Config > conf,
    bool isSNode,
    std::shared_ptr< NodeDB > nodedb
) =0
```


**Reimplemented by**: [llarp::Router::Configure](Classes/structllarp_1_1Router.md#function-configure)


### function IsServiceNode

```cpp
virtual bool IsServiceNode() const =0
```


**Reimplemented by**: [llarp::Router::IsServiceNode](Classes/structllarp_1_1Router.md#function-isservicenode)


### function OxendErrorState

```cpp
virtual std::optional< std::string > OxendErrorState() const =0
```

Called to determine if we're in a bad state (which gets reported to our oxend) that should prevent uptime proofs from going out to the network (so that the error state gets noticed). 

**Reimplemented by**: [llarp::Router::OxendErrorState](Classes/structllarp_1_1Router.md#function-oxenderrorstate)


Currently this means we require a decent number of peers whenever we are fully staked (active or decommed). 


### function StartRpcServer

```cpp
virtual bool StartRpcServer() =0
```


**Reimplemented by**: [llarp::Router::StartRpcServer](Classes/structllarp_1_1Router.md#function-startrpcserver)


### function Run

```cpp
virtual bool Run() =0
```


**Reimplemented by**: [llarp::Router::Run](Classes/structllarp_1_1Router.md#function-run)


### function IsRunning

```cpp
virtual bool IsRunning() const =0
```


**Reimplemented by**: [llarp::Router::IsRunning](Classes/structllarp_1_1Router.md#function-isrunning)


### function LooksAlive

```cpp
virtual bool LooksAlive() const =0
```


**Reimplemented by**: [llarp::Router::LooksAlive](Classes/structllarp_1_1Router.md#function-looksalive)


### function Stop

```cpp
virtual void Stop() =0
```

stop running the router logic gracefully 

**Reimplemented by**: [llarp::Router::Stop](Classes/structllarp_1_1Router.md#function-stop)


### function Freeze

```cpp
virtual void Freeze() =0
```

indicate we are about to sleep for a while 

**Reimplemented by**: [llarp::Router::Freeze](Classes/structllarp_1_1Router.md#function-freeze)


### function Thaw

```cpp
virtual void Thaw() =0
```

thaw from long sleep or network changed event 

**Reimplemented by**: [llarp::Router::Thaw](Classes/structllarp_1_1Router.md#function-thaw)


### function Die

```cpp
virtual void Die() =0
```

non gracefully stop the router 

**Reimplemented by**: [llarp::Router::Die](Classes/structllarp_1_1Router.md#function-die)


### function TriggerPump

```cpp
virtual void TriggerPump() =0
```

Trigger a pump of low level links. Idempotent. 

**Reimplemented by**: [llarp::Router::TriggerPump](Classes/structllarp_1_1Router.md#function-triggerpump)


### function IsBootstrapNode

```cpp
virtual bool IsBootstrapNode(
    RouterID r
) const =0
```


**Reimplemented by**: [llarp::Router::IsBootstrapNode](Classes/structllarp_1_1Router.md#function-isbootstrapnode)


### function pubkey

```cpp
virtual const byte_t * pubkey() const =0
```


**Reimplemented by**: [llarp::Router::pubkey](Classes/structllarp_1_1Router.md#function-pubkey)


### function OurPublicIP

```cpp
virtual std::optional< std::variant< nuint32_t, nuint128_t > > OurPublicIP() const =0
```

get what our real public ip is if we can know it 

**Reimplemented by**: [llarp::Router::OurPublicIP](Classes/structllarp_1_1Router.md#function-ourpublicip)


### function ConnectToRandomRouters

```cpp
virtual void ConnectToRandomRouters(
    int N
) =0
```

connect to N random routers 

**Reimplemented by**: [llarp::Router::ConnectToRandomRouters](Classes/structllarp_1_1Router.md#function-connecttorandomrouters)


### function TryConnectAsync

```cpp
virtual bool TryConnectAsync(
    RouterContact rc,
    uint16_t tries
) =0
```


**Reimplemented by**: [llarp::Router::TryConnectAsync](Classes/structllarp_1_1Router.md#function-tryconnectasync)


### function SessionClosed

```cpp
virtual void SessionClosed(
    RouterID remote
) =0
```

called by link when a remote session has no more sessions open 

**Reimplemented by**: [llarp::Router::SessionClosed](Classes/structllarp_1_1Router.md#function-sessionclosed)


### function Now

```cpp
virtual llarp_time_t Now() const =0
```

returns system clock milliseconds since epoch 

**Reimplemented by**: [llarp::Router::Now](Classes/structllarp_1_1Router.md#function-now)


### function Uptime

```cpp
virtual llarp_time_t Uptime() const =0
```

returns milliseconds since started 

**Reimplemented by**: [llarp::Router::Uptime](Classes/structllarp_1_1Router.md#function-uptime)


### function GetRandomGoodRouter

```cpp
virtual bool GetRandomGoodRouter(
    RouterID & r
) =0
```


**Reimplemented by**: [llarp::Router::GetRandomGoodRouter](Classes/structllarp_1_1Router.md#function-getrandomgoodrouter)


### function SendToOrQueue

```cpp
virtual bool SendToOrQueue(
    const RouterID & remote,
    const ILinkMessage & msg,
    SendStatusHandler handler =nullptr
) =0
```


**Reimplemented by**: [llarp::Router::SendToOrQueue](Classes/structllarp_1_1Router.md#function-sendtoorqueue)


### function PersistSessionUntil

```cpp
virtual void PersistSessionUntil(
    const RouterID & remote,
    llarp_time_t until
) =0
```


**Reimplemented by**: [llarp::Router::PersistSessionUntil](Classes/structllarp_1_1Router.md#function-persistsessionuntil)


### function ParseRoutingMessageBuffer

```cpp
virtual bool ParseRoutingMessageBuffer(
    const llarp_buffer_t & buf,
    routing::IMessageHandler * h,
    const PathID_t & rxid
) =0
```


**Reimplemented by**: [llarp::Router::ParseRoutingMessageBuffer](Classes/structllarp_1_1Router.md#function-parseroutingmessagebuffer)


### function NumberOfConnectedRouters

```cpp
virtual size_t NumberOfConnectedRouters() const =0
```

count the number of service nodes we are connected to 

**Reimplemented by**: [llarp::Router::NumberOfConnectedRouters](Classes/structllarp_1_1Router.md#function-numberofconnectedrouters)


### function NumberOfConnectedClients

```cpp
virtual size_t NumberOfConnectedClients() const =0
```

count the number of clients that are connected to us 

**Reimplemented by**: [llarp::Router::NumberOfConnectedClients](Classes/structllarp_1_1Router.md#function-numberofconnectedclients)


### function GetRandomConnectedRouter

```cpp
virtual bool GetRandomConnectedRouter(
    RouterContact & result
) const =0
```


**Reimplemented by**: [llarp::Router::GetRandomConnectedRouter](Classes/structllarp_1_1Router.md#function-getrandomconnectedrouter)


### function HandleDHTLookupForExplore

```cpp
virtual void HandleDHTLookupForExplore(
    RouterID remote,
    const std::vector< RouterContact > & results
) =0
```


**Reimplemented by**: [llarp::Router::HandleDHTLookupForExplore](Classes/structllarp_1_1Router.md#function-handledhtlookupforexplore)


### function SetDownHook

```cpp
inline virtual void SetDownHook(
    std::function< void(void)> 
)
```


**Reimplemented by**: [llarp::Router::SetDownHook](Classes/structllarp_1_1Router.md#function-setdownhook)


### function LookupRouter

```cpp
virtual void LookupRouter(
    RouterID remote,
    RouterLookupHandler resultHandler
) =0
```

lookup router by pubkey if we are a service node this is done direct otherwise it's done via path 

**Reimplemented by**: [llarp::Router::LookupRouter](Classes/structllarp_1_1Router.md#function-lookuprouter)


### function CheckRenegotiateValid

```cpp
virtual bool CheckRenegotiateValid(
    RouterContact newRc,
    RouterContact oldRC
) =0
```

check if newRc matches oldRC and update local rc for this remote contact if valid returns true on valid and updated returns false otherwise 

**Reimplemented by**: [llarp::Router::CheckRenegotiateValid](Classes/structllarp_1_1Router.md#function-checkrenegotiatevalid)


### function SetRouterWhitelist

```cpp
virtual void SetRouterWhitelist(
    const std::vector< RouterID > & whitelist,
    const std::vector< RouterID > & greylist,
    const std::vector< RouterID > & unfundedlist
) =0
```

set router's service node whitelist 

**Reimplemented by**: [llarp::Router::SetRouterWhitelist](Classes/structllarp_1_1Router.md#function-setrouterwhitelist)


### function GetRouterWhitelist

```cpp
virtual std::unordered_set< RouterID > GetRouterWhitelist() const =0
```


**Reimplemented by**: [llarp::Router::GetRouterWhitelist](Classes/structllarp_1_1Router.md#function-getrouterwhitelist)


### function ForEachPeer

```cpp
virtual void ForEachPeer(
    std::function< void(const ILinkSession *, bool)> visit,
    bool randomize
) const =0
```

visit each connected link session 

**Reimplemented by**: [llarp::Router::ForEachPeer](Classes/structllarp_1_1Router.md#function-foreachpeer)


### function SessionToRouterAllowed

```cpp
virtual bool SessionToRouterAllowed(
    const RouterID & router
) const =0
```


**Reimplemented by**: [llarp::Router::SessionToRouterAllowed](Classes/structllarp_1_1Router.md#function-sessiontorouterallowed)


### function PathToRouterAllowed

```cpp
virtual bool PathToRouterAllowed(
    const RouterID & router
) const =0
```


**Reimplemented by**: [llarp::Router::PathToRouterAllowed](Classes/structllarp_1_1Router.md#function-pathtorouterallowed)


### function HasClientExit

```cpp
inline virtual bool HasClientExit() const
```

return true if we have an exit as a client 

**Reimplemented by**: [llarp::Router::HasClientExit](Classes/structllarp_1_1Router.md#function-hasclientexit)


### function pathBuildLimiter

```cpp
virtual path::BuildLimiter & pathBuildLimiter() =0
```


**Reimplemented by**: [llarp::Router::pathBuildLimiter](Classes/structllarp_1_1Router.md#function-pathbuildlimiter)


### function HasSessionTo

```cpp
virtual bool HasSessionTo(
    const RouterID & router
) const =0
```

return true if we have at least 1 session to this router in either direction 

**Reimplemented by**: [llarp::Router::HasSessionTo](Classes/structllarp_1_1Router.md#function-hassessionto)


### function NextPathBuildNumber

```cpp
virtual uint32_t NextPathBuildNumber() =0
```


**Reimplemented by**: [llarp::Router::NextPathBuildNumber](Classes/structllarp_1_1Router.md#function-nextpathbuildnumber)


### function ShortName

```cpp
virtual std::string ShortName() const =0
```


**Reimplemented by**: [llarp::Router::ShortName](Classes/structllarp_1_1Router.md#function-shortname)


### function ExtractStatus

```cpp
virtual util::StatusObject ExtractStatus() const =0
```


**Reimplemented by**: [llarp::Router::ExtractStatus](Classes/structllarp_1_1Router.md#function-extractstatus)


### function ExtractSummaryStatus

```cpp
virtual util::StatusObject ExtractSummaryStatus() const =0
```


**Reimplemented by**: [llarp::Router::ExtractSummaryStatus](Classes/structllarp_1_1Router.md#function-extractsummarystatus)


### function GossipRCIfNeeded

```cpp
virtual void GossipRCIfNeeded(
    const RouterContact rc
) =0
```

gossip an rc if required 

**Reimplemented by**: [llarp::Router::GossipRCIfNeeded](Classes/structllarp_1_1Router.md#function-gossiprcifneeded)


### function NotifyRouterEvent

```cpp
template <class EventType ,
class... Params>
inline void NotifyRouterEvent(
    ] Params &&... args
) const
```

Templated convenience function to generate a RouterHive event and delegate to non-templated (and overridable) function for handling. 

### function OutboundUDPSocket

```cpp
inline virtual int OutboundUDPSocket() const
```


**Reimplemented by**: [llarp::Router::OutboundUDPSocket](Classes/structllarp_1_1Router.md#function-outboundudpsocket)


## Protected Functions Documentation

### function HandleRouterEvent

```cpp
virtual void HandleRouterEvent(
    tooling::RouterEventPtr event
) const =0
```

Virtual function to handle RouterEvent. 

**Reimplemented by**: [tooling::HiveRouter::HandleRouterEvent](Classes/structtooling_1_1HiveRouter.md#function-handlerouterevent), [llarp::Router::HandleRouterEvent](Classes/structllarp_1_1Router.md#function-handlerouterevent)


HiveRouter overrides this in order to inject the event. The default implementation in [Router](Classes/structllarp_1_1Router.md) simply logs it. 


-------------------------------

Updated on 2022-10-26 at 17:18:02 +0000