Merge branch 'juewuy:dev' into patch-3

This commit is contained in:
Sofia
2026-01-15 03:01:19 +08:00
committed by GitHub
37 changed files with 2789 additions and 2182 deletions

View File

@@ -1,7 +1,4 @@
<h1 align="center"> <h1 align="center">ShellCrash</h1>
<br>ShellCrash<br>
</h1>
<p align="center"> <p align="center">
<a target="_blank" href="https://github.com/MetaCubeX/mihomo/releases"> <a target="_blank" href="https://github.com/MetaCubeX/mihomo/releases">
@@ -12,147 +9,177 @@
</a> </a>
</p> </p>
中文 | [English](README.md) <p align="center">
<strong>一款在 Shell 环境下便捷部署与管理 mihomo/sing-box 内核的脚本工具</strong>
</p>
功能简介: <p align="center">
-- 简体中文 | <a href="README.md">English</a>
</p>
~通过管理脚本在Shell环境下便捷使用Mihomo/Singbox内核<br> ---
~支持在Shell环境下管理<br>
~支持在线导入订阅及配置链接<br>
~支持配置定时任务,支持配置文件定时更新<br>
~支持在线安装及使用本地网页面板管理内置规则<br>
~支持路由模式、本机模式等多种模式切换<br>
~支持在线更新<br>
设备支持: ## :rocket: 核心特性
--
~支持各种基于OpenWrt或使用OpenWrt二次定制开发的路由器设备<br> - **多内核支持**:在 Shell 环境下便捷管理及切换 **mihomo****sing-box** 内核。
~支持各种运行标准Linux系统如Debian/CenOS/Armbian等的设备<br> - **灵活配置管理**:支持在线导入订阅连结及配置文件,简化配置流程。
~兼容Padavan固件保守模式、潘多拉固件以及华硕/梅林固件<br> - **自动化任务**:支持配置定时任务,实现配置文件与规则的自动定时更新。
~兼容各类使用Linux内核定制开发的各类型设备<br> - **图形化面板**:支持在线安装并使用本地 Web 面板Dashboard直观管理内置规则与流量。
- **多模式运行**:支持路由模式、本机模式等多种流量转发模式切换。
- **一键维护**:内置脚本在线更新功能,保持版本与功能的及时更迭。
——————————<br> ## :computer: 设备支持
~更多设备支持请提issue或前往TG群反馈需提供设备名称及运行uname -a返回的设备核心信息<br>
## 常见问题 ShellCrash 旨在兼容绝大多数基于 Linux 内核的网络设备
[ShellCrash常见问题 | Juewuy's Blog](https://juewuy.github.io/chang-jian-wen-ti/) * **路由器设备**:支持各种基于 OpenWrt 或其二次开发的固件。
* **Linux 服务器**:支持运行标准 Linux 发行版(如 Debian、CentOS、Armbian、Ubuntu 等)的设备。
* **第三方固件**:兼容 Padavan保守模式、潘多拉固件以及华硕/梅林固件。
* **各类定制设备**:兼容其他使用 Linux 内核开发的专用网络设备。
## 使用方式: > 更多设备支持,请提交 [Issue](https://github.com/juewuy/ShellCrash/issues) 或前往 [Telegram 群组](https://t.me/ShellClash) 反馈(请附上设备型号及 `uname -a` 命令的输出信息)。
~确认设备已经开启SSH并获取root权限带GUI桌面的Linux设备可使用自带终端安装<br> ---
~使用SSH连接工具如puttyJuiceSSH系统自带终端等路由器或Linux设备的SSH管理界面或终端界面
~之后在SSH界面执行目标设备对应的安装命令并按照后续提示完成安装<br> ## :hammer_and_wrench: 安装指南
### 在线安装:<br> > [!TIP]
> 若遇到连接失败或SSL相关问题请尝试切换至其他安装镜像站。
**如无法连接或出现SSL连接错误请尝试更换各种不同的安装源**<br> ### 前置条件
1. 确保设备已开启 **SSH** 并获得 **Root 权限**(带图形介面的 Linux 系统可直接使用终端)。
2. 使用 SSH 工具(如 Putty、JuiceSSH、或系统自带终端连接至设备。
~**标准Linux设备安装**<br> ### :penguin: 标准 Linux 设备安装
```shell > [!IMPORTANT]
sudo -i #切换到root用户,如果需要密码,请输入密码 > 请以 root 用户进行安装。
export url='https://testingcf.jsdelivr.net/gh/juewuy/ShellCrash@master' && wget -q --no-check-certificate -O /tmp/install.sh $url/install.sh && bash /tmp/install.sh && . /etc/profile &> /dev/null
``` > 使用 wget 安装jsDelivr CDN 源)
或者 ```sh
```shell export url='https://testingcf.jsdelivr.net/gh/juewuy/ShellCrash@master' \
sudo -i #切换到root用户如果需要密码请输入密码 && wget -q --no-check-certificate -O /tmp/install.sh $url/install.sh \
export url='https://gh.jwsc.eu.org/master' && bash -c "$(curl -kfsSl $url/install.sh)" && . /etc/profile &> /dev/null && bash /tmp/install.sh \
&& . /etc/profile &> /dev/null
``` ```
~**路由设备使用curl安装**<br> > 使用 curl 安装(作者私人源)
```shell ```sh
#GitHub源(可能需要代理) export url='https://gh.jwsc.eu.org/master' \
export url='https://raw.githubusercontent.com/juewuy/ShellCrash/master' && sh -c "$(curl -kfsSl $url/install.sh)" && . /etc/profile &> /dev/null && bash -c "$(curl -kfsSl $url/install.sh)" \
``` && . /etc/profile &> /dev/null
或者
```shell
#jsDelivrCDN源
export url='https://testingcf.jsdelivr.net/gh/juewuy/ShellCrash@master' && sh -c "$(curl -kfsSl $url/install.sh)" && . /etc/profile &> /dev/null
```
或者
```shell
#作者私人源
export url='https://gh.jwsc.eu.org/master' && sh -c "$(curl -kfsSl $url/install.sh)" && . /etc/profile &> /dev/null
``` ```
~**路由设备使用wget安装**<br> ### :satellite: 路由设备安装
```Shell **使用 `curl` 安装:**
#GitHub源(可能需要代理) > GitHub 源(推荐海外环境或具备代理环境使用)
export url='https://raw.githubusercontent.com/juewuy/ShellCrash/master' && wget -q --no-check-certificate -O /tmp/install.sh $url/install.sh && sh /tmp/install.sh && . /etc/profile &> /dev/null ```sh
``` export url='https://raw.githubusercontent.com/juewuy/ShellCrash/master' \
或者 && sh -c "$(curl -kfsSl $url/install.sh)" \
```shell && . /etc/profile &> /dev/null
#jsDelivrCDN源
export url='https://testingcf.jsdelivr.net/gh/juewuy/ShellCrash@master' && wget -q --no-check-certificate -O /tmp/install.sh $url/install.sh && sh /tmp/install.sh && . /etc/profile &> /dev/null
``` ```
~**老旧设备使用低版本wge安装**<br> > 或 jsDelivr CDN 源
```Shell ```sh
#作者私人http内测源 export url='https://testingcf.jsdelivr.net/gh/juewuy/ShellCrash@master' \
export url='http://t.jwsc.eu.org' && wget -q -O /tmp/install.sh $url/install.sh && sh /tmp/install.sh && . /etc/profile &> /dev/null && sh -c "$(curl -kfsSl $url/install.sh)" \
&& . /etc/profile &> /dev/null
``` ```
##### ~**虚拟机安装:**<br> > 或作者私人源
```sh
export url='https://gh.jwsc.eu.org/master' \
&& sh -c "$(curl -kfsSl $url/install.sh)" \
&& . /etc/profile &> /dev/null
```
虚拟机环境强烈建议使用Alpine镜像安装<br> **使用 `wget` 安装:**
> GitHub 源(推荐海外环境或具备代理环境使用)
```sh
export url='https://raw.githubusercontent.com/juewuy/ShellCrash/master' \
&& wget -q --no-check-certificate -O /tmp/install.sh $url/install.sh \
&& sh /tmp/install.sh \
&& . /etc/profile &> /dev/null
```
```shell > 或 jsDelivr CDN 源
```sh
export url='https://testingcf.jsdelivr.net/gh/juewuy/ShellCrash@master' \
&& wget -q --no-check-certificate -O /tmp/install.sh $url/install.sh \
&& sh /tmp/install.sh \
&& . /etc/profile &> /dev/null
```
### :pager: 老旧设备使用低版本 `wget` 安装
> 作者私人 http 内测源
```sh
export url='http://t.jwsc.eu.org' \
&& wget -q -O /tmp/install.sh $url/install.sh \
&& sh /tmp/install.sh \
&& . /etc/profile &> /dev/null
```
### :cloud: 虚拟机
- **Alpine Linux 虚拟机**:强烈建议使用 Alpine 镜像以获得最佳兼容性
```sh
# 安装必要依赖 # 安装必要依赖
apk add --no-cache wget openrc ca-certificates tzdata nftables iproute2 dcron apk add --no-cache wget openrc ca-certificates tzdata nftables iproute2 dcron
# 执行安装命令 # 执行安装命令
export url='https://testingcf.jsdelivr.net/gh/juewuy/ShellCrash@master' && wget -q --no-check-certificate -O /tmp/install.sh $url/install.sh && sh /tmp/install.sh && . /etc/profile &> /dev/null export url='https://testingcf.jsdelivr.net/gh/juewuy/ShellCrash@master' \
&& wget -q --no-check-certificate -O /tmp/install.sh $url/install.sh \
&& sh /tmp/install.sh \
&& . /etc/profile &> /dev/null
``` ```
##### ~Docker安装<br> ### :whale: Docker
请前往[ShellCrash官方Docker镜像](https://hub.docker.com/r/juewuy/shellcrash) 请访问官方 Docker 镜像
### **本地安装:**<br> - [ShellCrash on Docker Hub](https://hub.docker.com/r/juewuy/shellcrash)
如使用在线安装出现问题,请参考:[本地安装ShellCrash的教程 | Juewuy's Blog](https://juewuy.github.io/bdaz) 使用本地安装!<br>
### 使用脚本:<br> ### :package: 本地安装
安装完成管理脚本后,执行如下命令使用~ 若无法进行在线安装,请参照以下指南执行本地安装:
```Shell - [本地安装ShellCrash教程 | Juewuy's Blog](https://juewuy.github.io/bdaz)
crash #进入对话
crash -h #帮助列表
```
#### **运行时的额外依赖**<br> ---
> 大部分的设备/系统都已经预装了以下的大部分依赖,使用时如无影响可以无视之 ## :book: 使用说明
安装完成后,在终端输入以下指令即可启动管理界面:
```shell ```shell
curl/wget 必须 全部缺少时无法在线安装及更新,无法使用节点保存功能 crash # 启动脚本交互选单
iptables/nftables 重要 缺少时只能使用纯净模式 crash -h # 查看命令帮助列表
crontab 较低 缺少时无法启用定时任务功能
net-tools 极低 缺少时无法正常检测端口占用
ubus/iproute-doc 极低 缺少时无法正常获取本机host地址
``` ```
### 运行依赖说明
| 依赖组件 | 必要性 | 说明 |
| :--- | :--- | :--- |
| curl / wget | 必须 | 缺少时将无法进行节点保存、在线安装及更新操作 |
| iptables / nftables | 重要 | 缺少时仅能运行于纯淨模式 |
| crontab | 较低 | 缺少时定时任务功能将失效 |
| net-tools | 极低 | 缺少时无法自动检测端口占用 |
| ubus / iproute-doc | 极低 | 缺少时无法自动获取本机 Host 地址 |
---
更新日志: ## :link: 相关链接
-- - 常见问题:[Juewuy's Blog](https://juewuy.github.io/chang-jian-wen-ti/)
- 更新日志:[Release History](https://github.com/juewuy/ShellCrash/releases)
- 交流反馈:[Telegram 讨论组](https://t.me/ShellClash)
### [点击查看](https://github.com/juewuy/ShellCrash/releases) ---
交流反馈: ## :airplane: 机场推荐
--
### [TG讨论组](https://t.me/ShellClash)
机场推荐: - [**Dler-墙洞**](https://dler.pro/auth/register?affid=89698),多年稳定运行,功能齐全。
-- - [**大米**](https://1s.bigmeok.me/user#/register?code=2PuWY9I7),群友力荐,流媒体解锁,月付推荐。
#### [Dler-墙洞,多年稳定运行,功能齐全](https://dler.pro/auth/register?affid=89698)<br>
#### [大米-群友力荐,流媒体解锁,月付推荐](https://1s.bigmeok.me/user#/register?code=2PuWY9I7)<br>

Binary file not shown.

Binary file not shown.

View File

@@ -1,4 +1,4 @@
meta_v=v1.19.17 meta_v=v1.19.17
singboxr_v=1.13.0-alpha.27 singboxr_v=1.13.0-alpha.27
versionsh=1.9.4beta1.1 versionsh=1.9.4beta2
GeoIP_v=20251205 GeoIP_v=20251205

View File

@@ -1,36 +1,125 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# Copyright (C) Juewuy # Copyright (C) Juewuy
# ================================= table format tools =================================
# >>>>>>>>>>>>>>
# set the total width of the menu
# (adjusting this number will automatically change the entire menu, including the separator lines)
# note: The number represents the number of columns that appear when the "||" appears on the right
TABLE_WIDTH=60
# define two extra-long template strings in advance
# (the length should be greater than the expected TABLE_WIDTH)
FULL_EQ="===================================================================================================="
FULL_DASH="- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - "
# function to print content lines
# (using cursor jump)
content_line() {
echo -e " ${1}\033[${TABLE_WIDTH}G||"
}
# function to print sub content lines
# for printing accompanying instructions
sub_content_line() {
echo -e " ${1}\033[${TABLE_WIDTH}G||"
content_line
}
# increase the spacing between the front
# and back forms to improve readability
double_line_break() {
printf "\n\n"
}
# function to print separators
# (using string slicing)
# parameter $1: pass in "=" or "-"
separator_line() {
local separator_type="$1"
local output_line=""
local len=$((TABLE_WIDTH - 1))
if [ "$separator_type" == "=" ]; then
output_line="${FULL_EQ:0:$len}"
else
output_line="${FULL_DASH:0:$len}"
fi
echo "${output_line}||"
}
# <<<<<<<<<<<<<<
# ================================= table format tools =================================
# =============================== display prompt message ===============================
# >>>>>>>>>>>>>>
abort_install() {
double_line_break
separator_line "="
content_line "安装已取消"
separator_line "="
double_line_break
exit 1
}
invalid_input_retry() {
double_line_break
separator_line "="
content_line "\033[31m输入错误\033[0m"
content_line "\033[31m请重新设置\033[0m"
separator_line "="
sleep 1
}
# <<<<<<<<<<<<<<
# =============================== display prompt message ===============================
[ -z "$url" ] && url="https://testingcf.jsdelivr.net/gh/juewuy/ShellCrash@dev" [ -z "$url" ] && url="https://testingcf.jsdelivr.net/gh/juewuy/ShellCrash@dev"
type bash &>/dev/null && shtype=bash || shtype=sh type bash &>/dev/null && shtype=bash || shtype=sh
[ -n "$(echo -e | grep e)" ] && echo=echo || echo='echo -e'
echo "***********************************************"
echo "** 欢迎使用 **"
echo "** ShellCrash **"
echo "** by Juewuy **"
echo "***********************************************"
# Check available capacity error_down() {
content_line "\033[33m请参考\033[0m"
content_line "\033[33mgithub.com/juewuy/ShellCrash/blob/master/README_CN.md\033[0m"
content_line "\033[33m或使用其他安装源重新安装\033[0m"
}
# check available capacity
dir_avail() { dir_avail() {
df -h >/dev/null 2>&1 && h="$2" df -h >/dev/null 2>&1 && h="$2"
df -P $h "${1:-.}" 2>/dev/null | awk 'NR==2 {print $4}' df -P $h "${1:-.}" 2>/dev/null | awk 'NR==2 {print $4}'
} }
ckcmd() { #检查命令 # 检查命令
ckcmd() {
if command -v sh >/dev/null 2>&1; then if command -v sh >/dev/null 2>&1; then
command -v "$1" >/dev/null 2>&1 command -v "$1" >/dev/null 2>&1
else else
type "$1" >/dev/null 2>&1 type "$1" >/dev/null 2>&1
fi fi
} }
webget() { webget() {
#参数【$1】代表下载目录【$2】代表在线地址 #参数【$1】代表下载目录【$2】代表在线地址
#参数【$3】代表输出显示【$4】不启用重定向 #参数【$3】代表输出显示【$4】不启用重定向
if curl --version >/dev/null 2>&1; then if curl --version >/dev/null 2>&1; then
[ "$3" = "echooff" ] && progress='-s' || progress='-#' [ "$3" = "echooff" ] && progress='-s' || progress='-#'
[ -z "$4" ] && redirect='-L' || redirect='' [ -z "$4" ] && redirect='-L' || redirect=''
result=$(curl -w %{http_code} --connect-timeout 5 $progress $redirect -ko $1 $2) result=$(curl -w %{http_code} --connect-timeout 5 "$progress" "$redirect" -ko "$1" "$2")
[ -n "$(echo $result | grep -e ^2)" ] && result="200"
# === original version ===
# [ -n "$(echo $result | grep -e ^2)" ] && result="200"
# === fixed version ===
# strictly match the 200 status code to avoid 204 (empty content)
# or 202 being mistakenly interpreted as success
if [ "$result" = "200" ]; then
result="200"
fi
else else
if wget --version >/dev/null 2>&1; then if wget --version >/dev/null 2>&1; then
[ "$3" = "echooff" ] && progress='-q' || progress='-q --show-progress' [ "$3" = "echooff" ] && progress='-q' || progress='-q --show-progress'
@@ -40,110 +129,253 @@ webget() {
fi fi
[ "$3" = "echoon" ] && progress='' [ "$3" = "echoon" ] && progress=''
[ "$3" = "echooff" ] && progress='-q' [ "$3" = "echooff" ] && progress='-q'
wget $progress $redirect $certificate $timeout -O $1 $2 wget "$progress" "$redirect" "$certificate" "$timeout" -O "$1" "$2"
[ $? -eq 0 ] && result="200" [ $? -eq 0 ] && result="200"
fi fi
} }
error_down() {
$echo "请参考 \033[32mhttps://github.com/juewuy/ShellCrash/blob/master/README_CN.md"
$echo "\033[33m使用其他安装源重新安装\033[0m"
}
# 安装及初始化 # 安装及初始化
set_alias() { set_alias() {
echo "-----------------------------------------------" while true; do
$echo "\033[36m请选择一个别名或使用自定义别名\033[0m" double_line_break
echo "-----------------------------------------------" separator_line "="
$echo " 1 【\033[32mcrash\033[0m" content_line "\033[36m请选择一个别名\033[0m"
$echo " 2 【\033[32m sc \033[0m" content_line "\033[36m或直接输入自定义别名\033[0m"
$echo " 3 【\033[32m mm \033[0m】" separator_line "-"
$echo " 0 退出安装" content_line "1) 【\033[32mcrash\033[0m】"
echo "-----------------------------------------------" content_line "2) 【\033[32m sc \033[0m】"
read -p "请输入相应数字或自定义别名 > " res content_line "3) 【\033[32m mm \033[0m】"
content_line "E) 退出安装"
separator_line "="
read -p "请输入相应数字/自定义别名> " res
case "$res" in case "$res" in
1) my_alias=crash ;; 1)
2) my_alias=sc ;; my_alias=crash
3) my_alias=mm ;; ;;
0) echo "安装已取消"; exit 1 ;; 2)
*) my_alias=$res ;; my_alias=sc
;;
3)
my_alias=mm
;;
"E" | "e")
abort_install
;;
*)
my_alias=$res
;;
esac esac
cmd=$(ckcmd "$my_alias" | grep 'menu.sh') cmd=$(ckcmd "$my_alias" | grep 'menu.sh')
ckcmd "$my_alias" && [ -z "$cmd" ] && { ckcmd "$my_alias" && [ -z "$cmd" ] && {
$echo "\033[33m此别名和当前系统内置命令/别名冲突,请换一个!\033[0m" double_line_break
separator_line "="
content_line "该别名【\033[32m$my_alias\033[0m】和当前系统内置命令别名\033[33m冲突\033[0m请更换"
separator_line "="
sleep 1 sleep 1
set_alias continue
} }
break 1
done
} }
gettar() { gettar() {
webget /tmp/ShellCrash.tar.gz "$url/ShellCrash.tar.gz" webget /tmp/ShellCrash.tar.gz "$url/ShellCrash.tar.gz" >/dev/null 2>&1
if [ "$result" != "200" ]; then if [ "$result" != "200" ]; then
$echo "\033[33m文件下载失败!\033[0m" content_line "\033[31m下载失败!\033[0m"
error_down error_down
separator_line "="
double_line_break
exit 1 exit 1
else else
$CRASHDIR/start.sh stop 2>/dev/null content_line "下载成功"
"$CRASHDIR"/start.sh stop 2>/dev/null
# 解压 # 解压
echo "-----------------------------------------------" content_line "开始解压文件......"
echo 开始解压文件! mkdir -p "$CRASHDIR" >/dev/null
mkdir -p $CRASHDIR >/dev/null tar -zxf '/tmp/ShellCrash.tar.gz' -C "$CRASHDIR"/ || tar -zxf '/tmp/ShellCrash.tar.gz' --no-same-owner -C "$CRASHDIR"/
tar -zxf '/tmp/ShellCrash.tar.gz' -C $CRASHDIR/ || tar -zxf '/tmp/ShellCrash.tar.gz' --no-same-owner -C $CRASHDIR/ if [ -s "$CRASHDIR"/init.sh ]; then
if [ -s $CRASHDIR/init.sh ]; then content_line "解压成功"
separator_line "="
set_alias set_alias
. $CRASHDIR/init.sh >/dev/null . $CRASHDIR/init.sh >/dev/null
[ "$?" != 0 ] && $echo "\033[33m初始化失败请尝试本地安装\033[0m" && exit 1 if [ $? != 0 ]; then
content_line "\033[31m初始化失败请尝试本地安装\033[0m"
separator_line "="
double_line_break
exit 1
fi
else else
rm -rf /tmp/ShellCrash.tar.gz rm -rf /tmp/ShellCrash.tar.gz
$echo "\033[33m文件解压失败!\033[0m" content_line "\033[31m解压失败!\033[0m"
error_down error_down
separator_line "="
double_line_break
exit 1 exit 1
fi fi
fi fi
} }
setdir() {
set_usb_dir() { set_usb_dir() {
$echo "请选择安装目录" while true; do
du -hL /mnt | awk '{print " "NR" "$2" "$1}' double_line_break
separator_line "="
content_line "请选择安装目录:"
separator_line "-"
# original version
# du -hL /mnt | awk '{print " "NR" "$2" "$1}'
du -hL /mnt |
awk '{print NR") "$2" (已用空间:"$1""}' |
while IFS= read -r line; do
content_line "$line"
done
content_line "0) 返回上级菜单"
separator_line "="
read -p "请输入相应数字> " num read -p "请输入相应数字> " num
case "$num" in
0)
return 1
;;
*)
dir=$(du -hL /mnt | awk '{print $2}' | sed -n "$num"p) dir=$(du -hL /mnt | awk '{print $2}' | sed -n "$num"p)
if [ -z "$dir" ]; then if [ -z "$dir" ]; then
$echo "\033[31m输入错误请重新设置\033[0m" invalid_input_retry
set_usb_dir continue
fi fi
return 0
;;
esac
done
} }
set_asus_dir() { set_asus_dir() {
echo -e "请选择U盘目录" while true; do
du -hL /tmp/mnt | awk -F/ 'NF<=4' | awk '{print " "NR" "$2" "$1}' double_line_break
separator_line "="
content_line "请选择U盘目录"
separator_line "-"
# original version
# du -hL /tmp/mnt | awk -F/ 'NF<=4' | awk '{print " "NR" "$2" "$1}'
du -hL /tmp/mnt |
awk -F/ 'NF<=4 {print NR") "$2" (已用空间:"$1""}' |
while IFS= read -r line; do
content_line "$line"
done
content_line "0) 返回上级菜单"
separator_line "="
read -p "请输入相应数字> " num read -p "请输入相应数字> " num
case "$num" in
0)
return 1
;;
*)
dir=$(du -hL /tmp/mnt | awk -F/ 'NF<=4' | awk '{print $2}' | sed -n "$num"p) dir=$(du -hL /tmp/mnt | awk -F/ 'NF<=4' | awk '{print $2}' | sed -n "$num"p)
if [ ! -f "$dir/asusware.arm/etc/init.d/S50downloadmaster" ]; then if [ ! -f "$dir/asusware.arm/etc/init.d/S50downloadmaster" ]; then
echo -e "\033[31m未找到下载大师自启文件$dir/asusware.arm/etc/init.d/S50downloadmaster请检查设置\033[0m" double_line_break
set_asus_dir separator_line "="
content_line "\033[33m未找到下载大师自启文件\033[0m"
content_line "\033[33m$dir/asusware.arm/etc/init.d/S50downloadmaster\033[0m"
content_line "\033[33m请检查设置\033[0m"
separator_line "="
continue
fi fi
return 0
;;
esac
done
} }
set_cust_dir() { set_cust_dir() {
echo "-----------------------------------------------" while true; do
echo '可用路径 剩余空间:' double_line_break
df -h | awk '{print $6,$4}' | sed 1d separator_line "="
echo '路径是必须带 / 的格式,注意写入虚拟内存(/tmp,/opt,/sys...)的文件会在重启后消失!!!' content_line "\033[33m注意\033[0m"
read -p "请输入自定义路径 > " dir content_line "\033[33m路径必须是带 / 的格式\033[0m"
if [ "$(dir_avail $dir)" = 0 ] || [ -n "$(echo $dir | grep -E 'tmp|opt|sys')" ]; then content_line "\033[33m写入虚拟内存/tmp/opt/sys...)的文件会在重启后消失!\033[0m"
$echo "\033[31m路径错误请重新设置\033[0m" separator_line "-"
set_cust_dir content_line "参考路经:"
separator_line "-"
# original version
# df -h | awk '{print $6,$4}' | sed 1d
df -h |
awk 'NR>1 {
path="";
for(i=6;i<=NF;i++) path=path $i " ";
sub(/ $/, "", path);
print path "|" $4
}' |
while IFS='|' read -r mount_point path_avail; do
if [ -n "$mount_point" ]; then
i=$((i + 1))
printf -v line_content "%-3s %s" "$i)" "$mount_point"
content_line "$line_content"
sub_content_line " (可用空间:$path_avail"
fi fi
done
content_line "0) 返回上级菜单"
separator_line "="
read -p "请输入自定义路径> " dir
case "$dir" in
0)
return 1
;;
*)
if [ "$(dir_avail "$dir")" = 0 ] || [ -n "$(echo "$dir" | grep -E 'tmp|opt|sys')" ]; then
invalid_input_retry
continue
fi
return 0
;;
esac
done
} }
echo "-----------------------------------------------"
$echo "\033[33m注意安装ShellCrash至少需要预留约1MB的磁盘空间\033[0m" setdir() {
while true; do
double_line_break
separator_line "="
content_line "\033[33m注意\033[0m"
content_line "\033[33m安装ShellCrash至少需要预留约 1MB 的磁盘空间\033[0m"
if [ -n "$systype" ]; then if [ -n "$systype" ]; then
[ "$systype" = "Padavan" ] && dir=/etc/storage [ "$systype" = "Padavan" ] && dir=/etc/storage
[ "$systype" = "mi_snapshot" ] && { [ "$systype" = "mi_snapshot" ] && {
$echo "\033[33m检测到当前设备为小米官方系统,请选择安装位置\033[0m" content_line "\033[33m检测到当前设备为小米官方系统\033[0m"
[ -d /data ] && $echo " 1 安装到 /data 目录,剩余空间:$(dir_avail /data -h)(支持软固化功能)"
[ -d /userdisk ] && $echo " 2 安装到 /userdisk 目录,剩余空间:$(dir_avail /userdisk -h)(支持软固化功能)" separator_line "-"
[ -d /data/other_vol ] && $echo " 3 安装到 /data/other_vol 目录,剩余空间:$(dir_avail /data/other_vol -h)(支持软固化功能)" content_line "请选择安装位置:"
$echo " 4 安装到自定义目录(不推荐,不明勿用!)" separator_line "-"
$echo " 0 退出安装"
echo "-----------------------------------------------" if [ -d /data ]; then
content_line "1) 安装到 /data 目录"
sub_content_line "剩余空间:$(dir_avail /data -h)(支持软固化功能)"
fi
if [ -d /userdisk ]; then
content_line "2) 安装到 /userdisk 目录"
sub_content_line "剩余空间:$(dir_avail /userdisk -h)(支持软固化功能)"
fi
if [ -d /data/other_vol ]; then
content_line "3) 安装到 /data/other_vol 目录"
sub_content_line "剩余空间:$(dir_avail /data/other_vol -h)(支持软固化功能)"
fi
content_line "4) 安装到自定义目录"
sub_content_line "(不推荐,不明勿用!)"
content_line "E) 退出安装"
separator_line "="
read -p "请输入相应数字> " num read -p "请输入相应数字> " num
case "$num" in case "$num" in
1) 1)
@@ -157,50 +389,103 @@ setdir() {
;; ;;
4) 4)
set_cust_dir set_cust_dir
ret=$?
[ "$ret" -eq 1 ] && continue
;;
"E" | "e")
abort_install
;; ;;
*) *)
exit 1 invalid_input_retry
continue
;; ;;
esac esac
} }
[ "$systype" = "asusrouter" ] && { [ "$systype" = "asusrouter" ] && {
$echo "\033[33m检测到当前设备为华硕固件请选择安装方式\033[0m"
$echo " 1 基于USB设备安装(限23年9月之前固件须插入\033[31m任意\033[0mUSB设备)" content_line "\033[33m检测到当前设备为华硕固件\033[0m"
$echo " 2 基于自启脚本安装(仅支持梅林及部分非koolshare官改固件)" separator_line "-"
$echo " 3 基于U盘+下载大师安装(支持所有固件限ARM设备须插入U盘或移动硬盘)" content_line "请选择安装方式:"
$echo " 0 退出安装" separator_line "-"
echo "-----------------------------------------------"
content_line "1) 基于USB设备安装"
sub_content_line "限23年9月之前固件须插入任意USB设备"
content_line "2) 基于自启脚本安装"
sub_content_line "仅支持梅林及部分非koolshare官改固件"
content_line "3) 基于U盘 + 下载大师安装"
sub_content_line "支持所有固件限ARM设备须插入U盘或移动硬盘"
content_line "E) 退出安装"
separator_line "="
read -p "请输入相应数字> " num read -p "请输入相应数字> " num
case "$num" in case "$num" in
1) 1)
read -p "将脚本安装到USB存储/系统闪存?(1/0) > " res double_line_break
[ "$res" = "1" ] && set_usb_dir || dir=/jffs separator_line "="
content_line "请选择脚本安装位置:"
separator_line "-"
content_line "1) USB存储"
content_line "2) 系统闪存"
separator_line "="
read -p "请输入相应数字> " num
case "$num" in
1)
set_usb_dir
;;
*)
dir=/jffs
;;
esac
usb_status=1 usb_status=1
;; ;;
2) 2)
$echo "如无法正常开机启动请重新使用USB方式安装" double_line_break
separator_line "="
content_line "如无法正常开机启动请重新使用USB方式安装"
separator_line "="
sleep 2 sleep 2
dir=/jffs dir=/jffs
;; ;;
3) 3)
echo -e "请先在路由器网页后台安装下载大师并启用,之后选择外置存储所在目录!" double_line_break
separator_line "="
content_line "请先在路由器网页后台安装下载大师并启用,"
content_line "之后选择外置存储所在目录!"
separator_line "="
sleep 2 sleep 2
set_asus_dir set_asus_dir
ret=$?
[ "$ret" -eq 1 ] && continue
;;
"E" | "e")
abort_install
;; ;;
*) *)
exit 1 invalid_input_retry
continue
;; ;;
esac esac
} }
[ "$systype" = "ng_snapshot" ] && dir=/tmp/mnt [ "$systype" = "ng_snapshot" ] && dir=/tmp/mnt
else else
$echo " 1 在\033[32m/etc目录\033[0m下安装(适合root用户)" separator_line "-"
$echo " 2 在\033[32m/usr/share目录\033[0m下安装(适合Linux系统)" content_line "请选择安装目录:"
$echo " 3 在\033[32m当前用户目录\033[0m下安装(适合非root用户)" separator_line "-"
$echo " 4 在\033[32m外置存储\033[0m中安装" content_line "1) \033[32m/etc目录\033[0m 适合root用户"
$echo " 5 手动设置安装目录" content_line "2) \033[32m/usr/share目录\033[0m 适合Linux系统"
$echo " 0 退出安装" content_line "3) \033[32m当前用户目录\033[0m 适合非root用户"
echo "----------------------------------------------" content_line "4) \033[32m外置存储\033[0m"
content_line "5) 手动设置"
content_line "E) 退出安装"
separator_line "="
read -p "请输入相应数字> " num read -p "请输入相应数字> " num
# 设置目录 # 设置目录
case "$num" in case "$num" in
@@ -216,56 +501,131 @@ setdir() {
;; ;;
4) 4)
set_usb_dir set_usb_dir
ret=$?
[ "$ret" -eq 1 ] && continue
;; ;;
5) 5)
set_cust_dir set_cust_dir
ret=$?
[ "$ret" -eq 1 ] && continue
;;
"E" | "e")
abort_install
;; ;;
*) *)
echo "安装已取消" invalid_input_retry
exit 1 continue
;; ;;
esac esac
fi fi
if [ ! -w $dir ]; then if [ ! -w "$dir" ]; then
$echo "\033[31m没有$dir目录写入权限!请重新设置!\033[0m" && sleep 1 && setdir double_line_break
separator_line "="
content_line "\033[31m没有$dir目录写入权限\033[0m"
content_line "\033[31m请重新设置\033[0m"
separator_line "="
sleep 2
else else
$echo "目标目录\033[32m$dir\033[0m空间剩余$(dir_avail $dir -h)" while true; do
read -p "确认安装?(1/0) > " res double_line_break
[ "$res" = "1" ] && CRASHDIR=$dir/ShellCrash || setdir separator_line "="
fi content_line "目标目录:\033[32m$dir\033[0m"
} content_line "可用空间:$(dir_avail $dir -h)"
install() { separator_line "-"
echo "-----------------------------------------------" content_line "1) 确认安装"
echo 开始从服务器获取安装文件! content_line "E) 退出安装"
echo "-----------------------------------------------" content_line "0) 返回上级菜单"
gettar separator_line "="
echo "-----------------------------------------------"
echo "ShellCrash 已经安装成功!"
[ "$profile" = "~/.bashrc" ] && echo "请执行【. ~/.bashrc > /dev/null】命令以加载环境变量"
[ -n "$(ls -l /bin/sh | grep -oE 'zsh')" ] && echo "请执行【. ~/.zshrc > /dev/null】命令以加载环境变量"
echo "-----------------------------------------------"
$echo "\033[33m输入\033[30;47m $my_alias \033[0;33m命令即可管理\033[0m"
echo "-----------------------------------------------"
}
setversion() {
echo "-----------------------------------------------"
$echo "\033[33m请选择想要安装的版本\033[0m"
$echo " 1 \033[32m公测版(推荐)\033[0m"
$echo " 2 \033[36m稳定版\033[0m"
$echo " 3 \033[31m开发版\033[0m"
echo "-----------------------------------------------"
read -p "请输入相应数字> " num read -p "请输入相应数字> " num
case "$num" in case "$num" in
0)
break 1
;;
1)
CRASHDIR="${dir}/ShellCrash"
break 2
;;
"E" | "e")
abort_install
;;
*)
invalid_input_retry
continue
;;
esac
done
fi
done
}
install() {
double_line_break
separator_line "="
content_line "下载安装文件......"
gettar
double_line_break
separator_line "="
content_line "ShellCrash 已经安装成功!"
[ "$profile" = "~/.bashrc" ] && content_line "请执行【. ~/.bashrc > /dev/null】命令以更新环境变量"
[ -n "$(ls -l /bin/sh | grep -oE 'zsh')" ] && content_line "请执行【. ~/.zshrc > /dev/null】命令以更新环境变量"
content_line "输入\033[32m $my_alias \033[0m命令即可管理"
separator_line "="
double_line_break
}
setversion() {
while true; do
double_line_break
separator_line "="
content_line "请选择安装版本:"
separator_line "-"
content_line "1) \033[32m公测版推荐\033[0m"
content_line "2) \033[36m稳定版\033[0m"
content_line "3) \033[31m开发版\033[0m"
content_line "E) 退出安装"
separator_line "="
read -p "请输入相应数字> " num
case "$num" in
1)
break 1
;;
2) 2)
url=$(echo $url | sed 's/master/stable/') url=$(echo "$url" | sed 's/master/stable/')
break 1
;; ;;
3) 3)
url=$(echo $url | sed 's/master/dev/') url=$(echo "$url" | sed 's/master/dev/')
break 1
;;
"E" | "e")
abort_install
;;
*)
invalid_input_retry
continue
;; ;;
*) ;;
esac esac
done
} }
# =============================== the script start here ================================
# clean screen
printf "\033[H\033[2J"
double_line_break
separator_line "="
content_line " 欢迎使用"
content_line " ShellCrash"
content_line
content_line " 支持各种基于 openwrt 的路由器设备"
content_line " 支持Debian、Centos等标准 Linux 系统"
content_line " 如遇问题请加TG群反馈t.me/ShellClash"
content_line
content_line " by Juewuy"
separator_line "="
# 特殊固件识别及标记 # 特殊固件识别及标记
[ -f "/etc/storage/started_script.sh" ] && { [ -f "/etc/storage/started_script.sh" ] && {
systype=Padavan # 老毛子固件 systype=Padavan # 老毛子固件
@@ -280,55 +640,98 @@ setversion() {
[ -w "/var/mnt/cfg/firewall" ] && systype=ng_snapshot # NETGEAR设备 [ -w "/var/mnt/cfg/firewall" ] && systype=ng_snapshot # NETGEAR设备
# 检查root权限 # 检查root权限
if [ "$USER" != "root" -a -z "$systype" ]; then if [ "$USER" != "root" ] && [ -z "$systype" ]; then
echo 当前用户:$USER while true; do
$echo "\033[31m请尽量使用root用户不要直接使用sudo命令执行安装!\033[0m" double_line_break
echo "-----------------------------------------------" separator_line "="
read -p "仍要安装?可能会产生未知错误!(1/0) > " res content_line "当前用户 $USER 非 root 用户"
[ "$res" != "1" ] && exit 1 content_line "\033[33m请尽量使用 root 用户不要直接使用sudo命令执行安装\033[0m"
content_line "\033[31m继续安装可能会产生未知错误\033[0m"
separator_line "-"
content_line "1) 继续安装"
content_line "E) 退出安装"
separator_line "="
read -p "请输入相应数字> " num
case "$num" in
1)
break 1
;;
"E" | "e")
abort_install
;;
*)
invalid_input_retry
continue
;;
esac
done
fi fi
if [ -n "$(echo $url | grep master)" ]; then if [ -n "$(echo "$url" | grep master)" ]; then
setversion setversion
fi fi
# 获取版本信息 # 获取版本信息
webget /tmp/version "$url/version" echooff webget /tmp/version "$url/version" echooff
[ "$result" = "200" ] && versionsh=$(cat /tmp/version) [ "$result" = "200" ] && versionsh=$(cat /tmp/version)
rm -rf /tmp/version rm -rf /tmp/version
# 输出 # 输出
$echo "最新版本:\033[32m$versionsh\033[0m" double_line_break
echo "-----------------------------------------------" separator_line "="
$echo "\033[44m如遇问题请加TG群反馈\033[42;30m t.me/ShellClash \033[0m" content_line "最新版本:\033[32m$versionsh\033[0m"
$echo "\033[37m支持各种基于openwrt的路由器设备" separator_line "="
$echo "\033[33m支持Debian、Centos等标准Linux系统\033[0m"
if [ -n "$CRASHDIR" ]; then if [ -n "$CRASHDIR" ]; then
echo "-----------------------------------------------" while true; do
$echo "检测到旧的安装目录\033[36m$CRASHDIR\033[0m是否覆盖安装" double_line_break
$echo "\033[32m覆盖安装时不会移除配置文件\033[0m" separator_line "="
read -p "覆盖安装/卸载旧版本?(1/0) > " res content_line "检测到旧版本安装目录:\033[36m$CRASHDIR\033[0m"
case "$res" in content_line "\033[33m注意覆盖安装时不会移除配置文件\033[0m"
separator_line "-"
content_line "1) 覆盖安装"
content_line "2) 卸载旧版本"
content_line "E) 退出安装"
separator_line "="
read -p "请输入相应数字> " num
case "$num" in
1) 1)
install install
break 1
;; ;;
0) 2)
rm -rf $CRASHDIR rm -rf "$CRASHDIR"
echo "-----------------------------------------------"
$echo "\033[31m 旧版本文件已卸载!\033[0m" double_line_break
separator_line "="
content_line "\033[31m旧版本文件已卸载\033[0m"
separator_line "="
setdir setdir
install install
break 1
;; ;;
9) 9)
echo "测试模式,变更安装位置" double_line_break
separator_line "="
content_line "测试模式,变更安装位置"
separator_line "="
setdir setdir
install install
break 1
;;
"E" | "e")
abort_install
;; ;;
*) *)
$echo "\033[31m输入错误已取消安装\033[0m" invalid_input_retry
exit 1 continue
;; ;;
esac esac
done
else else
setdir setdir
install install

