-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathupstream_dnscrypt.h
45 lines (36 loc) · 1.22 KB
/
upstream_dnscrypt.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#pragma once
#include <chrono>
#include <memory>
#include "dns/dnsstamp/dns_stamp.h"
#include "dns/upstream/upstream.h"
#include "common/logger.h"
namespace ag::dns {
class DnscryptUpstream : public Upstream {
public:
/**
* Create DNSCrypt upstream
* @param stamp Stamp
* @param opts Upstream settings
*/
DnscryptUpstream(ServerStamp &&stamp, const UpstreamOptions &opts, const UpstreamFactoryConfig &config);
DnscryptUpstream(const DnscryptUpstream &) = delete;
DnscryptUpstream &operator=(const DnscryptUpstream &) = delete;
~DnscryptUpstream() override;
private:
Error<InitError> init() override;
coro::Task<ExchangeResult> exchange(const ldns_pkt *request_pkt, const DnsMessageInfo *info) override;
struct Impl;
using ImplPtr = std::unique_ptr<Impl>;
struct SetupResult {
Millis rtt;
Error<DnsError> error;
};
coro::Task<SetupResult> setup_impl();
coro::Task<ExchangeResult> apply_exchange(const ldns_pkt &request_pkt, Millis timeout);
[[nodiscard]] SocketFactory::SocketParameters make_socket_parameters() const;
Logger m_log;
ServerStamp m_stamp;
ImplPtr m_impl;
std::shared_ptr<bool> m_shutdown_guard;
};
} // namespace ag::dns