OSDN Git Service

luci-app-turboacc: adapted the new fullconenat-nft package
authorZiMing Mo <msylgj@immortalwrt.org>
Fri, 22 Apr 2022 07:35:33 +0000 (15:35 +0800)
committerZiMing Mo <msylgj@immortalwrt.org>
Fri, 22 Apr 2022 07:36:27 +0000 (15:36 +0800)
Signed-off-by: ZiMing Mo <msylgj@immortalwrt.org>
applications/luci-app-turboacc/luasrc/model/cbi/turboacc.lua
applications/luci-app-turboacc/root/etc/hotplug.d/iface/50-turboacc [deleted file]
applications/luci-app-turboacc/root/etc/init.d/turboacc

index 2241240..6af7ee3 100644 (file)
@@ -49,7 +49,7 @@ bbr_cca.default = 0
 bbr_cca.description = translate("Using BBR CCA can improve TCP network performance effectively")
 end 
 
-if nixio.fs.access("/lib/modules/" .. kernel_version .. "/xt_FULLCONENAT.ko") then
+if nixio.fs.access("/lib/modules/" .. kernel_version .. "/nft_fullcone.ko") then
 fullcone_nat = s:option(Flag, "fullcone_nat", translate("FullCone NAT"))
 fullcone_nat.default = 0
 fullcone_nat.description = translate("Using FullCone NAT can improve gaming performance effectively")
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
deleted file mode 100644 (file)
index dfc8089..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-#!/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
index 0f005c3..4fafd3a 100755 (executable)
@@ -5,19 +5,11 @@
 START=90
 STOP=10
 
-. /usr/share/libubox/jshn.sh
-
 extra_command "check_status" "Check running status of utils"
 
 restart_utils="true"
 
-get_ifname(){
-       json_load "$(ubus call network.interface.wan status)"
-       json_get_var "ifname" "l3_device"
-}
-
 inital_conf(){
-       get_ifname
        config_load "turboacc"
        config_get "sw_flow" "config" "sw_flow" "0"
        config_get "hw_flow" "config" "hw_flow" "0"
@@ -33,7 +25,7 @@ inital_conf(){
        [ ! -e "/lib/modules/$(uname -r)/nft_flow_offload.ko" ] && { sw_flow="0"; hw_flow="0"; }
        [ ! -e "/lib/modules/$(uname -r)/fast-classifier.ko" ] && { sfe_flow="0"; sfe_bridge="0"; sfe_ipv6="0"; }
        [ ! -e "/lib/modules/$(uname -r)/tcp_bbr.ko" ] && bbr_cca="0"
-       [ ! -e "/lib/modules/$(uname -r)/xt_FULLCONENAT.ko" ] && fullcone_nat="0"
+       [ ! -e "/lib/modules/$(uname -r)/nft_fullcone.ko" ] && fullcone_nat="0"
 }
 
 start_pdnsd() {
@@ -236,30 +228,14 @@ revert_dns() {
        rm -f "/var/run/dnscache/.dns-changed"
 }
 
-revert_fullcone() {
-       local count="$(iptables -t nat -L PREROUTING | grep 'FULLCONENAT' -c)"
-       [ "${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(){
        inital_conf
 
        uci set firewall.@defaults[0].flow_offloading="${sw_flow}"
        uci set firewall.@defaults[0].flow_offloading_hw="${hw_flow}"
+       uci set firewall.@defaults[0].fullcone="${fullcone_nat}"
        uci commit firewall
 
-       [ "${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
-       }
-
        [ "${sw_flow}" -ne "1" ] && [ "${sfe_flow}" -eq "1" ] && {
                lsmod | grep -q fast_classifier || modprobe fast_classifier 2>"/dev/null"
                echo "${sfe_bridge}" > "/sys/fast_classifier/skip_to_bridge_ingress" 2>"/dev/null"
@@ -300,7 +276,7 @@ start(){
        if [ "${restart_utils}" = "true" ]; then
                echo "DNSMASQ change"
                /etc/init.d/dnsmasq restart >"/dev/null" 2>&1
-               /etc/init.d/firewall restart >"/dev/null" 2>&1
+               /etc/init.d/firewall reload >"/dev/null" 2>&1
        fi
 }
 
@@ -309,10 +285,9 @@ stop(){
 
        uci set firewall.@defaults[0].flow_offloading="${sw_flow}"
        uci set firewall.@defaults[0].flow_offloading_hw="${hw_flow}"
+       uci set firewall.@defaults[0].fullcone="${fullcone_nat}"
        uci commit firewall
 
-       [ "${fullcone_nat}" -eq "1" ] || revert_fullcone
-
        [ "${sfe_flow}" -eq "1" ] || {
                echo "0" > "/sys/fast_classifier/skip_to_bridge_ingress" 2>"/dev/null"
                rm -f "/dev/sfe_ipv6"
@@ -325,7 +300,7 @@ stop(){
        if [ "${restart_utils}" = "true" ]; then
                echo "DNSMASQ revert"
                /etc/init.d/dnsmasq restart >"/dev/null" 2>&1
-               /etc/init.d/firewall restart >"/dev/null" 2>&1
+               /etc/init.d/firewall reload >"/dev/null" 2>&1
        fi
 }
 
@@ -337,7 +312,7 @@ restart(){
 
        echo "DNSMASQ restart"
        /etc/init.d/dnsmasq restart >"/dev/null" 2>&1
-       /etc/init.d/firewall restart >"/dev/null" 2>&1
+       /etc/init.d/firewall reload >"/dev/null" 2>&1
 }
 
 
@@ -358,7 +333,7 @@ check_status(){
                fi
                ;;
        "fullconenat")
-               [ "$(cat "/sys/module/xt_FULLCONENAT/refcnt" 2>"/dev/null" || echo 0)" -ne "0" ] && \
+               [ "$(cat "/sys/module/nft_fullcone/refcnt" 2>"/dev/null" || echo 0)" -ne "0" ] && \
                        exit 0 || exit 1
                ;;
        "bbr")