View File

@@ -8,6 +8,8 @@ proxy-groups:
- {name: 🪟 微软服务, type: select, proxies: [🎯 全球直连, 🚀 节点选择]} - {name: 🪟 微软服务, type: select, proxies: [🎯 全球直连, 🚀 节点选择]}
- {name: 🇬 谷歌服务, type: select, proxies: [🎯 全球直连, 🚀 节点选择]} - {name: 🇬 谷歌服务, type: select, proxies: [🎯 全球直连, 🚀 节点选择]}
- {name: 🍎 苹果服务, type: select, proxies: [🎯 全球直连, 🚀 节点选择]} - {name: 🍎 苹果服务, type: select, proxies: [🎯 全球直连, 🚀 节点选择]}
- {name: 🎥 奈飞视频, type: select, proxies: [🚀 节点选择, 🇭🇰 香港节点, 🇹🇼 台湾节点, 🇯🇵 日本节点, 🇸🇬 新加坡节点, 🇺🇸 美国节点, 👑 高级节点, 📉 省流节点, {providers_tags}]}
- {name: 📹 油管视频, type: select, proxies: [🚀 节点选择, 🇭🇰 香港节点, 🇹🇼 台湾节点, 🇯🇵 日本节点, 🇸🇬 新加坡节点, 🇺🇸 美国节点, 👑 高级节点, 📉 省流节点, {providers_tags}]}
- {name: 🌍 国外媒体, type: select, proxies: [🚀 节点选择, 🇭🇰 香港节点, 🇹🇼 台湾节点, 🇯🇵 日本节点, 🇸🇬 新加坡节点, 🇺🇸 美国节点, 👑 高级节点, 📉 省流节点, {providers_tags}]} - {name: 🌍 国外媒体, type: select, proxies: [🚀 节点选择, 🇭🇰 香港节点, 🇹🇼 台湾节点, 🇯🇵 日本节点, 🇸🇬 新加坡节点, 🇺🇸 美国节点, 👑 高级节点, 📉 省流节点, {providers_tags}]}
- {name: 🎮 游戏平台, type: select, proxies: [🚀 节点选择, 🎯 全球直连, 🇭🇰 香港节点, 🇹🇼 台湾节点, 🇯🇵 日本节点, 🇸🇬 新加坡节点, 🇺🇸 美国节点, 👑 高级节点, 📉 省流节点, {providers_tags}]} - {name: 🎮 游戏平台, type: select, proxies: [🚀 节点选择, 🎯 全球直连, 🇭🇰 香港节点, 🇹🇼 台湾节点, 🇯🇵 日本节点, 🇸🇬 新加坡节点, 🇺🇸 美国节点, 👑 高级节点, 📉 省流节点, {providers_tags}]}
- {name: 🛡️ 直连域名, type: select, proxies: [🎯 全球直连, 🚀 节点选择]} - {name: 🛡️ 直连域名, type: select, proxies: [🎯 全球直连, 🚀 节点选择]}

View File

