diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2018-05-30 01:37:57 +0200 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2018-05-31 01:24:51 +0200 |
commit | 206e8f08e2413d1b1dfc5724bc9567f9f0ace310 (patch) | |
tree | 89aec171f82b5b2279a309596797ae054ad6f416 /src/wg-quick/darwin.bash | |
parent | wg-quick: freebsd: configure as p2p link (diff) | |
download | wireguard-tools-206e8f08e2413d1b1dfc5724bc9567f9f0ace310.tar.xz wireguard-tools-206e8f08e2413d1b1dfc5724bc9567f9f0ace310.zip |
wg-quick: darwin: set DNS servers after delay on route change
This works around a race condition in macOS's network daemons, while
also adding one in the form of possibly calling kill -ALRM on a stale
PID; unfortunately bash can't wait from a trap.
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'src/wg-quick/darwin.bash')
-rwxr-xr-x | src/wg-quick/darwin.bash | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/wg-quick/darwin.bash b/src/wg-quick/darwin.bash index 81139e6..8bcc404 100755 --- a/src/wg-quick/darwin.bash +++ b/src/wg-quick/darwin.bash @@ -293,7 +293,8 @@ monitor_daemon() { echo "[+] Backgrounding route monitor" >&2 (trap 'del_routes; del_dns; exit 0' INT TERM EXIT exec >/dev/null 2>&1 - local event + local event pid=$BASHPID + [[ ${#DNS[@]} -gt 0 ]] && trap set_dns ALRM # TODO: this should also check to see if the endpoint actually changes # in response to incoming packets, and then call set_endpoint_direct_route # then too. That function should be able to gracefully cleanup if the @@ -303,7 +304,10 @@ monitor_daemon() { ifconfig "$REAL_INTERFACE" >/dev/null 2>&1 || break [[ $AUTO_ROUTE4 -eq 1 || $AUTO_ROUTE6 -eq 1 ]] && set_endpoint_direct_route [[ -z $MTU ]] && set_mtu - [[ ${#DNS[@]} -gt 0 ]] && set_dns + if [[ ${#DNS[@]} -gt 0 ]]; then + set_dns + sleep 2 && kill -ALRM $pid 2>/dev/null & + fi done < <(route -n monitor)) & disown } |