Merge pull request #1190 from sofia-riese/redesign-3

feat: improve UI/UX
This commit is contained in:
juewuy
2026-01-31 14:04:40 +08:00
committed by GitHub
5 changed files with 441 additions and 373 deletions

View File

@@ -218,7 +218,7 @@ setrules() {
fi fi
;; ;;
3) 3)
comp_box "是否确认清空全部自定义规则" comp_box "是否确认清空全部自定义规则"
btm_box "1) 是" \ btm_box "1) 是" \
"0) 否,返回上级菜单" "0) 否,返回上级菜单"
read -r -p "$COMMON_INPUT> " res read -r -p "$COMMON_INPUT> " res
@@ -233,9 +233,10 @@ setrules() {
4) 4)
if [ "$proxies_bypass" = "OFF" ]; then if [ "$proxies_bypass" = "OFF" ]; then
comp_box "\033[33m本功能会自动将当前配置文件中的节点域名或IP设置为直连规则以防止出现双重流量\033[0m" \ comp_box "\033[33m本功能会自动将当前配置文件中的节点域名或IP设置为直连规则以防止出现双重流量\033[0m" \
"\033[33m请确保下游设备使用的节点与ShellCrash中使用的节点相同否则无法生效\033[0m" "\033[33m请确保下游设备使用的节点与ShellCrash中使用的节点相同否则无法生效\033[0m" \
btm_box "是否启用节点绕过?" \
"" \ "" \
"是否启用节点绕过?"
btm_box
"1) 是" \ "1) 是" \
"0) 否,返回上级菜单" "0) 否,返回上级菜单"
read -r -p "$COMMON_INPUT> " res read -r -p "$COMMON_INPUT> " res
@@ -503,10 +504,10 @@ setproxies() {
4) 4)
if [ "$proxies_bypass" = "OFF" ]; then if [ "$proxies_bypass" = "OFF" ]; then
comp_box "\033[33m本功能会自动将当前配置文件中的节点域名或IP设置为直连规则以防止出现双重流量\033[0m" \ comp_box "\033[33m本功能会自动将当前配置文件中的节点域名或IP设置为直连规则以防止出现双重流量\033[0m" \
"\033[33m请确保下游设备使用的节点与ShellCrash中使用的节点相同否则无法生效\033[0m" "\033[33m请确保下游设备使用的节点与ShellCrash中使用的节点相同否则无法生效\033[0m" \
btm_box "是否确定启用节点绕过:" \
"" \ "" \
"1) 是" \ "是否确定启用节点绕过:"
btm_box "1) 是" \
"0) 否,返回上级菜单" "0) 否,返回上级菜单"
read -r -p "$COMMON_INPUT> " res read -r -p "$COMMON_INPUT> " res
if [ "$res" = "1" ]; then if [ "$res" = "1" ]; then

View File

