]>
Commit | Line | Data |
---|---|---|
1 | /* SPDX-License-Identifier: LGPL-2.1-or-later */ | |
2 | ||
3 | #include "conf-parser.h" | |
4 | #include "in-addr-util.h" | |
5 | #include "resolve-util.h" | |
6 | #include "string-table.h" | |
7 | ||
8 | DEFINE_CONFIG_PARSE_ENUM(config_parse_resolve_support, resolve_support, ResolveSupport); | |
9 | DEFINE_CONFIG_PARSE_ENUM(config_parse_dnssec_mode, dnssec_mode, DnssecMode); | |
10 | DEFINE_CONFIG_PARSE_ENUM(config_parse_dns_over_tls_mode, dns_over_tls_mode, DnsOverTlsMode); | |
11 | ||
12 | static const char* const resolve_support_table[_RESOLVE_SUPPORT_MAX] = { | |
13 | [RESOLVE_SUPPORT_NO] = "no", | |
14 | [RESOLVE_SUPPORT_YES] = "yes", | |
15 | [RESOLVE_SUPPORT_RESOLVE] = "resolve", | |
16 | }; | |
17 | DEFINE_STRING_TABLE_LOOKUP_WITH_BOOLEAN(resolve_support, ResolveSupport, RESOLVE_SUPPORT_YES); | |
18 | ||
19 | static const char* const dnssec_mode_table[_DNSSEC_MODE_MAX] = { | |
20 | [DNSSEC_NO] = "no", | |
21 | [DNSSEC_ALLOW_DOWNGRADE] = "allow-downgrade", | |
22 | [DNSSEC_YES] = "yes", | |
23 | }; | |
24 | DEFINE_STRING_TABLE_LOOKUP_WITH_BOOLEAN(dnssec_mode, DnssecMode, DNSSEC_YES); | |
25 | ||
26 | static const char* const dns_over_tls_mode_table[_DNS_OVER_TLS_MODE_MAX] = { | |
27 | [DNS_OVER_TLS_NO] = "no", | |
28 | [DNS_OVER_TLS_OPPORTUNISTIC] = "opportunistic", | |
29 | [DNS_OVER_TLS_YES] = "yes", | |
30 | }; | |
31 | DEFINE_STRING_TABLE_LOOKUP_WITH_BOOLEAN(dns_over_tls_mode, DnsOverTlsMode, DNS_OVER_TLS_YES); | |
32 | ||
33 | bool dns_server_address_valid(int family, const union in_addr_union *sa) { | |
34 | ||
35 | /* Refuses the 0 IP addresses as well as 127.0.0.53/127.0.0.54 (which is our own DNS stub) */ | |
36 | ||
37 | if (!in_addr_is_set(family, sa)) | |
38 | return false; | |
39 | ||
40 | if (family == AF_INET && IN_SET(be32toh(sa->in.s_addr), INADDR_DNS_STUB, INADDR_DNS_PROXY_STUB)) | |
41 | return false; | |
42 | ||
43 | return true; | |
44 | } | |
45 | ||
46 | DEFINE_CONFIG_PARSE_ENUM(config_parse_dns_cache_mode, dns_cache_mode, DnsCacheMode); | |
47 | ||
48 | static const char* const dns_cache_mode_table[_DNS_CACHE_MODE_MAX] = { | |
49 | [DNS_CACHE_MODE_YES] = "yes", | |
50 | [DNS_CACHE_MODE_NO] = "no", | |
51 | [DNS_CACHE_MODE_NO_NEGATIVE] = "no-negative", | |
52 | }; | |
53 | DEFINE_STRING_TABLE_LOOKUP_WITH_BOOLEAN(dns_cache_mode, DnsCacheMode, DNS_CACHE_MODE_YES); |