---
title: llarp::dns::Resolver_Base
summary: handler of dns query hooking intercepts dns for internal processing 

---

# llarp::dns::Resolver_Base



handler of dns query hooking intercepts dns for internal processing 


`#include <server.hpp>`

Inherited by [llarp::handlers::ExitEndpoint](Classes/structllarp_1_1handlers_1_1ExitEndpoint.md), [llarp::handlers::TunEndpoint](Classes/structllarp_1_1handlers_1_1TunEndpoint.md)

## Public Functions

|                | 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 std::string_view | **[ResolverName](Classes/classllarp_1_1dns_1_1Resolver__Base.md#function-resolvername)**() const =0<br>get printable name  |
| 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 | **[MaybeHookDNS](Classes/classllarp_1_1dns_1_1Resolver__Base.md#function-maybehookdns)**(std::shared_ptr< [PacketSource_Base](Classes/classllarp_1_1dns_1_1PacketSource__Base.md) > source, const [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) =0<br>attempt to handle a dns message returns true if we consumed this query and it should not be processed again  |

## Protected Functions

|                | Name           |
| -------------- | -------------- |
| virtual int | **[Rank](Classes/classllarp_1_1dns_1_1Resolver__Base.md#function-rank)**() const =0<br>return the sorting order for this resolver lower means it will be tried first  |

## Public Functions Documentation

### function ~Resolver_Base

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


### function operator<

```cpp
inline bool operator<(
    const Resolver_Base & other
) const
```

less than via rank 

### function operator>

```cpp
inline bool operator>(
    const Resolver_Base & other
) const
```

greater than via rank 

### function GetLocalAddr

```cpp
inline virtual std::optional< SockAddr > GetLocalAddr() const
```

get local socket address that queries are sent from 

### function ResolverName

```cpp
virtual std::string_view ResolverName() const =0
```

get printable name 

**Reimplemented by**: [llarp::handlers::ExitEndpoint::ResolverName](Classes/structllarp_1_1handlers_1_1ExitEndpoint.md#function-resolvername), [llarp::handlers::TunEndpoint::ResolverName](Classes/structllarp_1_1handlers_1_1TunEndpoint.md#function-resolvername)


### function ResetResolver

```cpp
inline virtual void ResetResolver(
    ] std::optional< std::vector< SockAddr >> replace_upstream =std::nullopt
)
```

reset the resolver state, optionally replace upstream info with new info. 

The default base implementation does nothing. 


### function Down

```cpp
inline virtual void Down()
```

cancel all pending requests and cease further operation. Default operation is a no-op. 

### function MaybeHookDNS

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

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

**Reimplemented by**: [llarp::handlers::ExitEndpoint::MaybeHookDNS](Classes/structllarp_1_1handlers_1_1ExitEndpoint.md#function-maybehookdns), [llarp::handlers::TunEndpoint::MaybeHookDNS](Classes/structllarp_1_1handlers_1_1TunEndpoint.md#function-maybehookdns)


## Protected Functions Documentation

### function Rank

```cpp
virtual int Rank() const =0
```

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

**Reimplemented by**: [llarp::handlers::ExitEndpoint::Rank](Classes/structllarp_1_1handlers_1_1ExitEndpoint.md#function-rank), [llarp::handlers::TunEndpoint::Rank](Classes/structllarp_1_1handlers_1_1TunEndpoint.md#function-rank)


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

Updated on 2023-01-27 at 23:09:26 +0000