@@ -7,6 +7,8 @@ proxy-groups:
- {name: 🎮 游戏服务, type: select, proxies: [🎯 全球直连, 👑 高级节点, 🚀 节点选择]} - {name: 🎮 游戏服务, type: select, proxies: [🎯 全球直连, 👑 高级节点, 🚀 节点选择]}
- {name: 🪟 微软服务, type: select, proxies: [🎯 全球直连, 🚀 节点选择]} - {name: 🪟 微软服务, type: select, proxies: [🎯 全球直连, 🚀 节点选择]}
- {name: 🇬 谷歌服务, type: select, proxies: [🎯 全球直连, 🚀 节点选择]} - {name: 🇬 谷歌服务, type: select, proxies: [🎯 全球直连, 🚀 节点选择]}
- {name: 🎥 奈飞视频, type: select, proxies: [🚀 节点选择, 🇭🇰 香港节点, 🇹🇼 台湾节点, 🇯🇵 日本节点, 🇸🇬 新加坡节点, 🇺🇸 美国节点, 👑 高级节点, 📉 省流节点, {providers_tags}]}
- {name: 📹 油管视频, type: select, proxies: [🚀 节点选择, 🇭🇰 香港节点, 🇹🇼 台湾节点, 🇯🇵 日本节点, 🇸🇬 新加坡节点, 🇺🇸 美国节点, 👑 高级节点, 📉 省流节点, {providers_tags}]}
- {name: 🌍 国外媒体, type: select, proxies: [🚀 节点选择, 🇭🇰 香港节点, 🇹🇼 台湾节点, 🇯🇵 日本节点, 🇸🇬 新加坡节点, 🇺🇸 美国节点, 👑 高级节点, 📉 省流节点, {providers_tags}]} - {name: 🌍 国外媒体, type: select, proxies: [🚀 节点选择, 🇭🇰 香港节点, 🇹🇼 台湾节点, 🇯🇵 日本节点, 🇸🇬 新加坡节点, 🇺🇸 美国节点, 👑 高级节点, 📉 省流节点, {providers_tags}]}
- {name: 🎮 游戏平台, type: select, proxies: [🚀 节点选择, 🎯 全球直连, 🇭🇰 香港节点, 🇹🇼 台湾节点, 🇯🇵 日本节点, 🇸🇬 新加坡节点, 🇺🇸 美国节点, 👑 高级节点, 📉 省流节点, {providers_tags}]} - {name: 🎮 游戏平台, type: select, proxies: [🚀 节点选择, 🎯 全球直连, 🇭🇰 香港节点, 🇹🇼 台湾节点, 🇯🇵 日本节点, 🇸🇬 新加坡节点, 🇺🇸 美国节点, 👑 高级节点, 📉 省流节点, {providers_tags}]}
- {name: 🍎 苹果服务, type: select, proxies: [🎯 全球直连, 🚀 节点选择]} - {name: 🍎 苹果服务, type: select, proxies: [🎯 全球直连, 🚀 节点选择]}
@@ -77,6 +79,22 @@ rule-providers:
url: "https://testingcf.jsdelivr.net/gh//DustinWin/ruleset_geodata@refs/heads/mihomo-ruleset/games-cn.mrs" url: "https://testingcf.jsdelivr.net/gh//DustinWin/ruleset_geodata@refs/heads/mihomo-ruleset/games-cn.mrs"
interval: 86400 interval: 86400
netflix:
type: http
behavior: domain
format: mrs
path: ./ruleset/netflix.mrs
url: "https://testingcf.jsdelivr.net/gh//DustinWin/ruleset_geodata@refs/heads/mihomo-ruleset/netflix.mrs"
interval: 86400
youtube:
type: http
behavior: domain
format: mrs
path: ./ruleset/youtube.mrs
url: "https://testingcf.jsdelivr.net/gh//DustinWin/ruleset_geodata@refs/heads/mihomo-ruleset/youtube.mrs"
interval: 86400
media: media:
type: http type: http
behavior: domain behavior: domain
@@ -141,6 +159,14 @@ rule-providers:
url: "https://testingcf.jsdelivr.net/gh//DustinWin/ruleset_geodata@refs/heads/mihomo-ruleset/cnip.mrs" url: "https://testingcf.jsdelivr.net/gh//DustinWin/ruleset_geodata@refs/heads/mihomo-ruleset/cnip.mrs"
interval: 86400 interval: 86400
netflixip:
type: http
behavior: domain
format: mrs
path: ./ruleset/netflixip.mrs
url: "https://testingcf.jsdelivr.net/gh//DustinWin/ruleset_geodata@refs/heads/mihomo-ruleset/netflixip.mrs"
interval: 86400
mediaip: mediaip:
type: http type: http
behavior: ipcidr behavior: ipcidr
@@ -172,6 +198,8 @@ rules:
- RULE-SET,apple-cn,🍎 苹果服务 - RULE-SET,apple-cn,🍎 苹果服务
- RULE-SET,google-cn,🇬 谷歌服务 - RULE-SET,google-cn,🇬 谷歌服务
- RULE-SET,games-cn,🎮 游戏服务 - RULE-SET,games-cn,🎮 游戏服务
- RULE-SET,netflix,🎥 奈飞视频
- RULE-SET,youtube,📹 油管视频
- RULE-SET,media,🌍 国外媒体 - RULE-SET,media,🌍 国外媒体
- RULE-SET,games,🎮 游戏平台 - RULE-SET,games,🎮 游戏平台
- RULE-SET,ai,🤖 AI 平台 - RULE-SET,ai,🤖 AI 平台
@@ -180,6 +208,7 @@ rules:
- RULE-SET,cn,🛡️ 直连域名 - RULE-SET,cn,🛡️ 直连域名
- RULE-SET,privateip,🔒 私有网络,no-resolve - RULE-SET,privateip,🔒 私有网络,no-resolve
- RULE-SET,cnip,🀄️ 直连 IP - RULE-SET,cnip,🀄️ 直连 IP
- RULE-SET,netflixip,🎥 奈飞视频
- RULE-SET,mediaip,🌍 国外媒体 - RULE-SET,mediaip,🌍 国外媒体
- RULE-SET,gamesip,🎮 游戏平台 - RULE-SET,gamesip,🎮 游戏平台
- RULE-SET,telegramip,📲 电报消息,no-resolve - RULE-SET,telegramip,📲 电报消息,no-resolve

View File

@@ -1,4 +1,4 @@
#ShellCrash-ruleset 全分组规则+去广告 For mihomo By Maozai 260107 #ShellCrash-ruleset 全分组规则+去广告 For mihomo By Maozai 260111
#此版本为Maozai根据ACL4SSR规则修改优化而来尽量在保持原有的基础上进行优化。 #此版本为Maozai根据ACL4SSR规则修改优化而来尽量在保持原有的基础上进行优化。
#数据源采用了DustinWin/ruleset_geodata和MetaCubeX/meta-rules-dat两个开源项目的规则感谢原作者的辛勤付出。 #数据源采用了DustinWin/ruleset_geodata和MetaCubeX/meta-rules-dat两个开源项目的规则感谢原作者的辛勤付出。
@@ -11,12 +11,12 @@ proxy-groups:
- {name: 🚀 节点选择, type: select, proxies: [♻️ 自动选择, ✨ 自动选择(去高倍率), 🛠️ 手动切换, ⚖️ 负载均衡, 🚑 故障转移, 🎯 本地直连, 🇭🇰 香港节点, 🇹🇼 台湾节点, 🇺🇸 美国节点, 🇯🇵 日本节点, 🇪🇺 欧洲节点, 🇰🇷 韩国节点, 🇸🇬 狮城节点, 👑 高级节点, 📉 省流节点, {providers_tags}]} - {name: 🚀 节点选择, type: select, proxies: [♻️ 自动选择, ✨ 自动选择(去高倍率), 🛠️ 手动切换, ⚖️ 负载均衡, 🚑 故障转移, 🎯 本地直连, 🇭🇰 香港节点, 🇹🇼 台湾节点, 🇺🇸 美国节点, 🇯🇵 日本节点, 🇪🇺 欧洲节点, 🇰🇷 韩国节点, 🇸🇬 狮城节点, 👑 高级节点, 📉 省流节点, {providers_tags}]}
- {name: 🛠️ 手动切换, type: select, include-all: true, proxies: [🎯 本地直连, 🇭🇰 香港节点, 🇹🇼 台湾节点, 🇺🇸 美国节点, 🇯🇵 日本节点, 🇪🇺 欧洲节点, 🇰🇷 韩国节点, 🇸🇬 狮城节点, 👑 高级节点, 📉 省流节点, {providers_tags}]} - {name: 🛠️ 手动切换, type: select, include-all: true, proxies: [🎯 本地直连, 🇭🇰 香港节点, 🇹🇼 台湾节点, 🇺🇸 美国节点, 🇯🇵 日本节点, 🇪🇺 欧洲节点, 🇰🇷 韩国节点, 🇸🇬 狮城节点, 👑 高级节点, 📉 省流节点, {providers_tags}]}
- {name: ♻️ 自动选择, type: url-test, interval: 1800, tolerance: 50, include-all: true, exclude-filter: "(?i)(剩余|重置|到期|防失联|官网|导航|客服|http|www)"} - {name: ♻️ 自动选择, type: url-test, interval: 1800, tolerance: 50, include-all: true, exclude-filter: "(?i)(剩余|重置|到期|防失联|官网|导航|客服|http|www)"}
- {name: ✨ 自动选择(去高倍率), type: url-test, interval: 1800, tolerance: 50, include-all: true, exclude-filter: "(?i)(剩余|重置|到期|防失联|官网|导航|客服|http|www|专线|专用|高级|直连|急速|高速|高倍率|游戏|铂金|钻石|企业|VIP|Ultra|Game|IEPL|IPLC|AIA|BGP|GIA|CN2|CMI|HGC|HKT|CTM|CC|AC|x([2-9]|\\d{2,}))"} - {name: ✨ 自动选择(去高倍率), type: url-test, interval: 1800, tolerance: 50, include-all: true, exclude-filter: "(?i)(剩余|重置|到期|防失联|官网|导航|客服|http|www)`(?i)(专线|专用|高级|直连|急速|高速|高倍率|游戏|铂金|钻石|企业|VIP|Ultra|Game|IEPL|IPLC|AIA|BGP|GIA|CN2|CMI|HGC|HKT|CTM|CC|AC|x([2-9]|\\d{2,}))"}
- {name: ⚖️ 负载均衡, type: load-balance, interval: 1800, include-all: true, hidden: true} - {name: ⚖️ 负载均衡, type: load-balance, interval: 1800, include-all: true, hidden: true, exclude-filter: "(?i)(剩余|重置|到期|防失联|官网|导航|客服|http|www)"}
- {name: 🚑 故障转移, type: fallback, interval: 1800, include-all: true, hidden: true} - {name: 🚑 故障转移, type: fallback, interval: 1800, include-all: true, hidden: true, exclude-filter: "(?i)(剩余|重置|到期|防失联|官网|导航|客服|http|www)"}
#
- {name: 🤖 AI 平台, type: select, proxies: [🚀 节点选择, 🤖 AI节点过滤港澳, 🎯 本地直连, ♻️ 自动选择, 🛠️ 手动切换, 🇭🇰 香港节点, 🇹🇼 台湾节点, 🇺🇸 美国节点, 🇯🇵 日本节点, 🇪🇺 欧洲节点, 🇰🇷 韩国节点, 🇸🇬 狮城节点, 👑 高级节点, 📉 省流节点, {providers_tags}]} - {name: 🤖 AI 平台, type: select, proxies: [🚀 节点选择, 🤖 AI节点过滤港澳, 🎯 本地直连, ♻️ 自动选择, 🛠️ 手动切换, 🇭🇰 香港节点, 🇹🇼 台湾节点, 🇺🇸 美国节点, 🇯🇵 日本节点, 🇪🇺 欧洲节点, 🇰🇷 韩国节点, 🇸🇬 狮城节点, 👑 高级节点, 📉 省流节点, {providers_tags}]}
- {name: 🤖 AI节点过滤港澳, type: url-test, interval: 3600, tolerance: 50, include-all: true, exclude-filter: "(?i)(剩余|重置|到期|防失联|官网|导航|客服|http|www|🇭🇰|港|🇲🇴|澳门|hk|hongkong|hong kong)", hidden: true} - {name: 🤖 AI节点过滤港澳, type: url-test, interval: 3600, tolerance: 50, include-all: true, exclude-filter: "(?i)(剩余|重置|到期|防失联|官网|导航|客服|http|www)`(?i)(🇭🇰|港|🇲🇴|澳门|hk|hongkong|hong kong)", hidden: true}
- {name: 🎬 奈飞视频, type: select, proxies: [🚀 节点选择, 🎬 奈飞节点, 🎯 本地直连, ♻️ 自动选择, 🛠️ 手动切换, 🇭🇰 香港节点, 🇹🇼 台湾节点, 🇺🇸 美国节点, 🇯🇵 日本节点, 🇪🇺 欧洲节点, 🇰🇷 韩国节点, 🇸🇬 狮城节点, 👑 高级节点, 📉 省流节点, {providers_tags}]} - {name: 🎬 奈飞视频, type: select, proxies: [🚀 节点选择, 🎬 奈飞节点, 🎯 本地直连, ♻️ 自动选择, 🛠️ 手动切换, 🇭🇰 香港节点, 🇹🇼 台湾节点, 🇺🇸 美国节点, 🇯🇵 日本节点, 🇪🇺 欧洲节点, 🇰🇷 韩国节点, 🇸🇬 狮城节点, 👑 高级节点, 📉 省流节点, {providers_tags}]}
- {name: 🎬 奈飞节点, type: url-test, interval: 1800, tolerance: 50, include-all: true, filter: "(?i)(NF|奈飞|解锁|Netflix|NETFLIX|Media)", hidden: true} - {name: 🎬 奈飞节点, type: url-test, interval: 1800, tolerance: 50, include-all: true, filter: "(?i)(NF|奈飞|解锁|Netflix|NETFLIX|Media)", hidden: true}
- {name: ▶️ 油管视频, type: select, proxies: [🚀 节点选择, 🎯 本地直连, ♻️ 自动选择, 🛠️ 手动切换, 🇭🇰 香港节点, 🇹🇼 台湾节点, 🇺🇸 美国节点, 🇯🇵 日本节点, 🇪🇺 欧洲节点, 🇰🇷 韩国节点, 🇸🇬 狮城节点, 👑 高级节点, 📉 省流节点, {providers_tags}]} - {name: ▶️ 油管视频, type: select, proxies: [🚀 节点选择, 🎯 本地直连, ♻️ 自动选择, 🛠️ 手动切换, 🇭🇰 香港节点, 🇹🇼 台湾节点, 🇺🇸 美国节点, 🇯🇵 日本节点, 🇪🇺 欧洲节点, 🇰🇷 韩国节点, 🇸🇬 狮城节点, 👑 高级节点, 📉 省流节点, {providers_tags}]}
@@ -45,10 +45,10 @@ proxy-groups:
- {name: 🎯 本地直连, type: select, proxies: [DIRECT], hidden: true} - {name: 🎯 本地直连, type: select, proxies: [DIRECT], hidden: true}
- {name: 🇭🇰 香港节点, type: url-test, tolerance: 50, include-all: true, filter: "(?i)(🇭🇰|港|hk|hongkong|hong kong)"} - {name: 🇭🇰 香港节点, type: url-test, tolerance: 50, include-all: true, filter: "(?i)(🇭🇰|港|hk|hongkong|hong kong)"}
- {name: 🇹🇼 台湾节点, type: url-test, tolerance: 50, include-all: true, filter: "(?i)(🇹🇼|台|tw|taiwan|tai wan)"} - {name: 🇹🇼 台湾节点, type: url-test, tolerance: 50, include-all: true, filter: "(?i)(🇹🇼|台|tw|taiwan|tai wan)", exclude-filter: "(?i)(仙台)"}
- {name: 🇺🇸 美国节点, type: url-test, tolerance: 50, include-all: true, filter: "(?i)(🇺🇸|美|洛杉矶|圣何塞|西雅图|纽约|波特兰|旧金山|us|unitedstates|united states)"} - {name: 🇺🇸 美国节点, type: url-test, tolerance: 50, include-all: true, filter: "(?i)(🇺🇸|美|洛杉矶|圣何塞|西雅图|纽约|波特兰|旧金山|休斯|达拉斯|硅谷|堪萨斯|迈阿密|凤凰城|芝加哥|奥勒姆|us|unitedstates|united states)", exclude-filter: "(?i)(南美|中美|拉美|亚美尼亚|美属)"}
- {name: 🇯🇵 日本节点, type: url-test, tolerance: 50, include-all: true, filter: "(?i)(🇯🇵|日|东京|大阪|埼玉|九州|jp|japan)"} - {name: 🇯🇵 日本节点, type: url-test, tolerance: 50, include-all: true, filter: "(?i)(🇯🇵|日|东京|大阪|埼玉|九州|仙台|jp|japan)", exclude-filter: "(?i)(尼日利亚|尼日尔|日内瓦)"}
- {name: 🇪🇺 欧洲节点, type: url-test, tolerance: 50, include-all: true, filter: "(?i)(🇪🇺|欧|德|英|法|荷|俄罗斯|西班牙|意大利|瑞士|瑞典|土耳其|挪威|芬兰|丹麦|比利时|爱尔兰|奥地利|波兰|葡萄牙|乌克兰|希腊|捷克|匈牙利|罗马尼亚|保加利亚|冰岛|克罗地亚)"} - {name: 🇪🇺 欧洲节点, type: url-test, tolerance: 50, include-all: true, filter: "(?i)(🇪🇺|欧|德|英|法|荷|俄罗斯|西班牙|意大利|瑞士|瑞典|土耳其|挪威|芬兰|丹麦|比利时|爱尔兰|奥地利|波兰|葡萄牙|乌克兰|希腊|捷克|匈牙利|罗马尼亚|保加利亚|冰岛|克罗地亚|阿姆斯特丹)"}
- {name: 🇰🇷 韩国节点, type: url-test, tolerance: 50, include-all: true, filter: "(?i)(🇰🇷|韩|韓|首尔|kr|kor)"} - {name: 🇰🇷 韩国节点, type: url-test, tolerance: 50, include-all: true, filter: "(?i)(🇰🇷|韩|韓|首尔|kr|kor)"}
- {name: 🇸🇬 狮城节点, type: url-test, tolerance: 50, include-all: true, filter: "(?i)(🇸🇬|新加坡|狮城|sg|singapore)"} - {name: 🇸🇬 狮城节点, type: url-test, tolerance: 50, include-all: true, filter: "(?i)(🇸🇬|新加坡|狮城|sg|singapore)"}
@@ -221,8 +221,8 @@ rule-providers:
#规则顺序 #规则顺序
rules: rules:
- DOMAIN-SUFFIX,captive.apple.com,DIRECT - DOMAIN-SUFFIX,captive.apple.com,🍎 苹果服务
- DOMAIN-SUFFIX,kamo.teracloud.jp,DIRECT - DOMAIN-SUFFIX,kamo.teracloud.jp,🀄️ 国内流量
- RULE-SET,privateip,🔒 私有网络,no-resolve - RULE-SET,privateip,🔒 私有网络,no-resolve
- RULE-SET,private,🔒 私有网络 - RULE-SET,private,🔒 私有网络

View File

