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,10 +1,7 @@
<h1 align="center">
<br>ShellCrash<br>
</h1>
<h1 align="center">ShellCrash</h1>
<p align="center">
<a target="_blank" href="https://github.com/MetaCubeX/mihomo/releases">
<p align="center">
<a target="_blank" href="https://github.com/MetaCubeX/mihomo/releases">
<img src="https://img.shields.io/github/release/MetaCubeX/mihomo.svg?style=flat-square&label=Core">
</a>
<a target="_blank" href="https://github.com/juewuy/ShellCrash/releases">
@@ -12,147 +9,177 @@
</a>
</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>
~支持各种运行标准Linux系统如Debian/CenOS/Armbian等的设备<br>
~兼容Padavan固件保守模式、潘多拉固件以及华硕/梅林固件<br>
~兼容各类使用Linux内核定制开发的各类型设备<br>
- **多内核支持**:在 Shell 环境下便捷管理及切换 **mihomo****sing-box** 内核。
- **灵活配置管理**:支持在线导入订阅连结及配置文件,简化配置流程。
- **自动化任务**:支持配置定时任务,实现配置文件与规则的自动定时更新。
- **图形化面板**:支持在线安装并使用本地 Web 面板Dashboard直观管理内置规则与流量。
- **多模式运行**:支持路由模式、本机模式等多种流量转发模式切换。
- **一键维护**:内置脚本在线更新功能,保持版本与功能的及时更迭。
——————————<br>
~更多设备支持请提issue或前往TG群反馈需提供设备名称及运行uname -a返回的设备核心信息<br>
## :computer: 设备支持
## 常见问题
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
sudo -i #切换到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
```
或者
```shell
sudo -i #切换到root用户如果需要密码请输入密码
export url='https://gh.jwsc.eu.org/master' && bash -c "$(curl -kfsSl $url/install.sh)" && . /etc/profile &> /dev/null
> [!IMPORTANT]
> 请以 root 用户进行安装。
> 使用 wget 安装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 \
&& bash /tmp/install.sh \
&& . /etc/profile &> /dev/null
```
~**路由设备使用curl安装**<br>
> 使用 curl 安装(作者私人源)
```shell
#GitHub源(可能需要代理)
export url='https://raw.githubusercontent.com/juewuy/ShellCrash/master' && sh -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
```sh
export url='https://gh.jwsc.eu.org/master' \
&& bash -c "$(curl -kfsSl $url/install.sh)" \
&& . /etc/profile &> /dev/null
```
~**路由设备使用wget安装**<br>
### :satellite: 路由设备安装
```Shell
#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
```
或者
```shell
#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
**使用 `curl` 安装:**
> GitHub 源(推荐海外环境或具备代理环境使用)
```sh
export url='https://raw.githubusercontent.com/juewuy/ShellCrash/master' \
&& sh -c "$(curl -kfsSl $url/install.sh)" \
&& . /etc/profile &> /dev/null
```
~**老旧设备使用低版本wge安装**<br>
> 或 jsDelivr CDN 源
```Shell
#作者私人http内测源
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
export url='https://testingcf.jsdelivr.net/gh/juewuy/ShellCrash@master' \
&& 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
#执行安装命令
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
crash #进入对话
crash -h #帮助列表
```
- [本地安装ShellCrash教程 | Juewuy's Blog](https://juewuy.github.io/bdaz)
#### **运行时的额外依赖**<br>
---
> 大部分的设备/系统都已经预装了以下的大部分依赖,使用时如无影响可以无视之
## :book: 使用说明
安装完成后,在终端输入以下指令即可启动管理界面:
```shell
curl/wget 必须 全部缺少时无法在线安装及更新,无法使用节点保存功能
iptables/nftables 重要 缺少时只能使用纯净模式
crontab 较低 缺少时无法启用定时任务功能
net-tools 极低 缺少时无法正常检测端口占用
ubus/iproute-doc 极低 缺少时无法正常获取本机host地址
crash # 启动脚本交互选单
crash -h # 查看命令帮助列表
```
### 运行依赖说明
| 依赖组件 | 必要性 | 说明 |
| :--- | :--- | :--- |
| 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)
---
交流反馈:
--
### [TG讨论组](https://t.me/ShellClash)
## :airplane: 机场推荐
机场推荐:
--
#### [Dler-墙洞,多年稳定运行,功能齐全](https://dler.pro/auth/register?affid=89698)<br>
#### [大米-群友力荐,流媒体解锁,月付推荐](https://1s.bigmeok.me/user#/register?code=2PuWY9I7)<br>
- [**Dler-墙洞**](https://dler.pro/auth/register?affid=89698),多年稳定运行,功能齐全。
- [**大米**](https://1s.bigmeok.me/user#/register?code=2PuWY9I7),群友力荐,流媒体解锁,月付推荐。

Binary file not shown.

Binary file not shown.

View File

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

View File

@@ -1,36 +1,125 @@
#!/usr/bin/env bash
# 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"
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() {
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}'
}
ckcmd() { #检查命令
if command -v sh >/dev/null 2>&1;then
# 检查命令
ckcmd() {
if command -v sh >/dev/null 2>&1; then
command -v "$1" >/dev/null 2>&1
else
type "$1" >/dev/null 2>&1
fi
}
webget() {
#参数【$1】代表下载目录【$2】代表在线地址
#参数【$3】代表输出显示【$4】不启用重定向
if curl --version >/dev/null 2>&1; then
[ "$3" = "echooff" ] && progress='-s' || progress='-#'
[ -z "$4" ] && redirect='-L' || redirect=''
result=$(curl -w %{http_code} --connect-timeout 5 $progress $redirect -ko $1 $2)
[ -n "$(echo $result | grep -e ^2)" ] && result="200"
result=$(curl -w %{http_code} --connect-timeout 5 "$progress" "$redirect" -ko "$1" "$2")
# === 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
if wget --version >/dev/null 2>&1; then
[ "$3" = "echooff" ] && progress='-q' || progress='-q --show-progress'
@@ -40,295 +129,609 @@ webget() {
fi
[ "$3" = "echoon" ] && progress=''
[ "$3" = "echooff" ] && progress='-q'
wget $progress $redirect $certificate $timeout -O $1 $2
wget "$progress" "$redirect" "$certificate" "$timeout" -O "$1" "$2"
[ $? -eq 0 ] && result="200"
fi
}
error_down() {
$echo "请参考 \033[32mhttps://github.com/juewuy/ShellCrash/blob/master/README_CN.md"
$echo "\033[33m使用其他安装源重新安装\033[0m"
}
#安装及初始化
# 安装及初始化
set_alias() {
echo "-----------------------------------------------"
$echo "\033[36m请选择一个别名或使用自定义别名\033[0m"
echo "-----------------------------------------------"
$echo " 1 【\033[32mcrash\033[0m"
$echo " 2 【\033[32m sc \033[0m"
$echo " 3 【\033[32m mm \033[0m】"
$echo " 0 退出安装"
echo "-----------------------------------------------"
read -p "请输入相应数字或自定义别名 > " res
case "$res" in
1) my_alias=crash ;;
2) my_alias=sc ;;
3) my_alias=mm ;;
0) echo "安装已取消"; exit 1 ;;
*) my_alias=$res ;;
esac
cmd=$(ckcmd "$my_alias" | grep 'menu.sh')
ckcmd "$my_alias" && [ -z "$cmd" ] && {
$echo "\033[33m此别名和当前系统内置命令/别名冲突,请换一个!\033[0m"
sleep 1
set_alias
}
while true; do
double_line_break
separator_line "="
content_line "\033[36m请选择一个别名\033[0m"
content_line "\033[36m或直接输入自定义别名\033[0m"
separator_line "-"
content_line "1) 【\033[32mcrash\033[0m】"
content_line "2) 【\033[32m sc \033[0m】"
content_line "3) 【\033[32m mm \033[0m】"
content_line "E) 退出安装"
separator_line "="
read -p "请输入相应数字/自定义别名> " res
case "$res" in
1)
my_alias=crash
;;
2)
my_alias=sc
;;
3)
my_alias=mm
;;
"E" | "e")
abort_install
;;
*)
my_alias=$res
;;
esac
cmd=$(ckcmd "$my_alias" | grep 'menu.sh')
ckcmd "$my_alias" && [ -z "$cmd" ] && {
double_line_break
separator_line "="
content_line "该别名【\033[32m$my_alias\033[0m】和当前系统内置命令别名\033[33m冲突\033[0m请更换"
separator_line "="
sleep 1
continue
}
break 1
done
}
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
$echo "\033[33m文件下载失败!\033[0m"
content_line "\033[31m下载失败!\033[0m"
error_down
separator_line "="
double_line_break
exit 1
else
$CRASHDIR/start.sh stop 2>/dev/null
#解压
echo "-----------------------------------------------"
echo 开始解压文件!
mkdir -p $CRASHDIR >/dev/null
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
content_line "下载成功"
"$CRASHDIR"/start.sh stop 2>/dev/null
# 解压
content_line "开始解压文件......"
mkdir -p "$CRASHDIR" >/dev/null
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
content_line "解压成功"
separator_line "="
set_alias
. $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
rm -rf /tmp/ShellCrash.tar.gz
$echo "\033[33m文件解压失败!\033[0m"
content_line "\033[31m解压失败!\033[0m"
error_down
separator_line "="
double_line_break
exit 1
fi
fi
}
setdir() {
set_usb_dir() {
$echo "请选择安装目录"
du -hL /mnt | awk '{print " "NR" "$2" "$1}'
read -p "请输入相应数字 > " num
dir=$(du -hL /mnt | awk '{print $2}' | sed -n "$num"p)
if [ -z "$dir" ]; then
$echo "\033[31m输入错误请重新设置\033[0m"
set_usb_dir
fi
}
set_asus_dir() {
echo -e "请选择U盘目录"
du -hL /tmp/mnt | awk -F/ 'NF<=4' | awk '{print " "NR" "$2" "$1}'
read -p "请输入相应数字 > " num
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
echo -e "\033[31m未找到下载大师自启文件$dir/asusware.arm/etc/init.d/S50downloadmaster请检查设置\033[0m"
set_asus_dir
fi
}
set_cust_dir() {
echo "-----------------------------------------------"
echo '可用路径 剩余空间:'
df -h | awk '{print $6,$4}' | sed 1d
echo '路径是必须带 / 的格式,注意写入虚拟内存(/tmp,/opt,/sys...)的文件会在重启后消失!!!'
read -p "请输入自定义路径 > " dir
if [ "$(dir_avail $dir)" = 0 ] || [ -n "$(echo $dir | grep -E 'tmp|opt|sys')" ]; then
$echo "\033[31m路径错误请重新设置\033[0m"
set_cust_dir
fi
}
echo "-----------------------------------------------"
$echo "\033[33m注意安装ShellCrash至少需要预留约1MB的磁盘空间\033[0m"
if [ -n "$systype" ]; then
[ "$systype" = "Padavan" ] && dir=/etc/storage
[ "$systype" = "mi_snapshot" ] && {
$echo "\033[33m检测到当前设备为小米官方系统请选择安装位置\033[0m"
[ -d /data ] && $echo " 1 安装到 /data 目录,剩余空间:$(dir_avail /data -h)(支持软固化功能)"
[ -d /userdisk ] && $echo " 2 安装到 /userdisk 目录,剩余空间:$(dir_avail /userdisk -h)(支持软固化功能)"
[ -d /data/other_vol ] && $echo " 3 安装到 /data/other_vol 目录,剩余空间:$(dir_avail /data/other_vol -h)(支持软固化功能)"
$echo " 4 安装到自定义目录(不推荐,不明勿用!)"
$echo " 0 退出安装"
echo "-----------------------------------------------"
read -p "请输入相应数字 > " num
case "$num" in
1)
dir=/data
;;
2)
dir=/userdisk
;;
3)
dir=/data/other_vol
;;
4)
set_cust_dir
;;
*)
exit 1
;;
esac
}
[ "$systype" = "asusrouter" ] && {
$echo "\033[33m检测到当前设备为华硕固件请选择安装方式\033[0m"
$echo " 1 基于USB设备安装(限23年9月之前固件须插入\033[31m任意\033[0mUSB设备)"
$echo " 2 基于自启脚本安装(仅支持梅林及部分非koolshare官改固件)"
$echo " 3 基于U盘+下载大师安装(支持所有固件限ARM设备须插入U盘或移动硬盘)"
$echo " 0 退出安装"
echo "-----------------------------------------------"
read -p "请输入相应数字 > " num
case "$num" in
1)
read -p "将脚本安装到USB存储/系统闪存?(1/0) > " res
[ "$res" = "1" ] && set_usb_dir || dir=/jffs
usb_status=1
;;
2)
$echo "如无法正常开机启动请重新使用USB方式安装"
sleep 2
dir=/jffs
;;
3)
echo -e "请先在路由器网页后台安装下载大师并启用,之后选择外置存储所在目录!"
sleep 2
set_asus_dir
;;
*)
exit 1
;;
esac
}
[ "$systype" = "ng_snapshot" ] && dir=/tmp/mnt
else
$echo " 1 在\033[32m/etc目录\033[0m下安装(适合root用户)"
$echo " 2 在\033[32m/usr/share目录\033[0m下安装(适合Linux系统)"
$echo " 3 在\033[32m当前用户目录\033[0m下安装(适合非root用户)"
$echo " 4 在\033[32m外置存储\033[0m中安装"
$echo " 5 手动设置安装目录"
$echo " 0 退出安装"
echo "----------------------------------------------"
read -p "请输入相应数字 > " num
#设置目录
set_usb_dir() {
while true; do
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
case "$num" in
1)
dir=/etc
;;
2)
dir=/usr/share
;;
3)
dir=~/.local/share
mkdir -p ~/.config/systemd/user
;;
4)
set_usb_dir
;;
5)
set_cust_dir
0)
return 1
;;
*)
echo "安装已取消"
exit 1
dir=$(du -hL /mnt | awk '{print $2}' | sed -n "$num"p)
if [ -z "$dir" ]; then
invalid_input_retry
continue
fi
return 0
;;
esac
fi
done
}
if [ ! -w $dir ]; then
$echo "\033[31m没有$dir目录写入权限!请重新设置!\033[0m" && sleep 1 && setdir
else
$echo "目标目录\033[32m$dir\033[0m空间剩余$(dir_avail $dir -h)"
read -p "确认安装?(1/0) > " res
[ "$res" = "1" ] && CRASHDIR=$dir/ShellCrash || setdir
fi
set_asus_dir() {
while true; do
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
case "$num" in
0)
return 1
;;
*)
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
double_line_break
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
return 0
;;
esac
done
}
set_cust_dir() {
while true; do
double_line_break
separator_line "="
content_line "\033[33m注意\033[0m"
content_line "\033[33m路径必须是带 / 的格式\033[0m"
content_line "\033[33m写入虚拟内存/tmp/opt/sys...)的文件会在重启后消失!\033[0m"
separator_line "-"
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
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
}
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
[ "$systype" = "Padavan" ] && dir=/etc/storage
[ "$systype" = "mi_snapshot" ] && {
content_line "\033[33m检测到当前设备为小米官方系统\033[0m"
separator_line "-"
content_line "请选择安装位置:"
separator_line "-"
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
case "$num" in
1)
dir=/data
;;
2)
dir=/userdisk
;;
3)
dir=/data/other_vol
;;
4)
set_cust_dir
ret=$?
[ "$ret" -eq 1 ] && continue
;;
"E" | "e")
abort_install
;;
*)
invalid_input_retry
continue
;;
esac
}
[ "$systype" = "asusrouter" ] && {
content_line "\033[33m检测到当前设备为华硕固件\033[0m"
separator_line "-"
content_line "请选择安装方式:"
separator_line "-"
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
case "$num" in
1)
double_line_break
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
;;
2)
double_line_break
separator_line "="
content_line "如无法正常开机启动请重新使用USB方式安装"
separator_line "="
sleep 2
dir=/jffs
;;
3)
double_line_break
separator_line "="
content_line "请先在路由器网页后台安装下载大师并启用,"
content_line "之后选择外置存储所在目录!"
separator_line "="
sleep 2
set_asus_dir
ret=$?
[ "$ret" -eq 1 ] && continue
;;
"E" | "e")
abort_install
;;
*)
invalid_input_retry
continue
;;
esac
}
[ "$systype" = "ng_snapshot" ] && dir=/tmp/mnt
else
separator_line "-"
content_line "请选择安装目录:"
separator_line "-"
content_line "1) \033[32m/etc目录\033[0m 适合root用户"
content_line "2) \033[32m/usr/share目录\033[0m 适合Linux系统"
content_line "3) \033[32m当前用户目录\033[0m 适合非root用户"
content_line "4) \033[32m外置存储\033[0m"
content_line "5) 手动设置"
content_line "E) 退出安装"
separator_line "="
read -p "请输入相应数字> " num
# 设置目录
case "$num" in
1)
dir=/etc
;;
2)
dir=/usr/share
;;
3)
dir=~/.local/share
mkdir -p ~/.config/systemd/user
;;
4)
set_usb_dir
ret=$?
[ "$ret" -eq 1 ] && continue
;;
5)
set_cust_dir
ret=$?
[ "$ret" -eq 1 ] && continue
;;
"E" | "e")
abort_install
;;
*)
invalid_input_retry
continue
;;
esac
fi
if [ ! -w "$dir" ]; then
double_line_break
separator_line "="
content_line "\033[31m没有$dir目录写入权限\033[0m"
content_line "\033[31m请重新设置\033[0m"
separator_line "="
sleep 2
else
while true; do
double_line_break
separator_line "="
content_line "目标目录:\033[32m$dir\033[0m"
content_line "可用空间:$(dir_avail $dir -h)"
separator_line "-"
content_line "1) 确认安装"
content_line "E) 退出安装"
content_line "0) 返回上级菜单"
separator_line "="
read -p "请输入相应数字> " num
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() {
echo "-----------------------------------------------"
echo 开始从服务器获取安装文件!
echo "-----------------------------------------------"
double_line_break
separator_line "="
content_line "下载安装文件......"
gettar
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 "-----------------------------------------------"
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() {
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
case "$num" in
2)
url=$(echo $url | sed 's/master/stable/')
;;
3)
url=$(echo $url | sed 's/master/dev/')
;;
*) ;;
esac
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)
url=$(echo "$url" | sed 's/master/stable/')
break 1
;;
3)
url=$(echo "$url" | sed 's/master/dev/')
break 1
;;
"E" | "e")
abort_install
;;
*)
invalid_input_retry
continue
;;
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" ] && {
systype=Padavan #老毛子固件
systype=Padavan # 老毛子固件
initdir='/etc/storage/started_script.sh'
}
[ -d "/jffs" ] && {
systype=asusrouter #华硕固件
systype=asusrouter # 华硕固件
[ -f "/jffs/.asusrouter" ] && initdir='/jffs/.asusrouter'
[ -d "/jffs/scripts" ] && initdir='/jffs/scripts/nat-start'
}
[ -f "/data/etc/crontabs/root" ] && systype=mi_snapshot #小米设备
[ -w "/var/mnt/cfg/firewall" ] && systype=ng_snapshot #NETGEAR设备
[ -f "/data/etc/crontabs/root" ] && systype=mi_snapshot # 小米设备
[ -w "/var/mnt/cfg/firewall" ] && systype=ng_snapshot # NETGEAR设备
#检查root权限
if [ "$USER" != "root" -a -z "$systype" ]; then
echo 当前用户:$USER
$echo "\033[31m请尽量使用root用户不要直接使用sudo命令执行安装!\033[0m"
echo "-----------------------------------------------"
read -p "仍要安装?可能会产生未知错误!(1/0) > " res
[ "$res" != "1" ] && exit 1
# 检查root权限
if [ "$USER" != "root" ] && [ -z "$systype" ]; then
while true; do
double_line_break
separator_line "="
content_line "当前用户 $USER 非 root 用户"
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
if [ -n "$(echo $url | grep master)" ]; then
if [ -n "$(echo "$url" | grep master)" ]; then
setversion
fi
#获取版本信息
# 获取版本信息
webget /tmp/version "$url/version" echooff
[ "$result" = "200" ] && versionsh=$(cat /tmp/version)
rm -rf /tmp/version
#输出
$echo "最新版本:\033[32m$versionsh\033[0m"
echo "-----------------------------------------------"
$echo "\033[44m如遇问题请加TG群反馈\033[42;30m t.me/ShellClash \033[0m"
$echo "\033[37m支持各种基于openwrt的路由器设备"
$echo "\033[33m支持Debian、Centos等标准Linux系统\033[0m"
# 输出
double_line_break
separator_line "="
content_line "最新版本:\033[32m$versionsh\033[0m"
separator_line "="
if [ -n "$CRASHDIR" ]; then
echo "-----------------------------------------------"
$echo "检测到旧的安装目录\033[36m$CRASHDIR\033[0m是否覆盖安装"
$echo "\033[32m覆盖安装时不会移除配置文件\033[0m"
read -p "覆盖安装/卸载旧版本?(1/0) > " res
case "$res" in
1)
install
;;
0)
rm -rf $CRASHDIR
echo "-----------------------------------------------"
$echo "\033[31m 旧版本文件已卸载!\033[0m"
setdir
install
;;
9)
echo "测试模式,变更安装位置"
setdir
install
;;
*)
$echo "\033[31m输入错误!已取消安装\033[0m"
exit 1
;;
esac
while true; do
double_line_break
separator_line "="
content_line "检测到旧版本安装目录:\033[36m$CRASHDIR\033[0m"
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)
install
break 1
;;
2)
rm -rf "$CRASHDIR"
double_line_break
separator_line "="
content_line "\033[31m旧版本文件已卸载\033[0m"
separator_line "="
setdir
install
break 1
;;
9)
double_line_break
separator_line "="
content_line "测试模式,变更安装位置"
separator_line "="
setdir
install
break 1
;;
"E" | "e")
abort_install
;;
*)
invalid_input_retry
continue
;;
esac
done
else
setdir
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: [🚀 节点选择, 🇭🇰 香港节点, 🇹🇼 台湾节点, 🇯🇵 日本节点, 🇸🇬 新加坡节点, 🇺🇸 美国节点, 👑 高级节点, 📉 省流节点, {providers_tags}]}
- {name: 📹 油管视频, type: select, proxies: [🚀 节点选择, 🇭🇰 香港节点, 🇹🇼 台湾节点, 🇯🇵 日本节点, 🇸🇬 新加坡节点, 🇺🇸 美国节点, 👑 高级节点, 📉 省流节点, {providers_tags}]}
- {name: 🌍 国外媒体, type: select, proxies: [🚀 节点选择, 🇭🇰 香港节点, 🇹🇼 台湾节点, 🇯🇵 日本节点, 🇸🇬 新加坡节点, 🇺🇸 美国节点, 👑 高级节点, 📉 省流节点, {providers_tags}]}
- {name: 🎮 游戏平台, type: select, proxies: [🚀 节点选择, 🎯 全球直连, 🇭🇰 香港节点, 🇹🇼 台湾节点, 🇯🇵 日本节点, 🇸🇬 新加坡节点, 🇺🇸 美国节点, 👑 高级节点, 📉 省流节点, {providers_tags}]}
- {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: [🚀 节点选择, 🇭🇰 香港节点, 🇹🇼 台湾节点, 🇯🇵 日本节点, 🇸🇬 新加坡节点, 🇺🇸 美国节点, 👑 高级节点, 📉 省流节点, {providers_tags}]}
- {name: 📹 油管视频, type: select, proxies: [🚀 节点选择, 🇭🇰 香港节点, 🇹🇼 台湾节点, 🇯🇵 日本节点, 🇸🇬 新加坡节点, 🇺🇸 美国节点, 👑 高级节点, 📉 省流节点, {providers_tags}]}
- {name: 🌍 国外媒体, type: select, proxies: [🚀 节点选择, 🇭🇰 香港节点, 🇹🇼 台湾节点, 🇯🇵 日本节点, 🇸🇬 新加坡节点, 🇺🇸 美国节点, 👑 高级节点, 📉 省流节点, {providers_tags}]}
- {name: 🎮 游戏平台, type: select, proxies: [🚀 节点选择, 🎯 全球直连, 🇭🇰 香港节点, 🇹🇼 台湾节点, 🇯🇵 日本节点, 🇸🇬 新加坡节点, 🇺🇸 美国节点, 👑 高级节点, 📉 省流节点, {providers_tags}]}
- {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"
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:
type: http
behavior: domain
@@ -141,6 +159,14 @@ rule-providers:
url: "https://testingcf.jsdelivr.net/gh//DustinWin/ruleset_geodata@refs/heads/mihomo-ruleset/cnip.mrs"
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:
type: http
behavior: ipcidr
@@ -172,6 +198,8 @@ rules:
- RULE-SET,apple-cn,🍎 苹果服务
- RULE-SET,google-cn,🇬 谷歌服务
- RULE-SET,games-cn,🎮 游戏服务
- RULE-SET,netflix,🎥 奈飞视频
- RULE-SET,youtube,📹 油管视频
- RULE-SET,media,🌍 国外媒体
- RULE-SET,games,🎮 游戏平台
- RULE-SET,ai,🤖 AI 平台
@@ -180,6 +208,7 @@ rules:
- RULE-SET,cn,🛡️ 直连域名
- RULE-SET,privateip,🔒 私有网络,no-resolve
- RULE-SET,cnip,🀄️ 直连 IP
- RULE-SET,netflixip,🎥 奈飞视频
- RULE-SET,mediaip,🌍 国外媒体
- RULE-SET,gamesip,🎮 游戏平台
- 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规则修改优化而来尽量在保持原有的基础上进行优化。
#数据源采用了DustinWin/ruleset_geodata和MetaCubeX/meta-rules-dat两个开源项目的规则感谢原作者的辛勤付出。
@@ -11,12 +11,12 @@ proxy-groups:
- {name: 🚀 节点选择, type: select, 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|专线|专用|高级|直连|急速|高速|高倍率|游戏|铂金|钻石|企业|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: fallback, interval: 1800, include-all: true, hidden: true}
- {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, exclude-filter: "(?i)(剩余|重置|到期|防失联|官网|导航|客服|http|www)"}
- {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: 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: url-test, interval: 1800, tolerance: 50, include-all: true, filter: "(?i)(NF|奈飞|解锁|Netflix|NETFLIX|Media)", hidden: true}
- {name: ▶️ 油管视频, type: select, proxies: [🚀 节点选择, 🎯 本地直连, ♻️ 自动选择, 🛠️ 手动切换, 🇭🇰 香港节点, 🇹🇼 台湾节点, 🇺🇸 美国节点, 🇯🇵 日本节点, 🇪🇺 欧洲节点, 🇰🇷 韩国节点, 🇸🇬 狮城节点, 👑 高级节点, 📉 省流节点, {providers_tags}]}
@@ -45,10 +45,10 @@ proxy-groups:
- {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)(🇹🇼|台|tw|taiwan|tai wan)"}
- {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)(🇯🇵|日|东京|大阪|埼玉|九州|jp|japan)"}
- {name: 🇪🇺 欧洲节点, type: url-test, tolerance: 50, include-all: true, filter: "(?i)(🇪🇺|欧|德|英|法|荷|俄罗斯|西班牙|意大利|瑞士|瑞典|土耳其|挪威|芬兰|丹麦|比利时|爱尔兰|奥地利|波兰|葡萄牙|乌克兰|希腊|捷克|匈牙利|罗马尼亚|保加利亚|冰岛|克罗地亚)"}
- {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)", exclude-filter: "(?i)(南美|中美|拉美|亚美尼亚|美属)"}
- {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)(🇰🇷|韩|韓|首尔|kr|kor)"}
- {name: 🇸🇬 狮城节点, type: url-test, tolerance: 50, include-all: true, filter: "(?i)(🇸🇬|新加坡|狮城|sg|singapore)"}
@@ -221,8 +221,8 @@ rule-providers:
#规则顺序
rules:
- DOMAIN-SUFFIX,captive.apple.com,DIRECT
- DOMAIN-SUFFIX,kamo.teracloud.jp,DIRECT
- DOMAIN-SUFFIX,captive.apple.com,🍎 苹果服务
- DOMAIN-SUFFIX,kamo.teracloud.jp,🀄️ 国内流量
- RULE-SET,privateip,🔒 私有网络,no-resolve
- 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": [ "🚀 节点选择", "🇭🇰 香港节点", "🇹🇼 台湾节点", "🇯🇵 日本节点", "🇸🇬 新加坡节点", "🇺🇸 美国节点", "👑 高级节点", "📉 省流节点", {providers_tags} ] },
{ "tag": "📹 油管视频", "type": "selector", "outbounds": [ "🚀 节点选择", "🇭🇰 香港节点", "🇹🇼 台湾节点", "🇯🇵 日本节点", "🇸🇬 新加坡节点", "🇺🇸 美国节点", "👑 高级节点", "📉 省流节点", {providers_tags} ] },
{ "tag": "🌍 国外媒体", "type": "selector", "outbounds": [ "🚀 节点选择", "🇭🇰 香港节点", "🇹🇼 台湾节点", "🇯🇵 日本节点", "🇸🇬 新加坡节点", "🇺🇸 美国节点", "👑 高级节点", "📉 省流节点", {providers_tags} ] },
{ "tag": "🎮 游戏平台", "type": "selector", "outbounds": [ "🚀 节点选择", "🎯 本地直连", "🇭🇰 香港节点", "🇹🇼 台湾节点", "🇯🇵 日本节点", "🇸🇬 新加坡节点", "🇺🇸 美国节点", "👑 高级节点", "📉 省流节点", {providers_tags} ] },
{ "tag": "🛡️ 直连域名", "type": "selector", "outbounds": [ "🎯 本地直连", "🚀 节点选择" ] },
@@ -39,6 +41,8 @@
{ "rule_set": [ "apple-cn" ], "outbound": "🍎 苹果服务" },
{ "rule_set": [ "google-cn" ], "outbound": "🇬 谷歌服务" },
{ "rule_set": [ "games-cn" ], "outbound": "🎮 游戏服务" },
{ "rule_set": [ "netflix" ], "outbound": "🎥 奈飞视频" },
{ "rule_set": [ "youtube" ], "outbound": "📹 油管视频" },
{ "rule_set": [ "media" ], "outbound": "🌍 国外媒体" },
{ "rule_set": [ "games" ], "outbound": "🎮 游戏平台" },
{ "rule_set": [ "ai" ], "outbound": "🤖 AI 平台" },
@@ -50,6 +54,7 @@
{ "action": "resolve", "server": "dns_proxy", "strategy": "prefer_ipv4", "match_only": true},
{ "rule_set": [ "cnip" ], "outbound": "🀄️ 直连 IP" },
{ "rule_set": [ "netflixip" ], "outbound": "🎥 奈飞视频" },
{ "rule_set": [ "mediaip" ], "outbound": "🌍 国外媒体" },
{ "rule_set": [ "gamesip" ], "outbound": "🎮 游戏平台" }
],
@@ -110,6 +115,22 @@
"url": "https://testingcf.jsdelivr.net/gh/DustinWin/ruleset_geodata@sing-box-ruleset/games-cn.srs",
"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",
"type": "remote",
@@ -174,6 +195,14 @@
"url": "https://testingcf.jsdelivr.net/gh/DustinWin/ruleset_geodata@sing-box-ruleset/cnip.srs",
"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",
"type": "remote",

View File

@@ -9,6 +9,8 @@
{ "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": [ "🎯 本地直连", "🚀 节点选择" ] },
@@ -36,6 +38,8 @@
{ "rule_set": [ "apple-cn" ], "outbound": "🍎 苹果服务" },
{ "rule_set": [ "google-cn" ], "outbound": "🇬 谷歌服务" },
{ "rule_set": [ "games-cn" ], "outbound": "🎮 游戏服务" },
{ "rule_set": [ "netflix" ], "outbound": "🎥 奈飞视频" },
{ "rule_set": [ "youtube" ], "outbound": "📹 油管视频" },
{ "rule_set": [ "media" ], "outbound": "🌍 国外媒体" },
{ "rule_set": [ "games" ], "outbound": "🎮 游戏平台" },
{ "rule_set": [ "ai" ], "outbound": "🤖 AI 平台" },
@@ -47,6 +51,7 @@
{ "action": "resolve", "server": "dns_proxy", "strategy": "prefer_ipv4", "match_only": true},
{ "rule_set": [ "cnip" ], "outbound": "🀄️ 直连 IP" },
{ "rule_set": [ "netflixip" ], "outbound": "🎥 奈飞视频" },
{ "rule_set": [ "mediaip" ], "outbound": "🌍 国外媒体" },
{ "rule_set": [ "gamesip" ], "outbound": "🎮 游戏平台" }
],
@@ -99,6 +104,22 @@
"url": "https://testingcf.jsdelivr.net/gh/DustinWin/ruleset_geodata@sing-box-ruleset/games-cn.srs",
"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",
"type": "remote",
@@ -163,6 +184,14 @@
"url": "https://testingcf.jsdelivr.net/gh/DustinWin/ruleset_geodata@sing-box-ruleset/cnip.srs",
"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",
"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": [
{ "tag": "🚀 节点选择", "type": "selector", "outbounds": ["♻️ 自动选择", "✨ 自动选择(去高倍率)", "🛠️ 手动切换", "🎯 本地直连", "🇭🇰 香港节点", "🇹🇼 台湾节点", "🇺🇸 美国节点", "🇯🇵 日本节点", "🇪🇺 欧洲节点", "🇰🇷 韩国节点", "🇸🇬 狮城节点", "👑 高级节点", "📉 省流节点", {providers_tags}] },
@@ -28,19 +28,18 @@
{ "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": "pass" },
{ "tag": "🎯 本地直连", "type": "direct" },
{ "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)(🇹🇼|台|tw|taiwan|tai wan)" },
{ "tag": "🇺🇸 美国节点", "type": "urltest", "use_all_providers": true, "include": "(?i)(🇺🇸|美|洛杉矶|圣何塞|西雅图|纽约|波特兰|旧金山|us|unitedstates|united states)" },
{ "tag": "🇯🇵 日本节点", "type": "urltest", "use_all_providers": true, "include": "(?i)(🇯🇵|日|东京|大阪|埼玉|九州|jp|japan)" },
{ "tag": "🇪🇺 欧洲节点", "type": "urltest", "use_all_providers": true, "include": "(?i)(🇪🇺|欧|德|英|法|荷|俄罗斯|西班牙|意大利|瑞士|瑞典|土耳其|挪威|芬兰|丹麦|比利时|爱尔兰|奥地利|波兰|葡萄牙|乌克兰|希腊|捷克|匈牙利|罗马尼亚|保加利亚|冰岛|克罗地亚)" },
{ "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)", "exclude": "(?i)(南美|中美|拉美|亚美尼亚|美属)" },
{ "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)(🇰🇷|韩|韓|首尔|kr|kor)" },
{ "tag": "🇸🇬 狮城节点", "type": "urltest", "use_all_providers": true, "include": "(?i)(🇸🇬|新加坡|狮城|sg|singapore)" },
@@ -49,9 +48,9 @@
],
"route": {
"rules": [
{ "domain_suffix": ["captive.apple.com"], "outbound": "DIRECT" },
{ "domain_suffix": ["kamo.teracloud.jp"], "outbound": "DIRECT" },
{ "domain_suffix": ["captive.apple.com"], "outbound": "🍎 苹果服务" },
{ "domain_suffix": ["kamo.teracloud.jp"], "outbound": "🀄️ 国内流量" },
{ "rule_set": ["private"], "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
#设置环境变量
[ -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
[ -z "$profile" ] && profile=/etc/profile
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 "$authentication" ] && auth="$authentication@" || auth=""
[ -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")
fi
[ "$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" = "200" ]
return $?

View File

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

View File

@@ -109,8 +109,8 @@ ckstatus() { #脚本启动前检查
echo "-----------------------------------------------"
#检查新手引导
if [ -z "$userguide" ]; then
. "$CRASHDIR"/menus/userguide.sh && userguide
setconfig userguide 1
. "$CRASHDIR"/menus/userguide.sh && userguide
fi
#检查执行权限
[ ! -x "$CRASHDIR"/start.sh ] && chmod +x "$CRASHDIR"/start.sh
@@ -159,88 +159,82 @@ ckstatus() { #脚本启动前检查
}
main_menu() {
ckstatus
while true; do
ckstatus
echo -e " 1 \033[32m$MENU_MAIN_1\033[0m"
echo -e " 2 \033[36m$MENU_MAIN_2\033[0m"
echo -e " 3 \033[31m$MENU_MAIN_3\033[0m"
echo -e " 4 \033[33m$MENU_MAIN_4\033[0m"
echo -e " 5 \033[32m$MENU_MAIN_5\033[0m"
echo -e " 6 \033[36m$MENU_MAIN_6\033[0m"
echo -e " 7 \033[33m$MENU_MAIN_7\033[0m"
echo -e " 8 $MENU_MAIN_8"
echo -e " 9 \033[32m$MENU_MAIN_9\033[0m"
echo "-----------------------------------------------"
echo -e " 0 $MENU_MAIN_0"
read -p "$MENU_MAIN_PROMPT" num
case "$num" in
0)
exit
;;
1)
start_service
exit
;;
2)
checkcfg=$(cat "$CFG_PATH")
. "$CRASHDIR"/menus/2_settings.sh && settings
if [ -n "$PID" ]; then
checkcfg_new=$(cat "$CFG_PATH")
[ "$checkcfg" != "$checkcfg_new" ] && checkrestart
fi
main_menu
;;
3)
[ "$bot_tg_service" = ON ] && . "$CRASHDIR"/menus/bot_tg_service.sh && bot_tg_stop
"$CRASHDIR"/start.sh stop
sleep 1
echo -e " 1 \033[32m$MENU_MAIN_1\033[0m"
echo -e " 2 \033[36m$MENU_MAIN_2\033[0m"
echo -e " 3 \033[31m$MENU_MAIN_3\033[0m"
echo -e " 4 \033[33m$MENU_MAIN_4\033[0m"
echo -e " 5 \033[32m$MENU_MAIN_5\033[0m"
echo -e " 6 \033[36m$MENU_MAIN_6\033[0m"
echo -e " 7 \033[33m$MENU_MAIN_7\033[0m"
echo -e " 8 $MENU_MAIN_8"
echo -e " 9 \033[32m$MENU_MAIN_9\033[0m"
echo "-----------------------------------------------"
echo -e "\033[31m$corename$MENU_SERVICE_STOPPED\033[0m"
main_menu
;;
4)
. "$CRASHDIR"/menus/4_setboot.sh && setboot
main_menu
;;
5)
. "$CRASHDIR"/menus/5_task.sh && task_menu
main_menu
;;
6)
. "$CRASHDIR"/menus/6_core_config.sh && set_core_config
main_menu
;;
7)
GT_CFG_PATH="$CRASHDIR"/configs/gateway.cfg
touch "$GT_CFG_PATH"
checkcfg=$(cat "$CFG_PATH" "$GT_CFG_PATH")
. "$CRASHDIR"/menus/7_gateway.sh && gateway
if [ -n "$PID" ]; then
checkcfg_new=$(cat "$CFG_PATH" "$GT_CFG_PATH")
[ "$checkcfg" != "$checkcfg_new" ] && checkrestart
fi
main_menu
;;
8)
. "$CRASHDIR"/menus/8_tools.sh && tools
main_menu
;;
9)
checkcfg=$(cat "$CFG_PATH")
. "$CRASHDIR"/menus/9_upgrade.sh && upgrade
if [ -n "$PID" ]; then
checkcfg_new=$(cat "$CFG_PATH")
[ "$checkcfg" != "$checkcfg_new" ] && checkrestart
fi
main_menu
;;
*)
errornum
exit
;;
esac
echo -e " 0 $MENU_MAIN_0"
read -p "$MENU_MAIN_PROMPT" num
case "$num" in
"" | 0)
exit
;;
1)
start_service
exit
;;
2)
checkcfg=$(cat "$CFG_PATH")
. "$CRASHDIR"/menus/2_settings.sh && settings
if [ -n "$PID" ]; then
checkcfg_new=$(cat "$CFG_PATH")
[ "$checkcfg" != "$checkcfg_new" ] && checkrestart
fi
;;
3)
[ "$bot_tg_service" = ON ] && . "$CRASHDIR"/menus/bot_tg_service.sh && bot_tg_stop
"$CRASHDIR"/start.sh stop
sleep 1
echo "-----------------------------------------------"
echo -e "\033[31m$corename$MENU_SERVICE_STOPPED\033[0m"
;;
4)
. "$CRASHDIR"/menus/4_setboot.sh && setboot
;;
5)
. "$CRASHDIR"/menus/5_task.sh && task_menu
;;
6)
. "$CRASHDIR"/menus/6_core_config.sh && set_core_config
;;
7)
GT_CFG_PATH="$CRASHDIR"/configs/gateway.cfg
touch "$GT_CFG_PATH"
checkcfg=$(cat "$CFG_PATH" "$GT_CFG_PATH")
. "$CRASHDIR"/menus/7_gateway.sh && gateway
if [ -n "$PID" ]; then
checkcfg_new=$(cat "$CFG_PATH" "$GT_CFG_PATH")
[ "$checkcfg" != "$checkcfg_new" ] && checkrestart
fi
;;
8)
. "$CRASHDIR"/menus/8_tools.sh && tools
;;
9)
checkcfg=$(cat "$CFG_PATH")
. "$CRASHDIR"/menus/9_upgrade.sh && upgrade
if [ -n "$PID" ]; then
checkcfg_new=$(cat "$CFG_PATH")
[ "$checkcfg" != "$checkcfg_new" ] && checkrestart
fi
;;
*)
errornum
sleep 1
;;
esac
done
}
case "$1" in

View File

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

View File

@@ -4,284 +4,283 @@
[ -n "$__IS_MODULE_2_SETTINGS_LOADED" ] && return
__IS_MODULE_2_SETTINGS_LOADED=1
settings() { #功能设置
#获取设置默认显示
[ -z "$skip_cert" ] && skip_cert=ON
[ -z "$sniffer" ] && sniffer=OFF
[ -z "$dns_mod" ] && dns_mod='redir_host'
#
echo "-----------------------------------------------"
echo -e "\033[30;47m欢迎使用功能设置菜单\033[0m"
echo "-----------------------------------------------"
echo -e " 1 路由模式设置: \033[36m$redir_mod\033[0m"
echo -e " 2 DNS设置 \033[36m$dns_mod\033[0m"
echo -e " 3 透明路由\033[32m流量过滤\033[0m"
[ "$disoverride" != "1" ] && {
echo -e " 4 跳过证书验证: \033[36m$skip_cert\033[0m"
echo -e " 5 启用域名嗅探: \033[36m$sniffer\033[0m"
echo -e " 6 自定义\033[32m端口及秘钥\033[0m"
}
echo -e " 8 ipv6设置 \033[36m$ipv6_redir\033[0m"
echo "-----------------------------------------------"
echo -e " 9 \033[31m重置/备份/还原\033[0m脚本设置"
echo -e " 0 返回上级菜单 \033[0m"
echo "-----------------------------------------------"
read -p "请输入对应数字 > " num
case "$num" in
0)
;;
1)
if [ "$USER" != "root" -a "$USER" != "admin" ]; then
echo "-----------------------------------------------"
read -p "非root用户可能无法正确配置其他模式依然尝试吗(1/0) > " res
[ "$res" = 1 ] && set_redir_mod
else
set_redir_mod
fi
sleep 1
settings
;;
2)
. "$CRASHDIR"/menus/dns.sh && set_dns_mod
sleep 1
settings
;;
3)
. "$CRASHDIR"/menus/fw_filter.sh && set_fw_filter
sleep 1
settings
;;
4)
# 功能设置
settings() {
while true; do
# 获取设置默认显示
[ -z "$skip_cert" ] && skip_cert=ON
[ -z "$sniffer" ] && sniffer=OFF
[ -z "$dns_mod" ] && dns_mod='redir_host'
echo "-----------------------------------------------"
if [ "$skip_cert" = "OFF" ] >/dev/null 2>&1; then
echo -e "\033[33m已设为开启跳过本地证书验证\033[0m"
skip_cert=ON
else
echo -e "\033[33m已设为禁止跳过本地证书验证\033[0m"
skip_cert=OFF
fi
setconfig skip_cert $skip_cert
settings
;;
5)
echo -e "\033[30;47m欢迎使用功能设置菜单\033[0m"
echo "-----------------------------------------------"
if [ "$sniffer" = "OFF" ]; then
if [ "$crashcore" = "clash" ]; then
rm -rf ${TMPDIR}/CrashCore
rm -rf "$CRASHDIR"/CrashCore
rm -rf "$CRASHDIR"/CrashCore.tar.gz
crashcore=meta
setconfig crashcore $crashcore
echo "已将ShellCrash内核切换为Meta内核域名嗅探依赖Meta或者高版本clashpre内核"
fi
sniffer=ON
elif [ "$crashcore" = "clashpre" -a "$dns_mod" = "redir_host" ]; then
echo -e "\033[31m使用clashpre内核且开启redir-host模式时无法关闭\033[0m"
else
sniffer=OFF
fi
setconfig sniffer $sniffer
settings
;;
6)
if [ -n "$(pidof CrashCore)" ]; then
echo "-----------------------------------------------"
echo -e "\033[33m检测到服务正在运行需要先停止服务\033[0m"
read -p "是否停止服务?(1/0) > " res
if [ "$res" = "1" ]; then
"$CRASHDIR"/start.sh stop
set_adv_config
fi
else
set_adv_config
fi
settings
;;
8)
set_ipv6
settings
;;
9)
echo "-----------------------------------------------"
echo -e " 1 备份脚本设置"
echo -e " 2 还原脚本设置"
echo -e " 3 重置脚本设置"
echo -e " 0 返回上级菜单"
echo -e " 1 路由模式设置: \033[36m$redir_mod\033[0m"
echo -e " 2 DNS设置 \033[36m$dns_mod\033[0m"
echo -e " 3 透明路由\033[32m流量过滤\033[0m"
[ "$disoverride" != "1" ] && {
echo -e " 4 跳过证书验证: \033[36m$skip_cert\033[0m"
echo -e " 5 启用域名嗅探: \033[36m$sniffer\033[0m"
echo -e " 6 自定义\033[32m端口及秘钥\033[0m"
}
echo -e " 8 ipv6设置 \033[36m$ipv6_redir\033[0m"
echo "-----------------------------------------------"
echo -e " 9 \033[31m重置/备份/还原\033[0m脚本设置"
echo -e " 0 返回上级菜单 \033[0m"
echo "-----------------------------------------------"
read -p "请输入对应数字 > " num
if [ -z "$num" ]; then
errornum
elif [ "$num" = 0 ]; then
i=
elif [ "$num" = 1 ]; then
cp -f "$CFG_PATH" "$CFG_PATH".bak
echo -e "\033[32m脚本设置已备份\033[0m"
elif [ "$num" = 2 ]; then
if [ -f "$CFG_PATH.bak" ]; then
mv -f "$CFG_PATH" "$CFG_PATH".bak2
mv -f "$CFG_PATH".bak "$CFG_PATH"
mv -f "$CFG_PATH".bak2 "$CFG_PATH".bak
echo -e "\033[32m脚本设置已还原(被覆盖的配置已备份!)\033[0m"
case "$num" in
"" | 0)
break
;;
1)
if [ "$USER" != "root" -a "$USER" != "admin" ]; then
echo "-----------------------------------------------"
read -p "非root用户可能无法正确配置其他模式依然尝试吗(1/0) > " res
[ "$res" = 1 ] && set_redir_mod
else
echo -e "\033[31m找不到备份文件请先备份脚本设置\033[0m"
set_redir_mod
fi
elif [ "$num" = 3 ]; then
mv -f "$CFG_PATH" "$CFG_PATH".bak
. "$CRASHDIR"/init.sh >/dev/null
echo -e "\033[32m脚本设置已重置(旧文件已备份!)\033[0m"
fi
echo -e "\033[33m请重新启动脚本\033[0m"
exit 0
;;
*)
errornum
;;
esac
sleep 1
;;
2)
. "$CRASHDIR"/menus/dns.sh && set_dns_mod
sleep 1
;;
3)
. "$CRASHDIR"/menus/fw_filter.sh && set_fw_filter
sleep 1
;;
4)
echo "-----------------------------------------------"
if [ "$skip_cert" = "OFF" ] >/dev/null 2>&1; then
echo -e "\033[33m已设为开启跳过本地证书验证\033[0m"
skip_cert=ON
else
echo -e "\033[33m已设为禁止跳过本地证书验证\033[0m"
skip_cert=OFF
fi
setconfig skip_cert $skip_cert
;;
5)
echo "-----------------------------------------------"
if [ "$sniffer" = "OFF" ]; then
if [ "$crashcore" = "clash" ]; then
rm -rf ${TMPDIR}/CrashCore
rm -rf "$CRASHDIR"/CrashCore
rm -rf "$CRASHDIR"/CrashCore.tar.gz
crashcore=meta
setconfig crashcore $crashcore
echo "已将ShellCrash内核切换为Meta内核域名嗅探依赖Meta或者高版本clashpre内核"
fi
sniffer=ON
elif [ "$crashcore" = "clashpre" -a "$dns_mod" = "redir_host" ]; then
echo -e "\033[31m使用clashpre内核且开启redir-host模式时无法关闭\033[0m"
else
sniffer=OFF
fi
setconfig sniffer $sniffer
;;
6)
if [ -n "$(pidof CrashCore)" ]; then
echo "-----------------------------------------------"
echo -e "\033[33m检测到服务正在运行需要先停止服务\033[0m"
read -p "是否停止服务?(1/0) > " res
if [ "$res" = "1" ]; then
"$CRASHDIR"/start.sh stop
set_adv_config
fi
else
set_adv_config
fi
;;
8)
set_ipv6
;;
9)
echo "-----------------------------------------------"
echo -e " 1 备份脚本设置"
echo -e " 2 还原脚本设置"
echo -e " 3 重置脚本设置"
echo -e " 0 返回上级菜单"
echo "-----------------------------------------------"
read -p "请输入对应数字 > " num
if [ -z "$num" ]; then
errornum
elif [ "$num" = 0 ]; then
i=
elif [ "$num" = 1 ]; then
cp -f "$CFG_PATH" "$CFG_PATH".bak
echo -e "\033[32m脚本设置已备份\033[0m"
elif [ "$num" = 2 ]; then
if [ -f "$CFG_PATH.bak" ]; then
mv -f "$CFG_PATH" "$CFG_PATH".bak2
mv -f "$CFG_PATH".bak "$CFG_PATH"
mv -f "$CFG_PATH".bak2 "$CFG_PATH".bak
echo -e "\033[32m脚本设置已还原(被覆盖的配置已备份!)\033[0m"
else
echo -e "\033[31m找不到备份文件请先备份脚本设置\033[0m"
fi
elif [ "$num" = 3 ]; then
mv -f "$CFG_PATH" "$CFG_PATH".bak
. "$CRASHDIR"/init.sh >/dev/null
echo -e "\033[32m脚本设置已重置(旧文件已备份!)\033[0m"
fi
echo -e "\033[33m请重新启动脚本\033[0m"
exit 0
;;
*)
errornum
sleep 1
break
;;
esac
done
}
set_redir_mod() { #路由模式设置
set_redir_config() {
setconfig redir_mod $redir_mod
setconfig dns_mod $dns_mod
echo "-----------------------------------------------"
echo -e "\033[36m已设为 $redir_mod \033[0m"
}
[ -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 "$redir_mod" ] && [ "$USER" = "root" -o "$USER" = "admin" ] && redir_mod='Redir模式'
[ -z "$redir_mod" ] && redir_mod='纯净模式'
firewall_area_dsc=$(echo "仅局域网 仅本机 局域网+本机 纯净模式 主-旁转发($bypass_host)" | cut -d' ' -f$firewall_area)
set_redir_config() {
setconfig redir_mod $redir_mod
setconfig dns_mod $dns_mod
echo "-----------------------------------------------"
echo -e "当前路由模式为:\033[47;30m$redir_mod\033[0mShellCrash核心为\033[47;30m $crashcore \033[0m"
echo -e "\033[33m切换模式后需要手动重启服务以生效\033[0m"
echo "-----------------------------------------------"
[ $firewall_area -le 3 ] && {
echo -e " 1 \033[32mRedir模式\033[0m Redir转发TCP不转发UDP"
echo -e " 2 \033[36m混合模式\033[0m Redir转发TCPTun转发UDP"
echo -e " 3 \033[32mTproxy模式\033[0m Tproxy转发TCP&UDP"
echo -e " 4 \033[33mTun模式\033[0m Tun转发TCP&UDP(占用高不推荐)"
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
[ -z "$firewall_area" ] && firewall_area=1
[ -z "$redir_mod" ] && [ "$USER" = "root" -o "$USER" = "admin" ] && redir_mod='Redir模式'
[ -z "$redir_mod" ] && redir_mod='纯净模式'
firewall_area_dsc=$(echo "仅局域网 仅本机 局域网+本机 纯净模式 主-旁转发($bypass_host)" | cut -d' ' -f$firewall_area)
echo "-----------------------------------------------"
}
[ "$firewall_area" = 5 ] && {
echo -e " 5 \033[32mTCP旁路转发\033[0m 仅转发TCP流量至旁路由"
echo -e " 6 \033[36mT&U旁路转发\033[0m 转发TCP&UDP流量至旁路由"
echo -e "当前路由模式为:\033[47;30m$redir_mod\033[0mShellCrash核心为\033[47;30m $crashcore \033[0m"
echo -e "\033[33m切换模式后需要手动重启服务以生效\033[0m"
echo "-----------------------------------------------"
}
echo -e " 7 设置路由劫持范围: \033[47;30m$firewall_area_dsc\033[0m"
echo -e " 8 容器/虚拟机劫持: \033[47;30m$vm_redir\033[0m"
echo -e " 9 切换防火墙应用: \033[47;30m$firewall_mod\033[0m"
echo "-----------------------------------------------"
echo " 0 返回上级菜单"
read -p "请输入对应数字 > " num
case "$num" in
0) ;;
1)
redir_mod=Redir模式
set_redir_config
set_redir_mod
;;
2)
if [ -n "$sup_tun" ]; then
redir_mod=混合模式
[ $firewall_area -le 3 ] && {
echo -e " 1 \033[32mRedir模式\033[0m Redir转发TCP不转发UDP"
echo -e " 2 \033[36m混合模式\033[0m Redir转发TCPTun转发UDP"
echo -e " 3 \033[32mTproxy模式\033[0m Tproxy转发TCP&UDP"
echo -e " 4 \033[33mTun模式\033[0m Tun转发TCP&UDP(占用高不推荐)"
echo "-----------------------------------------------"
}
[ "$firewall_area" = 5 ] && {
echo -e " 5 \033[32mTCP旁路转发\033[0m 仅转发TCP流量至旁路由"
echo -e " 6 \033[36mT&U旁路转发\033[0m 转发TCP&UDP流量至旁路由"
echo "-----------------------------------------------"
}
echo -e " 7 设置路由劫持范围: \033[47;30m$firewall_area_dsc\033[0m"
echo -e " 8 容器/虚拟机劫持: \033[47;30m$vm_redir\033[0m"
echo -e " 9 切换防火墙应用: \033[47;30m$firewall_mod\033[0m"
echo "-----------------------------------------------"
echo " 0 返回上级菜单"
read -p "请输入对应数字 > " num
case "$num" in
"" | 0)
break
;;
1)
redir_mod=Redir模式
set_redir_config
else
echo -e "\033[31m设备未检测到Tun内核模块请尝试其他模式或者安装相关依赖\033[0m"
sleep 1
fi
set_redir_mod
;;
3)
if [ "$firewall_mod" = "iptables" ]; then
if [ -f /etc/init.d/qca-nss-ecm -a "$systype" = "mi_snapshot" ]; then
read -p "xiaomi设备的QOS服务与本模式冲突是否禁用相关功能(1/0) > " res
[ "$res" = '1' ] && {
/data/shellcrash_init.sh tproxyfix
;;
2)
if [ -n "$sup_tun" ]; then
redir_mod=混合模式
set_redir_config
else
echo -e "\033[31m设备未检测到Tun内核模块请尝试其他模式或者安装相关依赖\033[0m"
sleep 1
fi
;;
3)
if [ "$firewall_mod" = "iptables" ]; then
if [ -f /etc/init.d/qca-nss-ecm -a "$systype" = "mi_snapshot" ]; then
read -p "xiaomi设备的QOS服务与本模式冲突是否禁用相关功能(1/0) > " res
[ "$res" = '1' ] && {
/data/shellcrash_init.sh tproxyfix
redir_mod=Tproxy模式
set_redir_config
}
elif grep -qE '^TPROXY$' /proc/net/ip_tables_targets || modprobe xt_TPROXY >/dev/null 2>&1; then
redir_mod=Tproxy模式
set_redir_config
}
elif grep -qE '^TPROXY$' /proc/net/ip_tables_targets || modprobe xt_TPROXY >/dev/null 2>&1; then
redir_mod=Tproxy模式
else
echo -e "\033[31m设备未检测到iptables-mod-tproxy模块请尝试其他模式或者安装相关依赖\033[0m"
sleep 1
fi
elif [ "$firewall_mod" = "nftables" ]; then
if modprobe nft_tproxy >/dev/null 2>&1 || lsmod 2>/dev/null | grep -q nft_tproxy; then
redir_mod=Tproxy模式
set_redir_config
else
echo -e "\033[31m设备未检测到nft_tproxy内核模块请尝试其他模式或者安装相关依赖\033[0m"
sleep 1
fi
fi
;;
4)
if [ -n "$sup_tun" ]; then
redir_mod=Tun模式
set_redir_config
else
echo -e "\033[31m设备未检测到iptables-mod-tproxy模块,请尝试其他模式或者安装相关依赖!\033[0m"
echo -e "\033[31m设备未检测到Tun内核模块,请尝试其他模式或者安装相关依赖!\033[0m"
sleep 1
fi
elif [ "$firewall_mod" = "nftables" ]; then
if modprobe nft_tproxy >/dev/null 2>&1 || lsmod 2>/dev/null | grep -q nft_tproxy; then
redir_mod=Tproxy模式
set_redir_config
else
echo -e "\033[31m设备未检测到nft_tproxy内核模块请尝试其他模式或者安装相关依赖\033[0m"
sleep 1
fi
fi
set_redir_mod
;;
4)
if [ -n "$sup_tun" ]; then
redir_mod=Tun模式
;;
5)
redir_mod='TCP旁路转发'
set_redir_config
else
echo -e "\033[31m设备未检测到Tun内核模块请尝试其他模式或者安装相关依赖\033[0m"
;;
6)
redir_mod='T&U旁路转发'
set_redir_config
;;
7)
set_firewall_area
;;
8)
set_firewall_vm
;;
9)
if [ "$firewall_mod" = 'iptables' ]; then
if nft add table inet shellcrash 2>/dev/null; then
firewall_mod=nftables
redir_mod=Redir模式
setconfig redir_mod $redir_mod
else
echo -e "\033[31m当前设备未安装nftables或者nftables版本过低(<1.0.2),无法切换!\033[0m"
fi
elif [ "$firewall_mod" = 'nftables' ]; then
if ckcmd iptables; then
firewall_mod=iptables
redir_mod=Redir模式
setconfig redir_mod $redir_mod
else
echo -e "\033[31m当前设备未安装iptables,无法切换!\033[0m"
fi
else
iptables -j REDIRECT -h >/dev/null 2>&1 && firewall_mod=iptables
nft add table inet shellcrash 2>/dev/null && firewall_mod=nftables
if [ -n "$firewall_mod" ]; then
redir_mod=Redir模式
setconfig redir_mod $redir_mod
setconfig firewall_mod $firewall_mod
else
echo -e "\033[31m检测不到可用的防火墙应用(iptables/nftables),无法切换!\033[0m"
fi
fi
sleep 1
fi
set_redir_mod
;;
5)
redir_mod='TCP旁路转发'
set_redir_config
set_redir_mod
;;
6)
redir_mod='T&U旁路转发'
set_redir_config
set_redir_mod
;;
7)
set_firewall_area
set_redir_mod
;;
8)
set_firewall_vm
set_redir_mod
;;
9)
if [ "$firewall_mod" = 'iptables' ]; then
if nft add table inet shellcrash 2>/dev/null; then
firewall_mod=nftables
redir_mod=Redir模式
setconfig redir_mod $redir_mod
else
echo -e "\033[31m当前设备未安装nftables或者nftables版本过低(<1.0.2),无法切换!\033[0m"
fi
elif [ "$firewall_mod" = 'nftables' ]; then
if ckcmd iptables; then
firewall_mod=iptables
redir_mod=Redir模式
setconfig redir_mod $redir_mod
else
echo -e "\033[31m当前设备未安装iptables,无法切换!\033[0m"
fi
else
iptables -j REDIRECT -h >/dev/null 2>&1 && firewall_mod=iptables
nft add table inet shellcrash 2>/dev/null && firewall_mod=nftables
if [ -n "$firewall_mod" ]; then
redir_mod=Redir模式
setconfig redir_mod $redir_mod
setconfig firewall_mod $firewall_mod
else
echo -e "\033[31m检测不到可用的防火墙应用(iptables/nftables),无法切换!\033[0m"
fi
fi
sleep 1
setconfig firewall_mod $firewall_mod
set_redir_mod
;;
*)
errornum
;;
esac
setconfig firewall_mod $firewall_mod
;;
*)
errornum
sleep 1
break
;;
esac
done
}
set_adv_config() { #端口设置
. "$CFG_PATH" >/dev/null
[ -z "$secret" ] && secret=未设置
@@ -490,36 +489,42 @@ set_firewall_vm(){
setconfig vm_redir $vm_redir
setconfig vm_ipv4 "'$vm_ipv4'"
}
set_ipv6() { #ipv6设置
[ -z "$ipv6_redir" ] && ipv6_redir=OFF
[ -z "$ipv6_dns" ] && ipv6_dns=ON
echo "-----------------------------------------------"
echo -e " 1 ipv6透明路由: \033[36m$ipv6_redir\033[0m ——劫持ipv6流量"
[ "$disoverride" != "1" ] && echo -e " 2 ipv6-DNS解析: \033[36m$ipv6_dns\033[0m ——决定内置DNS是否返回ipv6地址"
echo -e " 0 返回上级菜单"
echo "-----------------------------------------------"
read -p "请输入对应数字 > " num
case "$num" in
0) ;;
1)
if [ "$ipv6_redir" = "OFF" ]; then
ipv6_support=ON
ipv6_redir=ON
sleep 2
else
ipv6_redir=OFF
fi
setconfig ipv6_redir $ipv6_redir
setconfig ipv6_support $ipv6_support
set_ipv6
;;
2)
[ "$ipv6_dns" = "OFF" ] && ipv6_dns=ON || ipv6_dns=OFF
setconfig ipv6_dns $ipv6_dns
set_ipv6
;;
*)
errornum
;;
esac
# ipv6设置
set_ipv6() {
while true; do
[ -z "$ipv6_redir" ] && ipv6_redir=OFF
[ -z "$ipv6_dns" ] && ipv6_dns=ON
echo "-----------------------------------------------"
echo -e " 1 ipv6透明路由: \033[36m$ipv6_redir\033[0m ——劫持ipv6流量"
[ "$disoverride" != "1" ] && echo -e " 2 ipv6-DNS解析: \033[36m$ipv6_dns\033[0m ——决定内置DNS是否返回ipv6地址"
echo -e " 0 返回上级菜单"
echo "-----------------------------------------------"
read -p "请输入对应数字 > " num
case "$num" in
"" | 0)
break
;;
1)
if [ "$ipv6_redir" = "OFF" ]; then
ipv6_support=ON
ipv6_redir=ON
sleep 2
else
ipv6_redir=OFF
fi
setconfig ipv6_redir $ipv6_redir
setconfig ipv6_support $ipv6_support
;;
2)
[ "$ipv6_dns" = "OFF" ] && ipv6_dns=ON || ipv6_dns=OFF
setconfig ipv6_dns $ipv6_dns
;;
*)
errornum
sleep 1
break
;;
esac
done
}

View File

@@ -211,102 +211,114 @@ task_type(){ #任务条件选择菜单
;;
esac
}
task_manager(){ #任务管理列表
echo "-----------------------------------------------"
#抽取并生成临时列表
croncmd -l > "$TMPDIR"/task_cronlist
cat "$TMPDIR"/task_cronlist "$CRASHDIR"/task/running 2>/dev/null | sort -u | grep -oE "task/task.sh .*" | awk -F ' ' '{print $2" "$3}' > "$TMPDIR"/task_list
cat "$CRASHDIR"/task/bfstart "$CRASHDIR"/task/afstart "$CRASHDIR"/task/affirewall 2>/dev/null | awk -F ' ' '{print $2" "$3}' >> "$TMPDIR"/task_list
cat "$TMPDIR"/task_cronlist 2>/dev/null | sort -u | grep -oE " #.*" | grep -v "守护" | awk -F '#' '{print "0 旧版任务-"$2}' >> "$TMPDIR"/task_list
sed -i '/^ *$/d' "$TMPDIR"/task_list
rm -rf "$TMPDIR"/task_cronlist
#判断为空则返回
if [ ! -s "$TMPDIR"/task_list ];then
echo -e "\033[31m当前没有可供管理的任务\033[36m"
sleep 1
else
echo -e "\033[33m已添加的任务:\033[0m"
echo "-----------------------------------------------"
cat "$TMPDIR"/task_list | awk '{print " " NR " " $2}'
echo "-----------------------------------------------"
echo -e " a 清空旧版任务"
echo -e " d 清空任务列表"
echo -e " 0 返回上级菜单"
read -p "请输入对应数字 > " num
case "$num" in
0)
;;
a)
task_del "#"
echo -e "\033[31m旧版任务已清空\033[36m"
sleep 1
;;
d)
task_del "task.sh"
echo -e "\033[31m全部任务已清空\033[36m"
sleep 1
;;
[1-9]|[1-9][0-9])
task_txt=$(sed -n "$num p" "$TMPDIR"/task_list)
task_id=$(echo $task_txt | awk '{print $1}')
if [ "$task_id" = 0 ];then
read -p "旧版任务不支持管理,是否移除?(1/0) > " res
[ "$res" = 1 ] && {
cronname=$(echo $task_txt | awk -F '-' '{print $2}')
croncmd -l > $TMPDIR/conf && sed -i "/$cronname/d" $TMPDIR/conf && croncmd $TMPDIR/conf
sed -i "/$cronname/d" $clashdir/tools/cron 2>/dev/null
rm -f $TMPDIR/conf
}
else
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}')
echo "-----------------------------------------------"
echo -e "当前任务为:\033[36m $task_des\033[0m"
echo -e " 1 \033[33m修改\033[0m当前任务"
echo -e " 2 \033[31m删除\033[0m当前任务"
echo -e " 3 \033[32m立即执行\033[0m一次"
echo -e " 4 查看\033[33m执行记录\033[0m"
echo "-----------------------------------------------"
echo -e " 0 返回上级菜单"
read -p "请选择需要执行的操作 > " num
case "$num" in
0)
;;
1)
task_type && task_del $task_des
;;
2)
task_del $task_des
;;
3)
task_command=$(cat "$CRASHDIR"/task/task.list "$CRASHDIR"/task/task.user 2>/dev/null | grep "$task_id" | awk -F '#' '{print $2}')
eval $task_command && task_res='执行成功!' || task_res='执行失败!'
echo -e "\033[33m任务【$task_des$task_res\033[0m"
sleep 1
;;
4)
echo "-----------------------------------------------"
if [ -n "$(cat "$TMPDIR"/ShellCrash.log | grep "$task_name")" ];then
cat "$TMPDIR"/ShellCrash.log | grep "$task_name"
else
echo -e "\033[31m未找到相关执行记录\033[0m"
fi
sleep 1
;;
*)
errornum
;;
esac
fi
task_manager
;;
*)
errornum
;;
esac
fi
# 任务管理列表
task_manager() {
while true; do
echo "-----------------------------------------------"
# 抽取并生成临时列表
croncmd -l >"$TMPDIR"/task_cronlist
cat "$TMPDIR"/task_cronlist "$CRASHDIR"/task/running 2>/dev/null | sort -u | grep -oE "task/task.sh .*" | awk -F ' ' '{print $2" "$3}' >"$TMPDIR"/task_list
cat "$CRASHDIR"/task/bfstart "$CRASHDIR"/task/afstart "$CRASHDIR"/task/affirewall 2>/dev/null | awk -F ' ' '{print $2" "$3}' >>"$TMPDIR"/task_list
cat "$TMPDIR"/task_cronlist 2>/dev/null | sort -u | grep -oE " #.*" | grep -v "守护" | awk -F '#' '{print "0 旧版任务-"$2}' >>"$TMPDIR"/task_list
sed -i '/^ *$/d' "$TMPDIR"/task_list
rm -rf "$TMPDIR"/task_cronlist
# 判断为空则返回
if [ ! -s "$TMPDIR"/task_list ]; then
echo -e "\033[31m当前没有可供管理的任务\033[36m"
sleep 1
break
else
echo -e "\033[33m已添加的任务:\033[0m"
echo "-----------------------------------------------"
cat "$TMPDIR"/task_list | awk '{print " " NR " " $2}'
echo "-----------------------------------------------"
echo -e " a 清空旧版任务"
echo -e " d 清空任务列表"
echo -e " 0 返回上级菜单"
read -p "请输入对应数字 > " num
case "$num" in
"" | 0)
break
;;
a)
task_del "#"
echo -e "\033[31m旧版任务已清空\033[36m"
sleep 1
break
;;
d)
task_del "task.sh"
echo -e "\033[31m全部任务已清空\033[36m"
sleep 1
break
;;
[1-9] | [1-9][0-9])
task_txt=$(sed -n "$num p" "$TMPDIR"/task_list)
task_id=$(echo $task_txt | awk '{print $1}')
if [ "$task_id" = 0 ]; then
read -p "旧版任务不支持管理,是否移除?(1/0) > " res
[ "$res" = 1 ] && {
cronname=$(echo $task_txt | awk -F '-' '{print $2}')
croncmd -l >$TMPDIR/conf && sed -i "/$cronname/d" $TMPDIR/conf && croncmd $TMPDIR/conf
sed -i "/$cronname/d" $clashdir/tools/cron 2>/dev/null
rm -f $TMPDIR/conf
}
break
else
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}')
echo "-----------------------------------------------"
echo -e "当前任务为:\033[36m $task_des\033[0m"
echo -e " 1 \033[33m修改\033[0m当前任务"
echo -e " 2 \033[31m删除\033[0m当前任务"
echo -e " 3 \033[32m立即执行\033[0m一次"
echo -e " 4 查看\033[33m执行记录\033[0m"
echo "-----------------------------------------------"
echo -e " 0 返回上级菜单"
read -p "请选择需要执行的操作 > " num
case "$num" in
"" | 0)
return 0
;;
1)
task_type && task_del $task_des
;;
2)
task_del $task_des
;;
3)
task_command=$(cat "$CRASHDIR"/task/task.list "$CRASHDIR"/task/task.user 2>/dev/null | grep "$task_id" | awk -F '#' '{print $2}')
eval $task_command && task_res='执行成功!' || task_res='执行失败!'
echo -e "\033[33m任务【$task_des$task_res\033[0m"
sleep 1
;;
4)
echo "-----------------------------------------------"
if [ -n "$(cat "$TMPDIR"/ShellCrash.log | grep "$task_name")" ]; then
cat "$TMPDIR"/ShellCrash.log | grep "$task_name"
else
echo -e "\033[31m未找到相关执行记录\033[0m"
fi
sleep 1
;;
*)
errornum
sleep 1
;;
esac
fi
;;
*)
errornum
sleep 1
break
;;
esac
fi
done
}
task_recom(){ #任务推荐
echo "-----------------------------------------------"
echo -e "\033[32m启用推荐的自动任务配置这包括\033[0m"

View File

@@ -372,13 +372,13 @@ EOF
}
}
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
provider_temp_file=$(grep "provider_temp_${coretype}" "$CRASHDIR"/configs/ShellCrash.cfg | awk -F '=' '{print $2}')
fi
echo "-----------------------------------------------"
if [ -s "$provider_temp_file" ];then
ln -sf "$provider_temp_file" "$TMPDIR"/provider_temp_file
if [ -s "$TMPDIR/$provider_temp_file" ];then
ln -sf "$TMPDIR/$provider_temp_file" "$TMPDIR"/provider_temp_file
else
echo -e "\033[33m正在获取在线模版\033[0m"
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
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
echo -e "\033[32m配置文件生成成功\033[0m"
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
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
echo -e "\033[32m配置文件生成成功如果启动超时建议更新里手动安装Singbox-srs数据库常用包\033[0m"
mkdir -p "$CRASHDIR"/jsons
@@ -535,176 +535,176 @@ EOF
rm -rf "$TMPDIR"/providers
fi
}
setproviders(){ #自定义providers
. "$CRASHDIR"/libs/set_cron.sh
. "$CRASHDIR"/libs/web_get_bin.sh
#获取模版名称
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}')
else
provider_temp_file=$(grep "provider_temp_${coretype}" "$CRASHDIR"/configs/ShellCrash.cfg | awk -F '=' '{print $2}')
provider_temp_des=$(grep "$provider_temp_file" "$CRASHDIR"/configs/${coretype}_providers.list | awk '{print $1}')
[ -z "$provider_temp_des" ] && provider_temp_des=$provider_temp_file
fi
echo "-----------------------------------------------"
echo -e "\033[33m你可以在这里快捷管理与生成自定义的providers服务商\033[0m"
echo -e "\033[33m支持在线及本地的Yaml格式配置导入\033[0m"
[ -s "$CRASHDIR"/configs/providers.cfg ] && {
echo "-----------------------------------------------"
echo -e "\033[36m输入对应数字可管理providers服务商\033[0m"
cat "$CRASHDIR"/configs/providers.cfg | awk -F "#" '{print " "NR" "$1" "$2}'
}
echo -e " d \033[31m清空\033[0mproviders服务商列表"
echo -e " e \033[33m清理\033[0mproviders目录文件"
echo "-----------------------------------------------"
echo -e "\033[36m按照a-b-c的顺序即可完成配置生成\033[0m"
echo -e " a \033[36m添加\033[0mproviders服务商/节点"
echo -e " b 选择\033[33m规则模版\033[0m \033[32m$provider_temp_des\033[0m"
echo -e " c \033[32m生成\033[0m基于providers的配置文件"
echo "-----------------------------------------------"
echo -e " 0 返回上级菜单"
read -p "请输入对应字母或数字 > " num
case "$num" in
0)
;;
[1-9]|[1-9][0-9])
provider_name=$(sed -n "$num p" "$CRASHDIR"/configs/providers.cfg | awk '{print $1}')
provider_url=$(sed -n "$num p" "$CRASHDIR"/configs/providers.cfg | awk '{print $2}')
if [ -z "$provider_name" ];then
errornum
else
echo "-----------------------------------------------"
echo -e " 1 修改名称:\033[36m$provider_name\033[0m"
echo -e " 2 修改链接地址:\033[32m$provider_url\033[0m"
echo -e " 3 生成\033[33m仅包含此链接\033[0m的配置文件"
echo -e " 4 \033[31m移除此链接\033[0m"
echo "-----------------------------------------------"
echo -e " 0 返回上级菜单"
read -p "请选择需要执行的操作 > " num
case "$num" in
0)
;;
1)
read -p "请输入名称或者代号(不可重复,不支持纯数字) > " name
if [ -n "$name" ] && [ -z "$(echo "$name" | grep -E '^[0-9]+$')" ] && ! grep -q "$name" "$CRASHDIR"/configs/providers.cfg;then
sed -i "s|$provider_name $provider_url|$name $provider_url|" "$CRASHDIR"/configs/providers.cfg
else
echo -e "\033[31m输入错误请重新输入\033[0m"
fi
;;
2)
read -p "请输入链接地址或本地相对路径 > " link
if [ -n "$(echo $link | grep -E '.*\..*|^\./')" ] && [ -z "$(grep "$link" "$CRASHDIR"/configs/providers.cfg)" ];then
link=$(echo $link | sed 's/\&/\\\&/g') #特殊字符添加转义
sed -i "s|$provider_name $provider_url|$provider_name $link|" "$CRASHDIR"/configs/providers.cfg
else
echo -e "\033[31m输入错误请重新输入\033[0m"
fi
;;
3)
gen_${coretype}_providers $provider_name $provider_url
;;
4)
sed -i "/^$provider_name /d" "$CRASHDIR"/configs/providers.cfg
;;
*)
errornum
;;
esac
sleep 1
fi
setproviders
;;
a)
echo "-----------------------------------------------"
echo -e "支持填写在线的\033[32mYClash订阅地址\033[0m或者\033[32m本地Clash配置文件\033[0m"
echo -e "本地配置文件请放在\033[32m$CRASHDIR\033[0m目录下并填写相对路径如【\033[32m./providers/test.yaml\033[0m】"
echo "-----------------------------------------------"
read -p "请输入链接地址或本地相对路径 > " link
link=$(echo $link | sed 's/ //g') #去空格
[ -n "$(echo $link | grep -E '.*\..*|^\./')" ] && {
read -p "请输入名称或代号(不可重复,不支持纯数字) > " name
name=$(echo $name | sed 's/ //g')
[ -n "$name" ] && [ -z "$(echo "$name" | grep -E '^[0-9]+$')" ] && ! grep -q "$name" "$CRASHDIR"/configs/providers.cfg && {
echo "-----------------------------------------------"
echo -e "名称:\033[36m$name\033[0m"
echo -e "链接地址/路径:\033[32m$link\033[0m"
read -p "确认添加?(1/0) > " res
[ "$res" = 1 ] && {
echo "$name $link" >> "$CRASHDIR"/configs/providers.cfg
echo -e "\033[32mproviders已添加\033[0m"
}
}
}
[ "$?" != 0 ] && echo -e "\033[31m输入错误操作已取消\033[0m"
sleep 1
setproviders
;;
c)
echo "-----------------------------------------------"
if [ -s "$CRASHDIR"/configs/providers.cfg ];then
echo -e "\033[33msingboxr与mihomo内核的providers配置文件不互通\033[0m"
echo "-----------------------------------------------"
read -p "确认生成${coretype}配置文件?(1/0) > " res
[ "$res" = "1" ] && {
gen_${coretype}_providers
}
else
echo -e "\033[31m你还未添加链接或本地配置文件请先添加\033[0m"
sleep 1
fi
setproviders
;;
b)
echo "-----------------------------------------------"
echo -e "当前规则模版为:\033[32m$provider_temp_des\033[0m"
echo -e "\033[33m请选择在线模版\033[0m"
echo "-----------------------------------------------"
cat "$CRASHDIR"/configs/${coretype}_providers.list | awk '{print " "NR" "$1}'
echo "-----------------------------------------------"
echo -e " a 使用\033[36m本地模版\033[0m"
echo "-----------------------------------------------"
read -p "请输入对应字母或数字 > " num
case "$num" in
0)
;;
a)
read -p "请输入模版的路径(绝对路径) > " dir
if [ -s $dir ];then
provider_temp_file=$dir
setconfig provider_temp_${coretype} $provider_temp_file
echo -e "\033[32m设置成功\033[0m"
else
echo -e "\033[31m输入错误找不到对应模版文件\033[0m"
fi
sleep 1
;;
*)
provider_temp_file=$(sed -n "$num p" "$CRASHDIR"/configs/${coretype}_providers.list 2>/dev/null | awk '{print $2}')
if [ -z "$provider_temp_file" ];then
errornum
else
setconfig provider_temp_${coretype} $provider_temp_file
fi
;;
esac
setproviders
;;
d)
read -p "确认清空全部链接?(1/0) > " res
[ "$res" = "1" ] && rm -rf "$CRASHDIR"/configs/providers.cfg
setproviders
;;
e)
echo -e "\033[33m将清空 $CRASHDIR/providers 目录下所有内容\033[0m"
read -p "是否继续?(1/0) > " res
[ "$res" = "1" ] && rm -rf "$CRASHDIR"/providers
setproviders
;;
*)
errornum
;;
esac
# 自定义providers
setproviders() {
. "$CRASHDIR"/libs/set_cron.sh
. "$CRASHDIR"/libs/web_get_bin.sh
while true; do
# 获取模版名称
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}')
else
provider_temp_file=$(grep "provider_temp_${coretype}" "$CRASHDIR"/configs/ShellCrash.cfg | awk -F '=' '{print $2}')
provider_temp_des=$(grep "$provider_temp_file" "$CRASHDIR"/configs/${coretype}_providers.list | awk '{print $1}')
[ -z "$provider_temp_des" ] && provider_temp_des=$provider_temp_file
fi
echo "-----------------------------------------------"
echo -e "\033[33m你可以在这里快捷管理与生成自定义的providers服务商\033[0m"
echo -e "\033[33m支持在线及本地的Yaml格式配置导入\033[0m"
[ -s "$CRASHDIR"/configs/providers.cfg ] && {
echo "-----------------------------------------------"
echo -e "\033[36m输入对应数字可管理providers服务商\033[0m"
cat "$CRASHDIR"/configs/providers.cfg | awk -F "#" '{print " "NR" "$1" "$2}'
}
echo -e " d \033[31m清空\033[0mproviders服务商列表"
echo -e " e \033[33m清理\033[0mproviders目录文件"
echo "-----------------------------------------------"
echo -e "\033[36m按照a-b-c的顺序即可完成配置生成\033[0m"
echo -e " a \033[36m添加\033[0mproviders服务商/节点"
echo -e " b 选择\033[33m规则模版\033[0m \033[32m$provider_temp_des\033[0m"
echo -e " c \033[32m生成\033[0m基于providers的配置文件"
echo "-----------------------------------------------"
echo -e " 0 返回上级菜单"
read -p "请输入对应字母或数字 > " num
case "$num" in
"" | 0)
break
;;
[1-9] | [1-9][0-9])
provider_name=$(sed -n "$num p" "$CRASHDIR"/configs/providers.cfg | awk '{print $1}')
provider_url=$(sed -n "$num p" "$CRASHDIR"/configs/providers.cfg | awk '{print $2}')
if [ -z "$provider_name" ]; then
errornum
else
echo "-----------------------------------------------"
echo -e " 1 修改名称:\033[36m$provider_name\033[0m"
echo -e " 2 修改链接地址:\033[32m$provider_url\033[0m"
echo -e " 3 生成\033[33m仅包含此链接\033[0m的配置文件"
echo -e " 4 \033[31m移除此链接\033[0m"
echo "-----------------------------------------------"
echo -e " 0 返回上级菜单"
read -p "请选择需要执行的操作 > " num
case "$num" in
"" | 0) ;;
1)
read -p "请输入名称或者代号(不可重复,不支持纯数字) > " name
if [ -n "$name" ] && [ -z "$(echo "$name" | grep -E '^[0-9]+$')" ] && ! grep -q "$name" "$CRASHDIR"/configs/providers.cfg; then
sed -i "s|$provider_name $provider_url|$name $provider_url|" "$CRASHDIR"/configs/providers.cfg
else
echo -e "\033[31m输入错误请重新输入\033[0m"
fi
;;
2)
read -p "请输入链接地址或本地相对路径 > " link
if [ -n "$(echo $link | grep -E '.*\..*|^\./')" ] && [ -z "$(grep "$link" "$CRASHDIR"/configs/providers.cfg)" ]; then
link=$(echo $link | sed 's/\&/\\\&/g') #特殊字符添加转义
sed -i "s|$provider_name $provider_url|$provider_name $link|" "$CRASHDIR"/configs/providers.cfg
else
echo -e "\033[31m输入错误请重新输入\033[0m"
fi
;;
3)
gen_${coretype}_providers $provider_name $provider_url
;;
4)
sed -i "/^$provider_name /d" "$CRASHDIR"/configs/providers.cfg
;;
*)
errornum
;;
esac
fi
sleep 1
;;
a)
echo "-----------------------------------------------"
echo -e "支持填写在线的\033[32mYClash订阅地址\033[0m或者\033[32m本地Clash配置文件\033[0m"
echo -e "本地配置文件请放在\033[32m$CRASHDIR\033[0m目录下并填写相对路径如【\033[32m./providers/test.yaml\033[0m】"
echo "-----------------------------------------------"
read -p "请输入链接地址或本地相对路径 > " link
link=$(echo $link | sed 's/ //g') #去空格
[ -n "$(echo $link | grep -E '.*\..*|^\./')" ] && {
read -p "请输入名称或代号(不可重复,不支持纯数字) > " name
name=$(echo $name | sed 's/ //g')
[ -n "$name" ] && [ -z "$(echo "$name" | grep -E '^[0-9]+$')" ] && ! grep -q "$name" "$CRASHDIR"/configs/providers.cfg && {
echo "-----------------------------------------------"
echo -e "名称:\033[36m$name\033[0m"
echo -e "链接地址/路径:\033[32m$link\033[0m"
read -p "确认添加?(1/0) > " res
[ "$res" = 1 ] && {
echo "$name $link" >>"$CRASHDIR"/configs/providers.cfg
echo -e "\033[32mproviders已添加\033[0m"
}
}
}
[ "$?" != 0 ] && echo -e "\033[31m输入错误操作已取消\033[0m"
sleep 1
;;
c)
echo "-----------------------------------------------"
if [ -s "$CRASHDIR"/configs/providers.cfg ]; then
echo -e "\033[33msingboxr与mihomo内核的providers配置文件不互通\033[0m"
echo "-----------------------------------------------"
read -p "确认生成${coretype}配置文件?(1/0) > " res
[ "$res" = "1" ] && {
gen_${coretype}_providers
}
else
echo -e "\033[31m你还未添加链接或本地配置文件请先添加\033[0m"
sleep 1
fi
;;
b)
echo "-----------------------------------------------"
echo -e "当前规则模版为:\033[32m$provider_temp_des\033[0m"
echo -e "\033[33m请选择在线模版\033[0m"
echo "-----------------------------------------------"
cat "$CRASHDIR"/configs/${coretype}_providers.list | awk '{print " "NR" "$1}'
echo "-----------------------------------------------"
echo -e " a 使用\033[36m本地模版\033[0m"
echo "-----------------------------------------------"
read -p "请输入对应字母或数字 > " num
case "$num" in
"" | 0) ;;
a)
read -p "请输入模版的路径(绝对路径) > " dir
if [ -s $dir ]; then
provider_temp_file=$dir
setconfig provider_temp_${coretype} $provider_temp_file
echo -e "\033[32m设置成功\033[0m"
else
echo -e "\033[31m输入错误找不到对应模版文件\033[0m"
fi
sleep 1
;;
*)
provider_temp_file=$(sed -n "$num p" "$CRASHDIR"/configs/${coretype}_providers.list 2>/dev/null | awk '{print $2}')
if [ -z "$provider_temp_file" ]; then
errornum
sleep 1
else
setconfig provider_temp_${coretype} $provider_temp_file
fi
;;
esac
;;
d)
read -p "确认清空全部链接?(1/0) > " res
[ "$res" = "1" ] && rm -rf "$CRASHDIR"/configs/providers.cfg
;;
e)
echo -e "\033[33m将清空 $CRASHDIR/providers 目录下所有内容\033[0m"
read -p "是否继续?(1/0) > " res
[ "$res" = "1" ] && rm -rf "$CRASHDIR"/providers
;;
*)
errornum
sleep 1
break
;;
esac
done
}
set_clash_adv(){ #自定义clash高级规则
@@ -746,77 +746,78 @@ set_singbox_adv(){ #自定义singbox配置文件
echo "-----------------------------------------------"
echo -e "使用前请务必参考配置教程:\033[32;4m https://juewuy.github.io/nWTjEpkSK \033[0m"
}
override(){ #配置文件覆写
[ -z "$rule_link" ] && rule_link=1
[ -z "$server_link" ] && server_link=1
echo "-----------------------------------------------"
echo -e "\033[30;47m 欢迎使用配置文件覆写功能!\033[0m"
echo "-----------------------------------------------"
echo -e " 1 自定义\033[32m端口及秘钥\033[0m"
echo -e " 2 管理\033[36m自定义规则\033[0m"
echo "$crashcore" | grep -q 'singbox' || {
echo -e " 3 管理\033[33m自定义节点\033[0m"
echo -e " 4 管理\033[36m自定义策略组\033[0m"
}
echo -e " 5 \033[32m自定义\033[0m高级功能"
[ "$disoverride" != 1 ] && echo -e " 9 \033[33m禁用\033[0m配置文件覆写"
echo "-----------------------------------------------"
[ "$inuserguide" = 1 ] || echo -e " 0 返回上级菜单"
read -p "请输入对应数字 > " num
case "$num" in
0)
;;
1)
if [ -n "$(pidof CrashCore)" ];then
echo "-----------------------------------------------"
echo -e "\033[33m检测到服务正在运行需要先停止服务\033[0m"
read -p "是否停止服务?(1/0) > " res
if [ "$res" = "1" ];then
"$CRASHDIR"/start.sh stop
setport
fi
else
setport
fi
override
;;
2)
setrules
override
;;
3)
setproxies
override
;;
4)
setgroups
override
;;
5)
echo "$crashcore" | grep -q 'singbox' && set_singbox_adv || set_clash_adv
sleep 3
override
;;
9)
echo "-----------------------------------------------"
echo -e "\033[33m此功能可能会导致严重问题启用后脚本中大部分功能都将禁用\033[0m"
echo -e "如果你不是非常了解$crashcore的运行机制,切勿开启\033[0m"
echo -e "\033[33m继续后如出现任何问题请务必自行解决一切提问恕不受理\033[0m"
echo "-----------------------------------------------"
sleep 2
read -p "我确认遇到问题可以自行解决[1/0] > " res
[ "$res" = '1' ] && {
disoverride=1
setconfig disoverride $disoverride
echo "-----------------------------------------------"
echo -e "\033[32m设置成功\033[0m"
}
override
;;
*)
errornum
;;
esac
# 配置文件覆写
override() {
while true; do
[ -z "$rule_link" ] && rule_link=1
[ -z "$server_link" ] && server_link=1
echo "-----------------------------------------------"
echo -e "\033[30;47m 欢迎使用配置文件覆写功能!\033[0m"
echo "-----------------------------------------------"
echo -e " 1 自定义\033[32m端口及秘钥\033[0m"
echo -e " 2 管理\033[36m自定义规则\033[0m"
echo "$crashcore" | grep -q 'singbox' || {
echo -e " 3 管理\033[33m自定义节点\033[0m"
echo -e " 4 管理\033[36m自定义策略组\033[0m"
}
echo -e " 5 \033[32m自定义\033[0m高级功能"
[ "$disoverride" != 1 ] && echo -e " 9 \033[33m禁用\033[0m配置文件覆写"
echo "-----------------------------------------------"
[ "$inuserguide" = 1 ] || echo -e " 0 返回上级菜单"
read -p "请输入对应数字 > " num
case "$num" in
"" | 0)
break
;;
1)
if [ -n "$(pidof CrashCore)" ]; then
echo "-----------------------------------------------"
echo -e "\033[33m检测到服务正在运行需要先停止服务\033[0m"
read -p "是否停止服务?(1/0) > " res
if [ "$res" = "1" ]; then
"$CRASHDIR"/start.sh stop
setport
fi
else
setport
fi
;;
2)
setrules
;;
3)
setproxies
;;
4)
setgroups
;;
5)
echo "$crashcore" | grep -q 'singbox' && set_singbox_adv || set_clash_adv
sleep 3
;;
9)
echo "-----------------------------------------------"
echo -e "\033[33m此功能可能会导致严重问题启用后脚本中大部分功能都将禁用\033[0m"
echo -e "如果你不是非常了解$crashcore的运行机制,切勿开启\033[0m"
echo -e "\033[33m继续后如出现任何问题请务必自行解决一切提问恕不受理\033[0m"
echo "-----------------------------------------------"
sleep 2
read -p "我确认遇到问题可以自行解决[1/0] > " res
[ "$res" = '1' ] && {
disoverride=1
setconfig disoverride $disoverride
echo "-----------------------------------------------"
echo -e "\033[32m设置成功\033[0m"
}
;;
*)
errornum
sleep 1
break
;;
esac
done
}
gen_link_config(){ #选择在线规则
@@ -987,205 +988,206 @@ gen_core_config_link(){ #在线生成工具
fi
done
}
set_core_config_link(){ #直接导入配置
echo "-----------------------------------------------"
echo -e "\033[32m仅限导入完整的配置文件链接\033[0m"
echo "-----------------------------------------------"
echo -e "注意:\033[31m此功能不兼容“跳过证书验证”功能部分老旧\n设备可能出现x509报错导致节点不通\033[0m"
echo -e "你也可以搭配在线订阅转换网站或者自建SubStore使用"
echo "$crashcore" | grep -q 'singbox' &&echo -e "singbox内核建议使用\033[32;4mhttps://subv.jwsc.eu.org/\033[0m转换"
echo "-----------------------------------------------"
echo -e "\033[33m0 返回上级菜单\033[0m"
echo "-----------------------------------------------"
read -p "请输入完整链接 > " link
test=$(echo $link | grep -iE "tp.*://" )
link=`echo ${link/\ \(*\)/''}` #删除恶心的超链接内容
link=`echo ${link//\&/\\\&}` #处理分隔符
if [ -n "$link" -a -n "$test" ];then
echo "-----------------------------------------------"
echo -e 请检查输入的链接是否正确:
echo -e "\033[4;32m$link\033[0m"
read -p "确认导入配置文件?原配置文件将被备份![1/0] > " res
if [ "$res" = '1' ]; then
#将用户链接写入配置
Url=''
Https="$link"
setconfig Https "'$Https'"
setconfig Url
#获取在线yaml文件
jump_core_config
else
set_core_config_link
fi
elif [ "$link" = 0 ];then
i=
else
echo "-----------------------------------------------"
echo -e "\033[31m请输入正确的配置文件链接地址\033[0m"
echo -e "\033[33m仅支持http、https、ftp以及ftps链接\033[0m"
sleep 1
set_core_config_link
fi
# 直接导入配置
set_core_config_link() {
while true; do
echo "-----------------------------------------------"
echo -e "\033[32m仅限导入完整的配置文件链接\033[0m"
echo "-----------------------------------------------"
echo -e "注意:\033[31m此功能不兼容“跳过证书验证”功能部分老旧\n设备可能出现x509报错导致节点不通\033[0m"
echo -e "你也可以搭配在线订阅转换网站或者自建SubStore使用"
echo "$crashcore" | grep -q 'singbox' && echo -e "singbox内核建议使用\033[32;4mhttps://subv.jwsc.eu.org/\033[0m转换"
echo "-----------------------------------------------"
echo -e "\033[33m0 返回上级菜单\033[0m"
echo "-----------------------------------------------"
read -p "请输入完整链接 > " link
test=$(echo $link | grep -iE "tp.*://")
link=$(echo ${link/\ \(*\)/''}) # 删除恶心的超链接内容
link=$(echo ${link//\&/\\&}) # 处理分隔符
if [ -n "$link" -a -n "$test" ]; then
echo "-----------------------------------------------"
echo -e "请检查输入的链接是否正确:"
echo -e "\033[4;32m$link\033[0m"
read -p "确认导入配置文件?原配置文件将被备份![1/0] > " res
if [ "$res" = '1' ]; then
# 将用户链接写入配置
Url=''
Https="$link"
setconfig Https "'$Https'"
setconfig Url
# 获取在线yaml文件
jump_core_config
break
fi
elif [ "$link" = 0 ]; then
i=
break
else
echo "-----------------------------------------------"
echo -e "\033[31m请输入正确的配置文件链接地址\033[0m"
echo -e "\033[33m仅支持http、https、ftp以及ftps链接\033[0m"
sleep 1
fi
done
}
#配置文件主界面
set_core_config(){
[ -z "$rule_link" ] && rule_link=1
[ -z "$server_link" ] && server_link=1
echo "$crashcore" | grep -q 'singbox' && config_path="$JSONSDIR"/config.json || config_path="$YAMLSDIR"/config.yaml
echo "-----------------------------------------------"
echo -e "\033[30;47m ShellCrash配置文件管理\033[0m"
echo "-----------------------------------------------"
echo -e " 1 在线\033[32m生成配置文件\033[0m(基于Subconverter订阅转换)"
if [ -f "$CRASHDIR"/v2b_api.sh ];then
echo -e " 2 登录\033[33m获取订阅(推荐!)\033[0m"
else
echo -e " 2 在线\033[33m获取配置文件\033[0m(基于订阅提供者)"
fi
echo -e " 3 本地\033[32m生成配置文件\033[0m(基于内核providers,推荐!)"
echo -e " 4 本地\033[33m上传完整配置文件\033[0m"
echo -e " 5 设置\033[36m自动更新\033[0m"
echo -e " 6 \033[32m自定义\033[0m配置文件"
echo -e " 7 \033[33m更新\033[0m配置文件"
echo -e " 8 \033[36m还原\033[0m配置文件"
echo -e " 9 自定义浏览器UA \033[32m$user_agent\033[0m"
echo "-----------------------------------------------"
[ "$inuserguide" = 1 ] || echo -e " 0 返回上级菜单"
read -p "请输入对应数字 > " num
case "$num" in
0)
;;
1)
if [ -n "$Url" ];then
echo "-----------------------------------------------"
echo -e "\033[33m检测到已记录的链接内容\033[0m"
echo -e "\033[4;32m$Url\033[0m"
echo "-----------------------------------------------"
read -p "清空链接/追加导入?[1/0] > " res
if [ "$res" = '1' ]; then
Url_link=""
echo "-----------------------------------------------"
echo -e "\033[31m链接已清空\033[0m"
else
Url_link=$Url
fi
fi
gen_core_config_link
set_core_config
;;
2)
if [ -f "$CRASHDIR"/v2b_api.sh ];then
. "$CRASHDIR"/v2b_api.sh
set_core_config
else
set_core_config_link
fi
set_core_config
;;
3)
if [ "$crashcore" = meta -o "$crashcore" = clashpre ];then
coretype=clash
setproviders
elif [ "$crashcore" = singboxr ];then
coretype=singbox
setproviders
else
echo -e "\033[33msingbox官方内核及Clash基础内核不支持此功能请先更换内核\033[0m"
sleep 1
checkupdate && setcore
fi
set_core_config
;;
4)
echo "-----------------------------------------------"
echo -e "\033[33m请将本地配置文件上传到/tmp目录并重命名为config.yaml或者config.json\033[0m"
echo -e "\033[32m之后重新运行本脚本即可自动弹出导入提示\033[0m"
exit
;;
5)
. "$CRASHDIR"/menus/5_task.sh && task_menu
set_core_config
;;
6)
checkcfg=$(cat $CFG_PATH)
override
if [ -n "$PID" ];then
checkcfg_new=$(cat $CFG_PATH)
[ "$checkcfg" != "$checkcfg_new" ] && checkrestart
fi
set_core_config
;;
7)
if [ -z "$Url" -a -z "$Https" ];then
echo "-----------------------------------------------"
echo -e "\033[31m没有找到你的配置文件/订阅链接!请先输入链接!\033[0m"
sleep 1
set_core_config
else
echo "-----------------------------------------------"
echo -e "\033[33m当前系统记录的链接为\033[0m"
echo -e "\033[4;32m$Url$Https\033[0m"
echo "-----------------------------------------------"
read -p "确认更新配置文件?[1/0] > " res
if [ "$res" = '1' ]; then
jump_core_config
else
set_core_config
fi
fi
;;
8)
if [ ! -f ${config_path}.bak ];then
echo "-----------------------------------------------"
echo -e "\033[31m没有找到配置文件的备份\033[0m"
set_core_config
else
echo "-----------------------------------------------"
echo -e 备份文件共有"\033[32m`wc -l < ${config_path}.bak`\033[0m"行内容,当前文件共有"\033[32m`wc -l < ${config_path}`\033[0m"行内容
read -p "确认还原配置文件?此操作不可逆![1/0] > " res
if [ "$res" = '1' ]; then
mv ${config_path}.bak ${config_path}
echo "----------------------------------------------"
echo -e "\033[32m配置文件已还原请手动重启服务\033[0m"
sleep 1
else
echo "-----------------------------------------------"
echo -e "\033[31m操作已取消返回上级菜单\033[0m"
set_core_config
fi
fi
;;
9)
echo "-----------------------------------------------"
echo -e "\033[36m如果6-1或者6-2无法正确获取配置文件时可以尝试使用\033[0m"
echo -e " 1 使用自动UA"
echo -e " 2 不使用UA"
echo -e " 3 使用自定义UA\033[32m$user_agent\033[0m"
echo "-----------------------------------------------"
read -p "请输入对应数字 > " num
case "$num" in
0)
user_agent=''
;;
1)
user_agent='auto'
;;
2)
user_agent='none'
;;
3)
read -p "请输入自定义UA(不要包含空格和特殊符号!) > " text
[ -n "$text" ] && user_agent="$text"
;;
*)
errornum
;;
esac
[ "$num" -le 3 ] && setconfig user_agent "$user_agent"
set_core_config
;;
*)
errornum
;;
esac
# 配置文件主界面
set_core_config() {
while true; do
[ -z "$rule_link" ] && rule_link=1
[ -z "$server_link" ] && server_link=1
echo "$crashcore" | grep -q 'singbox' && config_path="$JSONSDIR"/config.json || config_path="$YAMLSDIR"/config.yaml
echo "-----------------------------------------------"
echo -e "\033[30;47m ShellCrash配置文件管理\033[0m"
echo "-----------------------------------------------"
echo -e " 1 在线\033[32m生成配置文件\033[0m(基于Subconverter订阅转换)"
if [ -f "$CRASHDIR"/v2b_api.sh ]; then
echo -e " 2 登录\033[33m获取订阅(推荐!)\033[0m"
else
echo -e " 2 在线\033[33m获取配置文件\033[0m(基于订阅提供者)"
fi
echo -e " 3 本地\033[32m生成配置文件\033[0m(基于内核providers,推荐!)"
echo -e " 4 本地\033[33m上传完整配置文件\033[0m"
echo -e " 5 设置\033[36m自动更新\033[0m"
echo -e " 6 \033[32m自定义\033[0m配置文件"
echo -e " 7 \033[33m更新\033[0m配置文件"
echo -e " 8 \033[36m还原\033[0m配置文件"
echo -e " 9 自定义浏览器UA \033[32m$user_agent\033[0m"
echo "-----------------------------------------------"
[ "$inuserguide" = 1 ] || echo -e " 0 返回上级菜单"
read -p "请输入对应数字 > " num
case "$num" in
"" | 0)
break
;;
1)
if [ -n "$Url" ]; then
echo "-----------------------------------------------"
echo -e "\033[33m检测到已记录的链接内容\033[0m"
echo -e "\033[4;32m$Url\033[0m"
echo "-----------------------------------------------"
read -p "清空链接/追加导入?[1/0] > " res
if [ "$res" = '1' ]; then
Url_link=""
echo "-----------------------------------------------"
echo -e "\033[31m链接已清空\033[0m"
else
Url_link=$Url
fi
fi
gen_core_config_link
;;
2)
if [ -f "$CRASHDIR"/v2b_api.sh ]; then
. "$CRASHDIR"/v2b_api.sh
else
set_core_config_link
fi
;;
3)
if [ "$crashcore" = meta -o "$crashcore" = clashpre ]; then
coretype=clash
setproviders
elif [ "$crashcore" = singboxr ]; then
coretype=singbox
setproviders
else
echo -e "\033[33msingbox官方内核及Clash基础内核不支持此功能请先更换内核\033[0m"
sleep 1
checkupdate && setcore
fi
;;
4)
echo "-----------------------------------------------"
echo -e "\033[33m请将本地配置文件上传到/tmp目录并重命名为config.yaml或者config.json\033[0m"
echo -e "\033[32m之后重新运行本脚本即可自动弹出导入提示\033[0m"
sleep 2
exit
;;
5)
. "$CRASHDIR"/menus/5_task.sh && task_menu
break
;;
6)
checkcfg=$(cat $CFG_PATH)
override
if [ -n "$PID" ]; then
checkcfg_new=$(cat $CFG_PATH)
[ "$checkcfg" != "$checkcfg_new" ] && checkrestart
fi
;;
7)
if [ -z "$Url" -a -z "$Https" ]; then
echo "-----------------------------------------------"
echo -e "\033[31m没有找到你的配置文件/订阅链接!请先输入链接!\033[0m"
sleep 1
else
echo "-----------------------------------------------"
echo -e "\033[33m当前系统记录的链接为\033[0m"
echo -e "\033[4;32m$Url$Https\033[0m"
echo "-----------------------------------------------"
read -p "确认更新配置文件?[1/0] > " res
if [ "$res" = '1' ]; then
jump_core_config
break
fi
fi
;;
8)
if [ ! -f ${config_path}.bak ]; then
echo "-----------------------------------------------"
echo -e "\033[31m没有找到配置文件的备份\033[0m"
else
echo "-----------------------------------------------"
echo -e 备份文件共有"\033[32m$(wc -l <${config_path}.bak)\033[0m"行内容,当前文件共有"\033[32m$(wc -l <${config_path})\033[0m"行内容
read -p "确认还原配置文件?此操作不可逆![1/0] > " res
if [ "$res" = '1' ]; then
mv ${config_path}.bak ${config_path}
echo "----------------------------------------------"
echo -e "\033[32m配置文件已还原请手动重启服务\033[0m"
sleep 1
break
else
echo "-----------------------------------------------"
echo -e "\033[31m操作已取消返回上级菜单\033[0m"
sleep 1
fi
fi
;;
9)
echo "-----------------------------------------------"
echo -e "\033[36m如果6-1或者6-2无法正确获取配置文件时可以尝试使用\033[0m"
echo -e " 1 使用自动UA"
echo -e " 2 不使用UA"
echo -e " 3 使用自定义UA\033[32m$user_agent\033[0m"
echo "-----------------------------------------------"
read -p "请输入对应数字 > " num
case "$num" in
0)
user_agent=''
;;
1)
user_agent='auto'
;;
2)
user_agent='none'
;;
3)
read -p "请输入自定义UA(不要包含空格和特殊符号!) > " text
[ -n "$text" ] && user_agent="$text"
;;
*)
errornum
;;
esac
[ "$num" -le 3 ] && setconfig user_agent "$user_agent"
;;
*)
errornum
sleep 1
break
;;
esac
done
}

