2023年12月

本补丁文件,修正了V1.0.0版本的适配问题。新增了用户运行权限。
微信图片_20231229001008.png

--- feeds/thunder/openwrt/luci-app-thunder/luasrc/view/thunder/thunder_status.htm
+++ feeds/thunder/openwrt/luci-app-thunder/luasrc/view/thunder/thunder_status.htm
@@ -7,7 +7,7 @@
             {
                 if (data.running)
                 {
-                    tb.innerHTML = '<em style=\"color:green\"><b>' + data.application + '<%:RUNNING%></b></em>' + "<input class=\"cbi-button cbi-button-reload mar-10\" type=\"button\" value=\" <%:Open Web Interface%> \" onclick=\"window.open('//" + window.location.hostname + ":" + <%=luci.sys.exec("uci -q get thunder.@thunder[0].port"):gsub("^%s*(.-)%s*$", "%1")%> + "/')\"/>";
+                    tb.innerHTML = '<em style=\"color:green\"><b>' + data.application + '<%:RUNNING%></b></em>' + "<input class=\"cbi-button cbi-button-reload mar-10\" type=\"button\" value=\" <%:Open Web Interface%> \" onclick=\"window.open('//" + window.location.hostname + ":" + <%=luci.sys.exec("uci -q get thunder.@thunder[0].bind | awk -F: '//{print $2}'"):gsub("^%s*(.-)%s*$", "%1")%> + "/')\"/>";
                 }
                 else
                 {


--- feeds/thunder/openwrt/luci-app-thunder/luasrc/model/cbi/thunder/client.lua
+++ feeds/thunder/openwrt/luci-app-thunder/luasrc/model/cbi/thunder/client.lua
@@ -1,3 +1,6 @@
+local sys  = require "luci.sys"
+local util = require "luci.util"
+
 local m, s
 
 m = Map("thunder", translate("Thunder"))
@@ -15,6 +18,12 @@
 o = s:option(Flag, "debug", translate("Debug"))
 o.rmempty = false
 
+user = s:option(ListValue, "user", translate("Run daemon as user"))
+local p_user
+for _, p_user in util.vspairs(util.split(sys.exec("cat /etc/passwd | cut -f 1 -d :"))) do
+    user:value(p_user)
+end
+
 o = s:option(Value, "bind", translate("Bind"))
 o.default = "0.0.0.0:5055"
 

--- feeds/thunder/openwrt/thunder/files/thunder.init
+++ feeds/thunder/openwrt/thunder/files/thunder.init
@@ -8,6 +8,7 @@
     config_get_bool enabled $1 enabled 0
     config_get_bool debug $1 debug 0
     config_get bind $1 bind "0.0.0.0:5055"
+    config_get user $1 user "root"
     config_get auth_password $1 auth_password ''
     config_get config_path $1 config_path "/opt/thunder"
     config_get download_path $1 download_path "/opt/thunder/downloads"
@@ -42,10 +43,19 @@
     fi
 
     rm -rf /var/packages/pan-xunlei-com
-    mkdir -p /var/packages/pan-xunlei-com
-    ln -s /usr/share/thunder/target /var/packages/pan-xunlei-com
-    ln -s /usr/share/thunder/target/host/etc/synoinfo.conf /etc/synoinfo.conf
-    ln -s /usr/share/thunder/target/host/usr/syno/synoman/webman/modules/authenticate.cgi /usr/syno/synoman/webman/modules/authenticate.cgi
+    #mkdir -p /var/packages/pan-xunlei-com
+    if [ ! -d  "/opt/pan-xunlei-com" ] ; then
+        ln -s /mnt/sdb1 /opt
+    fi
+    ln -s /opt/pan-xunlei-com /var/packages/pan-xunlei-com
+    #ln -s /usr/share/thunder/target /var/packages/pan-xunlei-com
+    #ln -s /usr/share/thunder/target/host/etc/synoinfo.conf /etc/synoinfo.conf
+    #ln -s /usr/share/thunder/target/host/usr/syno/synoman/webman/modules/authenticate.cgi /usr/syno/synoman/webman/modules/authenticate.cgi
+
+    /bin/sh -c "$PROG uninstall --uid 0 --gid 0 "
+
+    /bin/sh -c "$PROG install --uid $(awk -F: '/'$user'/{print $3}' /etc/passwd)  --gid 0  --config-path $config_path --download-path $download_path --mount-bind-download-path $mount_bind_download_path"
+
 
     if [ ! -d "$config_path" ]; then
         mkdir -p $config_path
@@ -59,7 +69,7 @@
         mkdir -p $mount_bind_download_path
     fi
     
-    args="--bind $bind --config-path $config_path --download-path $download_path --mount-bind-download-path $mount_bind_download_path"
+    args="--bind $bind"
 
     if [ -n "$auth_password" ]; then
         args="$args --auth-password $auth_password"
@@ -70,7 +80,7 @@
     fi
     
     procd_open_instance
-    procd_set_param command /bin/sh -c "$PROG launcher $args >>/var/log/thunder.log 2>&1"
+    procd_set_param command /bin/sh -c "$PROG start $args >>/var/log/thunder.log 2>&1"
     procd_set_param stdout 0
     procd_set_param stderr 0
     procd_set_param pidfile /var/run/thunder.pid
@@ -91,3 +101,8 @@
     done
     start
 }
+
+stop_service() {
+    /bin/sh -c "$PROG stop --uid 0 --gid 0 "
+
+}


--- feeds/thunder/openwrt/thunder/files/thunder.config
+++ feeds/thunder/openwrt/thunder/files/thunder.config
@@ -3,7 +3,7 @@
     option 'enabled' '0'
     option 'debug' '0'
     option 'bind' '0.0.0.0:5055'
-    option 'port' '5055'
+    option 'user' 'root'
     option 'auth_password' ''
     option 'download_path' '/opt/thunder/downloads'
     option 'mount_bind_download_path' '/thunder'


--- feeds/thunder/openwrt/thunder/Makefile
+++ feeds/thunder/openwrt/thunder/Makefile
@@ -2,7 +2,7 @@
 
 PKG_NAME:=thunder
 
-PKG_VERSION:=3.11.2-32
+PKG_VERSION:=1.0.0
 
 PKG_LICENSE:=MIT
 PKG_MAINTAINER:=gngpp <gngppz@gmail.com>
@@ -42,7 +42,7 @@
     rm $(PKG_SOURCE).sha256 $(PKG_SOURCE)
 
     tar -xvf $(DL_DIR)/$(PKG_SOURCE)
-    mv thunder-$(PKG_VERSION)-$(ARCH)-unknown-linux-musl/* $(PKG_BUILD_DIR)/
+    mv thunder $(PKG_BUILD_DIR)/
 endef
 
 define Build/Compile
@@ -69,7 +69,7 @@
     $(INSTALL_DIR) $(1)/usr/share/thunder/target
     $(INSTALL_DIR) $(1)/usr/share/thunder/target/host
     $(INSTALL_DIR) $(1)/usr/share/thunder/target/etc
-    $(CP) $(PKG_BUILD_DIR)/bin/* $(1)/usr/share/thunder/target/
+    #$(CP) $(PKG_BUILD_DIR)/bin/* $(1)/usr/share/thunder/target/
 
     $(INSTALL_DIR) $(1)/etc/init.d
     $(INSTALL_BIN) $(CURDIR)/files/thunder.init $(1)/etc/init.d/thunder

补丁文件下载:071_fix-thunder.zip

有买这个开发板的可以先刷breed-mt7621-newifi-d1的引导程序,原厂的bootload不怎么好用,而且不支持新板的lzma内核解压。微信图片_20231229005124.jpg

--- target/linux/ramips/dts/mt7621_hilink_hlk-7621a.dts
+++ target/linux/ramips/dts/mt7621_hilink_hlk-7621a.dts
@@ -1,14 +1,26 @@
 // SPDX-License-Identifier: GPL-2.0-or-later
-/dts-v1/;
 
 #include "mt7621.dtsi"
 
+#include <dt-bindings/gpio/gpio.h>
+#include <dt-bindings/input/input.h>
+
 / {
     compatible = "hilink,hlk-7621a", "mediatek,mt7621-soc";
     model = "HiLink HLK-7621A";
 
     chosen {
-        bootargs = "console=ttyS0,57600";
+        bootargs = "console=ttyS0,115200";
+    };
+
+    keys {
+        compatible = "gpio-keys";
+
+        reset {
+            label = "reset";
+            gpios = <&gpio 15 GPIO_ACTIVE_LOW>;
+            linux,code = <KEY_RESTART>;
+        };
     };
 };
 
@@ -19,7 +31,8 @@
         compatible = "jedec,spi-nor";
         reg = <0>;
         spi-max-frequency = <44000000>;
-
+        broken-flash-reset;
+            
         partitions {
             compatible = "fixed-partitions";
             #address-cells = <1>;
@@ -53,51 +66,28 @@
 };
 
 &switch0 {
-    ports {
-        port@0 {
-            status = "okay";
-            label = "lan1";
-        };
-
-        port@1 {
-            status = "okay";
-            label = "lan2";
-        };
-
-        port@2 {
-            status = "okay";
-            label = "lan3";
-        };
-
-        port@3 {
-            status = "okay";
-            label = "lan4";
-        };
-
-        port@4 {
-            status = "okay";
-            label = "wan";
-        };
-    };
+    /* must delete compatible property */
+    /delete-property/ compatible;
 };
 
 &gmac0 {
-    mtd-mac-address = <&factory 0x8004>;
+    nvmem-cells = <&macaddr_factory_e000>;
+    nvmem-cell-names = "mac-address";
 };
 
 &state_default {
     gpio {
-        groups = "rgmii2", "jtag";
+        groups = "jtag", "uart", "wdt";
         function = "gpio";
     };
 };
 
 &uartlite2 {
-    status = "okay";
+    status = "disable";
 };
 
 &uartlite3 {
-    status = "okay";
+    status = "disable";
 };
 
 &xhci {
@@ -105,9 +95,80 @@
 };
 
 &sdhci {
-    status = "okay";
+    status = "disable";
 };
 
 &i2c {
-    status = "okay";
+    status = "disable";
+};
+
+&gmac1 {
+    nvmem-cells = <&macaddr_factory_e006>;
+    nvmem-cell-names = "mac-address";
+};
+
+&hnat {
+        mtketh-wan = "eth1";
+        mtketh-ppd = "eth0";
+        mtketh-lan = "eth0";
+    ext-devices = "radio0","radio1","radio2";
+        mtketh-max-gmac = <2>;
+        status = "okay";
+};
+
+&gsw {
+    mediatek,mdio = <&mdio>;
+    mediatek,portmap = "llllw";
+    mediatek,mcm;
+    mt7530,direct-phy-access;
+
+    resets = <&rstctrl 2>;
+    reset-names = "mcm";
+
+    port5: port@5 {
+        compatible = "mediatek,mt753x-port";
+        reg = <5>;
+        phy-mode = "rgmii";
+        fixed-link {
+            speed = <1000>;
+            full-duplex;
+        };
+    };
+
+    port6: port@6 {
+        compatible = "mediatek,mt753x-port";
+        reg = <6>;
+        phy-mode = "rgmii";
+        fixed-link {
+            speed = <1000>;
+            full-duplex;
+        };
+    };
+
+    mdio-bus {
+        #address-cells = <1>;
+        #size-cells = <0>;
+    };
+};
+
+&factory {
+    compatible = "nvmem-cells";
+    #address-cells = <1>;
+    #size-cells = <1>;
+
+    macaddr_factory_e000: macaddr@e000 {
+        reg = <0xe000 0x6>;
+    };
+
+    macaddr_factory_e006: macaddr@e006 {
+        reg = <0xe006 0x6>;
+    };
+};
+
+&pcie {
+    status = "okay";
+};
+
+&uartlite {
+    status = "okay";
 };

