aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/contrib/highlighter/highlighter.c
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2020-05-08 23:15:50 -0600
committerJason A. Donenfeld <Jason@zx2c4.com>2020-05-09 00:29:53 -0600
commit7f236c79570642d466c5acab890b26c3a07f4f7a (patch)
treeefae9b46fc54a72fb408e56a0fb11960f0ebfb97 /contrib/highlighter/highlighter.c
parentsystemd: add wg-quick.target (diff)
downloadwireguard-tools-7f236c79570642d466c5acab890b26c3a07f4f7a.tar.xz
wireguard-tools-7f236c79570642d466c5acab890b26c3a07f4f7a.zip
wg-quick: support dns search domains
If DNS= has an IP in it, treat it as a DNS server. If DNS= has a non-IP in it, treat it as a DNS search domain. Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'contrib/highlighter/highlighter.c')
-rw-r--r--contrib/highlighter/highlighter.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/contrib/highlighter/highlighter.c b/contrib/highlighter/highlighter.c
index e0d4e04..d89feda 100644
--- a/contrib/highlighter/highlighter.c
+++ b/contrib/highlighter/highlighter.c
@@ -337,11 +337,6 @@ static bool is_valid_network(string_span_t s)
return is_valid_ipv4(s) || is_valid_ipv6(s);
}
-static bool is_valid_dns(string_span_t s)
-{
- return is_valid_ipv4(s) || is_valid_ipv6(s);
-}
-
enum field {
InterfaceSection,
PrivateKey,
@@ -451,7 +446,12 @@ static void highlight_multivalue_value(struct highlight_span_array *ret, const s
{
switch (section) {
case DNS:
- append_highlight_span(ret, parent.s, s, is_valid_dns(s) ? HighlightIP : HighlightError);
+ if (is_valid_ipv4(s) || is_valid_ipv6(s))
+ append_highlight_span(ret, parent.s, s, HighlightIP);
+ else if (is_valid_hostname(s))
+ append_highlight_span(ret, parent.s, s, HighlightHost);
+ else
+ append_highlight_span(ret, parent.s, s, HighlightError);
break;
case Address:
case AllowedIPs: {