Merge pull request #22400 from poettering/resolved-single-invalid-list

resolved: maintain only a single list of "dont-resolve" domain names
This commit is contained in:
Anita Zhang
2022-02-03 11:54:00 -08:00
committed by GitHub
4 changed files with 21 additions and 13 deletions

View File

@@ -624,14 +624,8 @@ DnsScopeMatch dns_scope_good_domain(
dns_name_equal(domain, "1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.arpa") > 0)
return DNS_SCOPE_NO;
/* Never respond to some of the domains listed in RFC6303 */
if (dns_name_endswith(domain, "0.in-addr.arpa") > 0 ||
dns_name_equal(domain, "255.255.255.255.in-addr.arpa") > 0 ||
dns_name_equal(domain, "0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.arpa") > 0)
return DNS_SCOPE_NO;
/* Never respond to some of the domains listed in RFC6761 */
if (dns_name_endswith(domain, "invalid") > 0)
/* Never respond to some of the domains listed in RFC6303 + RFC6761 */
if (dns_name_dont_resolve(domain))
return DNS_SCOPE_NO;
/* Never go to network for the _gateway or _outbound domain — they're something special, synthesized locally. */

View File

@@ -397,11 +397,8 @@ int dns_synthesize_answer(
if (dns_name_is_empty(name)) {
/* Do nothing. */
} else if (dns_name_endswith(name, "0.in-addr.arpa") > 0 ||
dns_name_equal(name, "255.255.255.255.in-addr.arpa") > 0 ||
dns_name_equal(name, "0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.arpa") > 0 ||
dns_name_endswith(name, "invalid") > 0) {
} else if (dns_name_dont_resolve(name)) {
/* Synthesize NXDOMAIN for some of the domains in RFC6303 + RFC6761 */
nxdomain = true;
continue;

View File

@@ -1415,3 +1415,18 @@ int dns_name_dot_suffixed(const char *name) {
return false;
}
}
bool dns_name_dont_resolve(const char *name) {
/* Never respond to some of the domains listed in RFC6303 */
if (dns_name_endswith(name, "0.in-addr.arpa") > 0 ||
dns_name_equal(name, "255.255.255.255.in-addr.arpa") > 0 ||
dns_name_equal(name, "0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.arpa") > 0)
return true;
/* Never respond to some of the domains listed in RFC6761 */
if (dns_name_endswith(name, "invalid") > 0)
return true;
return false;
}

View File

@@ -103,3 +103,5 @@ int dns_name_apply_idna(const char *name, char **ret);
int dns_name_is_valid_or_address(const char *name);
int dns_name_dot_suffixed(const char *name);
bool dns_name_dont_resolve(const char *name);