summaryrefslogtreecommitdiffhomepage
path: root/cli
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2017-07-31 05:15:05 +0200
committerSamuel Holland <samuel@sholland.org>2017-07-31 05:15:05 +0200
commitb2f4a755a0edba81eede6e87577a80d5def7d27a (patch)
treebad36d19238d0641db719df0c6ace3f725ecb77e /cli
parentdf4fc984934e074725ca9aa003cfc73be67dc756 (diff)
cli: add multi-DNS to wg-quick
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'cli')
-rw-r--r--cli/wg-quick.bash8
1 files changed, 4 insertions, 4 deletions
diff --git a/cli/wg-quick.bash b/cli/wg-quick.bash
index 40417358..7720f349 100644
--- a/cli/wg-quick.bash
+++ b/cli/wg-quick.bash
@@ -15,7 +15,7 @@ INTERFACE=""
NETID=0
ADDRESSES=( )
MTU=""
-DNS=""
+DNS=( )
CONFIG_FILE=""
PROGRAM="${0##*/}"
ARGS=( "$@" )
@@ -38,7 +38,7 @@ parse_options() {
case "$key" in
Address) ADDRESSES+=( ${value//,/ } ); continue ;;
MTU) MTU="$value"; continue ;;
- DNS) DNS="$value"; continue ;;
+ DNS) DNS+=( ${value//,/ } ); continue ;;
esac
fi
WG_CONFIG+="$line"$'\n'
@@ -86,7 +86,7 @@ up_if() {
}
set_dns() {
- cndc resolver setnetdns "$NETID" "" "$1"
+ cndc resolver setnetdns "$NETID" "" "${DNS[@]}"
}
add_addr() {
@@ -157,7 +157,7 @@ cmd_up() {
add_addr "$i"
done
up_if
- [[ -z $DNS ]] || set_dns "$DNS"
+ set_dns
for i in $(while read -r _ i; do for i in $i; do [[ $i =~ ^[0-9a-z:.]+/[0-9]+$ ]] && echo "$i"; done; done < <(wg show "$INTERFACE" allowed-ips) | sort -nr -k 2 -t /); do
[[ $(ip route get "$i" 2>/dev/null) == *dev\ $INTERFACE\ * ]] || add_route "$i"
done