~增加AX6S的tun模块修复功能
This commit is contained in:
juewuy
2023-03-01 14:06:53 +08:00
parent 89f0336f7f
commit da4258dd34
7 changed files with 45 additions and 619 deletions

View File

@@ -1051,8 +1051,8 @@ clashcfg(){
set_redir_config
elif [ "$num" = 2 ]; then
modprobe tun &>/dev/null || {
echo -e "\033[32m设备未检测到Tun模块可能无法代理UDP流量\033[0m"
modinfo tun &>/dev/null || {
echo -e "\033[32m设备未检测到Tun内核模块可能无法代理UDP流量\033[0m"
sleep 1
}
redir_mod=混合模式
@@ -1063,10 +1063,10 @@ clashcfg(){
set_redir_config
elif [ "$num" = 4 ]; then
if modprobe tun &>/dev/null;then
if modinfo tun &>/dev/null;then
redir_mod=Tun模式
else
read -p "未检测到Tun模块是否强制开启可能导致无法联网(1/0)" res
read -p "设备未检测到Tun内核模块,是否强制开启?可能导致无法联网!(1/0) > " res
[ "$res" = '1' ] && redir_mod=Tun模式
fi
set_redir_config
@@ -1077,7 +1077,7 @@ clashcfg(){
elif [ "$num" = 6 ]; then
if ckcmd opkg && [ -z "$(opkg list-installed | grep firewall4)" ];then
read -p "检测到缺少firewall4依赖是否自动安装(1/0)" res
read -p "检测到缺少firewall4依赖是否自动安装(1/0) > " res
[ "$res" = '1' ] && opkg install firewall4 && redir_mod=Nft基础
else
redir_mod=Nft基础
@@ -1086,7 +1086,7 @@ clashcfg(){
elif [ "$num" = 7 ]; then
if ckcmd opkg && [ -z "$(opkg list-installed | grep kmod-nft-tproxy)" ];then
read -p "检测到缺少kmod-nft-tproxy依赖是否自动安装(1/0)" res
read -p "检测到缺少kmod-nft-tproxy依赖是否自动安装(1/0) > " res
[ "$res" = '1' ] && opkg install kmod-nft-tproxy && redir_mod=Nft混合
else
redir_mod=Nft混合

View File

@@ -672,7 +672,7 @@ setdb(){
}
getcrt(){
crtlink="${update_url}/bin/ca-certificates.crt"
crtlink="${update_url}/bin/fix/ca-certificates.crt"
echo -----------------------------------------------
echo 正在连接服务器获取安装文件…………
$clashdir/start.sh webget /tmp/ca-certificates.crt $crtlink
@@ -939,7 +939,8 @@ userguide(){
errornum
forwhat
elif [ "$num" = 1 ];then
setconfig redir_mod "Redir模式"
redir_mod="Redir模式"
setconfig redir_mod "$redir_mod"
#设置开机启动
[ -f /etc/rc.common ] && /etc/init.d/clash enable
[ "$(pidof systemd)" = 1 ] && systemctl enable clash.service > /dev/null 2>&1

View File

@@ -4,27 +4,55 @@
clashdir=/data/clash
profile=/etc/profile
#检查clash运行状态
if [ -z $(pidof clash) ]; then
tunfix(){
#在/tmp创建并挂载overlay
[ -e /tmp/overlay ] || mkdir /tmp/overlay
[ -e /tmp/overlay/upper ] || mkdir /tmp/overlay/upper
[ -e /tmp/overlay/work ] || mkdir /tmp/overlay/work
mount --bind /tmp/overlay /overlay
. /lib/functions/preinit.sh
fopivot /overlay/upper /overlay/work /rom 1
#Fixup miwifi misc, and DO NOT use /overlay/upper/etc instead, /etc/uci-defaults/* may be already removed
mount -o noatime,move /rom/data /data 2>&-
mount -o noatime,move /rom/etc /etc 2>&-
mount -o noatime,move /rom/userdisk /userdisk 2>&-
#将tun.ko链接到lib
ln -s $clashdir/tun.ko /overlay/upper/lib/modules/4.4.198/tun.ko
}
init(){
#初始化环境变量
sed -i "/alias clash/d" $profile
sed -i "/export clashdir/d" $profile
echo "alias clash=\"$clashdir/clash.sh\"" >>$profile
echo "export clashdir=\"$clashdir\"" >>$profile
#设置init.d服务并启动clash服务
#设置init.d服务
cp -f $clashdir/clashservice /etc/init.d/clash
chmod 755 /etc/init.d/clash
#启动服务
if [ ! -f $clashdir/.dis_startup ]; then
log_file=$(uci get system.@system[0].log_file)
while [ "$i" -lt 10 ]; do
sleep 5
[ -n "$(grep 'init complete' $log_file)" ] && i=10 || i=$((i + 1))
done
#AX6S/AX6000修复tun功能
[ -f $clashdir/tun.ko -a ! -f /lib/modules/4.4.198/tun.ko ] && tunfix
#
/etc/init.d/clash start
/etc/init.d/clash enable
fi
else
sleep 10
$clashdir/start.sh restart
fi
}
case "$1" in
tunfix) tunfix ;;
init) init ;;
*)
if [ -z $(pidof clash) ];then
init
else
sleep 10
$clashdir/start.sh restart
fi
;;
esac