OSDN Git Service

luci-app-turboacc: fix fullconenat doesn't work after reboot
authorZiMing Mo <msylgj@immortalwrt.org>
Thu, 10 Mar 2022 13:31:16 +0000 (21:31 +0800)
committerZiMing Mo <msylgj@immortalwrt.org>
Thu, 10 Mar 2022 19:38:48 +0000 (03:38 +0800)
applications/luci-app-turboacc/root/etc/hotplug.d/iface/50-turboacc [new file with mode: 0644]
applications/luci-app-turboacc/root/etc/init.d/turboacc

diff --git a/applications/luci-app-turboacc/root/etc/hotplug.d/iface/50-turboacc b/applications/luci-app-turboacc/root/etc/hotplug.d/iface/50-turboacc
new file mode 100644 (file)
index 0000000..a8dc852
--- /dev/null
@@ -0,0 +1,6 @@
+#!/bin/sh
+
+[ "Z$ACTION" = "Zifup" -a "Z$INTERFACE" = "Zwan" ] || exit 0
+
+logger -t turboacc "Reloading turboacc due to $ACTION of $INTERFACE ($DEVICE)"
+sleep 10 && /etc/init.d/turboacc restart >> /var/log/turboacc.log
\ No newline at end of file
index 79bea4b..0f005c3 100755 (executable)
@@ -238,11 +238,13 @@ revert_dns() {
 
 revert_fullcone() {
        local count="$(iptables -t nat -L PREROUTING | grep 'FULLCONENAT' -c)"
-       for i in "${count}"
-       do
-               iptables -t nat -D PREROUTING -i "${ifname}" -j FULLCONENAT
-               iptables -t nat -D POSTROUTING -o "${ifname}" -j FULLCONENAT
-       done
+       [ "${count}" -ne "0" ] && [ -n "${ifname}" ] && {
+               for i in "${count}"
+               do
+                       iptables -t nat -D PREROUTING -i "${ifname}" -j FULLCONENAT
+                       iptables -t nat -D POSTROUTING -o "${ifname}" -j FULLCONENAT
+               done
+       }
 }
 
 start(){
@@ -252,11 +254,11 @@ start(){
        uci set firewall.@defaults[0].flow_offloading_hw="${hw_flow}"
        uci commit firewall
 
-       if [ "${fullcone_nat}" -eq "1" ];  then
+       [ "${fullcone_nat}" -eq "1" ] && [ -n "${ifname}" ] && {
                revert_fullcone
                iptables -t nat -A PREROUTING -i "${ifname}" -j FULLCONENAT
                iptables -t nat -A POSTROUTING -o "${ifname}" -j FULLCONENAT
-       fi
+       }
 
        [ "${sw_flow}" -ne "1" ] && [ "${sfe_flow}" -eq "1" ] && {
                lsmod | grep -q fast_classifier || modprobe fast_classifier 2>"/dev/null"
@@ -272,7 +274,7 @@ start(){
                sysctl -w net.ipv4.tcp_congestion_control="bbr"
        else
                sysctl -w net.ipv4.tcp_congestion_control="cubic"
-       fi      
+       fi
 
        if [ "${dns_caching}" -eq "1" ];  then
                stop_dnscache