---
title: llarp/dns/platform.hpp

---

# llarp/dns/platform.hpp



## Namespaces

| Name           |
| -------------- |
| **[llarp](Namespaces/namespacellarp.md)** <br>[crypto.hpp] |
| **[llarp::dns](Namespaces/namespacellarp_1_1dns.md)**  |

## Classes

|                | Name           |
| -------------- | -------------- |
| class | **[llarp::dns::I_Platform](Classes/classllarp_1_1dns_1_1I__Platform.md)** <br>sets dns settings in a platform dependant way  |
| class | **[llarp::dns::Null_Platform](Classes/classllarp_1_1dns_1_1Null__Platform.md)** <br>a dns platform does silently does nothing, successfully  |
| class | **[llarp::dns::Multi_Platform](Classes/classllarp_1_1dns_1_1Multi__Platform.md)** <br>a collection of dns platforms that are tried in order when setting dns  |




## Source code

```cpp
#pragma once
#include <string>
#include <memory>
#include <llarp/net/sock_addr.hpp>
#include <llarp/util/logging.hpp>
#include <stdexcept>

#ifndef _WIN32
#include <net/if.h>
#endif

namespace llarp::dns
{
  class I_Platform
  {
   public:
    virtual ~I_Platform() = default;

    virtual void
    set_resolver(unsigned int if_index, llarp::SockAddr dns, bool global) = 0;
  };

  class Null_Platform : public I_Platform
  {
   public:
    ~Null_Platform() override = default;
    void
    set_resolver(unsigned int, llarp::SockAddr, bool) override
    {}
  };

  class Multi_Platform : public I_Platform
  {
    std::vector<std::unique_ptr<I_Platform>> m_Impls;

   public:
    ~Multi_Platform() override = default;
    void
    add_impl(std::unique_ptr<I_Platform> impl);

    void
    set_resolver(unsigned int if_index, llarp::SockAddr dns, bool global) override;
  };
}  // namespace llarp::dns
```


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

Updated on 2023-01-09 at 18:23:49 +0000