@@ -9,6 +9,8 @@
{ "tag": "🪟 微软服务", "type": "selector", "outbounds": [ "🎯 本地直连", "🚀 节点选择" ] }, { "tag": "🪟 微软服务", "type": "selector", "outbounds": [ "🎯 本地直连", "🚀 节点选择" ] },
{ "tag": "🇬 谷歌服务", "type": "selector", "outbounds": [ "🎯 本地直连", "🚀 节点选择" ] }, { "tag": "🇬 谷歌服务", "type": "selector", "outbounds": [ "🎯 本地直连", "🚀 节点选择" ] },
{ "tag": "🍎 苹果服务", "type": "selector", "outbounds": [ "🎯 本地直连", "🚀 节点选择" ] }, { "tag": "🍎 苹果服务", "type": "selector", "outbounds": [ "🎯 本地直连", "🚀 节点选择" ] },
{ "tag": "🎥 奈飞视频", "type": "selector", "outbounds": [ "🚀 节点选择", "🇭🇰 香港节点", "🇹🇼 台湾节点", "🇯🇵 日本节点", "🇸🇬 新加坡节点", "🇺🇸 美国节点", "👑 高级节点", "📉 省流节点", {providers_tags} ] },
{ "tag": "📹 油管视频", "type": "selector", "outbounds": [ "🚀 节点选择", "🇭🇰 香港节点", "🇹🇼 台湾节点", "🇯🇵 日本节点", "🇸🇬 新加坡节点", "🇺🇸 美国节点", "👑 高级节点", "📉 省流节点", {providers_tags} ] },
{ "tag": "🌍 国外媒体", "type": "selector", "outbounds": [ "🚀 节点选择", "🇭🇰 香港节点", "🇹🇼 台湾节点", "🇯🇵 日本节点", "🇸🇬 新加坡节点", "🇺🇸 美国节点", "👑 高级节点", "📉 省流节点", {providers_tags} ] }, { "tag": "🌍 国外媒体", "type": "selector", "outbounds": [ "🚀 节点选择", "🇭🇰 香港节点", "🇹🇼 台湾节点", "🇯🇵 日本节点", "🇸🇬 新加坡节点", "🇺🇸 美国节点", "👑 高级节点", "📉 省流节点", {providers_tags} ] },
{ "tag": "🎮 游戏平台", "type": "selector", "outbounds": [ "🚀 节点选择", "🎯 本地直连", "🇭🇰 香港节点", "🇹🇼 台湾节点", "🇯🇵 日本节点", "🇸🇬 新加坡节点", "🇺🇸 美国节点", "👑 高级节点", "📉 省流节点", {providers_tags} ] }, { "tag": "🎮 游戏平台", "type": "selector", "outbounds": [ "🚀 节点选择", "🎯 本地直连", "🇭🇰 香港节点", "🇹🇼 台湾节点", "🇯🇵 日本节点", "🇸🇬 新加坡节点", "🇺🇸 美国节点", "👑 高级节点", "📉 省流节点", {providers_tags} ] },
{ "tag": "🛡️ 直连域名", "type": "selector", "outbounds": [ "🎯 本地直连", "🚀 节点选择" ] }, { "tag": "🛡️ 直连域名", "type": "selector", "outbounds": [ "🎯 本地直连", "🚀 节点选择" ] },
@@ -39,6 +41,8 @@
{ "rule_set": [ "apple-cn" ], "outbound": "🍎 苹果服务" }, { "rule_set": [ "apple-cn" ], "outbound": "🍎 苹果服务" },
{ "rule_set": [ "google-cn" ], "outbound": "🇬 谷歌服务" }, { "rule_set": [ "google-cn" ], "outbound": "🇬 谷歌服务" },
{ "rule_set": [ "games-cn" ], "outbound": "🎮 游戏服务" }, { "rule_set": [ "games-cn" ], "outbound": "🎮 游戏服务" },
{ "rule_set": [ "netflix" ], "outbound": "🎥 奈飞视频" },
{ "rule_set": [ "youtube" ], "outbound": "📹 油管视频" },
{ "rule_set": [ "media" ], "outbound": "🌍 国外媒体" }, { "rule_set": [ "media" ], "outbound": "🌍 国外媒体" },
{ "rule_set": [ "games" ], "outbound": "🎮 游戏平台" }, { "rule_set": [ "games" ], "outbound": "🎮 游戏平台" },
{ "rule_set": [ "ai" ], "outbound": "🤖 AI 平台" }, { "rule_set": [ "ai" ], "outbound": "🤖 AI 平台" },
@@ -50,6 +54,7 @@
{ "action": "resolve", "server": "dns_proxy", "strategy": "prefer_ipv4", "match_only": true}, { "action": "resolve", "server": "dns_proxy", "strategy": "prefer_ipv4", "match_only": true},
{ "rule_set": [ "cnip" ], "outbound": "🀄️ 直连 IP" }, { "rule_set": [ "cnip" ], "outbound": "🀄️ 直连 IP" },
{ "rule_set": [ "netflixip" ], "outbound": "🎥 奈飞视频" },
{ "rule_set": [ "mediaip" ], "outbound": "🌍 国外媒体" }, { "rule_set": [ "mediaip" ], "outbound": "🌍 国外媒体" },
{ "rule_set": [ "gamesip" ], "outbound": "🎮 游戏平台" } { "rule_set": [ "gamesip" ], "outbound": "🎮 游戏平台" }
], ],
@@ -110,6 +115,22 @@
"url": "https://testingcf.jsdelivr.net/gh/DustinWin/ruleset_geodata@sing-box-ruleset/games-cn.srs", "url": "https://testingcf.jsdelivr.net/gh/DustinWin/ruleset_geodata@sing-box-ruleset/games-cn.srs",
"download_detour": "DIRECT" "download_detour": "DIRECT"
}, },
{
"tag": "netflix",
"type": "remote",
"format": "binary",
"path": "./ruleset/netflix.srs",
"url": "https://testingcf.jsdelivr.net/gh/DustinWin/ruleset_geodata@sing-box-ruleset/netflix.srs",
"download_detour": "DIRECT"
},
{
"tag": "youtube",
"type": "remote",
"format": "binary",
"path": "./ruleset/youtube.srs",
"url": "https://testingcf.jsdelivr.net/gh/DustinWin/ruleset_geodata@sing-box-ruleset/youtube.srs",
"download_detour": "DIRECT"
},
{ {
"tag": "media", "tag": "media",
"type": "remote", "type": "remote",
@@ -174,6 +195,14 @@
"url": "https://testingcf.jsdelivr.net/gh/DustinWin/ruleset_geodata@sing-box-ruleset/cnip.srs", "url": "https://testingcf.jsdelivr.net/gh/DustinWin/ruleset_geodata@sing-box-ruleset/cnip.srs",
"download_detour": "DIRECT" "download_detour": "DIRECT"
}, },
{
"tag": "netflixip",
"type": "remote",
"format": "binary",
"path": "./ruleset/netflixip.srs",
"url": "https://testingcf.jsdelivr.net/gh/DustinWin/ruleset_geodata@sing-box-ruleset/netflixip.srs",
"download_detour": "DIRECT"
},
{ {
"tag": "mediaip", "tag": "mediaip",
"type": "remote", "type": "remote",

View File

@@ -9,6 +9,8 @@
{ "tag": "🪟 微软服务", "type": "selector", "outbounds": [ "🎯 本地直连", "🚀 节点选择" ] }, { "tag": "🪟 微软服务", "type": "selector", "outbounds": [ "🎯 本地直连", "🚀 节点选择" ] },
{ "tag": "🇬 谷歌服务", "type": "selector", "outbounds": [ "🎯 本地直连", "🚀 节点选择" ] }, { "tag": "🇬 谷歌服务", "type": "selector", "outbounds": [ "🎯 本地直连", "🚀 节点选择" ] },
{ "tag": "🍎 苹果服务", "type": "selector", "outbounds": [ "🎯 本地直连", "🚀 节点选择" ] }, { "tag": "🍎 苹果服务", "type": "selector", "outbounds": [ "🎯 本地直连", "🚀 节点选择" ] },
{ "tag": "🎥 奈飞视频", "type": "selector", "outbounds": [ "🚀 节点选择", "🇭🇰 香港节点", "🇹🇼 台湾节点", "🇯🇵 日本节点", "🇸🇬 新加坡节点", "🇺🇸 美国节点", "👑 高级节点", "📉 省流节点", {providers_tags} ] },
{ "tag": "📹 油管视频", "type": "selector", "outbounds": [ "🚀 节点选择", "🇭🇰 香港节点", "🇹🇼 台湾节点", "🇯🇵 日本节点", "🇸🇬 新加坡节点", "🇺🇸 美国节点", "👑 高级节点", "📉 省流节点", {providers_tags} ] },
{ "tag": "🌍 国外媒体", "type": "selector", "outbounds": [ "🚀 节点选择", "🇭🇰 香港节点", "🇹🇼 台湾节点", "🇯🇵 日本节点", "🇸🇬 新加坡节点", "🇺🇸 美国节点", "👑 高级节点", "📉 省流节点", {providers_tags} ] }, { "tag": "🌍 国外媒体", "type": "selector", "outbounds": [ "🚀 节点选择", "🇭🇰 香港节点", "🇹🇼 台湾节点", "🇯🇵 日本节点", "🇸🇬 新加坡节点", "🇺🇸 美国节点", "👑 高级节点", "📉 省流节点", {providers_tags} ] },
{ "tag": "🎮 游戏平台", "type": "selector", "outbounds": [ "🚀 节点选择", "🎯 本地直连", "🇭🇰 香港节点", "🇹🇼 台湾节点", "🇯🇵 日本节点", "🇸🇬 新加坡节点", "🇺🇸 美国节点", "👑 高级节点", "📉 省流节点", {providers_tags} ] }, { "tag": "🎮 游戏平台", "type": "selector", "outbounds": [ "🚀 节点选择", "🎯 本地直连", "🇭🇰 香港节点", "🇹🇼 台湾节点", "🇯🇵 日本节点", "🇸🇬 新加坡节点", "🇺🇸 美国节点", "👑 高级节点", "📉 省流节点", {providers_tags} ] },
{ "tag": "🛡️ 直连域名", "type": "selector", "outbounds": [ "🎯 本地直连", "🚀 节点选择" ] }, { "tag": "🛡️ 直连域名", "type": "selector", "outbounds": [ "🎯 本地直连", "🚀 节点选择" ] },
@@ -36,6 +38,8 @@
{ "rule_set": [ "apple-cn" ], "outbound": "🍎 苹果服务" }, { "rule_set": [ "apple-cn" ], "outbound": "🍎 苹果服务" },
{ "rule_set": [ "google-cn" ], "outbound": "🇬 谷歌服务" }, { "rule_set": [ "google-cn" ], "outbound": "🇬 谷歌服务" },
{ "rule_set": [ "games-cn" ], "outbound": "🎮 游戏服务" }, { "rule_set": [ "games-cn" ], "outbound": "🎮 游戏服务" },
{ "rule_set": [ "netflix" ], "outbound": "🎥 奈飞视频" },
{ "rule_set": [ "youtube" ], "outbound": "📹 油管视频" },
{ "rule_set": [ "media" ], "outbound": "🌍 国外媒体" }, { "rule_set": [ "media" ], "outbound": "🌍 国外媒体" },
{ "rule_set": [ "games" ], "outbound": "🎮 游戏平台" }, { "rule_set": [ "games" ], "outbound": "🎮 游戏平台" },
{ "rule_set": [ "ai" ], "outbound": "🤖 AI 平台" }, { "rule_set": [ "ai" ], "outbound": "🤖 AI 平台" },
@@ -47,6 +51,7 @@
{ "action": "resolve", "server": "dns_proxy", "strategy": "prefer_ipv4", "match_only": true}, { "action": "resolve", "server": "dns_proxy", "strategy": "prefer_ipv4", "match_only": true},
{ "rule_set": [ "cnip" ], "outbound": "🀄️ 直连 IP" }, { "rule_set": [ "cnip" ], "outbound": "🀄️ 直连 IP" },
{ "rule_set": [ "netflixip" ], "outbound": "🎥 奈飞视频" },
{ "rule_set": [ "mediaip" ], "outbound": "🌍 国外媒体" }, { "rule_set": [ "mediaip" ], "outbound": "🌍 国外媒体" },
{ "rule_set": [ "gamesip" ], "outbound": "🎮 游戏平台" } { "rule_set": [ "gamesip" ], "outbound": "🎮 游戏平台" }
], ],
@@ -99,6 +104,22 @@
"url": "https://testingcf.jsdelivr.net/gh/DustinWin/ruleset_geodata@sing-box-ruleset/games-cn.srs", "url": "https://testingcf.jsdelivr.net/gh/DustinWin/ruleset_geodata@sing-box-ruleset/games-cn.srs",
"download_detour": "DIRECT" "download_detour": "DIRECT"
}, },
{
"tag": "netflix",
"type": "remote",
"format": "binary",
"path": "./ruleset/netflix.srs",
"url": "https://testingcf.jsdelivr.net/gh/DustinWin/ruleset_geodata@sing-box-ruleset/netflix.srs",
"download_detour": "DIRECT"
},
{
"tag": "youtube",
"type": "remote",
"format": "binary",
"path": "./ruleset/youtube.srs",
"url": "https://testingcf.jsdelivr.net/gh/DustinWin/ruleset_geodata@sing-box-ruleset/youtube.srs",
"download_detour": "DIRECT"
},
{ {
"tag": "media", "tag": "media",
"type": "remote", "type": "remote",
@@ -163,6 +184,14 @@
"url": "https://testingcf.jsdelivr.net/gh/DustinWin/ruleset_geodata@sing-box-ruleset/cnip.srs", "url": "https://testingcf.jsdelivr.net/gh/DustinWin/ruleset_geodata@sing-box-ruleset/cnip.srs",
"download_detour": "DIRECT" "download_detour": "DIRECT"
}, },
{
"tag": "netflixip",
"type": "remote",
"format": "binary",
"path": "./ruleset/netflixip.srs",
"url": "https://testingcf.jsdelivr.net/gh/DustinWin/ruleset_geodata@sing-box-ruleset/netflixip.srs",
"download_detour": "DIRECT"
},
{ {
"tag": "mediaip", "tag": "mediaip",
"type": "remote", "type": "remote",

View File

@@ -1,4 +1,4 @@
//ShellCrash-ruleset 全分组规则+去广告 For Sing-box By Maozai 260107 //ShellCrash-ruleset 全分组规则+去广告 For Sing-box By Maozai 260111
{ {
"outbounds": [ "outbounds": [
{ "tag": "🚀 节点选择", "type": "selector", "outbounds": ["♻️ 自动选择", "✨ 自动选择(去高倍率)", "🛠️ 手动切换", "🎯 本地直连", "🇭🇰 香港节点", "🇹🇼 台湾节点", "🇺🇸 美国节点", "🇯🇵 日本节点", "🇪🇺 欧洲节点", "🇰🇷 韩国节点", "🇸🇬 狮城节点", "👑 高级节点", "📉 省流节点", {providers_tags}] }, { "tag": "🚀 节点选择", "type": "selector", "outbounds": ["♻️ 自动选择", "✨ 自动选择(去高倍率)", "🛠️ 手动切换", "🎯 本地直连", "🇭🇰 香港节点", "🇹🇼 台湾节点", "🇺🇸 美国节点", "🇯🇵 日本节点", "🇪🇺 欧洲节点", "🇰🇷 韩国节点", "🇸🇬 狮城节点", "👑 高级节点", "📉 省流节点", {providers_tags}] },
@@ -29,7 +29,6 @@
{ "tag": "🐟 漏网之鱼", "type": "selector", "outbounds": ["🚀 节点选择", "🎯 本地直连", "♻️ 自动选择", "🛠️ 手动切换", "🇭🇰 香港节点", "🇹🇼 台湾节点", "🇺🇸 美国节点", "🇯🇵 日本节点", "🇪🇺 欧洲节点", "🇰🇷 韩国节点", "🇸🇬 狮城节点", "👑 高级节点", "📉 省流节点", {providers_tags}] }, { "tag": "🐟 漏网之鱼", "type": "selector", "outbounds": ["🚀 节点选择", "🎯 本地直连", "♻️ 自动选择", "🛠️ 手动切换", "🇭🇰 香港节点", "🇹🇼 台湾节点", "🇺🇸 美国节点", "🇯🇵 日本节点", "🇪🇺 欧洲节点", "🇰🇷 韩国节点", "🇸🇬 狮城节点", "👑 高级节点", "📉 省流节点", {providers_tags}] },
{ "tag": "🛑 广告拦截", "type": "selector", "outbounds": ["⛔ 禁止连接", "🔀 规则放行", "🎯 本地直连"] }, { "tag": "🛑 广告拦截", "type": "selector", "outbounds": ["⛔ 禁止连接", "🔀 规则放行", "🎯 本地直连"] },
{ "tag": "⛔ 禁止连接", "type": "block" }, { "tag": "⛔ 禁止连接", "type": "block" },
{ "tag": "🔀 规则放行", "type": "pass" }, { "tag": "🔀 规则放行", "type": "pass" },
@@ -37,10 +36,10 @@
{ "tag": "GLOBAL", "type": "selector", "outbounds": ["🚀 节点选择", "🎯 本地直连"] }, { "tag": "GLOBAL", "type": "selector", "outbounds": ["🚀 节点选择", "🎯 本地直连"] },
{ "tag": "🇭🇰 香港节点", "type": "urltest", "use_all_providers": true, "include": "(?i)(🇭🇰|港|hk|hongkong|hong kong)" }, { "tag": "🇭🇰 香港节点", "type": "urltest", "use_all_providers": true, "include": "(?i)(🇭🇰|港|hk|hongkong|hong kong)" },
{ "tag": "🇹🇼 台湾节点", "type": "urltest", "use_all_providers": true, "include": "(?i)(🇹🇼|台|tw|taiwan|tai wan)" }, { "tag": "🇹🇼 台湾节点", "type": "urltest", "use_all_providers": true, "include": "(?i)(🇹🇼|台|tw|taiwan|tai wan)", "exclude": "(?i)(仙台)" },
{ "tag": "🇺🇸 美国节点", "type": "urltest", "use_all_providers": true, "include": "(?i)(🇺🇸|美|洛杉矶|圣何塞|西雅图|纽约|波特兰|旧金山|us|unitedstates|united states)" }, { "tag": "🇺🇸 美国节点", "type": "urltest", "use_all_providers": true, "include": "(?i)(🇺🇸|美|洛杉矶|圣何塞|西雅图|纽约|波特兰|旧金山|休斯|达拉斯|硅谷|堪萨斯|迈阿密|凤凰城|芝加哥|奥勒姆|us|unitedstates|united states)", "exclude": "(?i)(南美|中美|拉美|亚美尼亚|美属)" },
{ "tag": "🇯🇵 日本节点", "type": "urltest", "use_all_providers": true, "include": "(?i)(🇯🇵|日|东京|大阪|埼玉|九州|jp|japan)" }, { "tag": "🇯🇵 日本节点", "type": "urltest", "use_all_providers": true, "include": "(?i)(🇯🇵|日|东京|大阪|埼玉|九州|jp|japan)", "exclude": "(?i)(尼日利亚|尼日尔|日内瓦)" },
{ "tag": "🇪🇺 欧洲节点", "type": "urltest", "use_all_providers": true, "include": "(?i)(🇪🇺|欧|德|英|法|荷|俄罗斯|西班牙|意大利|瑞士|瑞典|土耳其|挪威|芬兰|丹麦|比利时|爱尔兰|奥地利|波兰|葡萄牙|乌克兰|希腊|捷克|匈牙利|罗马尼亚|保加利亚|冰岛|克罗地亚)" }, { "tag": "🇪🇺 欧洲节点", "type": "urltest", "use_all_providers": true, "include": "(?i)(🇪🇺|欧|德|英|法|荷|俄罗斯|西班牙|意大利|瑞士|瑞典|土耳其|挪威|芬兰|丹麦|比利时|爱尔兰|奥地利|波兰|葡萄牙|乌克兰|希腊|捷克|匈牙利|罗马尼亚|保加利亚|冰岛|克罗地亚|阿姆斯特丹)" },
{ "tag": "🇰🇷 韩国节点", "type": "urltest", "use_all_providers": true, "include": "(?i)(🇰🇷|韩|韓|首尔|kr|kor)" }, { "tag": "🇰🇷 韩国节点", "type": "urltest", "use_all_providers": true, "include": "(?i)(🇰🇷|韩|韓|首尔|kr|kor)" },
{ "tag": "🇸🇬 狮城节点", "type": "urltest", "use_all_providers": true, "include": "(?i)(🇸🇬|新加坡|狮城|sg|singapore)" }, { "tag": "🇸🇬 狮城节点", "type": "urltest", "use_all_providers": true, "include": "(?i)(🇸🇬|新加坡|狮城|sg|singapore)" },
@@ -49,8 +48,8 @@
], ],
"route": { "route": {
"rules": [ "rules": [
{ "domain_suffix": ["captive.apple.com"], "outbound": "DIRECT" }, { "domain_suffix": ["captive.apple.com"], "outbound": "🍎 苹果服务" },
{ "domain_suffix": ["kamo.teracloud.jp"], "outbound": "DIRECT" }, { "domain_suffix": ["kamo.teracloud.jp"], "outbound": "🀄️ 国内流量" },
{ "rule_set": ["private"], "outbound": "🎯 本地直连" }, { "rule_set": ["private"], "outbound": "🎯 本地直连" },
{ "rule_set": ["ads"], "outbound": "🛑 广告拦截" }, { "rule_set": ["ads"], "outbound": "🛑 广告拦截" },

View File

@@ -102,7 +102,7 @@ grep -q 'firewall_mod' "$CRASHDIR/configs/ShellClash.cfg" 2>/dev/null || {
#设置更新地址 #设置更新地址
[ -n "$url" ] && setconfig update_url $url [ -n "$url" ] && setconfig update_url $url
#设置环境变量 #设置环境变量
[ -w /opt/etc/profile ] && profile=/opt/etc/profile [ -w /opt/etc/profile ] && [ "$systype" = "Padavan" ] && profile=/opt/etc/profile
[ -w /jffs/configs/profile.add ] && profile=/jffs/configs/profile.add [ -w /jffs/configs/profile.add ] && profile=/jffs/configs/profile.add
[ -z "$profile" ] && profile=/etc/profile [ -z "$profile" ] && profile=/etc/profile
if [ -n "$profile" ]; then if [ -n "$profile" ]; then

View File

@@ -0,0 +1,11 @@
# ===== 启动完成 =====
START_SERVICE_OK="服务已启动!"
START_WEB_HINT="请使用"
START_WEB_HINT2="管理内置规则"
START_PAC_HINT="其他设备可使用 PAC 配置:"
START_PROXY_HINT="或使用 HTTP / SOCKS5 方式连接:"
# ===== 启动流程 =====
START_NO_CORE_CFG_TRY_GEN="没有找到核心配置文件,尝试生成 providers 配置文件!"
START_NO_CORE_CFG_IMPORT_FIRST="没有找到核心配置文件,请先导入配置文件!"
START_FIREWALL_DONE="已完成防火墙设置!"

View File

@@ -0,0 +1,11 @@
# ===== Startup =====
START_SERVICE_OK="Service started successfully!"
START_WEB_HINT="Please use"
START_WEB_HINT2="manage built-in rules"
START_PAC_HINT="Other devices can connect using PAC configuration:"
START_PROXY_HINT="Or connect using HTTP / SOCKS5:"
# ===== Startup Flow =====
START_NO_CORE_CFG_TRY_GEN="Core configuration not found. Attempting to generate providers configuration!"
START_NO_CORE_CFG_IMPORT_FIRST="Core configuration not found. Please import a configuration first!"
START_FIREWALL_DONE="Firewall configuration completed!"

View File

@@ -3,6 +3,7 @@ setproxy(){
[ -n "$(pidof CrashCore)" ] && { [ -n "$(pidof CrashCore)" ] && {
[ -n "$authentication" ] && auth="$authentication@" || auth="" [ -n "$authentication" ] && auth="$authentication@" || auth=""
[ -z "$mix_port" ] && mix_port=7890 [ -z "$mix_port" ] && mix_port=7890
export all_proxy="http://${auth}127.0.0.1:$mix_port" export https_proxy="http://${auth}127.0.0.1:$mix_port"
export http_proxy="http://${auth}127.0.0.1:$mix_port"
} }
} }

View File

@@ -32,7 +32,8 @@ webget(){
result=$(curl $agent -w '%{http_code}' --connect-timeout 3 $progress $redirect $certificate -o "$1" "$url") result=$(curl $agent -w '%{http_code}' --connect-timeout 3 $progress $redirect $certificate -o "$1" "$url")
fi fi
[ "$result" = "200" ] && return 0 #成功则退出否则重试 [ "$result" = "200" ] && return 0 #成功则退出否则重试
export all_proxy="" export https_proxy=""
export http_proxy=""
result=$(curl $agent -w '%{http_code}' --connect-timeout 5 $progress $redirect $certificate -o "$1" "$2") result=$(curl $agent -w '%{http_code}' --connect-timeout 5 $progress $redirect $certificate -o "$1" "$2")
[ "$result" = "200" ] [ "$result" = "200" ]
return $? return $?

View File

@@ -20,11 +20,13 @@ web_save() { #最小化保存面板节点选择
} }
done <"$TMPDIR"/web_proxies done <"$TMPDIR"/web_proxies
rm -rf "$TMPDIR"/web_proxies rm -rf "$TMPDIR"/web_proxies
#对比文件,如果有变动且不为空则写入磁盘,否则清除缓存 #对比文件,如果有变动则写入磁盘,否则清除缓存
for file in web_save web_configs; do for file in web_save; do
if [ -s "$TMPDIR"/${file} ]; then if [ -s "$TMPDIR/$file" ]; then
. "$CRASHDIR"/libs/compare.sh && compare "$TMPDIR"/${file} "$CRASHDIR"/configs/${file} . "$CRASHDIR"/libs/compare.sh && compare "$TMPDIR/$file" "$CRASHDIR/configs/$file"
[ "$?" = 0 ] && rm -rf "$TMPDIR"/${file} || mv -f "$TMPDIR"/${file} "$CRASHDIR"/configs/${file} [ "$?" = 0 ] && rm -f "$TMPDIR/$file" || mv -f "$TMPDIR/$file" "$CRASHDIR/configs/$file"
else
rm -f "$CRASHDIR/configs/$file" #空文件时移除旧文件
fi fi
done done
} }

View File

@@ -109,8 +109,8 @@ ckstatus() { #脚本启动前检查
echo "-----------------------------------------------" echo "-----------------------------------------------"
#检查新手引导 #检查新手引导
if [ -z "$userguide" ]; then if [ -z "$userguide" ]; then
setconfig userguide 1
. "$CRASHDIR"/menus/userguide.sh && userguide . "$CRASHDIR"/menus/userguide.sh && userguide
setconfig userguide 1
fi fi
#检查执行权限 #检查执行权限
[ ! -x "$CRASHDIR"/start.sh ] && chmod +x "$CRASHDIR"/start.sh [ ! -x "$CRASHDIR"/start.sh ] && chmod +x "$CRASHDIR"/start.sh
@@ -159,6 +159,7 @@ ckstatus() { #脚本启动前检查
} }
main_menu() { main_menu() {
while true; do
ckstatus ckstatus
echo -e " 1 \033[32m$MENU_MAIN_1\033[0m" echo -e " 1 \033[32m$MENU_MAIN_1\033[0m"
@@ -176,7 +177,7 @@ main_menu() {
read -p "$MENU_MAIN_PROMPT" num read -p "$MENU_MAIN_PROMPT" num
case "$num" in case "$num" in
0) "" | 0)
exit exit
;; ;;
1) 1)
@@ -190,7 +191,6 @@ main_menu() {
checkcfg_new=$(cat "$CFG_PATH") checkcfg_new=$(cat "$CFG_PATH")
[ "$checkcfg" != "$checkcfg_new" ] && checkrestart [ "$checkcfg" != "$checkcfg_new" ] && checkrestart
fi fi
main_menu
;; ;;
3) 3)
[ "$bot_tg_service" = ON ] && . "$CRASHDIR"/menus/bot_tg_service.sh && bot_tg_stop [ "$bot_tg_service" = ON ] && . "$CRASHDIR"/menus/bot_tg_service.sh && bot_tg_stop
@@ -198,19 +198,15 @@ main_menu() {
sleep 1 sleep 1
echo "-----------------------------------------------" echo "-----------------------------------------------"
echo -e "\033[31m$corename$MENU_SERVICE_STOPPED\033[0m" echo -e "\033[31m$corename$MENU_SERVICE_STOPPED\033[0m"
main_menu
;; ;;
4) 4)
. "$CRASHDIR"/menus/4_setboot.sh && setboot . "$CRASHDIR"/menus/4_setboot.sh && setboot
main_menu
;; ;;
5) 5)
. "$CRASHDIR"/menus/5_task.sh && task_menu . "$CRASHDIR"/menus/5_task.sh && task_menu
main_menu
;; ;;
6) 6)
. "$CRASHDIR"/menus/6_core_config.sh && set_core_config . "$CRASHDIR"/menus/6_core_config.sh && set_core_config
main_menu
;; ;;
7) 7)
GT_CFG_PATH="$CRASHDIR"/configs/gateway.cfg GT_CFG_PATH="$CRASHDIR"/configs/gateway.cfg
@@ -221,11 +217,9 @@ main_menu() {
checkcfg_new=$(cat "$CFG_PATH" "$GT_CFG_PATH") checkcfg_new=$(cat "$CFG_PATH" "$GT_CFG_PATH")
[ "$checkcfg" != "$checkcfg_new" ] && checkrestart [ "$checkcfg" != "$checkcfg_new" ] && checkrestart
fi fi
main_menu
;; ;;
8) 8)
. "$CRASHDIR"/menus/8_tools.sh && tools . "$CRASHDIR"/menus/8_tools.sh && tools
main_menu
;; ;;
9) 9)
checkcfg=$(cat "$CFG_PATH") checkcfg=$(cat "$CFG_PATH")
@@ -234,13 +228,13 @@ main_menu() {
checkcfg_new=$(cat "$CFG_PATH") checkcfg_new=$(cat "$CFG_PATH")
[ "$checkcfg" != "$checkcfg_new" ] && checkrestart [ "$checkcfg" != "$checkcfg_new" ] && checkrestart
fi fi
main_menu
;; ;;
*) *)
errornum errornum
exit sleep 1
;; ;;
esac esac
done
} }
case "$1" in case "$1" in

