mirror of
https://github.com/juewuy/ShellCrash.git
synced 2026-03-13 17:01:38 +00:00
Merge branch 'dev' of https://github.com/juewuy/ShellCrash into dev
This commit is contained in:
@@ -105,6 +105,7 @@ set_fw_filter() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
set_common_ports() {
|
set_common_ports() {
|
||||||
|
while true; do
|
||||||
[ -z "$multiport" ] && multiport='22,80,443,8080,8443'
|
[ -z "$multiport" ] && multiport='22,80,443,8080,8443'
|
||||||
echo "-----------------------------------------------"
|
echo "-----------------------------------------------"
|
||||||
echo -e "\033[31m注意:\033[0mMIX模式下,所有fake-ip来源的非常用端口流量不会被过滤"
|
echo -e "\033[31m注意:\033[0mMIX模式下,所有fake-ip来源的非常用端口流量不会被过滤"
|
||||||
@@ -118,24 +119,26 @@ set_common_ports() {
|
|||||||
echo -e " 5 重置为旧版放行端口"
|
echo -e " 5 重置为旧版放行端口"
|
||||||
echo -e " 0 返回上级菜单"
|
echo -e " 0 返回上级菜单"
|
||||||
echo "-----------------------------------------------"
|
echo "-----------------------------------------------"
|
||||||
read -p "请输入对应数字 > " num
|
read -r -p "请输入对应数字 > " num
|
||||||
case $num in
|
case "$num" in
|
||||||
|
"" | 0)
|
||||||
|
break
|
||||||
|
;;
|
||||||
1)
|
1)
|
||||||
if [ "$common_ports" = ON ];then
|
if [ "$common_ports" = ON ]; then
|
||||||
common_ports=OFF
|
common_ports=OFF
|
||||||
else
|
else
|
||||||
common_ports=ON
|
common_ports=ON
|
||||||
fi
|
fi
|
||||||
setconfig common_ports "$common_ports"
|
setconfig common_ports "$common_ports"
|
||||||
set_common_ports
|
|
||||||
;;
|
;;
|
||||||
2)
|
2)
|
||||||
port_count=$(echo "$multiport" | awk -F',' '{print NF}' )
|
port_count=$(echo "$multiport" | awk -F',' '{print NF}')
|
||||||
if [ "$port_count" -ge 15 ];then
|
if [ "$port_count" -ge 15 ]; then
|
||||||
echo -e "\033[31m最多支持设置放行15个端口,请先减少一些!\033[0m"
|
echo -e "\033[31m最多支持设置放行15个端口,请先减少一些!\033[0m"
|
||||||
else
|
else
|
||||||
read -p "请输入要放行的端口号 > " port
|
read -r -p "请输入要放行的端口号 > " port
|
||||||
if echo ",$multiport," | grep -q ",$port,";then
|
if echo ",$multiport," | grep -q ",$port,"; then
|
||||||
echo -e "\033[31m输入错误!请勿重复添加!\033[0m"
|
echo -e "\033[31m输入错误!请勿重复添加!\033[0m"
|
||||||
elif [ "$port" -lt 1 ] || [ "$port" -gt 65535 ]; then
|
elif [ "$port" -lt 1 ] || [ "$port" -gt 65535 ]; then
|
||||||
echo -e "\033[31m输入错误!请输入正确的数值(1-65535)!\033[0m"
|
echo -e "\033[31m输入错误!请输入正确的数值(1-65535)!\033[0m"
|
||||||
@@ -145,11 +148,10 @@ set_common_ports() {
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
sleep 1
|
sleep 1
|
||||||
set_common_ports
|
|
||||||
;;
|
;;
|
||||||
3)
|
3)
|
||||||
read -p "请输入要移除的端口号 > " port
|
read -r -p "请输入要移除的端口号 > " port
|
||||||
if echo ",$multiport," | grep -q ",$port,";then
|
if echo ",$multiport," | grep -q ",$port,"; then
|
||||||
if [ "$port" -lt 1 ] || [ "$port" -gt 65535 ]; then
|
if [ "$port" -lt 1 ] || [ "$port" -gt 65535 ]; then
|
||||||
echo -e "\033[31m输入错误!请输入正确的数值(1-65535)!\033[0m"
|
echo -e "\033[31m输入错误!请输入正确的数值(1-65535)!\033[0m"
|
||||||
else
|
else
|
||||||
@@ -160,25 +162,25 @@ set_common_ports() {
|
|||||||
echo -e "\033[31m输入错误!请输入已添加过的端口!\033[0m"
|
echo -e "\033[31m输入错误!请输入已添加过的端口!\033[0m"
|
||||||
fi
|
fi
|
||||||
sleep 1
|
sleep 1
|
||||||
set_common_ports
|
|
||||||
;;
|
;;
|
||||||
4)
|
4)
|
||||||
multiport=''
|
multiport=''
|
||||||
setconfig multiport
|
setconfig multiport
|
||||||
sleep 1
|
sleep 1
|
||||||
set_common_ports
|
|
||||||
;;
|
;;
|
||||||
5)
|
5)
|
||||||
multiport='22,80,143,194,443,465,587,853,993,995,5222,8080,8443'
|
multiport='22,80,143,194,443,465,587,853,993,995,5222,8080,8443'
|
||||||
setconfig multiport "$multiport"
|
setconfig multiport "$multiport"
|
||||||
sleep 1
|
sleep 1
|
||||||
set_common_ports
|
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
errornum
|
errornum
|
||||||
|
sleep 1
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
set_cust_host_ipv4() { #自定义ipv4透明路由网段
|
set_cust_host_ipv4() { #自定义ipv4透明路由网段
|
||||||
[ -z "$replace_default_host_ipv4" ] && replace_default_host_ipv4="OFF"
|
[ -z "$replace_default_host_ipv4" ] && replace_default_host_ipv4="OFF"
|
||||||
. "$CRASHDIR"/starts/fw_getlanip.sh && getlanip
|
. "$CRASHDIR"/starts/fw_getlanip.sh && getlanip
|
||||||
|
|||||||
@@ -14,10 +14,35 @@ FULL_EQ="=======================================================================
|
|||||||
FULL_DASH="- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - "
|
FULL_DASH="- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - "
|
||||||
|
|
||||||
# function to print content lines
|
# function to print content lines
|
||||||
# (using cursor jump)
|
# (using cursor jump with auto-wrapping and color handling)
|
||||||
content_line() {
|
content_line() {
|
||||||
local param="${1:-}"
|
local param="${1:-}"
|
||||||
echo -e " ${param}\033[${TABLE_WIDTH}G||"
|
|
||||||
|
# Calculate Available Text Width
|
||||||
|
local text_width=$((TABLE_WIDTH - 3))
|
||||||
|
|
||||||
|
# 1. Extract color codes (if present)
|
||||||
|
# Use sed to capture the leading ANSI Escape Code (\x1b is the hexadecimal representation of ESC)
|
||||||
|
# This line extracts \033[33m... from \033[33m and stores it in color_code
|
||||||
|
local color_code
|
||||||
|
color_code=$(echo -e "$param" | sed -n 's/^\(\x1b\[[0-9;]*m\).*/\1/p')
|
||||||
|
|
||||||
|
# 2. Generate Clean Text
|
||||||
|
# Use sed to remove all ANSI color codes, retaining only plain text content
|
||||||
|
# This allows fold to accurately count characters without premature line breaks
|
||||||
|
local clean_text
|
||||||
|
clean_text=$(echo -e "$param" | sed 's/\x1b\[[0-9;]*m//g')
|
||||||
|
|
||||||
|
if [ -z "$clean_text" ]; then
|
||||||
|
echo -e " \033[${TABLE_WIDTH}G||"
|
||||||
|
else
|
||||||
|
# 3. Insert line breaks in plain text
|
||||||
|
echo "$clean_text" | fold -s -w "$text_width" | while IFS= read -r line; do
|
||||||
|
# 4. Output Restructuring
|
||||||
|
# Force the addition of color_code to each line and append \033[0m to reset at the end
|
||||||
|
echo -e " ${color_code}${line}\033[0m\033[${TABLE_WIDTH}G||"
|
||||||
|
done
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# function to print sub content lines
|
# function to print sub content lines
|
||||||
|
|||||||
Reference in New Issue
Block a user