Merge pull request #1126 from sofia-riese/patch-5

style(8_tools): format code with shfmt
This commit is contained in:
juewuy
2026-01-15 17:05:49 +08:00
committed by GitHub

View File

@@ -28,7 +28,7 @@ ssh_tools() {
echo "-----------------------------------------------" echo "-----------------------------------------------"
read -p "请输入对应数字 > " num read -p "请输入对应数字 > " num
case "$num" in case "$num" in
""|0) "" | 0)
break break
;; ;;
1) 1)
@@ -77,10 +77,10 @@ ssh_tools() {
done done
} }
#工具与优化 # 工具与优化
tools() { tools() {
while true; do while true; do
#获取设置默认显示 # 获取设置默认显示
grep -qE "^\s*[^#].*otapredownload" /etc/crontabs/root >/dev/null 2>&1 && mi_update=禁用 || mi_update=启用 grep -qE "^\s*[^#].*otapredownload" /etc/crontabs/root >/dev/null 2>&1 && mi_update=禁用 || mi_update=启用
[ "$mi_mi_autoSSH" = "已配置" ] && mi_mi_autoSSH_type=32m已配置 || mi_mi_autoSSH_type=31m未配置 [ "$mi_mi_autoSSH" = "已配置" ] && mi_mi_autoSSH_type=32m已配置 || mi_mi_autoSSH_type=31m未配置
[ -f "$CRASHDIR"/tools/tun.ko ] && mi_tunfix=32mON || mi_tunfix=31mOFF [ -f "$CRASHDIR"/tools/tun.ko ] && mi_tunfix=32mON || mi_tunfix=31mOFF
@@ -103,7 +103,7 @@ tools() {
echo "-----------------------------------------------" echo "-----------------------------------------------"
read -p "请输入对应数字 > " num read -p "请输入对应数字 > " num
case "$num" in case "$num" in
""|0) "" | 0)
break break
;; ;;
1) 1)
@@ -219,7 +219,7 @@ mi_autoSSH() {
sleep 1 sleep 1
} }
#日志菜单 # 日志菜单
log_pusher() { log_pusher() {
while true; do while true; do
[ -n "$push_TG" ] && stat_TG=32mON || stat_TG=33mOFF [ -n "$push_TG" ] && stat_TG=32mON || stat_TG=33mOFF
@@ -249,7 +249,7 @@ log_pusher() {
echo "-----------------------------------------------" echo "-----------------------------------------------"
read -p "请输入对应数字 > " num read -p "请输入对应数字 > " num
case "$num" in case "$num" in
""|0) "" | 0)
break break
;; ;;
1) 1)
@@ -496,8 +496,8 @@ log_pusher() {
done done
} }
#测试菜单 # 测试菜单
testcommand(){ testcommand() {
echo "$crashcore" | grep -q 'singbox' && config_path=${JSONSDIR}/config.json || config_path=${YAMLSDIR}/config.yaml echo "$crashcore" | grep -q 'singbox' && config_path=${JSONSDIR}/config.json || config_path=${YAMLSDIR}/config.yaml
echo "-----------------------------------------------" echo "-----------------------------------------------"
echo -e "\033[30;47m这里是测试命令菜单\033[0m" echo -e "\033[30;47m这里是测试命令菜单\033[0m"
@@ -522,19 +522,19 @@ testcommand(){
;; ;;
2) 2)
echo "-----------------------------------------------" echo "-----------------------------------------------"
netstat -ntulp |grep 53 netstat -ntulp | grep 53
echo "-----------------------------------------------" echo "-----------------------------------------------"
echo -e "可以使用\033[44m netstat -ntulp |grep xxx \033[0m来查询任意(xxx)端口" echo -e "可以使用\033[44m netstat -ntulp |grep xxx \033[0m来查询任意(xxx)端口"
exit; exit
;; ;;
3) 3)
echo "-----------------------------------------------" echo "-----------------------------------------------"
openssl speed -multi 4 -evp aes-128-gcm openssl speed -multi 4 -evp aes-128-gcm
echo "-----------------------------------------------" echo "-----------------------------------------------"
exit; exit
;; ;;
4) 4)
if [ "$firewall_mod" = "nftables" ];then if [ "$firewall_mod" = "nftables" ]; then
nft list table inet shellcrash | sed '/set cn_ip {/,/}/d;/set cn_ip6 {/,/}/d;/^[[:space:]]*}/d' nft list table inet shellcrash | sed '/set cn_ip {/,/}/d;/set cn_ip6 {/,/}/d;/^[[:space:]]*}/d'
else else
[ "$firewall_area" = 1 -o "$firewall_area" = 3 -o "$firewall_area" = 5 -o "$vm_redir" = "ON" ] && { [ "$firewall_area" = 1 -o "$firewall_area" = 3 -o "$firewall_area" = 5 -o "$vm_redir" = "ON" ] && {
@@ -582,20 +582,26 @@ testcommand(){
echo "----------------本机防火墙---------------------" echo "----------------本机防火墙---------------------"
iptables -L INPUT --line-numbers iptables -L INPUT --line-numbers
fi fi
exit; exit
;; ;;
5) 5)
echo "-----------------------------------------------" echo "-----------------------------------------------"
sed -n '1,40p' ${config_path} sed -n '1,40p' ${config_path}
echo "-----------------------------------------------" echo "-----------------------------------------------"
exit; exit
;; ;;
6) 6)
echo "注意依赖curl(不支持wget),且测试结果不保证一定准确!" echo "注意依赖curl(不支持wget),且测试结果不保证一定准确!"
delay=`curl -kx ${authentication}@127.0.0.1:$mix_port -o /dev/null -s -w '%{time_starttransfer}' 'https://google.tw' & { sleep 3 ; kill $! >/dev/null 2>&1 & }` > /dev/null 2>&1 delay=$(
delay=`echo |awk "{print $delay*1000}"` > /dev/null 2>&1 curl -kx ${authentication}@127.0.0.1:$mix_port -o /dev/null -s -w '%{time_starttransfer}' 'https://google.tw' &
{
sleep 3
kill $! >/dev/null 2>&1 &
}
) >/dev/null 2>&1
delay=$(echo | awk "{print $delay*1000}") >/dev/null 2>&1
echo "-----------------------------------------------" echo "-----------------------------------------------"
if [ `echo ${#delay}` -gt 1 ];then if [ $(echo ${#delay}) -gt 1 ]; then
echo -e "\033[32m连接成功响应时间为"$delay" ms\033[0m" echo -e "\033[32m连接成功响应时间为"$delay" ms\033[0m"
else else
echo -e "\033[31m连接超时请重试或检查节点配置\033[0m" echo -e "\033[31m连接超时请重试或检查节点配置\033[0m"
@@ -608,7 +614,8 @@ testcommand(){
;; ;;
esac esac
} }
debug(){
debug() {
echo "$crashcore" | grep -q 'singbox' && config_tmp="$TMPDIR"/jsons || config_tmp="$TMPDIR"/config.yaml echo "$crashcore" | grep -q 'singbox' && config_tmp="$TMPDIR"/jsons || config_tmp="$TMPDIR"/config.yaml
echo "-----------------------------------------------" echo "-----------------------------------------------"
echo -e "\033[36m注意Debug运行均会停止原本的内核服务\033[0m" echo -e "\033[36m注意Debug运行均会停止原本的内核服务\033[0m"
@@ -633,9 +640,12 @@ debug(){
1) 1)
"$CRASHDIR"/start.sh stop "$CRASHDIR"/start.sh stop
"$CRASHDIR"/start.sh bfstart "$CRASHDIR"/start.sh bfstart
if echo "$crashcore" | grep -q 'singbox' ;then if echo "$crashcore" | grep -q 'singbox'; then
"$TMPDIR"/CrashCore run -D "$BINDIR" -C "$TMPDIR"/jsons & "$TMPDIR"/CrashCore run -D "$BINDIR" -C "$TMPDIR"/jsons &
{ sleep 4 ; kill $! >/dev/null 2>&1 & } {
sleep 4
kill $! >/dev/null 2>&1 &
}
wait wait
else else
"$TMPDIR"/CrashCore -t -d "$BINDIR" -f "$TMPDIR"/config.yaml "$TMPDIR"/CrashCore -t -d "$BINDIR" -f "$TMPDIR"/config.yaml
@@ -684,4 +694,3 @@ debug(){
;; ;;
esac esac
} }