View File

@@ -8,72 +8,74 @@ __IS_MODULE_7_GATEWAY_LOADED=1
. "$CRASHDIR"/menus/check_port.sh
. "$CRASHDIR"/libs/gen_base64.sh
#访问与控制主菜单
gateway(){
echo "-----------------------------------------------"
echo -e "\033[30;47m欢迎使用访问与控制菜单\033[0m"
echo "-----------------------------------------------"
echo -e " 1 配置\033[33m公网访问防火墙 \033[32m$fw_wan\033[0m"
echo -e " 2 配置\033[36mTelegram专属控制机器人 \033[32m$bot_tg_service\033[0m"
echo -e " 3 配置\033[36mDDNS自动域名\033[0m"
[ "$disoverride" != "1" ] && {
echo -e " 4 自定义\033[33m公网Vmess入站\033[0m节点 \033[32m$vms_service\033[0m"
echo -e " 5 自定义\033[33m公网ShadowSocks入站\033[0m节点 \033[32m$sss_service\033[0m"
echo -e " 6 配置\033[36mTailscale内网穿透\033[0m(限Singbox) \033[32m$ts_service\033[0m"
echo -e " 7 配置\033[36mWireguard客户端\033[0m(限Singbox) \033[32m$wg_service\033[0m"
}
echo -e " 0 返回上级菜单"
echo "-----------------------------------------------"
read -p "请输入对应数字 > " num
case "$num" in
0) ;;
1)
# 访问与控制主菜单
gateway() {
while true; do
echo "-----------------------------------------------"
if [ -n "$(pidof CrashCore)" ] && [ "$firewall_mod" = 'iptables' ]; then
read -p "需要先停止服务,是否继续?(1/0) > " res
[ "$res" = 1 ] && "$CRASHDIR"/start.sh stop && set_fw_wan
else
set_fw_wan
fi
gateway
;;
2)
set_bot_tg
gateway
;;
3)
. "$CRASHDIR"/menus/ddns.sh && ddns_menu
gateway
;;
4)
set_vmess
gateway
;;
5)
set_shadowsocks
gateway
;;
6)
if echo "$crashcore" | grep -q 'sing';then
set_tailscale
else
echo -e "\033[33m$crashcore内核暂不支持此功能,请先更换内核!\033[0m"
sleep 1
fi
gateway
;;
7)
if echo "$crashcore" | grep -q 'sing';then
set_wireguard
else
echo -e "\033[33m$crashcore内核暂不支持此功能,请先更换内核!\033[0m"
sleep 1
fi
gateway
;;
*) errornum ;;
esac
echo -e "\033[30;47m欢迎使用访问与控制菜单\033[0m"
echo "-----------------------------------------------"
echo -e " 1 配置\033[33m公网访问防火墙 \033[32m$fw_wan\033[0m"
echo -e " 2 配置\033[36mTelegram专属控制机器人 \033[32m$bot_tg_service\033[0m"
echo -e " 3 配置\033[36mDDNS自动域名\033[0m"
[ "$disoverride" != "1" ] && {
echo -e " 4 自定义\033[33m公网Vmess入站\033[0m节点 \033[32m$vms_service\033[0m"
echo -e " 5 自定义\033[33m公网ShadowSocks入站\033[0m节点 \033[32m$sss_service\033[0m"
echo -e " 6 配置\033[36mTailscale内网穿透\033[0m(限Singbox) \033[32m$ts_service\033[0m"
echo -e " 7 配置\033[36mWireguard客户端\033[0m(限Singbox) \033[32m$wg_service\033[0m"
}
echo -e " 0 返回上级菜单"
echo "-----------------------------------------------"
read -p "请输入对应数字 > " num
case "$num" in
"" | 0)
break
;;
1)
echo "-----------------------------------------------"
if [ -n "$(pidof CrashCore)" ] && [ "$firewall_mod" = 'iptables' ]; then
read -p "需要先停止服务,是否继续?(1/0) > " res
[ "$res" = 1 ] && "$CRASHDIR"/start.sh stop && set_fw_wan
else
set_fw_wan
fi
;;
2)
set_bot_tg
;;
3)
. "$CRASHDIR"/menus/ddns.sh && ddns_menu
;;
4)
set_vmess
;;
5)
set_shadowsocks
;;
6)
if echo "$crashcore" | grep -q 'sing'; then
set_tailscale
else
echo -e "\033[33m$crashcore内核暂不支持此功能,请先更换内核!\033[0m"
sleep 1
fi
;;
7)
if echo "$crashcore" | grep -q 'sing'; then
set_wireguard
else
echo -e "\033[33m$crashcore内核暂不支持此功能,请先更换内核!\033[0m"
sleep 1
fi
;;
*)
errornum
sleep 1
break
;;
esac
done
}
#公网防火墙
set_fw_wan() {
[ -z "$fw_wan" ] && fw_wan=ON
@@ -228,104 +230,103 @@ set_bot_tg(){
;;
esac
}
#自定义入站
set_vmess(){
echo "-----------------------------------------------"
echo -e "\033[31m注意\033[0m设置的端口会添加到公网访问防火墙并自动放行\n 脚本只提供基础功能,更多需求请用自定义配置文件功能!"
echo -e " \033[31m切勿用于搭建违法翻墙节点违者后果自负\033[0m"
echo "-----------------------------------------------"
echo -e " 1 \033[32m启用/关闭\033[0mVmess入站 \033[32m$vms_service\033[0m"
echo "-----------------------------------------------"
echo -e " 2 设置\033[36m监听端口\033[0m \033[36m$vms_port\033[0m"
echo -e " 3 设置\033[33mWS-path(可选)\033[0m \033[33m$vms_ws_path\033[0m"
echo -e " 4 设置\033[36m秘钥-uuid\033[0m \033[36m$vms_uuid\033[0m"
echo -e " 5 一键生成\033[32m随机秘钥\033[0m"
echo -e " 6 设置\033[36m混淆host(可选)\033[0m \033[33m$vms_host\033[0m"
gen_base64 1 >/dev/null 2>&1 &&
echo -e " 7 一键生成\033[32m分享链接\033[0m"
echo -e " 0 返回上级菜单 \033[0m"
echo "-----------------------------------------------"
read -p "请输入对应数字 > " num
case "$num" in
0) ;;
1)
if [ "$vms_service" = ON ];then
vms_service=OFF
setconfig vms_service "$vms_service"
else
if [ -n "$vms_port" ] && [ -n "$vms_uuid" ];then
vms_service=ON
setconfig vms_service "$vms_service"
else
echo -e "\033[31m请先完成必选设置\033[0m"
sleep 1
fi
fi
set_vmess
;;
2)
read -p "请输入端口号(输入0删除) > " text
if [ "$text" = 0 ];then
vms_port=''
setconfig vms_port "" "$GT_CFG_PATH"
elif check_port "$text"; then
vms_port="$text"
setconfig vms_port "$text" "$GT_CFG_PATH"
else
sleep 1
fi
set_vmess
;;
3)
read -p "请输入ws-path路径(输入0删除) > " text
if [ "$text" = 0 ];then
vms_ws_path=''
setconfig vms_ws_path "" "$GT_CFG_PATH"
elif echo "$text" |grep -qE '^/';then
vms_ws_path="$text"
setconfig vms_ws_path "$text" "$GT_CFG_PATH"
else
echo -e "\033[31m不是合法的path路径必须以【/】开头!\033[0m"
sleep 1
fi
set_vmess
;;
4)
read -p "请输入UUID(输入0删除) > " text
if [ "$text" = 0 ];then
vms_uuid=''
setconfig vms_uuid "" "$GT_CFG_PATH"
elif echo "$text" |grep -qiE '^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$';then
vms_uuid="$text"
setconfig vms_uuid "$text" "$GT_CFG_PATH"
else
echo -e "\033[31m不是合法的UUID格式请重新输入或使用随机生成功能\033[0m"
sleep 1
fi
set_vmess
;;
5)
vms_uuid=$(cat /proc/sys/kernel/random/uuid)
setconfig vms_uuid "$vms_uuid" "$GT_CFG_PATH"
sleep 1
set_vmess
;;
6)
read -p "请输入免流混淆host(输入0删除) > " text
if [ "$text" = 0 ];then
vms_host=''
setconfig vms_host "" "$GT_CFG_PATH"
else
vms_host="$text"
setconfig vms_host "$text" "$GT_CFG_PATH"
fi
set_vmess
;;
7)
read -p "请输入本机公网IP(4/6)或域名 > " host_wan
if [ -n "$host_wan" ] && [ -n "$vms_port" ] && [ -n "$vms_uuid" ];then
[ -n "$vms_ws_path" ] && vms_net=ws
vms_json=$(cat <<EOF
# 自定义入站
set_vmess() {
while true; do
echo "-----------------------------------------------"
echo -e "\033[31m注意\033[0m设置的端口会添加到公网访问防火墙并自动放行\n 脚本只提供基础功能,更多需求请用自定义配置文件功能!"
echo -e " \033[31m切勿用于搭建违法翻墙节点违者后果自负\033[0m"
echo "-----------------------------------------------"
echo -e " 1 \033[32m启用/关闭\033[0mVmess入站 \033[32m$vms_service\033[0m"
echo "-----------------------------------------------"
echo -e " 2 设置\033[36m监听端口\033[0m \033[36m$vms_port\033[0m"
echo -e " 3 设置\033[33mWS-path(可选)\033[0m \033[33m$vms_ws_path\033[0m"
echo -e " 4 设置\033[36m秘钥-uuid\033[0m \033[36m$vms_uuid\033[0m"
echo -e " 5 一键生成\033[32m随机秘钥\033[0m"
echo -e " 6 设置\033[36m混淆host(可选)\033[0m \033[33m$vms_host\033[0m"
gen_base64 1 >/dev/null 2>&1 &&
echo -e " 7 一键生成\033[32m分享链接\033[0m"
echo -e " 0 返回上级菜单 \033[0m"
echo "-----------------------------------------------"
read -p "请输入对应数字 > " num
case "$num" in
"" | 0)
break
;;
1)
if [ "$vms_service" = ON ]; then
vms_service=OFF
setconfig vms_service "$vms_service"
else
if [ -n "$vms_port" ] && [ -n "$vms_uuid" ]; then
vms_service=ON
setconfig vms_service "$vms_service"
else
echo -e "\033[31m请先完成必选设置\033[0m"
sleep 1
fi
fi
;;
2)
read -p "请输入端口号(输入0删除) > " text
if [ "$text" = 0 ]; then
vms_port=''
setconfig vms_port "" "$GT_CFG_PATH"
elif check_port "$text"; then
vms_port="$text"
setconfig vms_port "$text" "$GT_CFG_PATH"
else
sleep 1
fi
;;
3)
read -p "请输入ws-path路径(输入0删除) > " text
if [ "$text" = 0 ]; then
vms_ws_path=''
setconfig vms_ws_path "" "$GT_CFG_PATH"
elif echo "$text" | grep -qE '^/'; then
vms_ws_path="$text"
setconfig vms_ws_path "$text" "$GT_CFG_PATH"
else
echo -e "\033[31m不是合法的path路径必须以【/】开头!\033[0m"
sleep 1
fi
;;
4)
read -p "请输入UUID(输入0删除) > " text
if [ "$text" = 0 ]; then
vms_uuid=''
setconfig vms_uuid "" "$GT_CFG_PATH"
elif echo "$text" | grep -qiE '^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$'; then
vms_uuid="$text"
setconfig vms_uuid "$text" "$GT_CFG_PATH"
else
echo -e "\033[31m不是合法的UUID格式请重新输入或使用随机生成功能\033[0m"
sleep 1
fi
;;
5)
vms_uuid=$(cat /proc/sys/kernel/random/uuid)
setconfig vms_uuid "$vms_uuid" "$GT_CFG_PATH"
sleep 1
;;
6)
read -p "请输入免流混淆host(输入0删除) > " text
if [ "$text" = 0 ]; then
vms_host=''
setconfig vms_host "" "$GT_CFG_PATH"
else
vms_host="$text"
setconfig vms_host "$text" "$GT_CFG_PATH"
fi
;;
7)
read -p "请输入本机公网IP(4/6)或域名 > " host_wan
if [ -n "$host_wan" ] && [ -n "$vms_port" ] && [ -n "$vms_uuid" ]; then
[ -n "$vms_ws_path" ] && vms_net=ws
vms_json=$(
cat <<EOF
{
"v": "2",
"ps": "ShellCrash_vms_in",
@@ -339,19 +340,24 @@ set_vmess(){
"host": "$vms_host"
}
EOF
)
vms_link="vmess://$(gen_base64 "$vms_json")"
echo "-----------------------------------------------"
echo -e "你的分享链接是(请勿随意分享给他人):\n\033[32m$vms_link\033[0m"
else
echo -e "\033[31m请先完成必选设置\033[0m"
fi
sleep 1
set_vmess
;;
*) errornum ;;
esac
)
vms_link="vmess://$(gen_base64 "$vms_json")"
echo "-----------------------------------------------"
echo -e "你的分享链接是(请勿随意分享给他人):\n\033[32m$vms_link\033[0m"
else
echo -e "\033[31m请先完成必选设置\033[0m"
fi
sleep 1
;;
*)
errornum
sleep 1
break
;;
esac
done
}
set_shadowsocks(){
echo "-----------------------------------------------"
echo -e "\033[31m注意\033[0m设置的端口会添加到公网访问防火墙并自动放行\n 脚本只提供基础功能,更多需求请用自定义配置文件功能!"

File diff suppressed because it is too large Load Diff

View File

@@ -181,8 +181,9 @@ set_common_ports() {
}
set_cust_host_ipv4() { #自定义ipv4透明路由网段
[ -z "$replace_default_host_ipv4" ] && replace_default_host_ipv4="OFF"
. "$CRASHDIR"/starts/fw_getlanip.sh && getlanip
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 "-----------------------------------------------"
echo -e " 1 移除所有自定义网段"

View File

@@ -1,6 +1,6 @@
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 #用于延迟启动的校验
start_time=$(cat "$TMPDIR"/crash_start_time)

View File

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

View File

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

View File

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

View File

@@ -2,8 +2,8 @@
getlanip() { #获取局域网host地址
i=1
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局域网网段
[ "$ipv6_redir" = "ON" ] && host_ipv6=$(ip a 2>&1 | grep -w 'inet6' | grep -E 'global' | sed 's/.*inet6.//g' | sed 's/scope.*$//g') #ipv6公网地址段
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 -6 route show | grep 'default' | awk '{print $3}') #ipv6公网地址段
[ -f "$TMPDIR"/ShellCrash.log ] && break
[ -n "$host_ipv4" -a "$ipv6_redir" != "ON" ] && break
[ -n "$host_ipv4" -a -n "$host_ipv6" ] && break

View File

@@ -1,6 +1,9 @@
#!/bin/sh
# 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通用工具
#$1:iptables/ip6tables $2:所在的表(nat/mangle) $3:所在的链(OUTPUT/PREROUTING) $4:新创建的shellcrash链表 $5:tcp/udp/all
#区分ipv4/ipv6
@@ -28,7 +31,10 @@ start_ipt_route() { #iptables-route通用工具
"$1" $w -t "$2" -A "$4" -m owner --gid-owner $gid -j RETURN
done
[ "$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
"$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"
}
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(){
$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
@@ -141,7 +145,7 @@ start_ipt_wan() { #iptables公网防火墙
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 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
}
#端口拦截
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 ip6 saddr {$HOST_IP6} accept
nft add rule inet shellcrash input tcp dport $reject_ports reject

View File

@@ -55,8 +55,8 @@ ckcmd iptables && {
done
$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 tcp -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,$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" -j REJECT 2>/dev/null
#清理shellcrash自建表
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
@@ -105,8 +105,8 @@ ckcmd ip6tables && {
done
$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 tcp -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,$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" -j REJECT 2>/dev/null
#清理shellcrash自建表
for text in shellcrashv6_dns shellcrashv6 shellcrashv6_out; do
$ip6table -t nat -F "$text" 2>/dev/null

View File

@@ -200,20 +200,21 @@ EOF
EOF
#生成add_route.json
#域名嗅探配置
[ "$sniffer" = ON ] && sniffer_set='{ "action": "sniff", "timeout": "500ms" },'
[ "$ts_service" = ON ] && tailscale_set='{ "inbound": [ "ts-ep" ], "port": 53, "action": "hijack-dns" },'
[ "$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" },'
sed -i '/"clash_mode".*"outbound"/d' "$CRASHDIR"/jsons/*.json
cat >"$TMPDIR"/jsons/add_route.json <<EOF
{
"route": {
"default_domain_resolver": "dns_resolver",
"default_domain_resolver": "dns_resolver",
"default_mark": $routing_mark,
"rules": [
{ "inbound": [ "dns-in" ], "action": "hijack-dns" },
$tailscale_set
$sniffer_set
{ "clash_mode": "Direct" , "outbound": "DIRECT" },
{ "clash_mode": "Global" , "outbound": "GLOBAL" }
]
"rules": [
{ "inbound": [ "dns-in" ], "action": "hijack-dns" },
$tailscale_set
$sniffer_set
{ "clash_mode": [ "Direct" ] , "outbound": "DIRECT" },
{ "clash_mode": [ "Global" ], "outbound": "GLOBAL" }
]
}
}
EOF

View File

@@ -7,6 +7,7 @@ else
sleep 2
kill $! >/dev/null 2>&1
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 "$error" 31

View File

@@ -2,16 +2,14 @@
. "$CRASHDIR"/libs/check_cmd.sh
start_legacy(){
ckcmd nohup && _nohup=nohup
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
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"
else
$1 >/dev/null 2>&1 &
$_nohup $1 >/dev/null 2>&1 &
echo $! > "/tmp/ShellCrash/$2.pid"
fi
}

View File

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