@@ -14,77 +14,89 @@ providers() {
while true; do while true; do
# 获取模版名称 # 获取模版名称
if [ -z "$(grep "provider_temp_${CORE_TYPE}" "$CRASHDIR"/configs/ShellCrash.cfg)" ]; then if [ -z "$(grep "provider_temp_${CORE_TYPE}" "$CRASHDIR"/configs/ShellCrash.cfg)" ]; then
provider_temp_des=$(sed -n "1 p" "$CRASHDIR"/configs/${CORE_TYPE}_providers.list | awk '{print $1}') provider_temp_des=$(sed -n "1 p" "$CRASHDIR"/configs/"${CORE_TYPE}"_providers.list | awk '{print $1}')
else else
provider_temp_file=$(grep "provider_temp_${CORE_TYPE}" "$CRASHDIR"/configs/ShellCrash.cfg | awk -F '=' '{print $2}') provider_temp_file=$(grep "provider_temp_${CORE_TYPE}" "$CRASHDIR"/configs/ShellCrash.cfg | awk -F '=' '{print $2}')
provider_temp_des=$(grep "$provider_temp_file" "$CRASHDIR"/configs/${CORE_TYPE}_providers.list | awk '{print $1}') provider_temp_des=$(grep "$provider_temp_file" "$CRASHDIR"/configs/"${CORE_TYPE}"_providers.list | awk '{print $1}')
[ -z "$provider_temp_des" ] && provider_temp_des=$provider_temp_file [ -z "$provider_temp_des" ] && provider_temp_des=$provider_temp_file
fi fi
separator_line "-"
content_line "1) \033[32m生成\033[0m包含全部提供者的配置文件" top_box "1) \033[32m生成\033[0m包含全部提供者的配置文件" \
content_line "2) 选择\033[33m规则模版\033[0m \033[32m$provider_temp_des\033[0m" "2) 选择\033[33m规则模版\033[0m \033[32m$provider_temp_des\033[0m" \
content_line "3) \033[33m清理\033[0mproviders目录文件" "3) \033[33m清理\033[0mproviders目录文件" \
separator_line "-" ""
common_back common_back
read -p "请输入对应字母或数字 > " num read -r -p "请输入对应字母或数字> " num
case "$num" in case "$num" in
"" | 0) "" | 0)
break break
;; ;;
1) 1)
separator_line "-"
if [ -s "$CRASHDIR"/configs/providers.cfg ] || [ -s "$CRASHDIR"/configs/providers_uri.cfg ]; then if [ -s "$CRASHDIR"/configs/providers.cfg ] || [ -s "$CRASHDIR"/configs/providers_uri.cfg ]; then
. "$CRASHDIR/menus/providers_$CORE_TYPE.sh" . "$CRASHDIR/menus/providers_$CORE_TYPE.sh"
gen_providers gen_providers
else else
content_line "\033[31m你还未添加链接或本地配置文件请先添加\033[0m" msg_alert "\033[31m你还未添加链接或本地配置文件请先添加\033[0m"
sleep 1
fi fi
;; ;;
2) 2)
list=$(cat "$CRASHDIR/configs/${CORE_TYPE}_providers.list" | awk '{print $1}') list=$(cat "$CRASHDIR/configs/${CORE_TYPE}_providers.list" | awk '{print $1}')
separator_line "-"
content_line "当前规则模版为:\033[32m$provider_temp_des\033[0m" comp_box "当前规则模版为:\033[32m$provider_temp_des\033[0m" \
content_line "\033[33m请选择在线模版\033[0m" "\033[33m请选择在线模版\033[0m"
separator_line "-"
list_box "$list" list_box "$list"
separator_line "-" content_line ""
content_line "a) 使用\033[36m本地模版\033[0m" content_line "a) 使用\033[36m本地模版\033[0m"
content_line ""
common_back common_back
read -p "请输入对应字母或数字 > " num read -r -p "请输入对应字母或数字> " num
case "$num" in case "$num" in
"" | 0) ;; "" | 0) ;;
a) a)
read -p "请输入模版的路径(绝对路径) > " dir echo ""
if [ -s $dir ]; then read -r -p "请输入模版的路径(绝对路径)> " dir
if [ -s "$dir" ]; then
provider_temp_file=$dir provider_temp_file=$dir
setconfig provider_temp_"$CORE_TYPE" "$provider_temp_file" if setconfig provider_temp_"$CORE_TYPE" "$provider_temp_file"; then
content_line "\033[32m设置成功\033[0m" common_success
else else
content_line "\033[31m输入错误找不到对应模版文件\033[0m" common_failed
fi
else
msg_alert "\033[31m输入错误找不到对应模版文件\033[0m"
fi fi
sleep 1
;; ;;
*) *)
provider_temp_file=$(sed -n "$num p" "$CRASHDIR"/configs/${CORE_TYPE}_providers.list 2>/dev/null | awk '{print $2}') provider_temp_file=$(sed -n "$num p" "$CRASHDIR"/configs/"${CORE_TYPE}"_providers.list 2>/dev/null | awk '{print $2}')
if [ -z "$provider_temp_file" ]; then if [ -z "$provider_temp_file" ]; then
errornum errornum
sleep 1
else else
setconfig provider_temp_"$CORE_TYPE" "$provider_temp_file" if setconfig provider_temp_"$CORE_TYPE" "$provider_temp_file"; then
common_success
else
common_failed
fi
fi fi
;; ;;
esac esac
;; ;;
3) 3)
content_line "\033[33m将清空 $CRASHDIR/providers 目录下所有内容\033[0m" comp_box "\033[33m将清空 $CRASHDIR/providers 目录下所有内容\033[0m" \
read -p "是否继续?(1/0) > " res "" \
[ "$res" = "1" ] && rm -rf "$CRASHDIR"/providers && common_success "是否继续?"
btm_box "1) 是" \
"0) 否"
read -r -p "$COMMON_INPUT> " res
if [ "$res" = "1" ]; then
if rm -rf "$CRASHDIR"/providers; then
common_success
else
common_failed
fi
fi
;; ;;
*) *)
errornum errornum
sleep 1
break
;; ;;
esac esac
done done

