wg-quick: properly match IPv6 endpoint

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
This commit is contained in:
Jason A. Donenfeld 2017-06-23 14:48:03 +02:00
parent e7fd4cfd3f
commit cf4b3ebd08

View file

@ -117,7 +117,7 @@ set_mtu() {
return
fi
while read -r _ endpoint; do
[[ $endpoint =~ ^([a-z0-9:.]+):[0-9]+$ ]] || continue
[[ $endpoint =~ ^\[?([a-z0-9:.]+)\]?:[0-9]+$ ]] || continue
output="$(ip route get "${BASH_REMATCH[1]}" || true)"
[[ ( $output =~ mtu\ ([0-9]+) || ( $output =~ dev\ ([^ ]+) && $(ip link show dev "${BASH_REMATCH[1]}") =~ mtu\ ([0-9]+) ) ) && ${BASH_REMATCH[1]} -gt $mtu ]] && mtu="${BASH_REMATCH[1]}"
done < <(wg show "$INTERFACE" endpoints)