View File

@@ -3,49 +3,65 @@
[ -n "$__IS_MODULE_1_START_LOADED" ] && return [ -n "$__IS_MODULE_1_START_LOADED" ] && return
__IS_MODULE_1_START_LOADED=1 __IS_MODULE_1_START_LOADED=1
load_lang 1_start
#启动相关 # ===== 启动完成提示 =====
startover() { startover() {
echo -ne " \r" echo -ne " \r"
echo -e "\033[32m服务已启动!\033[0m" echo -e "\033[32m$START_SERVICE_OK\033[0m"
echo -e "请使用 \033[4;36mhttp://$host$hostdir\033[0m 管理内置规则" echo -e "$START_WEB_HINT \033[4;36mhttp://$host$hostdir\033[0m $START_WEB_HINT2"
if [ "$redir_mod" = "纯净模式" ]; then if [ "$redir_mod" = "纯净模式" ]; then
echo "-----------------------------------------------" echo "-----------------------------------------------"
echo -e "其他设备可以使用PAC配置连接\033[4;32mhttp://$host:$db_port/ui/pac\033[0m" echo -e "$START_PAC_HINT \033[4;32mhttp://$host:$db_port/ui/pac\033[0m"
echo -e "或者使用HTTP/SOCK5方式连接IP{\033[36m$host\033[0m}Port{\033[36m$mix_port\033[0m}" echo -e "$START_PROXY_HINT IP{\033[36m$host\033[0m} Port{\033[36m$mix_port\033[0m}"
fi fi
return 0 return 0
} }
# ===== 启动核心 =====
start_core() { start_core() {
if echo "$crashcore" | grep -q 'singbox'; then if echo "$crashcore" | grep -q 'singbox'; then
core_config="$CRASHDIR"/jsons/config.json core_config="$CRASHDIR/jsons/config.json"
else else
core_config="$CRASHDIR"/yamls/config.yaml core_config="$CRASHDIR/yamls/config.yaml"
fi fi
echo "-----------------------------------------------" echo "-----------------------------------------------"
if [ ! -s $core_config -a -s "$CRASHDIR"/configs/providers.cfg ]; then
echo -e "\033[33m没有找到${crashcore}配置文件尝试生成providers配置文件\033[0m" if [ ! -s "$core_config" ] && [ -s "$CRASHDIR/configs/providers.cfg" ]; then
echo -e "\033[33m$START_NO_CORE_CFG_TRY_GEN\033[0m"
[ "$crashcore" = singboxr ] && coretype=singbox [ "$crashcore" = singboxr ] && coretype=singbox
[ "$crashcore" = meta -o "$crashcore" = clashpre ] && coretype=clash [ "$crashcore" = meta -o "$crashcore" = clashpre ] && coretype=clash
. "$CRASHDIR"/menus/6_core_config.sh && gen_${coretype}_providers
elif [ -s $core_config -o -n "$Url" -o -n "$Https" ]; then . "$CRASHDIR/menus/6_core_config.sh" && gen_${coretype}_providers
"$CRASHDIR"/start.sh start
#设置循环检测以判定服务启动是否成功 elif [ -s "$core_config" ] || [ -n "$Url" ] || [ -n "$Https" ]; then
. "$CRASHDIR"/libs/start_wait.sh "$CRASHDIR/start.sh" start
[ -n "$test" -o -n "$(pidof CrashCore)" ] && {
# 循环检测服务启动状态
. "$CRASHDIR/libs/start_wait.sh"
[ -n "$test" ] || pidof CrashCore >/dev/null && {
# 启动 TG 机器人 # 启动 TG 机器人
[ "$bot_tg_service" = ON ] && . "$CRASHDIR"/menus/bot_tg_service.sh && bot_tg_start if [ "$bot_tg_service" = ON ]; then
. "$CRASHDIR/menus/bot_tg_service.sh" && bot_tg_start
fi
startover startover
} }
else else
echo -e "\033[31m没有找到${crashcore}配置文件,请先导入配置文件!\033[0m" echo -e "\033[31m$START_NO_CORE_CFG_IMPORT_FIRST\033[0m"
. "$CRASHDIR"/menus/6_core_config.sh && set_core_config . "$CRASHDIR/menus/6_core_config.sh" && set_core_config
fi fi
} }
# ===== 启动服务入口 =====
start_service() { start_service() {
if [ "$firewall_area" = 5 ]; then if [ "$firewall_area" = 5 ]; then
"$CRASHDIR"/start.sh start "$CRASHDIR/start.sh" start
echo -e "\033[32m已完成防火墙设置!\033[0m" echo -e "\033[32m$START_FIREWALL_DONE\033[0m"
else else
start_core start_core
fi fi

View File

@@ -4,12 +4,14 @@
[ -n "$__IS_MODULE_2_SETTINGS_LOADED" ] && return [ -n "$__IS_MODULE_2_SETTINGS_LOADED" ] && return
__IS_MODULE_2_SETTINGS_LOADED=1 __IS_MODULE_2_SETTINGS_LOADED=1
settings() { #功能设置 # 功能设置
settings() {
while true; do
# 获取设置默认显示 # 获取设置默认显示
[ -z "$skip_cert" ] && skip_cert=ON [ -z "$skip_cert" ] && skip_cert=ON
[ -z "$sniffer" ] && sniffer=OFF [ -z "$sniffer" ] && sniffer=OFF
[ -z "$dns_mod" ] && dns_mod='redir_host' [ -z "$dns_mod" ] && dns_mod='redir_host'
#
echo "-----------------------------------------------" echo "-----------------------------------------------"
echo -e "\033[30;47m欢迎使用功能设置菜单\033[0m" echo -e "\033[30;47m欢迎使用功能设置菜单\033[0m"
echo "-----------------------------------------------" echo "-----------------------------------------------"
@@ -28,7 +30,8 @@ settings() { #功能设置
echo "-----------------------------------------------" echo "-----------------------------------------------"
read -p "请输入对应数字 > " num read -p "请输入对应数字 > " num
case "$num" in case "$num" in
0) "" | 0)
break
;; ;;
1) 1)
if [ "$USER" != "root" -a "$USER" != "admin" ]; then if [ "$USER" != "root" -a "$USER" != "admin" ]; then
@@ -39,17 +42,14 @@ settings() { #功能设置
set_redir_mod set_redir_mod
fi fi
sleep 1 sleep 1
settings
;; ;;
2) 2)
. "$CRASHDIR"/menus/dns.sh && set_dns_mod . "$CRASHDIR"/menus/dns.sh && set_dns_mod
sleep 1 sleep 1
settings
;; ;;
3) 3)
. "$CRASHDIR"/menus/fw_filter.sh && set_fw_filter . "$CRASHDIR"/menus/fw_filter.sh && set_fw_filter
sleep 1 sleep 1
settings
;; ;;
4) 4)
echo "-----------------------------------------------" echo "-----------------------------------------------"
@@ -61,7 +61,6 @@ settings() { #功能设置
skip_cert=OFF skip_cert=OFF
fi fi
setconfig skip_cert $skip_cert setconfig skip_cert $skip_cert
settings
;; ;;
5) 5)
echo "-----------------------------------------------" echo "-----------------------------------------------"
@@ -81,7 +80,6 @@ settings() { #功能设置
sniffer=OFF sniffer=OFF
fi fi
setconfig sniffer $sniffer setconfig sniffer $sniffer
settings
;; ;;
6) 6)
if [ -n "$(pidof CrashCore)" ]; then if [ -n "$(pidof CrashCore)" ]; then
@@ -95,11 +93,9 @@ settings() { #功能设置
else else
set_adv_config set_adv_config
fi fi
settings
;; ;;
8) 8)
set_ipv6 set_ipv6
settings
;; ;;
9) 9)
echo "-----------------------------------------------" echo "-----------------------------------------------"
@@ -135,17 +131,23 @@ settings() { #功能设置
;; ;;
*) *)
errornum errornum
sleep 1
break
;; ;;
esac esac
done
} }
set_redir_mod() { #路由模式设置
set_redir_config() { set_redir_config() {
setconfig redir_mod $redir_mod setconfig redir_mod $redir_mod
setconfig dns_mod $dns_mod setconfig dns_mod $dns_mod
echo "-----------------------------------------------" echo "-----------------------------------------------"
echo -e "\033[36m已设为 $redir_mod \033[0m" echo -e "\033[36m已设为 $redir_mod \033[0m"
} }
# 路由模式设置
set_redir_mod() {
while true; do
[ -n "$(ls /dev/net/tun 2>/dev/null)" ] || ip tuntap >/dev/null 2>&1 || modprobe tun 2>/dev/null && sup_tun=1 [ -n "$(ls /dev/net/tun 2>/dev/null)" ] || ip tuntap >/dev/null 2>&1 || modprobe tun 2>/dev/null && sup_tun=1
[ -z "$firewall_area" ] && firewall_area=1 [ -z "$firewall_area" ] && firewall_area=1
[ -z "$redir_mod" ] && [ "$USER" = "root" -o "$USER" = "admin" ] && redir_mod='Redir模式' [ -z "$redir_mod" ] && [ "$USER" = "root" -o "$USER" = "admin" ] && redir_mod='Redir模式'
@@ -174,11 +176,12 @@ set_redir_mod() { #路由模式设置
echo " 0 返回上级菜单" echo " 0 返回上级菜单"
read -p "请输入对应数字 > " num read -p "请输入对应数字 > " num
case "$num" in case "$num" in
0) ;; "" | 0)
break
;;
1) 1)
redir_mod=Redir模式 redir_mod=Redir模式
set_redir_config set_redir_config
set_redir_mod
;; ;;
2) 2)
if [ -n "$sup_tun" ]; then if [ -n "$sup_tun" ]; then
@@ -188,7 +191,6 @@ set_redir_mod() { #路由模式设置
echo -e "\033[31m设备未检测到Tun内核模块请尝试其他模式或者安装相关依赖\033[0m" echo -e "\033[31m设备未检测到Tun内核模块请尝试其他模式或者安装相关依赖\033[0m"
sleep 1 sleep 1
fi fi
set_redir_mod
;; ;;
3) 3)
if [ "$firewall_mod" = "iptables" ]; then if [ "$firewall_mod" = "iptables" ]; then
@@ -215,7 +217,6 @@ set_redir_mod() { #路由模式设置
sleep 1 sleep 1
fi fi
fi fi
set_redir_mod
;; ;;
4) 4)
if [ -n "$sup_tun" ]; then if [ -n "$sup_tun" ]; then
@@ -225,25 +226,20 @@ set_redir_mod() { #路由模式设置
echo -e "\033[31m设备未检测到Tun内核模块请尝试其他模式或者安装相关依赖\033[0m" echo -e "\033[31m设备未检测到Tun内核模块请尝试其他模式或者安装相关依赖\033[0m"
sleep 1 sleep 1
fi fi
set_redir_mod
;; ;;
5) 5)
redir_mod='TCP旁路转发' redir_mod='TCP旁路转发'
set_redir_config set_redir_config
set_redir_mod
;; ;;
6) 6)
redir_mod='T&U旁路转发' redir_mod='T&U旁路转发'
set_redir_config set_redir_config
set_redir_mod
;; ;;
7) 7)
set_firewall_area set_firewall_area
set_redir_mod
;; ;;
8) 8)
set_firewall_vm set_firewall_vm
set_redir_mod
;; ;;
9) 9)
if [ "$firewall_mod" = 'iptables' ]; then if [ "$firewall_mod" = 'iptables' ]; then
@@ -275,13 +271,16 @@ set_redir_mod() { #路由模式设置
fi fi
sleep 1 sleep 1
setconfig firewall_mod $firewall_mod setconfig firewall_mod $firewall_mod
set_redir_mod
;; ;;
*) *)
errornum errornum
sleep 1
break
;; ;;
esac esac
done
} }
set_adv_config() { #端口设置 set_adv_config() { #端口设置
. "$CFG_PATH" >/dev/null . "$CFG_PATH" >/dev/null
[ -z "$secret" ] && secret=未设置 [ -z "$secret" ] && secret=未设置
@@ -490,7 +489,10 @@ set_firewall_vm(){
setconfig vm_redir $vm_redir setconfig vm_redir $vm_redir
setconfig vm_ipv4 "'$vm_ipv4'" setconfig vm_ipv4 "'$vm_ipv4'"
} }
set_ipv6() { #ipv6设置
# ipv6设置
set_ipv6() {
while true; do
[ -z "$ipv6_redir" ] && ipv6_redir=OFF [ -z "$ipv6_redir" ] && ipv6_redir=OFF
[ -z "$ipv6_dns" ] && ipv6_dns=ON [ -z "$ipv6_dns" ] && ipv6_dns=ON
echo "-----------------------------------------------" echo "-----------------------------------------------"
@@ -500,7 +502,9 @@ set_ipv6() { #ipv6设置
echo "-----------------------------------------------" echo "-----------------------------------------------"
read -p "请输入对应数字 > " num read -p "请输入对应数字 > " num
case "$num" in case "$num" in
0) ;; "" | 0)
break
;;
1) 1)
if [ "$ipv6_redir" = "OFF" ]; then if [ "$ipv6_redir" = "OFF" ]; then
ipv6_support=ON ipv6_support=ON
@@ -511,15 +515,16 @@ set_ipv6() { #ipv6设置
fi fi
setconfig ipv6_redir $ipv6_redir setconfig ipv6_redir $ipv6_redir
setconfig ipv6_support $ipv6_support setconfig ipv6_support $ipv6_support
set_ipv6
;; ;;
2) 2)
[ "$ipv6_dns" = "OFF" ] && ipv6_dns=ON || ipv6_dns=OFF [ "$ipv6_dns" = "OFF" ] && ipv6_dns=ON || ipv6_dns=OFF
setconfig ipv6_dns $ipv6_dns setconfig ipv6_dns $ipv6_dns
set_ipv6
;; ;;
*) *)
errornum errornum
sleep 1
break
;; ;;
esac esac
done
} }

View File

