Преглед изворни кода

修复 gfwlist 模式下 restart 导致的无法连接问题

zfl9 пре 8 година
родитељ
комит
800126b920
1 измењених фајлова са 22 додато и 25 уклоњено
  1. 22 25
      ss-tproxy

+ 22 - 25
ss-tproxy

@@ -645,18 +645,17 @@ tproxy_gfwlist*)
     iptables -t nat -X SS-TCP &>/dev/null
 
     iptables -t nat -N SS-TCP
-    ipset -X gfwlist &>/dev/null
-    ipset -N gfwlist hash:net
-    ipset -A gfwlist 91.108.4.0/22
-    ipset -A gfwlist 91.108.8.0/22
-    ipset -A gfwlist 91.108.12.0/22
-    ipset -A gfwlist 91.108.20.0/22
-    ipset -A gfwlist 91.108.36.0/23
-    ipset -A gfwlist 91.108.38.0/23
-    ipset -A gfwlist 91.108.56.0/22
-    ipset -A gfwlist 149.154.160.0/20
-    ipset -A gfwlist 149.154.164.0/22
-    ipset -A gfwlist 149.154.172.0/22
+    ipset -N gfwlist hash:net &>/dev/null
+    ipset -A gfwlist 91.108.4.0/22 &>/dev/null
+    ipset -A gfwlist 91.108.8.0/22 &>/dev/null
+    ipset -A gfwlist 91.108.12.0/22 &>/dev/null
+    ipset -A gfwlist 91.108.20.0/22 &>/dev/null
+    ipset -A gfwlist 91.108.36.0/23 &>/dev/null
+    ipset -A gfwlist 91.108.38.0/23 &>/dev/null
+    ipset -A gfwlist 91.108.56.0/22 &>/dev/null
+    ipset -A gfwlist 149.154.160.0/20 &>/dev/null
+    ipset -A gfwlist 149.154.164.0/22 &>/dev/null
+    ipset -A gfwlist 149.154.172.0/22 &>/dev/null
     perl -ne 'print if m@^\d++\.\d++\.\d++\.\d++(?:/\d++)?$@' $dnsmasq_gfwlist_ext | xargs -n1 ipset -A gfwlist &>/dev/null
     [[ "$mode" == *tcp ]] && iptables -t nat -A SS-TCP -p tcp -d ${dns_remote%%:*} -j REDIRECT --to-ports 60080
     iptables -t nat -A SS-TCP -p tcp -m set --match-set gfwlist dst -j REDIRECT --to-ports 60080
@@ -743,18 +742,17 @@ tun2socks_gfwlist*)
     iptables -t nat -F POSTROUTING
 
     iptables -t mangle -N TUN2SOCKS
-    ipset -X gfwlist &>/dev/null
-    ipset -N gfwlist hash:net
-    ipset -A gfwlist 91.108.4.0/22
-    ipset -A gfwlist 91.108.8.0/22
-    ipset -A gfwlist 91.108.12.0/22
-    ipset -A gfwlist 91.108.20.0/22
-    ipset -A gfwlist 91.108.36.0/23
-    ipset -A gfwlist 91.108.38.0/23
-    ipset -A gfwlist 91.108.56.0/22
-    ipset -A gfwlist 149.154.160.0/20
-    ipset -A gfwlist 149.154.164.0/22
-    ipset -A gfwlist 149.154.172.0/22
+    ipset -N gfwlist hash:net &>/dev/null
+    ipset -A gfwlist 91.108.4.0/22 &>/dev/null
+    ipset -A gfwlist 91.108.8.0/22 &>/dev/null
+    ipset -A gfwlist 91.108.12.0/22 &>/dev/null
+    ipset -A gfwlist 91.108.20.0/22 &>/dev/null
+    ipset -A gfwlist 91.108.36.0/23 &>/dev/null
+    ipset -A gfwlist 91.108.38.0/23 &>/dev/null
+    ipset -A gfwlist 91.108.56.0/22 &>/dev/null
+    ipset -A gfwlist 149.154.160.0/20 &>/dev/null
+    ipset -A gfwlist 149.154.164.0/22 &>/dev/null
+    ipset -A gfwlist 149.154.172.0/22 &>/dev/null
     perl -ne 'print if m@^\d++\.\d++\.\d++\.\d++(?:/\d++)?$@' $dnsmasq_gfwlist_ext | xargs -n1 ipset -A gfwlist &>/dev/null
     [[ "$mode" != *tcp ]] && iptables -t mangle -A TUN2SOCKS -p udp -d ${dns_remote%%:*} -j MARK --set-mark $iptables_pbr_fwmark
     iptables -t mangle -A TUN2SOCKS -m set --match-set gfwlist dst -j MARK --set-mark $iptables_pbr_fwmark
@@ -836,7 +834,6 @@ function stop {
         iptables -t nat -A POSTROUTING -s $intranet ! -d $intranet -j MASQUERADE
     done
 
-    ipset -X gfwlist &>/dev/null
     ipset -X chnroute &>/dev/null
 
     ip rule show | grep "fwmark $iptables_pbr_fwmark" | awk -F':' '{print $1}' | xargs -n1 ip rule del pref &>/dev/null