wireaddr: is_dnsaddr allow underscore in hostname

The hostname part of a DNS FQDN can allow for additional characters
other than specified in `man 7 hostname`.

This extends is_dnsaddr and the test issue #5657.
Also fixes a typo in a comment.

Changelog-Fixed: wireaddr: #5657 allow '_' underscore in hostname part of DNS FQDN
This commit is contained in:
Michael Schmoock
2022-12-05 10:58:25 +01:00
committed by Christian Decker
parent a96ff3b097
commit 29f81baac9
2 changed files with 17 additions and 3 deletions

View File

@@ -126,11 +126,14 @@ int main(int argc, char *argv[])
assert(is_dnsaddr("123example.com"));
assert(is_dnsaddr("example123.com"));
assert(is_dnsaddr("is-valid.3hostname123.com"));
assert(is_dnsaddr("just-a-hostname-with-dashes"));
assert(is_dnsaddr("lightningd_dest.underscore.allowed.in.hostname.part.com"));
assert(!is_dnsaddr("UPPERCASE.invalid.com"));
assert(!is_dnsaddr("-.invalid.com"));
assert(!is_dnsaddr("invalid.-example.com"));
assert(!is_dnsaddr("invalid.example-.com"));
assert(!is_dnsaddr("invalid..example.com"));
assert(!is_dnsaddr("underscore.not.allowed.in.domain_name.com"));
/* Grossly invalid. */
assert(!separate_address_and_port(tmpctx, "[", &ip, &port));