@@ -211,7 +211,10 @@ task_type(){ #任务条件选择菜单
;; ;;
esac esac
} }
task_manager(){ #任务管理列表
# 任务管理列表
task_manager() {
while true; do
echo "-----------------------------------------------" echo "-----------------------------------------------"
# 抽取并生成临时列表 # 抽取并生成临时列表
croncmd -l >"$TMPDIR"/task_cronlist croncmd -l >"$TMPDIR"/task_cronlist
@@ -224,6 +227,7 @@ task_manager(){ #任务管理列表
if [ ! -s "$TMPDIR"/task_list ]; then if [ ! -s "$TMPDIR"/task_list ]; then
echo -e "\033[31m当前没有可供管理的任务\033[36m" echo -e "\033[31m当前没有可供管理的任务\033[36m"
sleep 1 sleep 1
break
else else
echo -e "\033[33m已添加的任务:\033[0m" echo -e "\033[33m已添加的任务:\033[0m"
echo "-----------------------------------------------" echo "-----------------------------------------------"
@@ -234,20 +238,22 @@ task_manager(){ #任务管理列表
echo -e " 0 返回上级菜单" echo -e " 0 返回上级菜单"
read -p "请输入对应数字 > " num read -p "请输入对应数字 > " num
case "$num" in case "$num" in
0) "" | 0)
break
;; ;;
a) a)
task_del "#" task_del "#"
echo -e "\033[31m旧版任务已清空\033[36m" echo -e "\033[31m旧版任务已清空\033[36m"
sleep 1 sleep 1
break
;; ;;
d) d)
task_del "task.sh" task_del "task.sh"
echo -e "\033[31m全部任务已清空\033[36m" echo -e "\033[31m全部任务已清空\033[36m"
sleep 1 sleep 1
break
;; ;;
[1-9] | [1-9][0-9]) [1-9] | [1-9][0-9])
task_txt=$(sed -n "$num p" "$TMPDIR"/task_list) task_txt=$(sed -n "$num p" "$TMPDIR"/task_list)
task_id=$(echo $task_txt | awk '{print $1}') task_id=$(echo $task_txt | awk '{print $1}')
if [ "$task_id" = 0 ]; then if [ "$task_id" = 0 ]; then
@@ -258,6 +264,7 @@ task_manager(){ #任务管理列表
sed -i "/$cronname/d" $clashdir/tools/cron 2>/dev/null sed -i "/$cronname/d" $clashdir/tools/cron 2>/dev/null
rm -f $TMPDIR/conf rm -f $TMPDIR/conf
} }
break
else else
task_des=$(echo $task_txt | awk '{print $2}') task_des=$(echo $task_txt | awk '{print $2}')
task_name=$(cat "$CRASHDIR"/task/task.list "$CRASHDIR"/task/task.user 2>/dev/null | grep "$task_id" | awk -F '#' '{print $3}') task_name=$(cat "$CRASHDIR"/task/task.list "$CRASHDIR"/task/task.user 2>/dev/null | grep "$task_id" | awk -F '#' '{print $3}')
@@ -271,7 +278,8 @@ task_manager(){ #任务管理列表
echo -e " 0 返回上级菜单" echo -e " 0 返回上级菜单"
read -p "请选择需要执行的操作 > " num read -p "请选择需要执行的操作 > " num
case "$num" in case "$num" in
0) "" | 0)
return 0
;; ;;
1) 1)
task_type && task_del $task_des task_type && task_del $task_des
@@ -296,17 +304,21 @@ task_manager(){ #任务管理列表
;; ;;
*) *)
errornum errornum
sleep 1
;; ;;
esac esac
fi fi
task_manager
;; ;;
*) *)
errornum errornum
sleep 1
break
;; ;;
esac esac
fi fi
done
} }
task_recom(){ #任务推荐 task_recom(){ #任务推荐
echo "-----------------------------------------------" echo "-----------------------------------------------"
echo -e "\033[32m启用推荐的自动任务配置这包括\033[0m" echo -e "\033[32m启用推荐的自动任务配置这包括\033[0m"

View File

@@ -372,13 +372,13 @@ EOF
} }
} }
if [ -z "$(grep "provider_temp_${coretype}" "$CRASHDIR"/configs/ShellCrash.cfg)" ];then if [ -z "$(grep "provider_temp_${coretype}" "$CRASHDIR"/configs/ShellCrash.cfg)" ];then
provider_temp_file="$TMPDIR/$(sed -n "1 p" "$CRASHDIR"/configs/${coretype}_providers.list | awk '{print $2}')" provider_temp_file="$(sed -n "1 p" "$CRASHDIR"/configs/${coretype}_providers.list | awk '{print $2}')"
else else
provider_temp_file=$(grep "provider_temp_${coretype}" "$CRASHDIR"/configs/ShellCrash.cfg | awk -F '=' '{print $2}') provider_temp_file=$(grep "provider_temp_${coretype}" "$CRASHDIR"/configs/ShellCrash.cfg | awk -F '=' '{print $2}')
fi fi
echo "-----------------------------------------------" echo "-----------------------------------------------"
if [ -s "$provider_temp_file" ];then if [ -s "$TMPDIR/$provider_temp_file" ];then
ln -sf "$provider_temp_file" "$TMPDIR"/provider_temp_file ln -sf "$TMPDIR/$provider_temp_file" "$TMPDIR"/provider_temp_file
else else
echo -e "\033[33m正在获取在线模版\033[0m" echo -e "\033[33m正在获取在线模版\033[0m"
get_bin "$TMPDIR"/provider_temp_file "rules/${coretype}_providers/$provider_temp_file" get_bin "$TMPDIR"/provider_temp_file "rules/${coretype}_providers/$provider_temp_file"
@@ -416,7 +416,7 @@ EOF
cut -c 1- "$TMPDIR"/providers/providers.yaml "$TMPDIR"/providers/proxy-groups.yaml "$TMPDIR"/providers/rules.yaml > "$TMPDIR"/config.yaml cut -c 1- "$TMPDIR"/providers/providers.yaml "$TMPDIR"/providers/proxy-groups.yaml "$TMPDIR"/providers/rules.yaml > "$TMPDIR"/config.yaml
rm -rf "$TMPDIR"/providers rm -rf "$TMPDIR"/providers
#调用内核测试 #调用内核测试
. "$CRASHDIR"/libs/core_tools.sh && core_find && "$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" echo -e "\033[32m配置文件生成成功\033[0m"
mkdir -p "$CRASHDIR"/yamls mkdir -p "$CRASHDIR"/yamls
@@ -518,7 +518,7 @@ EOF
cat "$TMPDIR"/provider_temp_file | sed "s/{providers_tags}/$providers_tags/g" > "$TMPDIR"/providers/outbounds.json cat "$TMPDIR"/provider_temp_file | sed "s/{providers_tags}/$providers_tags/g" > "$TMPDIR"/providers/outbounds.json
rm -rf "$TMPDIR"/provider_temp_file rm -rf "$TMPDIR"/provider_temp_file
#调用内核测试 #调用内核测试
. "$CRASHDIR"/libs/core_tools.sh && core_find && "$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" echo -e "\033[32m配置文件生成成功如果启动超时建议更新里手动安装Singbox-srs数据库常用包\033[0m"
mkdir -p "$CRASHDIR"/jsons mkdir -p "$CRASHDIR"/jsons
@@ -535,9 +535,12 @@ EOF
rm -rf "$TMPDIR"/providers rm -rf "$TMPDIR"/providers
fi fi
} }
setproviders(){ #自定义providers
# 自定义providers
setproviders() {
. "$CRASHDIR"/libs/set_cron.sh . "$CRASHDIR"/libs/set_cron.sh
. "$CRASHDIR"/libs/web_get_bin.sh . "$CRASHDIR"/libs/web_get_bin.sh
while true; do
# 获取模版名称 # 获取模版名称
if [ -z "$(grep "provider_temp_${coretype}" "$CRASHDIR"/configs/ShellCrash.cfg)" ]; then if [ -z "$(grep "provider_temp_${coretype}" "$CRASHDIR"/configs/ShellCrash.cfg)" ]; then
provider_temp_des=$(sed -n "1 p" "$CRASHDIR"/configs/${coretype}_providers.list | awk '{print $1}') provider_temp_des=$(sed -n "1 p" "$CRASHDIR"/configs/${coretype}_providers.list | awk '{print $1}')
@@ -565,7 +568,8 @@ setproviders(){ #自定义providers
echo -e " 0 返回上级菜单" echo -e " 0 返回上级菜单"
read -p "请输入对应字母或数字 > " num read -p "请输入对应字母或数字 > " num
case "$num" in case "$num" in
0) "" | 0)
break
;; ;;
[1-9] | [1-9][0-9]) [1-9] | [1-9][0-9])
provider_name=$(sed -n "$num p" "$CRASHDIR"/configs/providers.cfg | awk '{print $1}') provider_name=$(sed -n "$num p" "$CRASHDIR"/configs/providers.cfg | awk '{print $1}')
@@ -582,8 +586,7 @@ setproviders(){ #自定义providers
echo -e " 0 返回上级菜单" echo -e " 0 返回上级菜单"
read -p "请选择需要执行的操作 > " num read -p "请选择需要执行的操作 > " num
case "$num" in case "$num" in
0) "" | 0) ;;
;;
1) 1)
read -p "请输入名称或者代号(不可重复,不支持纯数字) > " name read -p "请输入名称或者代号(不可重复,不支持纯数字) > " name
if [ -n "$name" ] && [ -z "$(echo "$name" | grep -E '^[0-9]+$')" ] && ! grep -q "$name" "$CRASHDIR"/configs/providers.cfg; then if [ -n "$name" ] && [ -z "$(echo "$name" | grep -E '^[0-9]+$')" ] && ! grep -q "$name" "$CRASHDIR"/configs/providers.cfg; then
@@ -611,9 +614,8 @@ setproviders(){ #自定义providers
errornum errornum
;; ;;
esac esac
sleep 1
fi fi
setproviders sleep 1
;; ;;
a) a)
echo "-----------------------------------------------" echo "-----------------------------------------------"
@@ -638,7 +640,6 @@ setproviders(){ #自定义providers
} }
[ "$?" != 0 ] && echo -e "\033[31m输入错误操作已取消\033[0m" [ "$?" != 0 ] && echo -e "\033[31m输入错误操作已取消\033[0m"
sleep 1 sleep 1
setproviders
;; ;;
c) c)
echo "-----------------------------------------------" echo "-----------------------------------------------"
@@ -653,7 +654,6 @@ setproviders(){ #自定义providers
echo -e "\033[31m你还未添加链接或本地配置文件请先添加\033[0m" echo -e "\033[31m你还未添加链接或本地配置文件请先添加\033[0m"
sleep 1 sleep 1
fi fi
setproviders
;; ;;
b) b)
echo "-----------------------------------------------" echo "-----------------------------------------------"
@@ -666,8 +666,7 @@ setproviders(){ #自定义providers
echo "-----------------------------------------------" echo "-----------------------------------------------"
read -p "请输入对应字母或数字 > " num read -p "请输入对应字母或数字 > " num
case "$num" in case "$num" in
0) "" | 0) ;;
;;
a) a)
read -p "请输入模版的路径(绝对路径) > " dir read -p "请输入模版的路径(绝对路径) > " dir
if [ -s $dir ]; then if [ -s $dir ]; then
@@ -683,28 +682,29 @@ setproviders(){ #自定义providers
provider_temp_file=$(sed -n "$num p" "$CRASHDIR"/configs/${coretype}_providers.list 2>/dev/null | awk '{print $2}') provider_temp_file=$(sed -n "$num p" "$CRASHDIR"/configs/${coretype}_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_${coretype} $provider_temp_file setconfig provider_temp_${coretype} $provider_temp_file
fi fi
;; ;;
esac esac
setproviders
;; ;;
d) d)
read -p "确认清空全部链接?(1/0) > " res read -p "确认清空全部链接?(1/0) > " res
[ "$res" = "1" ] && rm -rf "$CRASHDIR"/configs/providers.cfg [ "$res" = "1" ] && rm -rf "$CRASHDIR"/configs/providers.cfg
setproviders
;; ;;
e) e)
echo -e "\033[33m将清空 $CRASHDIR/providers 目录下所有内容\033[0m" echo -e "\033[33m将清空 $CRASHDIR/providers 目录下所有内容\033[0m"
read -p "是否继续?(1/0) > " res read -p "是否继续?(1/0) > " res
[ "$res" = "1" ] && rm -rf "$CRASHDIR"/providers [ "$res" = "1" ] && rm -rf "$CRASHDIR"/providers
setproviders
;; ;;
*) *)
errornum errornum
sleep 1
break
;; ;;
esac esac
done
} }
set_clash_adv(){ #自定义clash高级规则 set_clash_adv(){ #自定义clash高级规则
@@ -746,7 +746,10 @@ set_singbox_adv(){ #自定义singbox配置文件
echo "-----------------------------------------------" echo "-----------------------------------------------"
echo -e "使用前请务必参考配置教程:\033[32;4m https://juewuy.github.io/nWTjEpkSK \033[0m" echo -e "使用前请务必参考配置教程:\033[32;4m https://juewuy.github.io/nWTjEpkSK \033[0m"
} }
override(){ #配置文件覆写
# 配置文件覆写
override() {
while true; do
[ -z "$rule_link" ] && rule_link=1 [ -z "$rule_link" ] && rule_link=1
[ -z "$server_link" ] && server_link=1 [ -z "$server_link" ] && server_link=1
echo "-----------------------------------------------" echo "-----------------------------------------------"
@@ -764,7 +767,8 @@ override(){ #配置文件覆写
[ "$inuserguide" = 1 ] || echo -e " 0 返回上级菜单" [ "$inuserguide" = 1 ] || echo -e " 0 返回上级菜单"
read -p "请输入对应数字 > " num read -p "请输入对应数字 > " num
case "$num" in case "$num" in
0) "" | 0)
break
;; ;;
1) 1)
if [ -n "$(pidof CrashCore)" ]; then if [ -n "$(pidof CrashCore)" ]; then
@@ -778,24 +782,19 @@ override(){ #配置文件覆写
else else
setport setport
fi fi
override
;; ;;
2) 2)
setrules setrules
override
;; ;;
3) 3)
setproxies setproxies
override
;; ;;
4) 4)
setgroups setgroups
override
;; ;;
5) 5)
echo "$crashcore" | grep -q 'singbox' && set_singbox_adv || set_clash_adv echo "$crashcore" | grep -q 'singbox' && set_singbox_adv || set_clash_adv
sleep 3 sleep 3
override
;; ;;
9) 9)
echo "-----------------------------------------------" echo "-----------------------------------------------"
@@ -811,12 +810,14 @@ override(){ #配置文件覆写
echo "-----------------------------------------------" echo "-----------------------------------------------"
echo -e "\033[32m设置成功\033[0m" echo -e "\033[32m设置成功\033[0m"
} }
override
;; ;;
*) *)
errornum errornum
sleep 1
break
;; ;;
esac esac
done
} }
gen_link_config(){ #选择在线规则 gen_link_config(){ #选择在线规则
@@ -987,7 +988,10 @@ gen_core_config_link(){ #在线生成工具
fi fi
done done
} }
set_core_config_link(){ #直接导入配置
# 直接导入配置
set_core_config_link() {
while true; do
echo "-----------------------------------------------" echo "-----------------------------------------------"
echo -e "\033[32m仅限导入完整的配置文件链接\033[0m" echo -e "\033[32m仅限导入完整的配置文件链接\033[0m"
echo "-----------------------------------------------" echo "-----------------------------------------------"
@@ -999,11 +1003,11 @@ set_core_config_link(){ #直接导入配置
echo "-----------------------------------------------" echo "-----------------------------------------------"
read -p "请输入完整链接 > " link read -p "请输入完整链接 > " link
test=$(echo $link | grep -iE "tp.*://") test=$(echo $link | grep -iE "tp.*://")
link=`echo ${link/\ \(*\)/''}` #删除恶心的超链接内容 link=$(echo ${link/\ \(*\)/''}) # 删除恶心的超链接内容
link=`echo ${link//\&/\\\&}` #处理分隔符 link=$(echo ${link//\&/\\&}) # 处理分隔符
if [ -n "$link" -a -n "$test" ]; then if [ -n "$link" -a -n "$test" ]; then
echo "-----------------------------------------------" echo "-----------------------------------------------"
echo -e 请检查输入的链接是否正确: echo -e "请检查输入的链接是否正确:"
echo -e "\033[4;32m$link\033[0m" echo -e "\033[4;32m$link\033[0m"
read -p "确认导入配置文件?原配置文件将被备份![1/0] > " res read -p "确认导入配置文件?原配置文件将被备份![1/0] > " res
if [ "$res" = '1' ]; then if [ "$res" = '1' ]; then
@@ -1014,22 +1018,23 @@ set_core_config_link(){ #直接导入配置
setconfig Url setconfig Url
# 获取在线yaml文件 # 获取在线yaml文件
jump_core_config jump_core_config
else break
set_core_config_link
fi fi
elif [ "$link" = 0 ]; then elif [ "$link" = 0 ]; then
i= i=
break
else else
echo "-----------------------------------------------" echo "-----------------------------------------------"
echo -e "\033[31m请输入正确的配置文件链接地址\033[0m" echo -e "\033[31m请输入正确的配置文件链接地址\033[0m"
echo -e "\033[33m仅支持http、https、ftp以及ftps链接\033[0m" echo -e "\033[33m仅支持http、https、ftp以及ftps链接\033[0m"
sleep 1 sleep 1
set_core_config_link
fi fi
done
} }
# 配置文件主界面 # 配置文件主界面
set_core_config() { set_core_config() {
while true; do
[ -z "$rule_link" ] && rule_link=1 [ -z "$rule_link" ] && rule_link=1
[ -z "$server_link" ] && server_link=1 [ -z "$server_link" ] && server_link=1
echo "$crashcore" | grep -q 'singbox' && config_path="$JSONSDIR"/config.json || config_path="$YAMLSDIR"/config.yaml echo "$crashcore" | grep -q 'singbox' && config_path="$JSONSDIR"/config.json || config_path="$YAMLSDIR"/config.yaml
@@ -1053,7 +1058,8 @@ set_core_config(){
[ "$inuserguide" = 1 ] || echo -e " 0 返回上级菜单" [ "$inuserguide" = 1 ] || echo -e " 0 返回上级菜单"
read -p "请输入对应数字 > " num read -p "请输入对应数字 > " num
case "$num" in case "$num" in
0) "" | 0)
break
;; ;;
1) 1)
if [ -n "$Url" ]; then if [ -n "$Url" ]; then
@@ -1071,16 +1077,13 @@ set_core_config(){
fi fi
fi fi
gen_core_config_link gen_core_config_link
set_core_config
;; ;;
2) 2)
if [ -f "$CRASHDIR"/v2b_api.sh ]; then if [ -f "$CRASHDIR"/v2b_api.sh ]; then
. "$CRASHDIR"/v2b_api.sh . "$CRASHDIR"/v2b_api.sh
set_core_config
else else
set_core_config_link set_core_config_link
fi fi
set_core_config
;; ;;
3) 3)
if [ "$crashcore" = meta -o "$crashcore" = clashpre ]; then if [ "$crashcore" = meta -o "$crashcore" = clashpre ]; then
@@ -1094,17 +1097,17 @@ set_core_config(){
sleep 1 sleep 1
checkupdate && setcore checkupdate && setcore
fi fi
set_core_config
;; ;;
4) 4)
echo "-----------------------------------------------" echo "-----------------------------------------------"
echo -e "\033[33m请将本地配置文件上传到/tmp目录并重命名为config.yaml或者config.json\033[0m" echo -e "\033[33m请将本地配置文件上传到/tmp目录并重命名为config.yaml或者config.json\033[0m"
echo -e "\033[32m之后重新运行本脚本即可自动弹出导入提示\033[0m" echo -e "\033[32m之后重新运行本脚本即可自动弹出导入提示\033[0m"
sleep 2
exit exit
;; ;;
5) 5)
. "$CRASHDIR"/menus/5_task.sh && task_menu . "$CRASHDIR"/menus/5_task.sh && task_menu
set_core_config break
;; ;;
6) 6)
checkcfg=$(cat $CFG_PATH) checkcfg=$(cat $CFG_PATH)
@@ -1113,14 +1116,12 @@ set_core_config(){
checkcfg_new=$(cat $CFG_PATH) checkcfg_new=$(cat $CFG_PATH)
[ "$checkcfg" != "$checkcfg_new" ] && checkrestart [ "$checkcfg" != "$checkcfg_new" ] && checkrestart
fi fi
set_core_config
;; ;;
7) 7)
if [ -z "$Url" -a -z "$Https" ]; then if [ -z "$Url" -a -z "$Https" ]; then
echo "-----------------------------------------------" echo "-----------------------------------------------"
echo -e "\033[31m没有找到你的配置文件/订阅链接!请先输入链接!\033[0m" echo -e "\033[31m没有找到你的配置文件/订阅链接!请先输入链接!\033[0m"
sleep 1 sleep 1
set_core_config
else else
echo "-----------------------------------------------" echo "-----------------------------------------------"
echo -e "\033[33m当前系统记录的链接为\033[0m" echo -e "\033[33m当前系统记录的链接为\033[0m"
@@ -1129,8 +1130,7 @@ set_core_config(){
read -p "确认更新配置文件?[1/0] > " res read -p "确认更新配置文件?[1/0] > " res
if [ "$res" = '1' ]; then if [ "$res" = '1' ]; then
jump_core_config jump_core_config
else break
set_core_config
fi fi
fi fi
;; ;;
@@ -1138,20 +1138,20 @@ set_core_config(){
if [ ! -f ${config_path}.bak ]; then if [ ! -f ${config_path}.bak ]; then
echo "-----------------------------------------------" echo "-----------------------------------------------"
echo -e "\033[31m没有找到配置文件的备份\033[0m" echo -e "\033[31m没有找到配置文件的备份\033[0m"
set_core_config
else else
echo "-----------------------------------------------" echo "-----------------------------------------------"
echo -e 备份文件共有"\033[32m`wc -l < ${config_path}.bak`\033[0m"行内容,当前文件共有"\033[32m`wc -l < ${config_path}`\033[0m"行内容 echo -e 备份文件共有"\033[32m$(wc -l <${config_path}.bak)\033[0m"行内容,当前文件共有"\033[32m$(wc -l <${config_path})\033[0m"行内容
read -p "确认还原配置文件?此操作不可逆![1/0] > " res read -p "确认还原配置文件?此操作不可逆![1/0] > " res
if [ "$res" = '1' ]; then if [ "$res" = '1' ]; then
mv ${config_path}.bak ${config_path} mv ${config_path}.bak ${config_path}
echo "----------------------------------------------" echo "----------------------------------------------"
echo -e "\033[32m配置文件已还原请手动重启服务\033[0m" echo -e "\033[32m配置文件已还原请手动重启服务\033[0m"
sleep 1 sleep 1
break
else else
echo "-----------------------------------------------" echo "-----------------------------------------------"
echo -e "\033[31m操作已取消返回上级菜单\033[0m" echo -e "\033[31m操作已取消返回上级菜单\033[0m"
set_core_config sleep 1
fi fi
fi fi
;; ;;
@@ -1182,10 +1182,12 @@ set_core_config(){
;; ;;
esac esac
[ "$num" -le 3 ] && setconfig user_agent "$user_agent" [ "$num" -le 3 ] && setconfig user_agent "$user_agent"
set_core_config
;; ;;
*) *)
errornum errornum
sleep 1
break
;; ;;
esac esac
done
} }

View File

