From 3d5ff73d1e12fa758138f28dd3ed86935749409f Mon Sep 17 00:00:00 2001 From: action Date: Thu, 24 Sep 2026 03:28:54 +0800 Subject: [PATCH] update 2026-09-24 03:28:54 --- .../root/usr/share/passwall/iptables.sh | 52 ++++++++++--------- .../root/usr/share/passwall/nftables.sh | 46 ++++++++-------- 2 files changed, 53 insertions(+), 45 deletions(-) diff --git a/luci-app-passwall/root/usr/share/passwall/iptables.sh b/luci-app-passwall/root/usr/share/passwall/iptables.sh index 10c60e07..e45d0bcf 100755 --- a/luci-app-passwall/root/usr/share/passwall/iptables.sh +++ b/luci-app-passwall/root/usr/share/passwall/iptables.sh @@ -842,33 +842,37 @@ update_wan_sets() { [ -z "$(command -v get_wan_ips)" ] && . "$UTILS_PATH" - local WAN_IP=$(get_wan_ips ip4) - [ -n "$WAN_IP" ] && { - ipset -F "$IPSET_WAN" - for wan_ip in $WAN_IP; do - ipset -! add "$IPSET_WAN" "$wan_ip" - done - [ "$log" = "log" ] && { - local wan_ip - for wan_ip in $WAN_IP; do - echolog " - [$?]加入WAN IPv4到ipset[$IPSET_WAN]:${wan_ip}" - done - } - } + ( + flock -x 9 || exit 1 - local WAN6_IP=$(get_wan_ips ip6) - [ -n "$WAN6_IP" ] && { - ipset -F "$IPSET_WAN6" - for wan6_ip in $WAN6_IP; do - ipset -! add "$IPSET_WAN6" "$wan6_ip" - done - [ "$log" = "log" ] && { - local wan6_ip - for wan6_ip in $WAN6_IP; do - echolog " - [$?]加入WAN IPv6到ipset[$IPSET_WAN6]:${wan6_ip}" + local WAN_IP=$(get_wan_ips ip4) + [ -n "$WAN_IP" ] && { + # ipset -F "$IPSET_WAN" + for wan_ip in $WAN_IP; do + ipset -! add "$IPSET_WAN" "$wan_ip" done + [ "$log" = "log" ] && { + local wan_ip + for wan_ip in $WAN_IP; do + echolog " - [$?]加入WAN IPv4到ipset[$IPSET_WAN]:${wan_ip}" + done + } } - } + + local WAN6_IP=$(get_wan_ips ip6) + [ -n "$WAN6_IP" ] && { + # ipset -F "$IPSET_WAN6" + for wan6_ip in $WAN6_IP; do + ipset -! add "$IPSET_WAN6" "$wan6_ip" + done + [ "$log" = "log" ] && { + local wan6_ip + for wan6_ip in $WAN6_IP; do + echolog " - [$?]加入WAN IPv6到ipset[$IPSET_WAN6]:${wan6_ip}" + done + } + } + ) 9>"${LOCK_PATH}/${CONFIG}_update_wan_sets.lock" } set_tproxy_sysctl() { diff --git a/luci-app-passwall/root/usr/share/passwall/nftables.sh b/luci-app-passwall/root/usr/share/passwall/nftables.sh index 66474cde..fefd092a 100755 --- a/luci-app-passwall/root/usr/share/passwall/nftables.sh +++ b/luci-app-passwall/root/usr/share/passwall/nftables.sh @@ -931,29 +931,33 @@ update_wan_sets() { [ -z "$(command -v get_wan_ips)" ] && . "$UTILS_PATH" - local WAN_IP=$(get_wan_ips ip4) - [ -n "$WAN_IP" ] && { - nft flush set $NFTABLE_NAME $NFTSET_WAN - echo "$WAN_IP" | insert_nftset $NFTSET_WAN - [ "$log" = "log" ] && { - local wan_ip - for wan_ip in $WAN_IP; do - echolog " - [$?]加入WAN IPv4到nftset[$NFTSET_WAN]:${wan_ip}" - done - } - } + ( + flock -x 9 || exit 1 - local WAN6_IP=$(get_wan_ips ip6) - [ -n "${WAN6_IP}" ] && { - nft flush set $NFTABLE_NAME $NFTSET_WAN6 - echo "$WAN6_IP" | insert_nftset $NFTSET_WAN6 - [ "$log" = "log" ] && { - local wan6_ip - for wan6_ip in $WAN6_IP; do - echolog " - [$?]加入WAN IPv6到nftset[$NFTSET_WAN6]:${wan6_ip}" - done + local WAN_IP=$(get_wan_ips ip4) + [ -n "$WAN_IP" ] && { + # nft flush set $NFTABLE_NAME $NFTSET_WAN + echo "$WAN_IP" | insert_nftset $NFTSET_WAN + [ "$log" = "log" ] && { + local wan_ip + for wan_ip in $WAN_IP; do + echolog " - [$?]加入WAN IPv4到nftset[$NFTSET_WAN]:${wan_ip}" + done + } } - } + + local WAN6_IP=$(get_wan_ips ip6) + [ -n "${WAN6_IP}" ] && { + # nft flush set $NFTABLE_NAME $NFTSET_WAN6 + echo "$WAN6_IP" | insert_nftset $NFTSET_WAN6 + [ "$log" = "log" ] && { + local wan6_ip + for wan6_ip in $WAN6_IP; do + echolog " - [$?]加入WAN IPv6到nftset[$NFTSET_WAN6]:${wan6_ip}" + done + } + } + ) 9>"${LOCK_PATH}/${CONFIG}_update_wan_sets.lock" } set_tproxy_sysctl() {