--- target/linux/ramips/mt7621/base-files/etc/board.d/02_network
+++ target/linux/ramips/mt7621/base-files/etc/board.d/02_network
@@ -54,6 +54,7 @@
         ucidef_add_switch "switch0" \
             "0:lan:4" "1:lan:3" "2:lan:2" "3:lan:1" "4:wan:5" "6@eth0"
         ;;
+    hilink,hlk-7621a|\
     gehua,ghl-r-001)
         ucidef_add_switch "switch0" \
             "0:lan" "1:lan" "2:lan" "4:wan" "6u@eth0" "5u@eth1"

--- target/linux/ramips/image/mt7621.mk
+++ target/linux/ramips/image/mt7621.mk
@@ -778,10 +778,14 @@
 TARGET_DEVICES += hatlab_gateboard-one
 
 define Device/hilink_hlk-7621a
+  $(Device/dsa-migration)
+  $(Device/uimage-lzma-loader)
   IMAGE_SIZE := 32448k
   DEVICE_VENDOR := HiLink
   DEVICE_MODEL := HLK-7621A
-  DEVICE_PACKAGES := kmod-usb3
+  SUPPORTED_DEVICES += hlk-7621a
+  DEVICE_COMPAT_VERSION := 1.1
+  DEVICE_PACKAGES := kmod-usb3 
 endef
 TARGET_DEVICES += hilink_hlk-7621a
 
