10#include <userver/engine/io/sockaddr.hpp>
11#include <userver/engine/task/task.hpp>
13USERVER_NAMESPACE_BEGIN
15namespace internal::net {
21class DnsServerMock final {
23 enum class RecordType {
31 RecordType type{RecordType::kInvalid};
36 using AnswerData = std::variant<std::monostate, engine::io::Sockaddr, std::string>;
38 RecordType type{RecordType::kInvalid};
43 using DnsAnswerVector = std::vector<DnsAnswer>;
45 struct NoAnswer : std::exception {};
48 using DnsHandler = std::function<DnsAnswerVector(
const DnsQuery&)>;
50 explicit DnsServerMock(DnsHandler);
52 std::string GetServerAddress()
const;
55 void ProcessRequests();
57 std::shared_ptr<internal::net::UdpListener> listener_;
59 engine::Task receiver_task_;