Ver código fonte

luci-app-ssr-plus: Fix issue where switch the master node could not run due to persistence rules when using NFTS.

zxl hhyccc 1 mês atrás
pai
commit
6c1aaef625
1 arquivos alterados com 17 adições e 7 exclusões
  1. 17 7
      luci-app-ssr-plus/root/etc/init.d/shadowsocksr

+ 17 - 7
luci-app-ssr-plus/root/etc/init.d/shadowsocksr

@@ -1544,6 +1544,13 @@ start() {
 	fi
 	/etc/init.d/dnsmasq restart >/dev/null 2>&1
 	check_server
+    if command -v nft >/dev/null 2>&1; then
+		local CURRENT_SERVER="$(uci_get_by_type global global_server nil)"
+		if [ "$CURRENT_SERVER" != "nil" ]; then
+			uci set shadowsocksr.@global[0].old_global_server="$CURRENT_SERVER"
+			uci commit shadowsocksr
+		fi
+	fi
 	start_server
 	start_monitor
 	clean_log
@@ -1560,13 +1567,16 @@ boot() {
 stop() {
 	unlock
 	set_lock
-	if command -v nft >/dev/null 2>&1; then
-		/usr/bin/ssr-rules -K
-		#local CLEANUP_PERSISTENCE="$(uci_get_by_type global global_server nil)"
-		#if [ "$CLEANUP_PERSISTENCE" == "nil" ]; then
-		#	/usr/bin/ssr-rules -X
-		#fi
-	fi
+    if command -v nft >/dev/null 2>&1; then
+        /usr/bin/ssr-rules -K
+        local OLD_SERVER="$(uci_get_by_type global old_global_server nil)"
+        local NEW_SERVER="$(uci_get_by_type global global_server nil)"
+        if [ "$OLD_SERVER" != "nil" ] && [ "$NEW_SERVER" != "nil" ] && [ "$OLD_SERVER" != "$NEW_SERVER" ]; then
+			/usr/bin/ssr-rules -X
+        fi
+        uci delete shadowsocksr.@global[0].old_global_server 2>/dev/null
+        uci commit shadowsocksr
+    fi
 	/usr/bin/ssr-rules -f
 	local srulecount=0
 	if command -v nft >/dev/null 2>&1; then