--- target/linux/ramips/Makefile
+++ target/linux/ramips/Makefile
@@ -10,8 +10,8 @@
 SUBTARGETS:=mt7620 mt7621 mt76x8 rt288x rt305x rt3883
 FEATURES:=squashfs gpio boot-part rootfs-part
 
-KERNEL_PATCHVER:=5.4
-KERNEL_TESTING_PATCHVER:=5.10
+KERNEL_PATCHVER:=5.10
+KERNEL_TESTING_PATCHVER:=5.15
 
 define Target/Description
     Build firmware images for Ralink RT288x/RT3xxx based boards.

补丁文件下载:12_fix_hlk-7621.zip

#!/bin/sh
# Modify by HSIAO-YANG CHEN
# crontab: * * * * *  /bin/sh /usr/kickass.sh
#

#强信号 -60
STRONG=-60
#弱信号 -78
WEAK=-78


# 指定日志文件和5G频段设备MAC保存地址
logfile="/tmp/kickass.log"
dev5gmacfile="/usr/devmac_5g.db" ;


#默认自动添加计划任务  
crontabsfile="/etc/crontabs/root"
if [ -z $( grep -i $0 "$crontabsfile" )  ] ; then
    echo "* * * * *  /bin/sh /usr/kickass.sh" >>$crontabsfile
    echo "Add task scheduler to crontabs"