@@ -10,6 +10,7 @@ __IS_MODULE_7_GATEWAY_LOADED=1
# 访问与控制主菜单 # 访问与控制主菜单
gateway() { gateway() {
while true; do
echo "-----------------------------------------------" echo "-----------------------------------------------"
echo -e "\033[30;47m欢迎使用访问与控制菜单\033[0m" echo -e "\033[30;47m欢迎使用访问与控制菜单\033[0m"
echo "-----------------------------------------------" echo "-----------------------------------------------"
@@ -26,7 +27,9 @@ gateway(){
echo "-----------------------------------------------" echo "-----------------------------------------------"
read -p "请输入对应数字 > " num read -p "请输入对应数字 > " num
case "$num" in case "$num" in
0) ;; "" | 0)
break
;;
1) 1)
echo "-----------------------------------------------" echo "-----------------------------------------------"
if [ -n "$(pidof CrashCore)" ] && [ "$firewall_mod" = 'iptables' ]; then if [ -n "$(pidof CrashCore)" ] && [ "$firewall_mod" = 'iptables' ]; then
@@ -35,23 +38,18 @@ gateway(){
else else
set_fw_wan set_fw_wan
fi fi
gateway
;; ;;
2) 2)
set_bot_tg set_bot_tg
gateway
;; ;;
3) 3)
. "$CRASHDIR"/menus/ddns.sh && ddns_menu . "$CRASHDIR"/menus/ddns.sh && ddns_menu
gateway
;; ;;
4) 4)
set_vmess set_vmess
gateway
;; ;;
5) 5)
set_shadowsocks set_shadowsocks
gateway
;; ;;
6) 6)
if echo "$crashcore" | grep -q 'sing'; then if echo "$crashcore" | grep -q 'sing'; then
@@ -60,7 +58,6 @@ gateway(){
echo -e "\033[33m$crashcore内核暂不支持此功能,请先更换内核!\033[0m" echo -e "\033[33m$crashcore内核暂不支持此功能,请先更换内核!\033[0m"
sleep 1 sleep 1
fi fi
gateway
;; ;;
7) 7)
if echo "$crashcore" | grep -q 'sing'; then if echo "$crashcore" | grep -q 'sing'; then
@@ -69,11 +66,16 @@ gateway(){
echo -e "\033[33m$crashcore内核暂不支持此功能,请先更换内核!\033[0m" echo -e "\033[33m$crashcore内核暂不支持此功能,请先更换内核!\033[0m"
sleep 1 sleep 1
fi fi
gateway
;; ;;
*) errornum ;; *)
errornum
sleep 1
break
;;
esac esac
done
} }
#公网防火墙 #公网防火墙
set_fw_wan() { set_fw_wan() {
[ -z "$fw_wan" ] && fw_wan=ON [ -z "$fw_wan" ] && fw_wan=ON
@@ -228,8 +230,10 @@ set_bot_tg(){
;; ;;
esac esac
} }
# 自定义入站 # 自定义入站
set_vmess() { set_vmess() {
while true; do
echo "-----------------------------------------------" echo "-----------------------------------------------"
echo -e "\033[31m注意\033[0m设置的端口会添加到公网访问防火墙并自动放行\n 脚本只提供基础功能,更多需求请用自定义配置文件功能!" echo -e "\033[31m注意\033[0m设置的端口会添加到公网访问防火墙并自动放行\n 脚本只提供基础功能,更多需求请用自定义配置文件功能!"
echo -e " \033[31m切勿用于搭建违法翻墙节点违者后果自负\033[0m" echo -e " \033[31m切勿用于搭建违法翻墙节点违者后果自负\033[0m"
@@ -247,7 +251,9 @@ set_vmess(){
echo "-----------------------------------------------" echo "-----------------------------------------------"
read -p "请输入对应数字 > " num read -p "请输入对应数字 > " num
case "$num" in case "$num" in
0) ;; "" | 0)
break
;;
1) 1)
if [ "$vms_service" = ON ]; then if [ "$vms_service" = ON ]; then
vms_service=OFF vms_service=OFF
@@ -261,7 +267,6 @@ set_vmess(){
sleep 1 sleep 1
fi fi
fi fi
set_vmess
;; ;;
2) 2)
read -p "请输入端口号(输入0删除) > " text read -p "请输入端口号(输入0删除) > " text
@@ -274,7 +279,6 @@ set_vmess(){
else else
sleep 1 sleep 1
fi fi
set_vmess
;; ;;
3) 3)
read -p "请输入ws-path路径(输入0删除) > " text read -p "请输入ws-path路径(输入0删除) > " text
@@ -288,7 +292,6 @@ set_vmess(){
echo -e "\033[31m不是合法的path路径必须以【/】开头!\033[0m" echo -e "\033[31m不是合法的path路径必须以【/】开头!\033[0m"
sleep 1 sleep 1
fi fi
set_vmess
;; ;;
4) 4)
read -p "请输入UUID(输入0删除) > " text read -p "请输入UUID(输入0删除) > " text
@@ -302,13 +305,11 @@ set_vmess(){
echo -e "\033[31m不是合法的UUID格式请重新输入或使用随机生成功能\033[0m" echo -e "\033[31m不是合法的UUID格式请重新输入或使用随机生成功能\033[0m"
sleep 1 sleep 1
fi fi
set_vmess
;; ;;
5) 5)
vms_uuid=$(cat /proc/sys/kernel/random/uuid) vms_uuid=$(cat /proc/sys/kernel/random/uuid)
setconfig vms_uuid "$vms_uuid" "$GT_CFG_PATH" setconfig vms_uuid "$vms_uuid" "$GT_CFG_PATH"
sleep 1 sleep 1
set_vmess
;; ;;
6) 6)
read -p "请输入免流混淆host(输入0删除) > " text read -p "请输入免流混淆host(输入0删除) > " text
@@ -319,13 +320,13 @@ set_vmess(){
vms_host="$text" vms_host="$text"
setconfig vms_host "$text" "$GT_CFG_PATH" setconfig vms_host "$text" "$GT_CFG_PATH"
fi fi
set_vmess
;; ;;
7) 7)
read -p "请输入本机公网IP(4/6)或域名 > " host_wan read -p "请输入本机公网IP(4/6)或域名 > " host_wan
if [ -n "$host_wan" ] && [ -n "$vms_port" ] && [ -n "$vms_uuid" ]; then if [ -n "$host_wan" ] && [ -n "$vms_port" ] && [ -n "$vms_uuid" ]; then
[ -n "$vms_ws_path" ] && vms_net=ws [ -n "$vms_ws_path" ] && vms_net=ws
vms_json=$(cat <<EOF vms_json=$(
cat <<EOF
{ {
"v": "2", "v": "2",
"ps": "ShellCrash_vms_in", "ps": "ShellCrash_vms_in",
@@ -347,11 +348,16 @@ EOF
echo -e "\033[31m请先完成必选设置\033[0m" echo -e "\033[31m请先完成必选设置\033[0m"
fi fi
sleep 1 sleep 1
set_vmess
;; ;;
*) errornum ;; *)
errornum
sleep 1
break
;;
esac esac
done
} }
set_shadowsocks(){ set_shadowsocks(){
echo "-----------------------------------------------" echo "-----------------------------------------------"
echo -e "\033[31m注意\033[0m设置的端口会添加到公网访问防火墙并自动放行\n 脚本只提供基础功能,更多需求请用自定义配置文件功能!" echo -e "\033[31m注意\033[0m设置的端口会添加到公网访问防火墙并自动放行\n 脚本只提供基础功能,更多需求请用自定义配置文件功能!"

View File

@@ -160,7 +160,7 @@ setscripts(){
echo "-----------------------------------------------" echo "-----------------------------------------------"
echo -e "\033[32m管理脚本更新成功!\033[0m" echo -e "\033[32m管理脚本更新成功!\033[0m"
echo "-----------------------------------------------" echo "-----------------------------------------------"
exit; exit
fi fi
} }
@@ -170,18 +170,18 @@ setcpucore(){ #手动设置内核架构
echo "-----------------------------------------------" echo "-----------------------------------------------"
echo -e "\033[31m仅适合脚本无法正确识别核心或核心无法正常运行时使用\033[0m" echo -e "\033[31m仅适合脚本无法正确识别核心或核心无法正常运行时使用\033[0m"
echo -e "当前可供在线下载的处理器架构为:" echo -e "当前可供在线下载的处理器架构为:"
echo $cpucore_list | awk -F " " '{for(i=1;i<=NF;i++) {print i" "$i }}' echo "$cpucore_list" | awk -F " " '{for(i=1;i<=NF;i++) {print i" "$i }}'
echo -e "不知道如何获取核心版本?请参考:\033[36;4mhttps://juewuy.github.io/bdaz\033[0m" echo -e "不知道如何获取核心版本?请参考:\033[36;4mhttps://juewuy.github.io/bdaz\033[0m"
echo "-----------------------------------------------" echo "-----------------------------------------------"
read -p "请输入对应数字 > " num read -p "请输入对应数字 > " num
[ -n "$num" ] && setcpucore=$(echo $cpucore_list | awk '{print $"'"$num"'"}' ) [ -n "$num" ] && setcpucore=$(echo "$cpucore_list" | awk '{print $"'"$num"'"}')
if [ -z "$setcpucore" ]; then if [ -z "$setcpucore" ]; then
echo -e "\033[31m请输入正确的处理器架构\033[0m" echo -e "\033[31m请输入正确的处理器架构\033[0m"
sleep 1 sleep 1
cpucore="" cpucore=""
else else
cpucore=$setcpucore cpucore=$setcpucore
setconfig cpucore $cpucore setconfig cpucore "$cpucore"
fi fi
} }
setcoretype() { #手动指定内核类型 setcoretype() { #手动指定内核类型
@@ -228,15 +228,19 @@ switch_core(){ #clash与singbox内核切换
} }
} }
} }
getcore(){ #下载内核文件
. "$CRASHDIR"/libs/core_tools.sh #调用下载工具 # 下载内核文件
getcore() {
# 调用下载工具
. "$CRASHDIR"/libs/core_tools.sh
[ -z "$crashcore" ] && crashcore=meta [ -z "$crashcore" ] && crashcore=meta
[ -z "$cpucore" ] && check_cpucore [ -z "$cpucore" ] && check_cpucore
[ "$crashcore" = unknow ] && setcoretype [ "$crashcore" = unknow ] && setcoretype
echo "$crashcore" | grep -q 'singbox' && core_new=singbox || core_new=clash echo "$crashcore" | grep -q 'singbox' && core_new=singbox || core_new=clash
# 获取在线内核文件 # 获取在线内核文件
echo "-----------------------------------------------" echo "-----------------------------------------------"
echo "正在在线获取$crashcore核心文件……" echo "正在在线获取$crashcore核心文件......"
core_webget core_webget
case "$?" in case "$?" in
0) 0)
@@ -250,26 +254,26 @@ getcore(){ #下载内核文件
;; ;;
*) *)
echo -e "\033[31m核心文件下载成功但校验失败请尝试手动指定CPU版本\033[0m" echo -e "\033[31m核心文件下载成功但校验失败请尝试手动指定CPU版本\033[0m"
rm -rf ${TMPDIR}/core_new rm -rf "${TMPDIR}"/core_new
rm -rf ${TMPDIR}/core_new.tar.gz rm -rf "${TMPDIR}"/core_new.tar.gz
setcpucore setcpucore
;; ;;
esac esac
} }
setcustcore(){ #自定义内核
checkcustcore() { checkcustcore() {
[ "$api_tag" = "latest" ] && api_url=latest || api_url="tags/$api_tag" [ "$api_tag" = "latest" ] && api_url=latest || api_url="tags/$api_tag"
# 通过githubapi获取内核信息 # 通过githubapi获取内核信息
echo -e "\033[32m正在获取内核文件链接\033[0m" echo -e "\033[32m正在获取内核文件链接\033[0m"
webget "$TMPDIR"/github_api https://api.github.com/repos/${project}/releases/${api_url} webget "$TMPDIR"/github_api https://api.github.com/repos/"${project}"/releases/"${api_url}"
if [ "$?" = 0 ]; then if [ "$?" = 0 ]; then
release_tag=$(cat "$TMPDIR"/github_api | grep '"tag_name":' | awk -F '"' '{print $4}') release_tag=$(cat "$TMPDIR"/github_api | grep '"tag_name":' | awk -F '"' '{print $4}')
release_date=$(cat "$TMPDIR"/github_api | grep '"published_at":' | awk -F '"' '{print $4}') release_date=$(cat "$TMPDIR"/github_api | grep '"published_at":' | awk -F '"' '{print $4}')
update_date=$(cat "$TMPDIR"/github_api | grep '"updated_at":' | head -n 1 | awk -F '"' '{print $4}') update_date=$(cat "$TMPDIR"/github_api | grep '"updated_at":' | head -n 1 | awk -F '"' '{print $4}')
[ -n "$(echo $cpucore | grep mips)" ] && cpu_type=mips || cpu_type=$cpucore [ -n "$(echo "$cpucore" | grep mips)" ] && cpu_type=mips || cpu_type=$cpucore
cat "$TMPDIR"/github_api | grep "browser_download_url" | grep -oE "https://github.com/${project}/releases/download.*linux.*${cpu_type}.*\.gz\"$" | sed 's/"//' >"$TMPDIR"/core.list cat "$TMPDIR"/github_api | grep "browser_download_url" | grep -oE "https://github.com/${project}/releases/download.*linux.*${cpu_type}.*\.gz\"$" | sed 's/"//' >"$TMPDIR"/core.list
rm -rf "$TMPDIR"/github_api rm -rf "$TMPDIR"/github_api
#
if [ -s "$TMPDIR"/core.list ]; then if [ -s "$TMPDIR"/core.list ]; then
echo "-----------------------------------------------" echo "-----------------------------------------------"
echo -e "内核版本:\033[36m$release_tag\033[0m" echo -e "内核版本:\033[36m$release_tag\033[0m"
@@ -283,7 +287,7 @@ setcustcore(){ #自定义内核
read -p "请输入对应数字 > " num read -p "请输入对应数字 > " num
case "$num" in case "$num" in
0) 0)
setcustcore return 0
;; ;;
[1-9] | [1-9][0-9]) [1-9] | [1-9][0-9])
if [ "$num" -le "$(wc -l <"$TMPDIR"/core.list)" ]; then if [ "$num" -le "$(wc -l <"$TMPDIR"/core.list)" ]; then
@@ -291,10 +295,12 @@ setcustcore(){ #自定义内核
getcore getcore
else else
errornum errornum
sleep 1
fi fi
;; ;;
*) *)
errornum errornum
sleep 1
;; ;;
esac esac
else else
@@ -307,6 +313,10 @@ setcustcore(){ #自定义内核
fi fi
rm -rf "$TMPDIR"/core.list rm -rf "$TMPDIR"/core.list
} }
# 自定义内核
setcustcore() {
while true; do
[ -z "$cpucore" ] && check_cpucore [ -z "$cpucore" ] && check_cpucore
echo "-----------------------------------------------" echo "-----------------------------------------------"
echo -e "\033[36m此处内核通常源自互联网采集此处致谢各位开发者\033[0m" echo -e "\033[36m此处内核通常源自互联网采集此处致谢各位开发者\033[0m"
@@ -328,6 +338,9 @@ setcustcore(){ #自定义内核
echo -e " 0 返回上级菜单" echo -e " 0 返回上级菜单"
read -p "请输入对应数字 > " num read -p "请输入对应数字 > " num
case "$num" in case "$num" in
"" | 0)
break
;;
1) 1)
project=MetaCubeX/mihomo project=MetaCubeX/mihomo
api_tag=latest api_tag=latest
@@ -359,9 +372,14 @@ setcustcore(){ #自定义内核
getcore getcore
;; ;;
*) *)
errornum
sleep 1
break
;; ;;
esac esac
done
} }
setziptype() { setziptype() {
echo "-----------------------------------------------" echo "-----------------------------------------------"
echo -e "请选择内核内核分支及压缩方式:\033[0m" echo -e "请选择内核内核分支及压缩方式:\033[0m"
@@ -397,7 +415,7 @@ setcore() {
[ -z "$crashcore" ] && crashcore="unknow" [ -z "$crashcore" ] && crashcore="unknow"
[ -z "$zip_type" ] && zip_type="tar.gz" [ -z "$zip_type" ] && zip_type="tar.gz"
echo "$crashcore" | grep -q 'singbox' && core_old=singbox || core_old=clash echo "$crashcore" | grep -q 'singbox' && core_old=singbox || core_old=clash
[ -n "$custcorelink" ] && custcore="$(echo $custcorelink | sed 's#.*github.com##; s#/releases/download/#@#; s#-linux.*$##')" [ -n "$custcorelink" ] && custcore="$(echo "$custcorelink" | sed 's#.*github.com##; s#/releases/download/#@#; s#-linux.*$##')"
### ###
echo "-----------------------------------------------" echo "-----------------------------------------------"
[ -z "$cpucore" ] && check_cpucore [ -z "$cpucore" ] && check_cpucore
@@ -490,8 +508,8 @@ setcore() {
getgeo() { #下载Geo文件 getgeo() { #下载Geo文件
#生成链接 #生成链接
echo "-----------------------------------------------" echo "-----------------------------------------------"
echo "正在从服务器获取数据库文件…………" echo "正在从服务器获取数据库文件......"
get_bin "$TMPDIR"/${geoname} bin/geodata/$geotype get_bin "$TMPDIR"/"${geoname}" bin/geodata/"$geotype"
if [ "$?" = "1" ]; then if [ "$?" = "1" ]; then
echo "-----------------------------------------------" echo "-----------------------------------------------"
echo -e "\033[31m文件下载失败\033[0m" echo -e "\033[31m文件下载失败\033[0m"
@@ -502,24 +520,24 @@ getgeo(){ #下载Geo文件
[ ! -d "$BINDIR"/ruleset ] && mkdir -p "$BINDIR"/ruleset [ ! -d "$BINDIR"/ruleset ] && mkdir -p "$BINDIR"/ruleset
} }
if echo "$geoname" | grep -Eq '.tar.gz'; then if echo "$geoname" | grep -Eq '.tar.gz'; then
tar -zxf "$TMPDIR"/${geoname} ${tar_para} -C "$BINDIR"/${geofile} > /dev/null tar -zxf "$TMPDIR"/"${geoname}" "${tar_para}" -C "$BINDIR"/"${geofile}" >/dev/null
[ $? -ne 0 ] && echo "文件解压失败!" && rm -rf "$TMPDIR"/${geoname} && exit 1 [ $? -ne 0 ] && echo "文件解压失败!" && rm -rf "$TMPDIR"/${geoname} && exit 1
rm -rf "$TMPDIR"/${geoname} rm -rf "$TMPDIR"/${geoname}
else else
mv -f "$TMPDIR"/${geoname} "$BINDIR"/${geofile}${geoname} mv -f "$TMPDIR"/"${geoname}" "$BINDIR"/"${geofile}""${geoname}"
fi fi
echo "-----------------------------------------------" echo "-----------------------------------------------"
echo -e "\033[32m$geotype数据库文件下载成功\033[0m" echo -e "\033[32m$geotype数据库文件下载成功\033[0m"
geo_v="$(echo $geotype | awk -F "." '{print $1}')_v" geo_v="$(echo "$geotype" | awk -F "." '{print $1}')_v"
setconfig $geo_v $GeoIP_v setconfig "$geo_v" "$GeoIP_v"
fi fi
sleep 1 sleep 1
} }
getcustgeo() { getcustgeo() {
echo "-----------------------------------------------" echo "-----------------------------------------------"
echo "正在获取数据库文件…………" echo "正在获取数据库文件......"
webget "$TMPDIR"/$geoname $custgeolink webget "$TMPDIR"/"$geoname" "$custgeolink"
if [ "$?" = "1" ]; then if [ "$?" = "1" ]; then
echo "-----------------------------------------------" echo "-----------------------------------------------"
echo -e "\033[31m文件下载失败\033[0m" echo -e "\033[31m文件下载失败\033[0m"
@@ -529,7 +547,7 @@ getcustgeo(){
geofile='ruleset/' geofile='ruleset/'
[ ! -d "$BINDIR"/ruleset ] && mkdir -p "$BINDIR"/ruleset [ ! -d "$BINDIR"/ruleset ] && mkdir -p "$BINDIR"/ruleset
} }
mv -f "$TMPDIR"/${geoname} "$BINDIR"/${geofile}${geoname} mv -f "$TMPDIR"/"${geoname}" "$BINDIR"/"${geofile}""${geoname}"
echo "-----------------------------------------------" echo "-----------------------------------------------"
echo -e "\033[32m$geotype数据库文件下载成功\033[0m" echo -e "\033[32m$geotype数据库文件下载成功\033[0m"
fi fi
@@ -560,9 +578,9 @@ checkcustgeo() {
[1-99]) [1-99])
if [ "$num" -le "$(wc -l <"$TMPDIR"/geo.list)" ]; then if [ "$num" -le "$(wc -l <"$TMPDIR"/geo.list)" ]; then
geotype=$(sed -n "$num"p "$TMPDIR"/geo.list) geotype=$(sed -n "$num"p "$TMPDIR"/geo.list)
[ -n "$(echo $geotype | grep -oiE 'GeoSite.*dat')" ] && geoname=GeoSite.dat [ -n "$(echo "$geotype" | grep -oiE 'GeoSite.*dat')" ] && geoname=GeoSite.dat
[ -n "$(echo $geotype | grep -oiE 'Country.*mmdb')" ] && geoname=Country.mmdb [ -n "$(echo "$geotype" | grep -oiE 'Country.*mmdb')" ] && geoname=Country.mmdb
[ -n "$(echo $geotype | grep -oiE '.*(.srs|.mrs)')" ] && geoname=$geotype [ -n "$(echo "$geotype" | grep -oiE '.*(.srs|.mrs)')" ] && geoname=$geotype
custgeolink=https://github.com/${project}/releases/download/${release_tag}/${geotype} custgeolink=https://github.com/${project}/releases/download/${release_tag}/${geotype}
getcustgeo getcustgeo
else else
@@ -719,7 +737,7 @@ setgeo() {
for var in Country_v cn_mini_v china_ip_list_v china_ipv6_list_v geosite_v geoip_cn_v geosite_cn_v mrs_geosite_cn_v srs_geoip_cn_v srs_geosite_cn_v mrs_v srs_v; do for var in Country_v cn_mini_v china_ip_list_v china_ipv6_list_v geosite_v geoip_cn_v geosite_cn_v mrs_geosite_cn_v srs_geoip_cn_v srs_geosite_cn_v mrs_v srs_v; do
setconfig $var setconfig $var
done done
rm -rf $CRASHDIR/ruleset/* rm -rf "$CRASHDIR"/ruleset/*
echo -e "\033[33m所有数据库文件均已清理\033[0m" echo -e "\033[33m所有数据库文件均已清理\033[0m"
sleep 1 sleep 1
} }
@@ -747,17 +765,17 @@ getdb() {
return 1 return 1
else else
echo -e "\033[33m下载成功正在解压文件\033[0m" echo -e "\033[33m下载成功正在解压文件\033[0m"
mkdir -p $dbdir >/dev/null mkdir -p "$dbdir" >/dev/null
tar -zxf "$TMPDIR/clashdb.tar.gz" ${tar_para} -C $dbdir >/dev/null tar -zxf "$TMPDIR/clashdb.tar.gz" "${tar_para}" -C "$dbdir" >/dev/null
[ $? -ne 0 ] && echo "文件解压失败!" && rm -rf "$TMPDIR"/clashfm.tar.gz && exit 1 [ $? -ne 0 ] && echo "文件解压失败!" && rm -rf "$TMPDIR"/clashfm.tar.gz && exit 1
#修改默认host和端口 #修改默认host和端口
if [ "$db_type" = "clashdb" -o "$db_type" = "meta_db" -o "$db_type" = "zashboard" ]; then if [ "$db_type" = "clashdb" -o "$db_type" = "meta_db" -o "$db_type" = "zashboard" ]; then
sed -i "s/127.0.0.1/${host}/g" $dbdir/assets/*.js sed -i "s/127.0.0.1/${host}/g" "$dbdir"/assets/*.js
sed -i "s/9090/${db_port}/g" $dbdir/assets/*.js sed -i "s/9090/${db_port}/g" "$dbdir"/assets/*.js
elif [ "$db_type" = "meta_xd" ]; then elif [ "$db_type" = "meta_xd" ]; then
sed -i "s/127.0.0.1:9090/${host}:${db_port}/g" $dbdir/_nuxt/*.js sed -i "s/127.0.0.1:9090/${host}:${db_port}/g" "$dbdir"/_nuxt/*.js
else else
sed -i "s/127.0.0.1:9090/${host}:${db_port}/g" $dbdir/*.html sed -i "s/127.0.0.1:9090/${host}:${db_port}/g" "$dbdir"/*.html
fi fi
#写入配置文件 #写入配置文件
setconfig hostdir "'$hostdir'" setconfig hostdir "'$hostdir'"
@@ -891,7 +909,7 @@ setdb() {
#根证书 #根证书
getcrt() { getcrt() {
echo "-----------------------------------------------" echo "-----------------------------------------------"
echo "正在连接服务器获取安装文件…………" echo "正在连接服务器获取安装文件......"
get_bin "$TMPDIR"/ca-certificates.crt bin/fix/ca-certificates.crt get_bin "$TMPDIR"/ca-certificates.crt bin/fix/ca-certificates.crt
if [ "$?" = "1" ]; then if [ "$?" = "1" ]; then
echo "-----------------------------------------------" echo "-----------------------------------------------"
@@ -899,13 +917,13 @@ getcrt(){
error_down error_down
else else
echo "-----------------------------------------------" echo "-----------------------------------------------"
[ "$systype" = 'mi_snapshot' ] && cp -f "$TMPDIR"/ca-certificates.crt $CRASHDIR/tools #镜像化设备特殊处理 [ "$systype" = 'mi_snapshot' ] && cp -f "$TMPDIR"/ca-certificates.crt "$CRASHDIR"/tools #镜像化设备特殊处理
[ -f $openssldir/certs ] && rm -rf $openssldir/certs #如果certs不是目录而是文件则删除并创建目录 [ -f "$openssldir"/certs ] && rm -rf "$openssldir"/certs #如果certs不是目录而是文件则删除并创建目录
mkdir -p $openssldir/certs mkdir -p "$openssldir"/certs
mv -f "$TMPDIR"/ca-certificates.crt $crtdir mv -f "$TMPDIR"/ca-certificates.crt "$crtdir"
webget /dev/null https://baidu.com echooff rediron skipceroff webget /dev/null https://baidu.com echooff rediron skipceroff
if [ "$?" = "1" ]; then if [ "$?" = "1" ]; then
export CURL_CA_BUNDLE=$crtdir export CURL_CA_BUNDLE="$crtdir"
echo "export CURL_CA_BUNDLE=$crtdir" >>/etc/profile echo "export CURL_CA_BUNDLE=$crtdir" >>/etc/profile
fi fi
echo -e "\033[32m证书安装成功\033[0m" echo -e "\033[32m证书安装成功\033[0m"
@@ -947,8 +965,8 @@ setcrt(){
# 写入配置文件 # 写入配置文件
saveserver() { saveserver() {
setconfig update_url "'$update_url'" setconfig update_url "'$update_url'"
setconfig url_id $url_id setconfig url_id "$url_id"
setconfig release_type $release_type setconfig release_type "$release_type"
version_new='' version_new=''
echo "-----------------------------------------------" echo "-----------------------------------------------"
echo -e "\033[32m源地址切换成功\033[0m" echo -e "\033[32m源地址切换成功\033[0m"
@@ -1049,7 +1067,7 @@ setserver() {
read -p "请输入对应数字 > " num read -p "请输入对应数字 > " num
if [ -z "$num" -o "$num" = 0 ]; then if [ -z "$num" -o "$num" = 0 ]; then
continue continue
elif [ $num -le $(cat "$TMPDIR"/release_version 2>/dev/null | awk 'END{print NR}') ]; then elif [ "$num" -le $(cat "$TMPDIR"/release_version 2>/dev/null | awk 'END{print NR}') ]; then
release_type=$(cat "$TMPDIR"/release_version | awk '{print $1}' | sed -n "$num"p) release_type=$(cat "$TMPDIR"/release_version | awk '{print $1}' | sed -n "$num"p)
update_url='' update_url=''
saveserver saveserver

View File

@@ -181,8 +181,9 @@ set_common_ports() {
} }
set_cust_host_ipv4() { #自定义ipv4透明路由网段 set_cust_host_ipv4() { #自定义ipv4透明路由网段
[ -z "$replace_default_host_ipv4" ] && replace_default_host_ipv4="OFF" [ -z "$replace_default_host_ipv4" ] && replace_default_host_ipv4="OFF"
. "$CRASHDIR"/starts/fw_getlanip.sh && getlanip
echo "-----------------------------------------------" echo "-----------------------------------------------"
echo -e "当前默认透明路由的网段为: \033[32m$(ip a 2>&1 | grep -w 'inet' | grep 'global' | grep 'br' | grep -v 'iot' | grep -E ' 1(92|0|72)\.' | sed 's/.*inet.//g' | sed 's/br.*$//g' | sed 's/metric.*$//g' | tr '\n' ' ' && echo) \033[0m" echo -e "当前默认透明路由的网段为: \033[32m$host_ipv4 \033[0m"
echo -e "当前已添加的自定义网段为:\033[36m$cust_host_ipv4\033[0m" echo -e "当前已添加的自定义网段为:\033[36m$cust_host_ipv4\033[0m"
echo "-----------------------------------------------" echo "-----------------------------------------------"
echo -e " 1 移除所有自定义网段" echo -e " 1 移除所有自定义网段"

View File

@@ -1,6 +1,6 @@
running_status(){ running_status(){
VmRSS=$(cat /proc/$PID/status | grep -w VmRSS | awk 'unit="MB" {printf "%.2f %s\n", $2/1000, unit}') VmRSS=$(awk '/^VmRSS:/ {printf "%.2f MB\n", ($2 * 1024) / 1000000}' /proc/$PID/status)
#获取运行时长 #获取运行时长
touch "$TMPDIR"/crash_start_time #用于延迟启动的校验 touch "$TMPDIR"/crash_start_time #用于延迟启动的校验
start_time=$(cat "$TMPDIR"/crash_start_time) start_time=$(cat "$TMPDIR"/crash_start_time)

View File

@@ -123,5 +123,5 @@ userguide(){
echo "-----------------------------------------------" echo "-----------------------------------------------"
read -p "立即启动服务?(1/0) > " res read -p "立即启动服务?(1/0) > " res
[ "$res" = 1 ] && start_core && sleep 2 [ "$res" = 1 ] && start_core && sleep 2
main_menu return 0
} }

View File

@@ -37,6 +37,7 @@ case "$1" in
start) start)
[ -n "$(pidof CrashCore)" ] && $0 stop #禁止多实例 [ -n "$(pidof CrashCore)" ] && $0 stop #禁止多实例
stop_firewall #清理路由策略 stop_firewall #清理路由策略
rm -f "CRASHDIR"/.start_error #移除自启失败标记
#使用不同方式启动服务 #使用不同方式启动服务
if [ "$firewall_area" = "5" ]; then #主旁转发 if [ "$firewall_area" = "5" ]; then #主旁转发
. "$CRASHDIR"/starts/fw_start.sh . "$CRASHDIR"/starts/fw_start.sh

View File

@@ -6,6 +6,9 @@
. "$CRASHDIR"/libs/get_config.sh . "$CRASHDIR"/libs/get_config.sh
[ -z "$BINDIR" -o -z "$TMPDIR" -o -z "$COMMAND" ] && . "$CRASHDIR"/init.sh >/dev/null 2>&1 [ -z "$BINDIR" -o -z "$TMPDIR" -o -z "$COMMAND" ] && . "$CRASHDIR"/init.sh >/dev/null 2>&1
[ ! -f "$TMPDIR" ] && mkdir -p "$TMPDIR" [ ! -f "$TMPDIR" ] && mkdir -p "$TMPDIR"
#当上次启动失败时终止自启动
[ -f "CRASHDIR"/.start_error ] && exit 1
#加载工具 #加载工具
. "$CRASHDIR"/libs/check_cmd.sh . "$CRASHDIR"/libs/check_cmd.sh
. "$CRASHDIR"/libs/check_target.sh . "$CRASHDIR"/libs/check_target.sh
@@ -18,6 +21,7 @@
[ -z "$redir_mod" ] && [ "$USER" = "root" -o "$USER" = "admin" ] && redir_mod='Redir模式' [ -z "$redir_mod" ] && [ "$USER" = "root" -o "$USER" = "admin" ] && redir_mod='Redir模式'
[ -z "$dns_mod" ] && dns_mod='redir_host' [ -z "$dns_mod" ] && dns_mod='redir_host'
[ -z "$redir_mod" ] && firewall_area='4' [ -z "$redir_mod" ] && firewall_area='4'
routing_mark=$((fwmark + 2))
makehtml() { #生成面板跳转文件 makehtml() { #生成面板跳转文件
cat >"$BINDIR"/ui/index.html <<EOF cat >"$BINDIR"/ui/index.html <<EOF
@@ -69,7 +73,7 @@ EOF
[ "$?" = 0 ] && rm -rf "$TMPDIR"/shellcrash_pac || mv -f "$TMPDIR"/shellcrash_pac "$BINDIR"/ui/pac [ "$?" = 0 ] && rm -rf "$TMPDIR"/shellcrash_pac || mv -f "$TMPDIR"/shellcrash_pac "$BINDIR"/ui/pac
} }
routing_mark=$((fwmark + 2))
#检测网络连接 #检测网络连接
[ "$network_check" != "OFF" ] && [ ! -f "$TMPDIR"/crash_start_time ] && ckcmd ping && . "$CRASHDIR"/starts/check_network.sh && check_network [ "$network_check" != "OFF" ] && [ ! -f "$TMPDIR"/crash_start_time ] && ckcmd ping && . "$CRASHDIR"/starts/check_network.sh && check_network
[ ! -d "$BINDIR"/ui ] && mkdir -p "$BINDIR"/ui [ ! -d "$BINDIR"/ui ] && mkdir -p "$BINDIR"/ui
@@ -99,7 +103,7 @@ if echo "$crashcore" | grep -q 'singbox'; then
if [ "$disoverride" != "1" ];then if [ "$disoverride" != "1" ];then
. "$CRASHDIR"/starts/singbox_modify.sh && modify_json . "$CRASHDIR"/starts/singbox_modify.sh && modify_json
else else
ln -sf "$core_config" "$TMPDIR"/config.json ln -sf "$core_config" "$TMPDIR"/configs/config.json
fi fi
else else
. "$CRASHDIR"/starts/clash_check.sh && clash_check . "$CRASHDIR"/starts/clash_check.sh && clash_check

View File

@@ -2,8 +2,8 @@
getlanip() { #获取局域网host地址 getlanip() { #获取局域网host地址
i=1 i=1
while [ "$i" -le "20" ]; do while [ "$i" -le "20" ]; do
host_ipv4=$(ip a 2>&1 | grep -w 'inet' | grep 'global' | grep 'brd' | grep -Ev 'utun|iot|peer|docker|podman|virbr|vnet|ovs|vmbr|veth|vmnic|vboxnet|lxcbr|xenbr|vEthernet' | grep -E ' 1(92|0|72)\.' | sed 's/.*inet.//g' | sed 's/[[:space:]]br.*$//g' | sed 's/metric.*$//g') #ipv4局域网网段 host_ipv4=$(ip route show scope link | grep -Ev 'wan|utun|iot|peer|docker|podman|virbr|vnet|ovs|vmbr|veth|vmnic|vboxnet|lxcbr|xenbr|vEthernet' | grep -E ' 1(92|0|72)\.' | awk '{print $1}') #ipv4局域网网段
[ "$ipv6_redir" = "ON" ] && host_ipv6=$(ip a 2>&1 | grep -w 'inet6' | grep -E 'global' | sed 's/.*inet6.//g' | sed 's/scope.*$//g') #ipv6公网地址段 [ "$ipv6_redir" = "ON" ] && host_ipv6=$(ip -6 route show | grep 'default' | awk '{print $3}') #ipv6公网地址段
[ -f "$TMPDIR"/ShellCrash.log ] && break [ -f "$TMPDIR"/ShellCrash.log ] && break
[ -n "$host_ipv4" -a "$ipv6_redir" != "ON" ] && break [ -n "$host_ipv4" -a "$ipv6_redir" != "ON" ] && break
[ -n "$host_ipv4" -a -n "$host_ipv6" ] && break [ -n "$host_ipv4" -a -n "$host_ipv6" ] && break

View File

@@ -1,6 +1,9 @@
#!/bin/sh #!/bin/sh
# Copyright (C) Juewuy # Copyright (C) Juewuy
ckcmd iptables && iptables -h | grep -q '\-w' && iptable='iptables -w' || iptable=iptables
ckcmd ip6tables && ip6tables -h | grep -q '\-w' && ip6table='ip6tables -w' || ip6table=ip6tables
start_ipt_route() { #iptables-route通用工具 start_ipt_route() { #iptables-route通用工具
#$1:iptables/ip6tables $2:所在的表(nat/mangle) $3:所在的链(OUTPUT/PREROUTING) $4:新创建的shellcrash链表 $5:tcp/udp/all #$1:iptables/ip6tables $2:所在的表(nat/mangle) $3:所在的链(OUTPUT/PREROUTING) $4:新创建的shellcrash链表 $5:tcp/udp/all
#区分ipv4/ipv6 #区分ipv4/ipv6
@@ -28,7 +31,10 @@ start_ipt_route() { #iptables-route通用工具
"$1" $w -t "$2" -A "$4" -m owner --gid-owner $gid -j RETURN "$1" $w -t "$2" -A "$4" -m owner --gid-owner $gid -j RETURN
done done
[ "$firewall_area" = 5 ] && "$1" $w -t "$2" -A "$4" -s $bypass_host -j RETURN [ "$firewall_area" = 5 ] && "$1" $w -t "$2" -A "$4" -s $bypass_host -j RETURN
[ -z "$ports" ] && "$1" $w -t "$2" -A "$4" -p tcp -m multiport --dports "$mix_port,$redir_port,$tproxy_port" -j RETURN [ -z "$ports" ] && {
"$1" $w -t "$2" -A "$4" -p tcp -m multiport --dports "$mix_port,$redir_port,$tproxy_port" -j RETURN
"$1" $w -t "$2" -A "$4" -p udp -m multiport --dports "$mix_port,$redir_port,$tproxy_port" -j RETURN
}
#跳过目标保留地址及目标本机网段 #跳过目标保留地址及目标本机网段
for ip in $HOST_IP $RESERVED_IP; do for ip in $HOST_IP $RESERVED_IP; do
"$1" $w -t "$2" -A "$4" -d $ip -j RETURN "$1" $w -t "$2" -A "$4" -d $ip -j RETURN
@@ -130,8 +136,6 @@ start_ipt_dns() { #iptables-dns通用工具
"$1" $w -t nat -I "$2" -p udp --dport 53 -j "$3" "$1" $w -t nat -I "$2" -p udp --dport 53 -j "$3"
} }
start_ipt_wan() { #iptables公网防火墙 start_ipt_wan() { #iptables公网防火墙
ckcmd iptables && iptables -h | grep -q '\-w' && iptable='iptables -w' || iptable=iptables
ckcmd ip6tables && ip6tables -h | grep -q '\-w' && ip6table='ip6tables -w' || ip6table=ip6tables
ipt_wan_accept(){ ipt_wan_accept(){
$iptable -I INPUT -p "$1" -m multiport --dports "$accept_ports" -j ACCEPT $iptable -I INPUT -p "$1" -m multiport --dports "$accept_ports" -j ACCEPT
ckcmd ip6tables && $ip6table -I INPUT -p "$1" -m multiport --dports "$accept_ports" -j ACCEPT ckcmd ip6tables && $ip6table -I INPUT -p "$1" -m multiport --dports "$accept_ports" -j ACCEPT
@@ -141,7 +145,7 @@ start_ipt_wan() { #iptables公网防火墙
ckcmd ip6tables && $ip6table -I INPUT -p "$1" -m multiport --dports "$reject_ports" -j REJECT ckcmd ip6tables && $ip6table -I INPUT -p "$1" -m multiport --dports "$reject_ports" -j REJECT
} }
#端口拦截 #端口拦截
reject_ports="$mix_port,$db_port,$dns_port" reject_ports="$mix_port,$db_port"
ipt_wan_reject tcp ipt_wan_reject tcp
ipt_wan_reject udp ipt_wan_reject udp
#端口放行 #端口放行

View File

@@ -146,7 +146,7 @@ start_nft_wan() { #nftables公网防火墙
nft add rule inet shellcrash input udp dport $fw_wan_nfports meta mark set 0x67890 accept nft add rule inet shellcrash input udp dport $fw_wan_nfports meta mark set 0x67890 accept
} }
#端口拦截 #端口拦截
reject_ports="{ $mix_port, $db_port, $dns_port }" reject_ports="{ $mix_port, $db_port }"
nft add rule inet shellcrash input ip saddr {$HOST_IP} accept nft add rule inet shellcrash input ip saddr {$HOST_IP} accept
nft add rule inet shellcrash input ip6 saddr {$HOST_IP6} accept nft add rule inet shellcrash input ip6 saddr {$HOST_IP6} accept
nft add rule inet shellcrash input tcp dport $reject_ports reject nft add rule inet shellcrash input tcp dport $reject_ports reject

View File

@@ -55,8 +55,8 @@ ckcmd iptables && {
done done
$iptable -D INPUT -p tcp -m multiport --dports "$accept_ports" -j ACCEPT 2>/dev/null $iptable -D INPUT -p tcp -m multiport --dports "$accept_ports" -j ACCEPT 2>/dev/null
$iptable -D INPUT -p udp -m multiport --dports "$accept_ports" -j ACCEPT 2>/dev/null $iptable -D INPUT -p udp -m multiport --dports "$accept_ports" -j ACCEPT 2>/dev/null
$iptable -D INPUT -p tcp -m multiport --dports "$mix_port,$db_port,$dns_port" -j REJECT 2>/dev/null $iptable -D INPUT -p tcp -m multiport --dports "$mix_port,$db_port" -j REJECT 2>/dev/null
$iptable -D INPUT -p udp -m multiport --dports "$mix_port,$db_port,$dns_port" -j REJECT 2>/dev/null $iptable -D INPUT -p udp -m multiport --dports "$mix_port,$db_port" -j REJECT 2>/dev/null
#清理shellcrash自建表 #清理shellcrash自建表
for text in shellcrash_dns shellcrash shellcrash_out shellcrash_dns_out shellcrash_vm shellcrash_vm_dns; do for text in shellcrash_dns shellcrash shellcrash_out shellcrash_dns_out shellcrash_vm shellcrash_vm_dns; do
$iptable -t nat -F "$text" 2>/dev/null $iptable -t nat -F "$text" 2>/dev/null
@@ -105,8 +105,8 @@ ckcmd ip6tables && {
done done
$ip6table -D INPUT -p tcp -m multiport --dports "$accept_ports" -j ACCEPT 2>/dev/null $ip6table -D INPUT -p tcp -m multiport --dports "$accept_ports" -j ACCEPT 2>/dev/null
$ip6table -D INPUT -p udp -m multiport --dports "$accept_ports" -j ACCEPT 2>/dev/null $ip6table -D INPUT -p udp -m multiport --dports "$accept_ports" -j ACCEPT 2>/dev/null
$ip6table -D INPUT -p tcp -m multiport --dports "$mix_port,$db_port,$dns_port" -j REJECT 2>/dev/null $ip6table -D INPUT -p tcp -m multiport --dports "$mix_port,$db_port" -j REJECT 2>/dev/null
$ip6table -D INPUT -p udp -m multiport --dports "$mix_port,$db_port,$dns_port" -j REJECT 2>/dev/null $ip6table -D INPUT -p udp -m multiport --dports "$mix_port,$db_port" -j REJECT 2>/dev/null
#清理shellcrash自建表 #清理shellcrash自建表
for text in shellcrashv6_dns shellcrashv6 shellcrashv6_out; do for text in shellcrashv6_dns shellcrashv6 shellcrashv6_out; do
$ip6table -t nat -F "$text" 2>/dev/null $ip6table -t nat -F "$text" 2>/dev/null

View File

@@ -200,8 +200,9 @@ EOF
EOF EOF
#生成add_route.json #生成add_route.json
#域名嗅探配置 #域名嗅探配置
[ "$sniffer" = ON ] && sniffer_set='{ "action": "sniff", "timeout": "500ms" },' [ "$sniffer" = ON ] && ! grep -Eq '"action" *:[[:space:]]*"sniff"' "$CRASHDIR"/jsons/*.json && sniffer_set='{ "action": "sniff", "timeout": "500ms" },'
[ "$ts_service" = ON ] && tailscale_set='{ "inbound": [ "ts-ep" ], "port": 53, "action": "hijack-dns" },' [ "$ts_service" = ON ] && tailscale_set='{ "inbound": [ "ts-ep" ], "port": 53, "action": "hijack-dns" },'
sed -i '/"clash_mode".*"outbound"/d' "$CRASHDIR"/jsons/*.json
cat >"$TMPDIR"/jsons/add_route.json <<EOF cat >"$TMPDIR"/jsons/add_route.json <<EOF
{ {
"route": { "route": {
@@ -211,8 +212,8 @@ EOF
{ "inbound": [ "dns-in" ], "action": "hijack-dns" }, { "inbound": [ "dns-in" ], "action": "hijack-dns" },
$tailscale_set $tailscale_set
$sniffer_set $sniffer_set
{ "clash_mode": "Direct" , "outbound": "DIRECT" }, { "clash_mode": [ "Direct" ] , "outbound": "DIRECT" },
{ "clash_mode": "Global" , "outbound": "GLOBAL" } { "clash_mode": [ "Global" ], "outbound": "GLOBAL" }
] ]
} }
} }

View File

@@ -7,6 +7,7 @@ else
sleep 2 sleep 2
kill $! >/dev/null 2>&1 kill $! >/dev/null 2>&1
fi fi
error=$(cat $TMPDIR/core_test.log | grep -iEo 'error.*=.*|.*ERROR.*|.*FATAL.*') touch "CRASHDIR"/.start_error #标记启动失败,防止自启
error=$(cat "$TMPDIR"/core_test.log | grep -iEo 'error.*=.*|.*ERROR.*|.*FATAL.*')
logger "服务启动失败!请查看报错信息!详细信息请查看$TMPDIR/core_test.log" 33 logger "服务启动失败!请查看报错信息!详细信息请查看$TMPDIR/core_test.log" 33
logger "$error" 31 logger "$error" 31

View File

@@ -2,16 +2,14 @@
. "$CRASHDIR"/libs/check_cmd.sh . "$CRASHDIR"/libs/check_cmd.sh
start_legacy(){ start_legacy(){
ckcmd nohup && _nohup=nohup
if ckcmd su && grep -q 'shellcrash:x:0:7890' /etc/passwd;then if ckcmd su && grep -q 'shellcrash:x:0:7890' /etc/passwd;then
su shellcrash -c "$1 >/dev/null 2>&1 & echo \$! > /tmp/ShellCrash/$2.pid" su shellcrash -c "$_nohup $1 >/dev/null 2>&1 & echo \$! > /tmp/ShellCrash/$2.pid"
elif ckcmd setsid; then elif ckcmd setsid; then
setsid $1 >/dev/null 2>&1 & $_nohup setsid $1 >/dev/null 2>&1 &
echo $! > "/tmp/ShellCrash/$2.pid"
elif ckcmd nohup; then
nohup $1 >/dev/null 2>&1 &
echo $! > "/tmp/ShellCrash/$2.pid" echo $! > "/tmp/ShellCrash/$2.pid"
else else
$1 >/dev/null 2>&1 & $_nohup $1 >/dev/null 2>&1 &
echo $! > "/tmp/ShellCrash/$2.pid" echo $! > "/tmp/ShellCrash/$2.pid"
fi fi
} }

View File

@@ -1 +1 @@
1.9.4beta1.1 1.9.4beta2