aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2020-01-03 17:21:11 +0100
committerJason A. Donenfeld <Jason@zx2c4.com>2020-01-03 17:21:11 +0100
commit85501fb0b605b10956b4f8f056d093087e4088ea (patch)
tree489749ab1a9845a96321890a7463e2ef2940a8da
parentMakefile: remove pwd from compile output (diff)
downloadwireguard-tools-jd/nft-version-detection.tar.xz
wireguard-tools-jd/nft-version-detection.zip
wg-quick: detect version of nft(8) before usingjd/nft-version-detection
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com> Reported-by: Eddie <stunnel@attglobal.net>
-rwxr-xr-xsrc/wg-quick/linux.bash2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/wg-quick/linux.bash b/src/wg-quick/linux.bash
index 7c2c002..7f7227a 100755
--- a/src/wg-quick/linux.bash
+++ b/src/wg-quick/linux.bash
@@ -233,7 +233,7 @@ add_default() {
printf -v nftcmd '%sadd rule %s %s postmangle meta l4proto udp mark %d ct mark set mark \n' "$nftcmd" "$pf" "$nftable" $table
printf -v nftcmd '%sadd rule %s %s premangle meta l4proto udp meta mark set ct mark \n' "$nftcmd" "$pf" "$nftable"
[[ $proto == -4 ]] && cmd sysctl -q net.ipv4.conf.all.src_valid_mark=1
- if type -p nft >/dev/null; then
+ if [[ $(nft --version 2>/dev/null) =~ .*v([0-9.]+).* && $(printf '%s\n0.7\n' "${BASH_REMATCH[1]}" | sort -Vr) == "$(printf '%s\n0.7\n' "${BASH_REMATCH[1]}")" ]]; then
cmd nft -f <(echo -n "$nftcmd")
else
echo -n "$restore" | cmd $iptables-restore -n