~增加了启动时对自定义配置文件的校验功能
~日志推送功能增加自定义设备名称
~修复新手引导的一个导致redir模式无法正常运行的bug
This commit is contained in:
juewuy
2023-04-12 21:03:18 +08:00
parent 86d7f46bf2
commit ca2da3f8fd
7 changed files with 23 additions and 9 deletions

Binary file not shown.

Binary file not shown.

View File

@@ -3,4 +3,4 @@ clashpre_v=2022.11.25
clash_v=v1.7.1
meta_v=v1.14.2
GeoIP_v=20230408
versionsh=1.7.4e
versionsh=1.7.4f

View File

@@ -193,12 +193,14 @@ log_pusher(){
[ -n "$push_Deer" ] && stat_Deer=32m已启用 || stat_Deer=33m未启用
[ -n "$push_bark" ] && stat_bark=32m已启用 || stat_bark=33m未启用
[ -n "$push_Po" ] && stat_Po=32m已启用 || stat_Po=33m未启用
[ -n "$device_name" ] && device_s=32m$device_name || device_s=33m未设置
echo -----------------------------------------------
echo -e " 1 查看\033[36m运行日志\033[0m"
echo -e " 2 Telegram推送 ——\033[$stat_TG\033[0m"
echo -e " 3 PushDeer推送 ——\033[$stat_Deer\033[0m"
echo -e " 4 Bark推送-IOS ——\033[$stat_bark\033[0m"
echo -e " 5 Passover推送 ——\033[$stat_Po\033[0m"
echo -e " 9 设置设备名称 ——\033[$device_s\033[0m"
echo -----------------------------------------------
read -p "请输入对应数字 > " num
case $num in
@@ -342,6 +344,12 @@ log_pusher(){
sleep 1
log_pusher
;;
9)
read -p "请输入本设备自定义推送名称 > " device_name
setconfig device_name $device_name
sleep 1
log_pusher
;;
*) errornum ;;
esac
}

View File

@@ -941,7 +941,7 @@ userguide(){
errornum
forwhat
elif [ "$num" = 1 ];then
redir_mod="redir模式"
redir_mod="Redir模式"
ckcmd nft && redir_mod="Nft基础"
modprobe nft_tproxy &> /dev/null && redir_mod="Nft混合"
setconfig redir_mod "$redir_mod"

View File

@@ -1,7 +1,7 @@
#!/bin/sh
# Copyright (C) Juewuy
version=1.7.4e
version=1.7.4f
setdir(){
dir_avail(){

View File

@@ -49,13 +49,14 @@ compare(){
fi
}
logger(){
#$1文字描述$2显示颜色$3是否推送
#$1日志内容$2显示颜色$3是否推送
[ -n "$2" ] && echo -e "\033[$2m$1\033[0m"
log_text="$(date "+%G-%m-%d_%H:%M:%S")~$1"
echo $log_text >> /tmp/ShellClash_log
[ "$(wc -l /tmp/ShellClash_log | awk '{print $1}')" -gt 99 ] && sed -i '1,5d' /tmp/ShellClash_log
[ -z "$3" ] && {
getconfig
[ -n "$device_name" ] && log_text="$log_text($device_name)"
[ -n "$(pidof clash)" ] && {
[ -n "$authentication" ] && auth="$authentication@"
export https_proxy="http://${auth}127.0.0.1:$mix_port"
@@ -403,8 +404,13 @@ EOF
[ -f $tmpdir/proxy.yaml ] && yaml_proxy=$tmpdir/proxy.yaml
[ -f $tmpdir/rule.yaml ] && yaml_rule=$tmpdir/rule.yaml
cut -c 1- $tmpdir/set.yaml $yaml_hosts $yaml_user $yaml_proxy $yaml_rule > $tmpdir/config.yaml
#测试自定义配置文件
$bindir/clash -t -d $bindir -f $tmpdir/config.yaml >/dev/null
if [ "$?" != 0 ];then
logger "$($bindir/clash -t -d $bindir -f $tmpdir/config.yaml | grep -Eo 'error=.*')" 31
logger "自定义配置文件校验失败!将使用基础配置文件启动!" 33
sed -i "/#自定义/d" $tmpdir/config.yaml
fi
#插入自定义代理
sed -i "/#自定义代理/d" $tmpdir/config.yaml
space=$(sed -n '/^proxies:/{n;p}' $tmpdir/config.yaml | grep -oE '^ *') #获取空格数
@@ -1211,6 +1217,7 @@ afstart(){
/etc/init.d/dnsmasq restart >/dev/null 2>&1
fi
fi
return 0
}
#设置路由规则
#[ "$ipv6_redir" = "已开启" ] && ipv6_wan=$(ip addr show|grep -A1 'inet6 [^f:]'|grep -oE 'inet6 ([a-f0-9:]+)/'|sed s#inet6\ ##g|sed s#/##g)
@@ -1243,9 +1250,8 @@ afstart(){
#推送日志
{ sleep 30;logger Clash服务已启动;} &
else
logger "Clash服务启动失败请查看报错信息" 31
$bindir/clash -t -d $bindir
echo "$($bindir/clash -t -d $bindir)" >> $clashdir/log
logger "Clash服务启动失败请查看报错信息" 33
logger "$($bindir/clash -t -d $bindir | grep -Eo 'error=.*')" 31
$0 stop
exit 1
fi