fi
#只能运行一个kickass任务
if [  "$( ps | grep -c "kick" )" -gt 3 ] ; then
    echo "shell script already running "
else

    datetime=`date +%Y-%m-%d_%H:%M:%S`
    if [ ! -f "$logfile" ]; then
        echo "creating kickass logfile: $logfile"
        echo "$datetime: kickass log file created." > $logfile
    fi
    #踢除wlan-MAC列表
    kicklist=""; while true ; do

        datetime=`date +%Y-%m-%d_%H:%M:%S`
        #从文件中读取5G频段的MAC地址
        if [ -f "$dev5gmacfile" ] ; then
            dev5gmac=$(cat "$dev5gmacfile")
        fi

        # wlanlist for multiple wlans (e.g., 5GHz/2.4GHz)
        wlanlist="" ; wlanlist=$(ifconfig | grep -i wlan | grep -i -v sta | awk '{ print $1 }')
        #echo "$wlanlist"

        #获取多张网卡的SSID,为后面2.4G强信号判定是否踢除5G设备
        ssid2g5g="" ;    for wlan in $wlanlist ; do 
            ssid2g5g="$ssid2g5g $(iw $wlan info | grep ssid | awk '{ print $2 }')"
        done
        #echo "$ssid2g5g"
        #loop for each wlan
        wlan="" ; for wlan in $wlanlist ; do

            maclist="" ; maclist=$(iw $wlan station dump | awk '/Station/{print $2}')

            #5G频段的网卡AP
            if [ "$(iw $wlan info | grep center1 | awk '{ print $2 }')" -gt "14"  ];then
                #loop for each associated client (station)
                for mac in $maclist ; do
                    #新增5G频段的设备MAC
                    if [ -z "$(echo $dev5gmac | grep -i "$mac")"  ] ; then
                            echo "$mac" >> $dev5gmacfile
                        echo  "$datetime: Add new 5G wifi $mac success! " >> $logfile
                    fi
                    #获取信号强度
                    signal=$(iwinfo $wlan assoclist  | awk 'BEGIN{IGNORECASE=1}/'$mac'/{print $2}')
                    #踢除弱信号设备,终端尝试连接2.4G频段
                    if [ "$signal"  -le "$WEAK" ] ; then
                        #匹配2次踢除设备记录,启动踢除设备
                        if [ -n "$(echo $kicklist | grep -i "$wlan-$mac.*$wlan-$mac")" ] ; then
                            ubus call hostapd.$wlan del_client '{"addr":"'"$mac"'", "reason": 5, "deauth": True, "ban_time": 100}' 
                            echo  "$datetime: Kick $wlan MAC:$mac signal:$signal dBm switch 2.4G!" >> $logfile
                            #踢除设备记录删减
                            kicklist=$(echo $kicklist |sed "s/$wlan-$mac//g")
                        else
                            #踢除设备记录新增      
                            kicklist="$kicklist$wlan-$mac"
                        fi
                    else
                            #踢除设备记录删减
                            kicklist=$(echo $kicklist |sed "s/$wlan-$mac//g")
                    fi
                done
            else
                #2.4G频段的网卡AP
                for mac in $maclist ; do
                    signal=$(iwinfo $wlan assoclist  | awk 'BEGIN{IGNORECASE=1}/'$mac'/{print $2}')
                    #踢除弱信号设备
                    if [ "$signal"  -le "$WEAK" ] ; then
                        #匹配2次踢除设备记录,启动踢除设备
                        if [ -n "$(echo $kicklist | grep -i "$wlan-$mac.*$wlan-$mac")" ] ; then
                            ubus call hostapd.$wlan del_client '{"addr":"'"$mac"'", "reason": 5, "deauth": True, "ban_time": 3000}' 
                            echo  "$datetime: Kick $wlan MAC:$mac signal:$signal dBm tool weak!" >> $logfile
                            kicklist=$(echo $kicklist |sed "s/$wlan-$mac//g")
                        else      
                            kicklist="$kicklist$wlan-$mac"
                        fi
                    #踢除强信号,终端尝试连接5G频段(判断条件:信号比STRONG值大,终端MAC记录在5G频段里,有2个相同SSID的AP)
                     elif [ "$signal" -gt "$STRONG" -a -n "$(echo $dev5gmac | grep -i "$mac")" -a -n "$( echo "$ssid2g5g" | grep -i  "$(iw $wlan info | grep ssid | awk '{ print $2 }').*$(iw $wlan info | grep ssid | awk '{ print $2 }')" )"  ] ; then
                        if [ -n "$(echo $kicklist | grep -i "$wlan-$mac.*$wlan-$mac")" ] ; then
                            ubus call hostapd.$wlan del_client '{"addr":"'"$mac"'", "reason": 5, "deauth": True, "ban_time": 100}' 
                            echo  "$datetime: Kick $wlan MAC:$mac signal:$signal dBm switch 5G!" >> $logfile
                            kicklist=$(echo $kicklist |sed "s/$wlan-$mac//g")
                        else      
                            kicklist="$kicklist$wlan-$mac"
                        fi

                    else
                        kicklist=$(echo $kicklist |sed "s/$wlan-$mac//g")
                    fi
                done
            fi
        done
        #监测周期时间
        sleep 2s
    done
