From f469378142744a5bb6111599afd86300d365b3ee Mon Sep 17 00:00:00 2001 From: ShanStone <31815718+ShanStone@users.noreply.github.com> Date: Mon, 8 May 2023 11:05:15 +0800 Subject: [PATCH] luci: fix nftset elements add --- luci-app-passwall/Makefile | 2 +- .../root/usr/share/passwall/nftables.sh | 12 +++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/luci-app-passwall/Makefile b/luci-app-passwall/Makefile index 55f59cc5a..877f7f77c 100644 --- a/luci-app-passwall/Makefile +++ b/luci-app-passwall/Makefile @@ -6,7 +6,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=luci-app-passwall -PKG_VERSION:=4.66-2 +PKG_VERSION:=4.66-3 PKG_RELEASE:= PKG_CONFIG_DEPENDS:= \ diff --git a/luci-app-passwall/root/usr/share/passwall/nftables.sh b/luci-app-passwall/root/usr/share/passwall/nftables.sh index c90d860a6..7f209d704 100755 --- a/luci-app-passwall/root/usr/share/passwall/nftables.sh +++ b/luci-app-passwall/root/usr/share/passwall/nftables.sh @@ -124,11 +124,21 @@ destroy_nftset() { insert_nftset() { local nftset_name="${1}"; shift local nftset_elements + for element in $@ do nftset_elements="$element,$nftset_elements" done - [ -n "${nftset_elements}" ] && nft "add element inet fw4 $nftset_name { $nftset_elements }" + [ -n "${nftset_elements}" ] && { + mkdir -p $TMP_PATH2/nftset + + cat > "$TMP_PATH2/nftset/$nftset_name" <<-EOF + define $nftset_name = {$nftset_elements} + add element inet fw4 $nftset_name \$$nftset_name + EOF + nft -f "$TMP_PATH2/nftset/$nftset_name" + rm -rf "$TMP_PATH2/nftset" + } } gen_nftset() {