From 4935015b18e660549e5e51b88f38e29dde43a8e1 Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Sat, 7 Mar 2020 12:37:55 -0800 Subject: [PATCH] ircd::net::dns: Consolidate cache interfaces in public header; weak unresolved for now. --- include/ircd/net/dns.h | 19 ------------------- include/ircd/net/dns_cache.h | 24 ++++++++++++++++++++---- include/ircd/net/net.h | 1 + ircd/net_dns.cc | 1 - ircd/net_dns_cache.cc | 2 -- modules/net_dns_cache.cc | 2 -- 6 files changed, 21 insertions(+), 28 deletions(-) diff --git a/include/ircd/net/dns.h b/include/ircd/net/dns.h index 70e651327..98ac5927d 100644 --- a/include/ircd/net/dns.h +++ b/include/ircd/net/dns.h @@ -97,25 +97,6 @@ struct ircd::net::dns::opts opts() = default; }; -/// (internal) DNS cache -namespace ircd::net::dns::cache -{ - using closure = std::function; - - extern conf::item min_ttl; - extern conf::item error_ttl; - extern conf::item nxdomain_ttl; - - string_view make_type(const mutable_buffer &out, const string_view &); - string_view make_type(const mutable_buffer &out, const uint16_t &); - - bool for_each(const string_view &type, const closure &); // do not make_type() here - bool for_each(const hostport &, const opts &, const closure &); - bool get(const hostport &, const opts &, const callback &); - bool put(const hostport &, const opts &, const records &); - bool put(const hostport &, const opts &, const uint &code, const string_view &msg = {}); -} - /// (internal) struct ircd::net::dns::init { diff --git a/include/ircd/net/dns_cache.h b/include/ircd/net/dns_cache.h index 981dc250b..5573ce610 100644 --- a/include/ircd/net/dns_cache.h +++ b/include/ircd/net/dns_cache.h @@ -8,11 +8,26 @@ // copyright notice and this permission notice is present in all copies. The // full license for this software is available in the LICENSE file. -// -// This file is not included in any include group. It is used when -// implementing the dns::cache by modules and extensions. -// +/// (internal) DNS cache +namespace ircd::net::dns::cache +{ + using closure = std::function; + extern conf::item min_ttl; + extern conf::item error_ttl; + extern conf::item nxdomain_ttl; + + string_view make_type(const mutable_buffer &out, const string_view &); + string_view make_type(const mutable_buffer &out, const uint16_t &); + + bool for_each(const string_view &type, const closure &); // do not make_type() here + bool for_each(const hostport &, const opts &, const closure &); + bool get(const hostport &, const opts &, const callback &); + bool put(const hostport &, const opts &, const records &); + bool put(const hostport &, const opts &, const uint &code, const string_view &msg = {}); +} + +/// (internal) DNS cache namespace ircd::net::dns::cache { struct waiter; @@ -25,6 +40,7 @@ namespace ircd::net::dns::cache extern ctx::dock dock; } +/// DNS cache result waiter struct ircd::net::dns::cache::waiter { dns::callback callback; diff --git a/include/ircd/net/net.h b/include/ircd/net/net.h index 1acb0dd9b..44e1bb824 100644 --- a/include/ircd/net/net.h +++ b/include/ircd/net/net.h @@ -38,6 +38,7 @@ namespace ircd::net #include "ipaddr.h" #include "ipport.h" #include "dns.h" +#include "dns_cache.h" #include "listener.h" #include "listener_udp.h" #include "sock_opts.h" diff --git a/ircd/net_dns.cc b/ircd/net_dns.cc index e7cc16caa..432d44590 100644 --- a/ircd/net_dns.cc +++ b/ircd/net_dns.cc @@ -9,7 +9,6 @@ // full license for this software is available in the LICENSE file. #include namespace ircd::net::dns { diff --git a/ircd/net_dns_cache.cc b/ircd/net_dns_cache.cc index f99759ae1..a6ceb8880 100644 --- a/ircd/net_dns_cache.cc +++ b/ircd/net_dns_cache.cc @@ -8,8 +8,6 @@ // copyright notice and this permission notice is present in all copies. The // full license for this software is available in the LICENSE file. -#include - decltype(ircd::net::dns::cache::min_ttl) ircd::net::dns::cache::min_ttl { diff --git a/modules/net_dns_cache.cc b/modules/net_dns_cache.cc index 6fa7c6f35..16ec54357 100644 --- a/modules/net_dns_cache.cc +++ b/modules/net_dns_cache.cc @@ -8,8 +8,6 @@ // copyright notice and this permission notice is present in all copies. The // full license for this software is available in the LICENSE file. -#include - namespace ircd::net::dns::cache { static bool call_waiter(const string_view &, const string_view &, const json::array &, waiter &);