fi

解决设备连接上2.4G频段后,不能自动切换回5G频段。
解决思路:

  1. 移动终端近距离连接上无线AP的5G频段,脚本将5G频段的设备MAC记录保存下来;
  2. 当连接上2.4G频段的移动终端,靠近无线AP时,当2.4G的信号强度高于-60dBm,且设备MAC符合5G频段的设备MAC记录,自动踢除2.4G频段的连接,让移动终端自动切换回5G频段;
  3. 当连接上5G频段的移动终端,远离无线AP时,当5G信号强度低于-75dBm,自动踢除5G频段的连接,让移动终端自动切换回信号强度较高的2.4G频段。

使用方法:

  1. 将脚本保存在/usr/目录下,且赋予可执行权限;
  2. 计划任务添加: * /bin/sh /usr/kickass.sh

脚本下载地址:kickass.zip

有遇到设置2.4G,却无法切换到2.4G频段的,可使用本补丁文件,恢复2.4G频段。

--- package/network/services/hostapd/Makefile
+++ package/network/services/hostapd/Makefile
@@ -28,6 +28,7 @@
     CONFIG_PACKAGE_hostapd-mini \
     CONFIG_WPA_RFKILL_SUPPORT \
     CONFIG_DRIVER_WEXT_SUPPORT \
