---
title: llarp::handlers::ExitEndpoint

---

# llarp::handlers::ExitEndpoint





Inherits from [llarp::dns::Resolver_Base](Classes/classllarp_1_1dns_1_1Resolver__Base.md), [llarp::EndpointBase](Classes/classllarp_1_1EndpointBase.md)

## Public Functions

|                | Name           |
| -------------- | -------------- |
| virtual int | **[Rank](Classes/structllarp_1_1handlers_1_1ExitEndpoint.md#function-rank)**() const override<br>return the sorting order for this resolver lower means it will be tried first  |
| virtual std::string_view | **[ResolverName](Classes/structllarp_1_1handlers_1_1ExitEndpoint.md#function-resolvername)**() const override<br>get printable name  |
| virtual bool | **[MaybeHookDNS](Classes/structllarp_1_1handlers_1_1ExitEndpoint.md#function-maybehookdns)**(std::shared_ptr< [dns::PacketSource_Base](Classes/classllarp_1_1dns_1_1PacketSource__Base.md) > source, const [dns::Message](Classes/structllarp_1_1dns_1_1Message.md) & query, const [SockAddr](Classes/structllarp_1_1SockAddr.md) & to, const [SockAddr](Classes/structllarp_1_1SockAddr.md) & from) override<br>attempt to handle a dns message returns true if we consumed this query and it should not be processed again  |
| | **[ExitEndpoint](Classes/structllarp_1_1handlers_1_1ExitEndpoint.md#function-exitendpoint)**(std::string name, [AbstractRouter](Classes/structllarp_1_1AbstractRouter.md) * r) |
| | **[~ExitEndpoint](Classes/structllarp_1_1handlers_1_1ExitEndpoint.md#function-~exitendpoint)**() override |
| virtual std::optional< AddressVariant_t > | **[GetEndpointWithConvoTag](Classes/structllarp_1_1handlers_1_1ExitEndpoint.md#function-getendpointwithconvotag)**([service::ConvoTag](Classes/structllarp_1_1service_1_1ConvoTag.md) tag) const override |
| virtual std::optional< [service::ConvoTag](Classes/structllarp_1_1service_1_1ConvoTag.md) > | **[GetBestConvoTagFor](Classes/structllarp_1_1handlers_1_1ExitEndpoint.md#function-getbestconvotagfor)**(AddressVariant_t addr) const override |
| virtual bool | **[EnsurePathTo](Classes/structllarp_1_1handlers_1_1ExitEndpoint.md#function-ensurepathto)**(AddressVariant_t addr, std::function< void(std::optional< [service::ConvoTag](Classes/structllarp_1_1service_1_1ConvoTag.md) >)> hook, llarp_time_t timeout) override |
| virtual void | **[LookupNameAsync](Classes/structllarp_1_1handlers_1_1ExitEndpoint.md#function-lookupnameasync)**(std::string name, std::function< void(std::optional< AddressVariant_t >)> resultHandler) override |
| virtual const EventLoop_ptr & | **[Loop](Classes/structllarp_1_1handlers_1_1ExitEndpoint.md#function-loop)**() override |
| virtual std::unordered_set< EndpointBase::AddressVariant_t > | **[AllRemoteEndpoints](Classes/structllarp_1_1handlers_1_1ExitEndpoint.md#function-allremoteendpoints)**() const override<br>list all remote endpoint addresses we have that are mapped  |
| virtual void | **[SRVRecordsChanged](Classes/structllarp_1_1handlers_1_1ExitEndpoint.md#function-srvrecordschanged)**() override<br>called when srv data changes in some way  |
| virtual void | **[MarkAddressOutbound](Classes/structllarp_1_1handlers_1_1ExitEndpoint.md#function-markaddressoutbound)**(AddressVariant_t ) override |
| virtual bool | **[SendToOrQueue](Classes/structllarp_1_1handlers_1_1ExitEndpoint.md#function-sendtoorqueue)**([service::ConvoTag](Classes/structllarp_1_1service_1_1ConvoTag.md) tag, const [llarp_buffer_t](Classes/structllarp__buffer__t.md) & payload, service::ProtocolType t) override |
| void | **[Tick](Classes/structllarp_1_1handlers_1_1ExitEndpoint.md#function-tick)**(llarp_time_t now) |
| void | **[Configure](Classes/structllarp_1_1handlers_1_1ExitEndpoint.md#function-configure)**(const [NetworkConfig](Classes/structllarp_1_1NetworkConfig.md) & networkConfig, const [DnsConfig](Classes/structllarp_1_1DnsConfig.md) & dnsConfig) |
| std::string | **[Name](Classes/structllarp_1_1handlers_1_1ExitEndpoint.md#function-name)**() const |
| bool | **[VisitEndpointsFor](Classes/structllarp_1_1handlers_1_1ExitEndpoint.md#function-visitendpointsfor)**(const [PubKey](Classes/structllarp_1_1PubKey.md) & pk, std::function< bool([exit::Endpoint](Classes/structllarp_1_1exit_1_1Endpoint.md) *const)> visit) const |
| util::StatusObject | **[ExtractStatus](Classes/structllarp_1_1handlers_1_1ExitEndpoint.md#function-extractstatus)**() const |
| bool | **[SupportsV6](Classes/structllarp_1_1handlers_1_1ExitEndpoint.md#function-supportsv6)**() const |
| bool | **[ShouldHookDNSMessage](Classes/structllarp_1_1handlers_1_1ExitEndpoint.md#function-shouldhookdnsmessage)**(const [dns::Message](Classes/structllarp_1_1dns_1_1Message.md) & msg) const |
| bool | **[HandleHookedDNSMessage](Classes/structllarp_1_1handlers_1_1ExitEndpoint.md#function-handlehookeddnsmessage)**([dns::Message](Classes/structllarp_1_1dns_1_1Message.md) msg, std::function< void([dns::Message](Classes/structllarp_1_1dns_1_1Message.md))> ) |
| virtual void | **[LookupServiceAsync](Classes/structllarp_1_1handlers_1_1ExitEndpoint.md#function-lookupserviceasync)**(std::string name, std::string service, std::function< void(std::vector< [dns::SRVData](Classes/structllarp_1_1dns_1_1SRVData.md) >)> resultHandler) override<br>lookup srv records async  |
| bool | **[AllocateNewExit](Classes/structllarp_1_1handlers_1_1ExitEndpoint.md#function-allocatenewexit)**(const [PubKey](Classes/structllarp_1_1PubKey.md) pk, const [PathID_t](Classes/structllarp_1_1PathID__t.md) & path, bool permitInternet) |
| [exit::Endpoint](Classes/structllarp_1_1exit_1_1Endpoint.md) * | **[FindEndpointByPath](Classes/structllarp_1_1handlers_1_1ExitEndpoint.md#function-findendpointbypath)**(const [PathID_t](Classes/structllarp_1_1PathID__t.md) & path) |
| [exit::Endpoint](Classes/structllarp_1_1exit_1_1Endpoint.md) * | **[FindEndpointByIP](Classes/structllarp_1_1handlers_1_1ExitEndpoint.md#function-findendpointbyip)**([huint32_t](Classes/structllarp_1_1huint__t.md) ip) |
| bool | **[UpdateEndpointPath](Classes/structllarp_1_1handlers_1_1ExitEndpoint.md#function-updateendpointpath)**(const [PubKey](Classes/structllarp_1_1PubKey.md) & remote, const [PathID_t](Classes/structllarp_1_1PathID__t.md) & next) |
| void | **[OnInetPacket](Classes/structllarp_1_1handlers_1_1ExitEndpoint.md#function-oninetpacket)**([net::IPPacket](Classes/structllarp_1_1net_1_1IPPacket.md) buf)<br>handle ip packet from outside  |
| [AbstractRouter](Classes/structllarp_1_1AbstractRouter.md) * | **[GetRouter](Classes/structllarp_1_1handlers_1_1ExitEndpoint.md#function-getrouter)**() |
| llarp_time_t | **[Now](Classes/structllarp_1_1handlers_1_1ExitEndpoint.md#function-now)**() const |
| template <typename Stats \> <br>void | **[CalculateTrafficStats](Classes/structllarp_1_1handlers_1_1ExitEndpoint.md#function-calculatetrafficstats)**(Stats & stats) |
| void | **[DelEndpointInfo](Classes/structllarp_1_1handlers_1_1ExitEndpoint.md#function-delendpointinfo)**(const [PathID_t](Classes/structllarp_1_1PathID__t.md) & path)<br>DO NOT CALL ME.  |
| void | **[RemoveExit](Classes/structllarp_1_1handlers_1_1ExitEndpoint.md#function-removeexit)**(const [exit::Endpoint](Classes/structllarp_1_1exit_1_1Endpoint.md) * ep)<br>DO NOT CALL ME.  |
| bool | **[QueueOutboundTraffic](Classes/structllarp_1_1handlers_1_1ExitEndpoint.md#function-queueoutboundtraffic)**([net::IPPacket](Classes/structllarp_1_1net_1_1IPPacket.md) pkt) |
| virtual AddressVariant_t | **[LocalAddress](Classes/structllarp_1_1handlers_1_1ExitEndpoint.md#function-localaddress)**() const override<br>get our local address  |
| virtual std::optional< [SendStat](Classes/structllarp_1_1EndpointBase_1_1SendStat.md) > | **[GetStatFor](Classes/structllarp_1_1handlers_1_1ExitEndpoint.md#function-getstatfor)**(AddressVariant_t remote) const override<br>get statistics about how much traffic we sent and recv'd to a remote endpoint  |
| bool | **[Start](Classes/structllarp_1_1handlers_1_1ExitEndpoint.md#function-start)**()<br>sets up networking and starts traffic  |
| bool | **[Stop](Classes/structllarp_1_1handlers_1_1ExitEndpoint.md#function-stop)**() |
| bool | **[ShouldRemove](Classes/structllarp_1_1handlers_1_1ExitEndpoint.md#function-shouldremove)**() const |
| bool | **[HasLocalMappedAddrFor](Classes/structllarp_1_1handlers_1_1ExitEndpoint.md#function-haslocalmappedaddrfor)**(const [PubKey](Classes/structllarp_1_1PubKey.md) & pk) const |
| [huint128_t](Classes/structllarp_1_1huint__t.md) | **[GetIfAddr](Classes/structllarp_1_1handlers_1_1ExitEndpoint.md#function-getifaddr)**() const |
| void | **[Flush](Classes/structllarp_1_1handlers_1_1ExitEndpoint.md#function-flush)**() |
| virtual [quic::TunnelManager](Classes/classllarp_1_1quic_1_1TunnelManager.md) * | **[GetQUICTunnel](Classes/structllarp_1_1handlers_1_1ExitEndpoint.md#function-getquictunnel)**() override |
| [huint128_t](Classes/structllarp_1_1huint__t.md) | **[GetIPForIdent](Classes/structllarp_1_1handlers_1_1ExitEndpoint.md#function-getipforident)**(const [PubKey](Classes/structllarp_1_1PubKey.md) pk) |
| void | **[ObtainSNodeSession](Classes/structllarp_1_1handlers_1_1ExitEndpoint.md#function-obtainsnodesession)**(const [RouterID](Classes/structllarp_1_1RouterID.md) & router, exit::SessionReadyFunc obtainCb)<br>async obtain snode session and call callback when it's ready to send  |

## Additional inherited members

**Public Functions inherited from [llarp::dns::Resolver_Base](Classes/classllarp_1_1dns_1_1Resolver__Base.md)**

|                | Name           |
| -------------- | -------------- |
| virtual | **[~Resolver_Base](Classes/classllarp_1_1dns_1_1Resolver__Base.md#function-~resolver-base)**() =default |
| bool | **[operator<](Classes/classllarp_1_1dns_1_1Resolver__Base.md#function-operator<)**(const [Resolver_Base](Classes/classllarp_1_1dns_1_1Resolver__Base.md) & other) const<br>less than via rank  |
| bool | **[operator>](Classes/classllarp_1_1dns_1_1Resolver__Base.md#function-operator>)**(const [Resolver_Base](Classes/classllarp_1_1dns_1_1Resolver__Base.md) & other) const<br>greater than via rank  |
| virtual std::optional< [SockAddr](Classes/structllarp_1_1SockAddr.md) > | **[GetLocalAddr](Classes/classllarp_1_1dns_1_1Resolver__Base.md#function-getlocaladdr)**() const<br>get local socket address that queries are sent from  |
| virtual void | **[ResetResolver](Classes/classllarp_1_1dns_1_1Resolver__Base.md#function-resetresolver)**(] std::optional< std::vector< [SockAddr](Classes/structllarp_1_1SockAddr.md) >> replace_upstream =std::nullopt)<br>reset the resolver state, optionally replace upstream info with new info.  |
| virtual void | **[Down](Classes/classllarp_1_1dns_1_1Resolver__Base.md#function-down)**()<br>cancel all pending requests and cease further operation. Default operation is a no-op.  |
| virtual bool | **[WouldLoop](Classes/classllarp_1_1dns_1_1Resolver__Base.md#function-wouldloop)**(const [SockAddr](Classes/structllarp_1_1SockAddr.md) & to, const [SockAddr](Classes/structllarp_1_1SockAddr.md) & from) const<br>Returns true if a packet with to and from addresses is something that would cause a resolution loop and thus should not be used on this resolver.  |

**Public Classes inherited from [llarp::EndpointBase](Classes/classllarp_1_1EndpointBase.md)**

|                | Name           |
| -------------- | -------------- |
| struct | **[QUICMappingInfo](Classes/structllarp_1_1EndpointBase_1_1QUICMappingInfo.md)** <br>info about a quic mapping  |
| struct | **[SendStat](Classes/structllarp_1_1EndpointBase_1_1SendStat.md)**  |

**Public Types inherited from [llarp::EndpointBase](Classes/classllarp_1_1EndpointBase.md)**

|                | Name           |
| -------------- | -------------- |
| using std::variant< [service::Address](Classes/structllarp_1_1service_1_1Address.md), [RouterID](Classes/structllarp_1_1RouterID.md) > | **[AddressVariant_t](Classes/classllarp_1_1EndpointBase.md#using-addressvariant-t)**  |

**Public Functions inherited from [llarp::EndpointBase](Classes/classllarp_1_1EndpointBase.md)**

|                | Name           |
| -------------- | -------------- |
| virtual | **[~EndpointBase](Classes/classllarp_1_1EndpointBase.md#function-~endpointbase)**() =default |
| std::optional< [QUICMappingInfo](Classes/structllarp_1_1EndpointBase_1_1QUICMappingInfo.md) > | **[GetQUICMappingInfoByID](Classes/classllarp_1_1EndpointBase.md#function-getquicmappinginfobyid)**(int stream_id) const<br>maybe get quic mapping info given its stream id returns std::nullopt if we have no stream given that id  |
| void | **[PutSRVRecord](Classes/classllarp_1_1EndpointBase.md#function-putsrvrecord)**([dns::SRVData](Classes/structllarp_1_1dns_1_1SRVData.md) srv)<br>add an srv record to this endpoint's descriptor  |
| virtual std::shared_ptr< [dns::Server](Classes/classllarp_1_1dns_1_1Server.md) > | **[DNS](Classes/classllarp_1_1EndpointBase.md#function-dns)**() const<br>get dns serverr if we have on on this endpoint  |
| bool | **[DelSRVRecordIf](Classes/classllarp_1_1EndpointBase.md#function-delsrvrecordif)**(std::function< bool(const [dns::SRVData](Classes/structllarp_1_1dns_1_1SRVData.md) &)> filter)<br>remove srv records from this endpoint that match a filter for each srv record call it with filter, remove if filter returns true return if we removed any srv records  |
| std::set< [dns::SRVData](Classes/structllarp_1_1dns_1_1SRVData.md) > | **[SRVRecords](Classes/classllarp_1_1EndpointBase.md#function-srvrecords)**() const<br>get copy of all srv records  |


## Public Functions Documentation

### function Rank

```cpp
inline virtual int Rank() const override
```

return the sorting order for this resolver lower means it will be tried first 

**Reimplements**: [llarp::dns::Resolver_Base::Rank](Classes/classllarp_1_1dns_1_1Resolver__Base.md#function-rank)


### function ResolverName

```cpp
inline virtual std::string_view ResolverName() const override
```

get printable name 

**Reimplements**: [llarp::dns::Resolver_Base::ResolverName](Classes/classllarp_1_1dns_1_1Resolver__Base.md#function-resolvername)


### function MaybeHookDNS

```cpp
virtual bool MaybeHookDNS(
    std::shared_ptr< dns::PacketSource_Base > source,
    const dns::Message & query,
    const SockAddr & to,
    const SockAddr & from
) override
```

attempt to handle a dns message returns true if we consumed this query and it should not be processed again 

**Reimplements**: [llarp::dns::Resolver_Base::MaybeHookDNS](Classes/classllarp_1_1dns_1_1Resolver__Base.md#function-maybehookdns)


### function ExitEndpoint

```cpp
ExitEndpoint(
    std::string name,
    AbstractRouter * r
)
```


### function ~ExitEndpoint

```cpp
~ExitEndpoint() override
```


### function GetEndpointWithConvoTag

```cpp
virtual std::optional< AddressVariant_t > GetEndpointWithConvoTag(
    service::ConvoTag tag
) const override
```


**Reimplements**: [llarp::EndpointBase::GetEndpointWithConvoTag](Classes/classllarp_1_1EndpointBase.md#function-getendpointwithconvotag)


### function GetBestConvoTagFor

```cpp
virtual std::optional< service::ConvoTag > GetBestConvoTagFor(
    AddressVariant_t addr
) const override
```


**Reimplements**: [llarp::EndpointBase::GetBestConvoTagFor](Classes/classllarp_1_1EndpointBase.md#function-getbestconvotagfor)


### function EnsurePathTo

```cpp
virtual bool EnsurePathTo(
    AddressVariant_t addr,
    std::function< void(std::optional< service::ConvoTag >)> hook,
    llarp_time_t timeout
) override
```


**Reimplements**: [llarp::EndpointBase::EnsurePathTo](Classes/classllarp_1_1EndpointBase.md#function-ensurepathto)


### function LookupNameAsync

```cpp
virtual void LookupNameAsync(
    std::string name,
    std::function< void(std::optional< AddressVariant_t >)> resultHandler
) override
```


**Reimplements**: [llarp::EndpointBase::LookupNameAsync](Classes/classllarp_1_1EndpointBase.md#function-lookupnameasync)


### function Loop

```cpp
virtual const EventLoop_ptr & Loop() override
```


**Reimplements**: [llarp::EndpointBase::Loop](Classes/classllarp_1_1EndpointBase.md#function-loop)


### function AllRemoteEndpoints

```cpp
virtual std::unordered_set< EndpointBase::AddressVariant_t > AllRemoteEndpoints() const override
```

list all remote endpoint addresses we have that are mapped 

**Reimplements**: [llarp::EndpointBase::AllRemoteEndpoints](Classes/classllarp_1_1EndpointBase.md#function-allremoteendpoints)


### function SRVRecordsChanged

```cpp
virtual void SRVRecordsChanged() override
```

called when srv data changes in some way 

**Reimplements**: [llarp::EndpointBase::SRVRecordsChanged](Classes/classllarp_1_1EndpointBase.md#function-srvrecordschanged)


### function MarkAddressOutbound

```cpp
inline virtual void MarkAddressOutbound(
    AddressVariant_t 
) override
```


**Reimplements**: [llarp::EndpointBase::MarkAddressOutbound](Classes/classllarp_1_1EndpointBase.md#function-markaddressoutbound)


### function SendToOrQueue

```cpp
virtual bool SendToOrQueue(
    service::ConvoTag tag,
    const llarp_buffer_t & payload,
    service::ProtocolType t
) override
```


**Reimplements**: [llarp::EndpointBase::SendToOrQueue](Classes/classllarp_1_1EndpointBase.md#function-sendtoorqueue)


### function Tick

```cpp
void Tick(
    llarp_time_t now
)
```


### function Configure

```cpp
void Configure(
    const NetworkConfig & networkConfig,
    const DnsConfig & dnsConfig
)
```


### function Name

```cpp
std::string Name() const
```


### function VisitEndpointsFor

```cpp
bool VisitEndpointsFor(
    const PubKey & pk,
    std::function< bool(exit::Endpoint *const)> visit
) const
```


### function ExtractStatus

```cpp
util::StatusObject ExtractStatus() const
```


### function SupportsV6

```cpp
bool SupportsV6() const
```


### function ShouldHookDNSMessage

```cpp
bool ShouldHookDNSMessage(
    const dns::Message & msg
) const
```


### function HandleHookedDNSMessage

```cpp
bool HandleHookedDNSMessage(
    dns::Message msg,
    std::function< void(dns::Message)> 
)
```


### function LookupServiceAsync

```cpp
virtual void LookupServiceAsync(
    std::string name,
    std::string service,
    std::function< void(std::vector< dns::SRVData >)> resultHandler
) override
```

lookup srv records async 

**Reimplements**: [llarp::EndpointBase::LookupServiceAsync](Classes/classllarp_1_1EndpointBase.md#function-lookupserviceasync)


### function AllocateNewExit

```cpp
bool AllocateNewExit(
    const PubKey pk,
    const PathID_t & path,
    bool permitInternet
)
```


### function FindEndpointByPath

```cpp
exit::Endpoint * FindEndpointByPath(
    const PathID_t & path
)
```


### function FindEndpointByIP

```cpp
exit::Endpoint * FindEndpointByIP(
    huint32_t ip
)
```


### function UpdateEndpointPath

```cpp
bool UpdateEndpointPath(
    const PubKey & remote,
    const PathID_t & next
)
```


### function OnInetPacket

```cpp
void OnInetPacket(
    net::IPPacket buf
)
```

handle ip packet from outside 

### function GetRouter

```cpp
AbstractRouter * GetRouter()
```


### function Now

```cpp
llarp_time_t Now() const
```


### function CalculateTrafficStats

```cpp
template <typename Stats >
inline void CalculateTrafficStats(
    Stats & stats
)
```


### function DelEndpointInfo

```cpp
void DelEndpointInfo(
    const PathID_t & path
)
```

DO NOT CALL ME. 

### function RemoveExit

```cpp
void RemoveExit(
    const exit::Endpoint * ep
)
```

DO NOT CALL ME. 

### function QueueOutboundTraffic

```cpp
bool QueueOutboundTraffic(
    net::IPPacket pkt
)
```


### function LocalAddress

```cpp
virtual AddressVariant_t LocalAddress() const override
```

get our local address 

**Reimplements**: [llarp::EndpointBase::LocalAddress](Classes/classllarp_1_1EndpointBase.md#function-localaddress)


### function GetStatFor

```cpp
virtual std::optional< SendStat > GetStatFor(
    AddressVariant_t remote
) const override
```

get statistics about how much traffic we sent and recv'd to a remote endpoint 

**Reimplements**: [llarp::EndpointBase::GetStatFor](Classes/classllarp_1_1EndpointBase.md#function-getstatfor)


### function Start

```cpp
bool Start()
```

sets up networking and starts traffic 

### function Stop

```cpp
bool Stop()
```


### function ShouldRemove

```cpp
bool ShouldRemove() const
```


### function HasLocalMappedAddrFor

```cpp
bool HasLocalMappedAddrFor(
    const PubKey & pk
) const
```


### function GetIfAddr

```cpp
huint128_t GetIfAddr() const
```


### function Flush

```cpp
void Flush()
```


### function GetQUICTunnel

```cpp
virtual quic::TunnelManager * GetQUICTunnel() override
```


**Reimplements**: [llarp::EndpointBase::GetQUICTunnel](Classes/classllarp_1_1EndpointBase.md#function-getquictunnel)


### function GetIPForIdent

```cpp
huint128_t GetIPForIdent(
    const PubKey pk
)
```


### function ObtainSNodeSession

```cpp
void ObtainSNodeSession(
    const RouterID & router,
    exit::SessionReadyFunc obtainCb
)
```

async obtain snode session and call callback when it's ready to send 

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

Updated on 2022-11-17 at 22:27:42 +0000