diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2020-05-08 23:15:50 -0600 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2020-05-09 00:29:53 -0600 |
commit | 7f236c79570642d466c5acab890b26c3a07f4f7a (patch) | |
tree | efae9b46fc54a72fb408e56a0fb11960f0ebfb97 /contrib | |
parent | systemd: add wg-quick.target (diff) | |
download | wireguard-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')
-rw-r--r-- | contrib/dns-hatchet/hatchet.bash | 5 | ||||
-rw-r--r-- | contrib/highlighter/highlighter.c | 12 |
2 files changed, 10 insertions, 7 deletions
diff --git a/contrib/dns-hatchet/hatchet.bash b/contrib/dns-hatchet/hatchet.bash index 5857cc1..bc4d090 100644 --- a/contrib/dns-hatchet/hatchet.bash +++ b/contrib/dns-hatchet/hatchet.bash @@ -2,7 +2,9 @@ set_dns() { [[ ${#DNS[@]} -gt 0 ]] || return 0 if [[ $(resolvconf --version 2>/dev/null) == openresolv\ * ]]; then - printf 'nameserver %s\n' "${DNS[@]}" | cmd resolvconf -a "$INTERFACE" -m 0 -x + { printf 'nameserver %s\n' "${DNS[@]}" + [[ ${#DNS_SEARCH[@]} -eq 0 ]] || printf 'search %s\n' "${DNS_SEARCH[*]}" + } | cmd resolvconf -a "$INTERFACE" -m 0 -x else echo "[#] mount \`${DNS[*]}' /etc/resolv.conf" >&2 [[ -e /etc/resolv.conf ]] || touch /etc/resolv.conf @@ -15,6 +17,7 @@ set_dns() { _EOF printf 'nameserver %s\n' "${DNS[@]}" + [[ ${#DNS_SEARCH[@]} -eq 0 ]] || printf 'search %s\n' "${DNS_SEARCH[*]}" } | unshare -m --propagation shared bash -c "$(cat <<-_EOF set -e context="\$(stat -c %C /etc/resolv.conf 2>/dev/null)" || unset context 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: { |