+    CONFIG_DRIVER_11N_SUPPORT \
     CONFIG_DRIVER_11AC_SUPPORT \
     CONFIG_DRIVER_11AX_SUPPORT \
     CONFIG_WPA_ENABLE_WEP
@@ -74,6 +75,10 @@
 
 STAMP_CONFIGURED:=$(STAMP_CONFIGURED)_$(CONFIG_WPA_MSG_MIN_PRIORITY)
 
+ifneq ($(CONFIG_DRIVER_11N_SUPPORT),)
+  HOSTAPD_IEEE80211N:=y
+endif
+
 ifneq ($(CONFIG_DRIVER_11AC_SUPPORT),)
   HOSTAPD_IEEE80211AC:=y
 endif
@@ -85,6 +90,7 @@
 DRIVER_MAKEOPTS= \
     CONFIG_ACS=$(CONFIG_PACKAGE_kmod-cfg80211) \
     CONFIG_DRIVER_NL80211=$(CONFIG_PACKAGE_kmod-cfg80211) \
+    CONFIG_IEEE80211N=$(HOSTAPD_IEEE80211N) \
     CONFIG_IEEE80211AC=$(HOSTAPD_IEEE80211AC) \
     CONFIG_IEEE80211AX=$(HOSTAPD_IEEE80211AX) \
     CONFIG_DRIVER_WEXT=$(CONFIG_DRIVER_WEXT_SUPPORT) \

--- package/network/services/hostapd/Config.in
+++ package/network/services/hostapd/Config.in
@@ -78,6 +78,10 @@
     select KERNEL_WIRELESS_EXT
     default n
 
+config DRIVER_11N_SUPPORT
+    bool
+    default n
+    
 config DRIVER_11AC_SUPPORT
     bool
     default n

--- package/network/services/hostapd/src/src/utils/build_features.h
+++ package/network/services/hostapd/src/src/utils/build_features.h
@@ -7,6 +7,10 @@
     if (!strcmp(feat, "eap"))
         return 1;
 #endif
+#ifdef CONFIG_IEEE80211N
+    if (!strcmp(feat, "11n"))
+        return 1;
+#endif
 #ifdef CONFIG_IEEE80211AC
     if (!strcmp(feat, "11ac"))
         return 1;

补丁文件下载:06_recover_11N.zip