View File

@@ -9,18 +9,18 @@ __IS_PROVIDERS_CLASH=1
# 生成clash的providers配置文件 # 生成clash的providers配置文件
gen_providers() { gen_providers() {
if [ -z "$(grep "provider_temp_${CORE_TYPE}" "$CRASHDIR"/configs/ShellCrash.cfg)" ]; then if [ -z "$(grep "provider_temp_${CORE_TYPE}" "$CRASHDIR"/configs/ShellCrash.cfg)" ]; then
provider_temp_file="$(sed -n "1 p" "$CRASHDIR"/configs/${CORE_TYPE}_providers.list | awk '{print $2}')" provider_temp_file="$(sed -n "1 p" "$CRASHDIR"/configs/"${CORE_TYPE}"_providers.list | awk '{print $2}')"
else else
provider_temp_file=$(grep "provider_temp_${CORE_TYPE}" "$CRASHDIR"/configs/ShellCrash.cfg | awk -F '=' '{print $2}') provider_temp_file=$(grep "provider_temp_${CORE_TYPE}" "$CRASHDIR"/configs/ShellCrash.cfg | awk -F '=' '{print $2}')
fi fi
echo "-----------------------------------------------"
if [ -s "$provider_temp_file" ]; then if [ -s "$provider_temp_file" ]; then
ln -sf "$provider_temp_file" "$TMPDIR"/provider_temp_file ln -sf "$provider_temp_file" "$TMPDIR"/provider_temp_file
else else
echo -e "\033[33m正在获取在线模版\033[0m" msg_alert "\033[33m正在获取在线模版......\033[0m"
get_bin "$TMPDIR"/provider_temp_file "rules/${CORE_TYPE}_providers/$provider_temp_file" get_bin "$TMPDIR"/provider_temp_file "rules/${CORE_TYPE}_providers/$provider_temp_file"
[ -z "$(grep -o 'rules' "$TMPDIR"/provider_temp_file)" ] && { [ -z "$(grep -o 'rules' "$TMPDIR"/provider_temp_file)" ] && {
echo -e "\033[31m下载失败请尝试更换安装源\033[0m" msg_alert "\033[31m下载失败请尝试更换安装源\033[0m"
. "$CRASHDIR"/menus/9_upgrade.sh && setserver . "$CRASHDIR"/menus/9_upgrade.sh && setserver
setproviders setproviders
} }
@@ -35,13 +35,13 @@ gen_providers(){
rm -rf "$TMPDIR"/provider_temp_file rm -rf "$TMPDIR"/provider_temp_file
# 基于单订阅生成providers模块 # 基于单订阅生成providers模块
if [ -n "$1" ]; then if [ -n "$1" ]; then
gen_providers_txt $@ gen_providers_txt "$@"
providers_tags=$1 providers_tags=$1
else else
# 基于全部订阅/本地文件生成 # 基于全部订阅/本地文件生成
[ -s "$CRASHDIR"/configs/providers.cfg ] && { [ -s "$CRASHDIR"/configs/providers.cfg ] && {
providers_tags='' providers_tags=''
while read line;do while read -r line; do
gen_providers_txt $line gen_providers_txt $line
providers_tags=$(echo "$providers_tags, $tag" | sed 's/^, //') providers_tags=$(echo "$providers_tags, $tag" | sed 's/^, //')
done <"$CRASHDIR"/configs/providers.cfg done <"$CRASHDIR"/configs/providers.cfg
@@ -61,10 +61,13 @@ gen_providers(){
# 调用内核测试 # 调用内核测试
. "$CRASHDIR"/starts/check_core.sh && check_core && "$TMPDIR"/CrashCore -t -d "$BINDIR" -f "$TMPDIR"/config.yaml . "$CRASHDIR"/starts/check_core.sh && check_core && "$TMPDIR"/CrashCore -t -d "$BINDIR" -f "$TMPDIR"/config.yaml
if [ "$?" = 0 ]; then if [ "$?" = 0 ]; then
echo -e "\033[32m配置文件生成成功\033[0m" msg_alert "\033[32m配置文件生成成功\033[0m"
mkdir -p "$CRASHDIR"/yamls mkdir -p "$CRASHDIR"/yamls
mv -f "$TMPDIR"/config.yaml "$CRASHDIR"/yamls/config.yaml mv -f "$TMPDIR"/config.yaml "$CRASHDIR"/yamls/config.yaml
read -p "是否立即启动/重启服务?(1/0) > " res comp_box "是否立即启动/重启服务?"
btm_box "1) 是" \
"0) 否"
read -r -p "$COMMON_INPUT> " res
[ "$res" = 1 ] && { [ "$res" = 1 ] && {
start_core && . "$CRASHDIR"/libs/set_cron.sh && cronset '更新订阅' start_core && . "$CRASHDIR"/libs/set_cron.sh && cronset '更新订阅'
exit exit
@@ -72,12 +75,12 @@ gen_providers(){
else else
rm -rf "$TMPDIR"/CrashCore rm -rf "$TMPDIR"/CrashCore
rm -rf "$TMPDIR"/config.yaml rm -rf "$TMPDIR"/config.yaml
echo -e "\033[31m生成配置文件出错请仔细检查输入\033[0m" msg_alert "\033[31m生成配置文件出错请仔细检查输入\033[0m"
fi fi
} }
gen_providers_txt() { gen_providers_txt() {
if [ -n "$(echo $2|grep -E '^./')" ];then if [ -n "$(echo "$2" | grep -E '^./')" ]; then
type=file type=file
path=$2 path=$2
download_url= download_url=
@@ -120,4 +123,3 @@ EOF
# 写入提供者 # 写入提供者
echo ' - {name: '"$tag"', type: url-test, tolerance: 100, lazy: true, use: ['"$tag"']}' >>"$TMPDIR"/providers/proxy-groups.yaml echo ' - {name: '"$tag"', type: url-test, tolerance: 100, lazy: true, use: ['"$tag"']}' >>"$TMPDIR"/providers/proxy-groups.yaml
} }

View File

@@ -9,18 +9,17 @@ __IS_PROVIDERS_SINGBOX=1
# 生成singbox的providers配置文件 # 生成singbox的providers配置文件
gen_providers() { gen_providers() {
if [ -z "$(grep "provider_temp_${CORE_TYPE}" "$CRASHDIR"/configs/ShellCrash.cfg)" ]; then if [ -z "$(grep "provider_temp_${CORE_TYPE}" "$CRASHDIR"/configs/ShellCrash.cfg)" ]; then
provider_temp_file="$(sed -n "1 p" "$CRASHDIR"/configs/${CORE_TYPE}_providers.list | awk '{print $2}')" provider_temp_file="$(sed -n "1 p" "$CRASHDIR"/configs/"${CORE_TYPE}"_providers.list | awk '{print $2}')"
else else
provider_temp_file=$(grep "provider_temp_${CORE_TYPE}" "$CRASHDIR"/configs/ShellCrash.cfg | awk -F '=' '{print $2}') provider_temp_file=$(grep "provider_temp_${CORE_TYPE}" "$CRASHDIR"/configs/ShellCrash.cfg | awk -F '=' '{print $2}')
fi fi
echo "-----------------------------------------------"
if [ -s "$provider_temp_file" ]; then if [ -s "$provider_temp_file" ]; then
ln -sf "$provider_temp_file" "$TMPDIR"/provider_temp_file ln -sf "$provider_temp_file" "$TMPDIR"/provider_temp_file
else else
echo -e "\033[33m正在获取在线模版\033[0m" msg_alert "\033[33m正在获取在线模版......\033[0m"
get_bin "$TMPDIR"/provider_temp_file "rules/${CORE_TYPE}_providers/$provider_temp_file" get_bin "$TMPDIR"/provider_temp_file "rules/${CORE_TYPE}_providers/$provider_temp_file"
[ -z "$(grep -o 'route' "$TMPDIR"/provider_temp_file)" ] && { [ -z "$(grep -o 'route' "$TMPDIR"/provider_temp_file)" ] && {
echo -e "\033[31m下载失败请尝试更换安装源\033[0m" msg_alert "\033[31m下载失败请尝试更换安装源\033[0m"
. "$CRASHDIR"/menus/9_upgrade.sh && setserver . "$CRASHDIR"/menus/9_upgrade.sh && setserver
setproviders setproviders
} }
@@ -38,14 +37,14 @@ EOF
EOF EOF
# 基于单订阅生成providers模块 # 基于单订阅生成providers模块
if [ -n "$1" ]; then if [ -n "$1" ]; then
gen_providers_txt $@ gen_providers_txt "$@"
providers_tags=\"$1\" providers_tags=\"$1\"
else else
# 基于全部订阅/本地文件生成 # 基于全部订阅/本地文件生成
[ -s "$CRASHDIR"/configs/providers.cfg ] && { [ -s "$CRASHDIR"/configs/providers.cfg ] && {
providers_tags='' providers_tags=''
while read line;do while read -r line; do
gen_providers_txt $line gen_providers_txt "$line"
providers_tags=$(echo "$providers_tags, \"$tag\"" | sed 's/^, //') providers_tags=$(echo "$providers_tags, \"$tag\"" | sed 's/^, //')
done <"$CRASHDIR"/configs/providers.cfg done <"$CRASHDIR"/configs/providers.cfg
} }
@@ -66,18 +65,21 @@ EOF
# 调用内核测试 # 调用内核测试
. "$CRASHDIR"/starts/check_core.sh && check_core && "$TMPDIR"/CrashCore merge "$TMPDIR"/config.json -C "$TMPDIR"/providers . "$CRASHDIR"/starts/check_core.sh && check_core && "$TMPDIR"/CrashCore merge "$TMPDIR"/config.json -C "$TMPDIR"/providers
if [ "$?" = 0 ]; then if [ "$?" = 0 ]; then
echo -e "\033[32m配置文件生成成功如果启动超时建议更新里手动安装Singbox-srs数据库常用包\033[0m" msg_alert "\033[32m配置文件生成成功如果启动超时建议更新里手动安装Singbox-srs数据库常用包\033[0m"
mkdir -p "$CRASHDIR"/jsons mkdir -p "$CRASHDIR"/jsons
mv -f "$TMPDIR"/config.json "$CRASHDIR"/jsons/config.json mv -f "$TMPDIR"/config.json "$CRASHDIR"/jsons/config.json
rm -rf "$TMPDIR"/providers rm -rf "$TMPDIR"/providerss
read -p "是否立即启动/重启服务?(1/0) > " res comp_box "是否立即启动/重启服务?"
btm_box "1) 是" \
"0) 否"
read -r -p "$COMMON_INPUT> " res
[ "$res" = 1 ] && { [ "$res" = 1 ] && {
start_core && . "$CRASHDIR"/libs/set_cron.sh && cronset '更新订阅' start_core && . "$CRASHDIR"/libs/set_cron.sh && cronset '更新订阅'
exit exit
} }
else else
echo -e "\033[31m生成配置文件出错请仔细检查输入\033[0m"
rm -rf "$TMPDIR"/CrashCore rm -rf "$TMPDIR"/CrashCore
msg_alert "\033[31m生成配置文件出错请仔细检查输入\033[0m"
# rm -rf "$TMPDIR"/providers # rm -rf "$TMPDIR"/providers
fi fi
} }
@@ -91,7 +93,7 @@ gen_providers_txt(){
include=${7#\#} include=${7#\#}
[ -n "$exclude" ] && exclude_ele="\"exclude\": \"$exclude\"," [ -n "$exclude" ] && exclude_ele="\"exclude\": \"$exclude\","
[ -n "$include" ] && include_ele="\"include\": \"$include\"," [ -n "$include" ] && include_ele="\"include\": \"$include\","
if [ -n "$(echo $2|grep -E '^./')" ];then if [ -n "$(echo "$2" | grep -E '^./')" ]; then
cat >>"$TMPDIR"/providers/providers.json <<EOF cat >>"$TMPDIR"/providers/providers.json <<EOF
{ {
"tag": "$tag", "tag": "$tag",

View File

@@ -10,13 +10,17 @@ __IS_MODULE_SUBCONVERTER=1
# Subconverter在线订阅转换 # Subconverter在线订阅转换
subconverter() { subconverter() {
while true; do while true; do
separator_line "-" [ -z "$exclude" ] && exclude="未设置"
content_line "1) \033[32m生成\033[0m包含全部节点/订阅的配置文件" [ -z "$include" ] && include="未设置"
line_break
separator_line "="
content_line "1) \033[32m生成\033[0m包含全部节点订阅的配置文件"
content_line "2) 设置\033[31m排除节点正则\033[0m \033[47;30m$exclude\033[0m" content_line "2) 设置\033[31m排除节点正则\033[0m \033[47;30m$exclude\033[0m"
content_line "3) 设置\033[32m包含节点正则\033[0m \033[47;30m$include\033[0m" content_line "3) 设置\033[32m包含节点正则\033[0m \033[47;30m$include\033[0m"
content_line "4) 选择\033[33m在线规则模版\033[0m" content_line "4) 选择\033[33m在线规则模版\033[0m"
content_line "5) 选择\033[0mSubconverter服务器\033[0m" content_line "5) 选择\033[0mSubconverter服务器\033[0m"
content_line "6) 自定义浏览器UA \033[32m$user_agent\033[0m" content_line "6) 自定义浏览器UA \033[32m$user_agent\033[0m"
content_line ""
common_back common_back
read -r -p "请输入对应数字> " num read -r -p "请输入对应数字> " num
case "$num" in case "$num" in
@@ -50,62 +54,78 @@ subconverter() {
;; ;;
*) *)
errornum errornum
break
;; ;;
esac esac
done done
} }
gen_link_flt() { # 排除节点正则 # 排除节点正则
[ -z "$exclude" ] && exclude="未设置" gen_link_flt() {
separator_line "-" comp_box "\033[33m当前过滤关键字\033[47;30m$exclude\033[0m" \
content_line "\033[33m当前过滤关键字\033[47;30m$exclude\033[0m" "" \
separator_line "-" "\033[33m匹配关键字的节点会在导入时被【屏蔽】\033[0m" \
content_line "\033[33m匹配关键字的节点会在导入时被【屏蔽】\033[0m" "多个关键字可以用\033[30;47m | \033[0m号分隔" \
content_line "多个关键字可以用\033[30;47m | \033[0m号分隔" "\033[32m支持正则表达式\033[0m空格请使用\033[30;47m + \033[0m号替代"
content_line "\033[32m支持正则表达式\033[0m空格请使用\033[30;47m + \033[0m号替代" btm_box "\033[36m请直接输入节点过滤关键字\033[0m" \
separator_line "-" "或输入 d \033[31m清空\033[0m节点过滤关键字" \
content_line " 000 \033[31m删除\033[0m关键字" "或输入 0 返回上级菜单"
content_line " 回车 取消输入并返回上级菜单" read -r -p "请输入> " res
separator_line "-" case "$res" in
read -r -p "请输入关键字 > " exclude 0)
if [ "$exclude" = '000' ]; then return 0
separator_line "-" ;;
d)
exclude='' exclude=''
content_line "\033[31m 已删除节点过滤关键字!!!\033[0m" ;;
*)
exclude="$res"
;;
esac
if setconfig exclude "'$exclude'"; then
common_success
else
common_failed
fi fi
setconfig exclude "'$exclude'"
} }
gen_link_ele() { # 包含节点正则 # 包含节点正则
[ -z "$include" ] && include="未设置" gen_link_ele() {
separator_line "-" comp_box "\033[33m当前筛选关键字\033[47;30m$include\033[0m" \
content_line "\033[33m当前筛选关键字\033[47;30m$include\033[0m" "" \
separator_line "-" "\033[33m仅有匹配关键字的节点才会被【导入】\033[0m" \
content_line "\033[33m仅有匹配关键字的节点才会被【导入】\033[0m" "多个关键字可以用\033[30;47m | \033[0m号分隔" \
content_line "多个关键字可以用\033[30;47m | \033[0m号分隔" "\033[32m支持正则表达式\033[0m空格请使用\033[30;47m + \033[0m号替代"
content_line "\033[32m支持正则表达式\033[0m空格请使用\033[30;47m + \033[0m号替代" btm_box "\033[36m请直接输入节点匹配关键字\033[0m" \
separator_line "-" "或输入 d \033[31m清空\033[0m节点匹配关键字" \
content_line " 000 \033[31m删除\033[0m关键字" "或输入 0 返回上级菜单"
content_line " 回车 取消输入并返回上级菜单" read -r -p "请输入> " res
separator_line "-" case "$res" in
read -r -p "请输入关键字 > " include 0)
if [ "$include" = '000' ]; then return 0
separator_line "-" ;;
include='' d)
content_line "\033[31m 已删除节点匹配关键字!!!\033[0m" include=""
;;
*)
include="$res"
;;
esac
if setconfig exclude "'$include'"; then
common_success
else
common_failed
fi fi
setconfig include "'$include'"
} }
gen_link_config() { #选择在线规则模版 # 选择在线规则模版
gen_link_config() {
list=$(grep -aE '^5' "$CRASHDIR"/configs/servers.list | awk '{print $2$4}') list=$(grep -aE '^5' "$CRASHDIR"/configs/servers.list | awk '{print $2$4}')
now=$(grep -aE '^5' "$CRASHDIR"/configs/servers.list | sed -n ""$rule_link"p" | awk '{print $2}') now=$(grep -aE '^5' "$CRASHDIR"/configs/servers.list | sed -n ""$rule_link"p" | awk '{print $2}')
separator_line "-" comp_box "当前使用规则为:\033[33m$now\033[0m"
content_line "当前使用规则为:\033[33m$now\033[0m"
separator_line "-"
list_box "$list" list_box "$list"
separator_line "-" content_line ""
common_back common_back
read -r -p "请输入对应数字> " num read -r -p "请输入对应数字> " num
totalnum=$(grep -acE '^5' "$CRASHDIR"/configs/servers.list) totalnum=$(grep -acE '^5' "$CRASHDIR"/configs/servers.list)
@@ -116,21 +136,25 @@ gen_link_config() { #选择在线规则模版
elif [ "$num" -le "$totalnum" ]; then elif [ "$num" -le "$totalnum" ]; then
# 将对应标记值写入配置 # 将对应标记值写入配置
rule_link=$num rule_link=$num
setconfig rule_link $rule_link if setconfig rule_link "$rule_link"; then
separator_line "-" msg_alert "\033[32m设置成功返回上级菜单\033[0m"
content_line "\033[32m设置成功返回上级菜单\033[0m" else
common_failed
fi
fi fi
} }
gen_link_server() { #选择Subconverter服务器 # 选择Subconverter服务器
gen_link_server() {
list=$(grep -aE '^3|^4' "$CRASHDIR"/configs/servers.list | awk '{print $3" "$2}') list=$(grep -aE '^3|^4' "$CRASHDIR"/configs/servers.list | awk '{print $3" "$2}')
now=$(grep -aE '^3|^4' "$CRASHDIR"/configs/servers.list | sed -n ""$server_link"p" | awk '{print $3}') now=$(grep -aE '^3|^4' "$CRASHDIR"/configs/servers.list | sed -n ""$server_link"p" | awk '{print $3}')
separator_line "-"
content_line "\033[36m以下为互联网采集的第三方服务器具体安全性请自行斟酌\033[0m" comp_box "\033[36m以下为互联网采集的第三方服务器具体安全性请自行斟酌\033[0m" \
content_line "\033[32m感谢以下作者的无私奉献\033[0m" "\033[32m感谢以下作者的无私奉献\033[0m" \
content_line "当前使用后端为:\033[33m$now\033[0m" "" \
separator_line "-" "当前使用后端为:\033[33m$now\033[0m"
list_box "$list" list_box "$list"
content_line ""
common_back common_back
read -r -p "请输入对应数字> " num read -r -p "请输入对应数字> " num
totalnum=$(grep -acE '^3|^4' "$CRASHDIR"/configs/servers.list) totalnum=$(grep -acE '^3|^4' "$CRASHDIR"/configs/servers.list)
@@ -141,23 +165,30 @@ gen_link_server() { #选择Subconverter服务器
elif [ "$num" -le "$totalnum" ]; then elif [ "$num" -le "$totalnum" ]; then
# 将对应标记值写入配置 # 将对应标记值写入配置
server_link=$num server_link=$num
setconfig server_link $server_link if setconfig server_link "$server_link"; then
separator_line "-"
content_line "\033[32m设置成功返回上级菜单\033[0m" content_line "\033[32m设置成功返回上级菜单\033[0m"
else
common_failed
fi
fi fi
} }
set_sub_ua() { set_sub_ua() {
separator_line "-" while true; do
content_line "\033[36m无法正确获取配置文件时可尝试使用\033[0m" comp_box "\033[36m无法正确获取配置文件时可尝试使用\033[0m" \
content_line " 1 使用自动UA(默认)" "" \
content_line " 2 不使用UA" "当前UA$user_agent"
content_line " 3 使用自定义UA\033[32m$user_agent\033[0m" content_line "1) 使用自动UA默认"
separator_line "-" content_line "2) 不使用UA"
content_line "3) 使用自定义UA"
content_line "4) 清空UA"
content_line ""
content_line "0) 返回上级菜单"
separator_line "="
read -r -p "请输入对应数字> " num read -r -p "请输入对应数字> " num
case "$num" in case "$num" in
0) 0)
user_agent='' break
;; ;;
1) 1)
user_agent='auto' user_agent='auto'
@@ -166,12 +197,32 @@ set_sub_ua() {
user_agent='none' user_agent='none'
;; ;;
3) 3)
read -r -p "请输入自定义UA(不要包含空格特殊符号!) > " text comp_box "\033[33m注意\n自定义UA不可包含空格特殊符号!\033[0m"
[ -n "$text" ] && user_agent="$text" btm_box "\033[36m请直接输入自定义UA\033[0m" \
"或输入 0 返回上级菜单"
read -r -p "请输入> " text
if [ "$text" = 0 ]; then
continue
elif [ -n "$text" ]; then
user_agent="$text"
fi
;;
4)
user_agent=''
;; ;;
*) *)
errornum errornum
continue
;; ;;
esac esac
[ "$num" -le 3 ] && setconfig user_agent "$user_agent"
if [ "$num" -ge 1 ] && [ "$num" -le 4 ]; then
if setconfig user_agent "$user_agent"; then
common_success
else
common_failed
fi
fi
break
done
} }