~Fix i18n support for 2_settings.sh

This commit is contained in:
juewuy
2026-01-17 20:08:11 +08:00
parent 23040b3570
commit 040accdef0
17 changed files with 184 additions and 168 deletions

View File

@@ -11,7 +11,7 @@ startover() {
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
if [ "$firewall_area" = 4 ]; then
echo "-----------------------------------------------"
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}"

View File

@@ -141,8 +141,7 @@ 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='纯净模式'
[ -z "$redir_mod" ] && redir_mod='Redir'
firewall_area_dsc=$(echo "$SET_FW_AREA_DESC($bypass_host)" | cut -d'|' -f$firewall_area)
echo "-----------------------------------------------"
echo -e "$SET_REDIR_CURRENT \033[47;30m$redir_mod\033[0m ; $SET_CORE_CURRENT \033[47;30m$crashcore\033[0m"
@@ -172,50 +171,50 @@ set_redir_mod() {
break
;;
1)
redir_mod=Redir模式
redir_mod=Redir
set_redir_config
;;
2)
if [ -n "$sup_tun" ]; then
redir_mod=混合模式
redir_mod=Mix
set_redir_config
else
echo -e "\033[31m设备未检测到Tun内核模块请尝试其他模式或者安装相关依赖\033[0m"
echo -e "\033[31m${SET_NO_MOD}TUN$SET_NO_MOD2\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
read -p "$XIAOMI_QOS(1/0) > " res
[ "$res" = '1' ] && {
/data/shellcrash_init.sh tproxyfix
redir_mod=Tproxy模式
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模式
redir_mod=Tproxy
set_redir_config
else
echo -e "\033[31m设备未检测到iptables-mod-tproxy模块请尝试其他模式或者安装相关依赖\033[0m"
echo -e "\033[31m${SET_NO_MOD}iptables-mod-tproxy$SET_NO_MOD2\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模式
redir_mod=Tproxy
set_redir_config
else
echo -e "\033[31m设备未检测到nft_tproxy内核模块请尝试其他模式或者安装相关依赖\033[0m"
echo -e "\033[31m${SET_NO_MOD}nft_tproxy$SET_NO_MOD2\033[0m"
sleep 1
fi
fi
;;
4)
if [ -n "$sup_tun" ]; then
redir_mod=Tun模式
redir_mod=Tun
set_redir_config
else
echo -e "\033[31m设备未检测到Tun内核模块请尝试其他模式或者安装相关依赖\033[0m"
echo -e "\033[31m$SET_NO_TUN\033[0m"
sleep 1
fi
;;
@@ -237,28 +236,28 @@ set_redir_mod() {
if [ "$firewall_mod" = 'iptables' ]; then
if nft add table inet shellcrash 2>/dev/null; then
firewall_mod=nftables
redir_mod=Redir模式
redir_mod=Redir
setconfig redir_mod $redir_mod
else
echo -e "\033[31m当前设备未安装nftables或者nftables版本过低(<1.0.2),无法切换!\033[0m"
echo -e "\033[31m$FW_NO_NFTABLES\033[0m"
fi
elif [ "$firewall_mod" = 'nftables' ]; then
if ckcmd iptables; then
firewall_mod=iptables
redir_mod=Redir模式
redir_mod=Redir
setconfig redir_mod $redir_mod
else
echo -e "\033[31m当前设备未安装iptables,无法切换!\033[0m"
echo -e "\033[31m$FW_NO_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模式
redir_mod=Redir
setconfig redir_mod $redir_mod
setconfig firewall_mod $firewall_mod
else
echo -e "\033[31m检测不到可用的防火墙应用(iptables/nftables),无法切换!\033[0m"
echo -e "\033[31m$FW_NO_FIREWALL_BACKEND\033[0m"
fi
fi
sleep 1
@@ -274,14 +273,14 @@ set_redir_mod() {
}
inputport() {
read -p "请输入端口号(1-65535) > " portx
read -p "$INPUT_PORT(1-65535) > " portx
. "$CRASHDIR"/menus/check_port.sh # 加载测试函数
if check_port "$portx"; then
setconfig "$xport" "$portx"
echo -e "\033[32m设置成功!!!\033[0m"
echo -e "\033[32m$COMMON_SUCCESS\033[0m"
return 0
else
echo -e "\033[31m设置失败!!!\033[0m"
echo -e "\033[31m$COMMON_FAILED\033[0m"
sleep 1
return 1
fi
@@ -290,146 +289,118 @@ inputport() {
# 端口设置
set_adv_config() {
while true; do
. "$CFG_PATH" >/dev/null
[ -z "$secret" ] && secret="$COMMON_UNSET"
[ -z "$table" ] && table=100
[ -z "$authentication" ] && auth="$COMMON_UNSET" || auth="******"
. "$CFG_PATH" >/dev/null
[ -z "$secret" ] && secret="$COMMON_UNSET"
[ -z "$table" ] && table=100
[ -z "$authentication" ] && auth="$COMMON_UNSET" || auth="******"
echo "-----------------------------------------------"
echo -e " 1 $ADV_HTTP_PORT:\t\033[36m$mix_port\033[0m"
echo -e " 2 $ADV_HTTP_AUTH:\t\033[36m$auth\033[0m"
echo -e " 3 $ADV_REDIR_PORT:\t\033[36m$redir_port,$((redir_port+1))\033[0m"
echo -e " 4 $ADV_DNS_PORT:\t\033[36m$dns_port\033[0m"
echo -e " 5 $ADV_PANEL_PORT:\t\033[36m$db_port\033[0m"
echo -e " 6 $ADV_PANEL_PASS:\t\033[36m$secret\033[0m"
echo -e " 8 $ADV_HOST:\t\033[36m$host\033[0m"
echo -e " 9 $ADV_TABLE:\t\033[36m$table,$((table+1))\033[0m"
echo -e " 0 $COMMON_BACK"
read -p "$COMMON_INPUT > " num
echo "-----------------------------------------------"
echo -e " 1 $ADV_HTTP_PORT:\t\033[36m$mix_port\033[0m"
echo -e " 2 $ADV_HTTP_AUTH:\t\033[36m$auth\033[0m"
echo -e " 3 $ADV_REDIR_PORT:\t\033[36m$redir_port,$((redir_port+1))\033[0m"
echo -e " 4 $ADV_DNS_PORT:\t\033[36m$dns_port\033[0m"
echo -e " 5 $ADV_PANEL_PORT:\t\033[36m$db_port\033[0m"
echo -e " 6 $ADV_PANEL_PASS:\t\033[36m$secret\033[0m"
echo -e " 8 $ADV_HOST:\t\033[36m$host\033[0m"
echo -e " 9 $ADV_TABLE:\t\033[36m$table,$((table+1))\033[0m"
echo -e " 0 $COMMON_BACK"
read -p "$COMMON_INPUT > " num
case "$num" in
case "$num" in
"" | 0)
break
;;
;;
1)
xport=mix_port
inputport
ret=$?
if [ "$ret" -eq 1 ]; then
break
else
continue
fi
;;
[ $? -eq 1 ] && break || continue
;;
2)
echo "-----------------------------------------------"
echo -e "格式必须是\033[32m 用户名:密码 \033[0m的形式注意用小写冒号分隔"
echo -e "请尽量不要使用特殊符号!避免产生未知错误!"
echo "输入 0 删除密码"
echo -e "$ADV_AUTH_FORMAT_DESC"
echo -e "$ADV_AUTH_WARN"
echo -e "$ADV_AUTH_REMOVE_HINT"
echo "-----------------------------------------------"
read -p "请输入Http/Sock5用户名及密码 > " input
read -p "$ADV_AUTH_INPUT > " input
if [ "$input" = "0" ]; then
authentication=""
setconfig authentication
echo "密码已移除!"
echo -e "\033[32m$ADV_AUTH_REMOVED\033[0m"
else
if [ "$local_proxy" = "ON" ] && [ "$local_type" = "环境变量" ]; then
if [ "$local_proxy" = "ON" ] && [ "$local_type" = "$LOCAL_TYPE_ENV" ]; then
echo "-----------------------------------------------"
echo -e "\033[33m请先禁用本机劫持功能或使用增强模式!\033[0m"
echo -e "\033[33m$ADV_AUTH_ENV_CONFLICT\033[0m"
sleep 1
else
authentication=$(echo "$input" | grep :)
if [ -n "$authentication" ]; then
setconfig authentication "'$authentication'"
echo -e "\033[32m设置成功!!!\033[0m"
echo -e "\033[32m$COMMON_SUCCESS\033[0m"
else
echo -e "\033[31m输入有误,请重新输入!\033[0m"
echo -e "\033[31m$ADV_AUTH_INVALID\033[0m"
fi
fi
fi
ret=$?
if [ "$ret" -eq 1 ]; then
break
else
continue
fi
;;
;;
3)
xport=redir_port
inputport
ret=$?
if [ "$ret" -eq 1 ]; then
break
else
continue
fi
;;
[ $? -eq 1 ] && break || continue
;;
4)
xport=dns_port
inputport
ret=$?
if [ "$ret" -eq 1 ]; then
break
else
continue
fi
;;
[ $? -eq 1 ] && break || continue
;;
5)
xport=db_port
inputport
ret=$?
if [ "$ret" -eq 1 ]; then
break
else
continue
fi
;;
6)
read -p "$ADV_PANEL_PASS_INPUT > " secret
[ $? -eq 1 ] && break || continue
;;
6)
read -p "$ADV_PANEL_PASS_INPUT > " secret
if [ -n "$secret" ]; then
[ "$secret" = "0" ] && secret=""
setconfig secret "$secret"
echo -e "\033[32m$COMMON_SUCCESS\033[0m"
setconfig secret "$secret"
echo -e "\033[32m$COMMON_SUCCESS\033[0m"
fi
;;
;;
8)
echo "-----------------------------------------------"
echo -e "\033[33m如果你的局域网网段不是192.168.x或172.16.x或10.x开头请务必修改\033[0m"
echo -e "\033[31m设置后如本机host地址有变动请务必重新修改\033[0m"
echo -e "\033[33m$ADV_HOST_WARN_LAN\033[0m"
echo -e "\033[31m$ADV_HOST_WARN_CHANGE\033[0m"
echo "-----------------------------------------------"
read -p "请输入自定义host地址(输入0移除自定义host) > " host
read -p "$ADV_HOST_INPUT > " host
if [ "$host" = "0" ]; then
host=""
setconfig host "$host"
echo -e "\033[32m已经移除自定义host地址请重新运行脚本以自动获取host\033[0m"
echo -e "\033[32m$ADV_HOST_REMOVED\033[0m"
exit 0
elif [ -n "$(echo "$host" | grep -E -o '\<([1-9]|[1-9][0-9]|1[0-9]{2}|2[01][0-9]|22[0-3])\>(\.\<([0-9]|[0-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\>){2}\.\<([1-9]|[0-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-4])\>')" ]; then
elif echo "$host" | grep -Eq '\<([1-9]|[1-9][0-9]|1[0-9]{2}|2[01][0-9]|22[0-3])\>(\.\<([0-9]|[0-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\>){2}\.\<([1-9]|[0-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-4])\>' ; then
setconfig host "$host"
echo -e "\033[32m设置成功!!!\033[0m"
echo -e "\033[32m$COMMON_SUCCESS\033[0m"
else
host=""
echo -e "\033[31m输入错误,请仔细核对!!!\033[0m"
echo -e "\033[31m$ADV_HOST_INVALID\033[0m"
fi
sleep 1
;;
;;
9)
echo "-----------------------------------------------"
echo -e "\033[33m仅限Tproxy、Tun或混合模式路由表出现冲突时才需要设置\033[0m"
read -p "请输入路由表地址(不明勿动建议102-125之间) > " table
echo -e "\033[33m$ADV_TABLE_WARN\033[0m"
read -p "$ADV_TABLE_INPUT > " table
if [ -n "$table" ]; then
[ "$table" = "0" ] && table="100"
setconfig table "$table"
echo -e "\033[32m设置成功!!!\033[0m"
echo -e "\033[32m$COMMON_SUCCESS\033[0m"
fi
;;
;;
*)
errornum
sleep 1
;;
;;
esac
done
}
@@ -450,11 +421,7 @@ set_firewall_area() {
case "$num" in
[1-4])
[ $firewall_area -ge 4 ] && {
redir_mod=Redir模式
setconfig redir_mod $redir_mod
}
[ "$num" = 4 ] && {
redir_mod=纯净模式
redir_mod=Redir
setconfig redir_mod $redir_mod
}
firewall_area=$num
@@ -482,12 +449,7 @@ set_firewall_area() {
sleep 1
}
set_firewall_vm(){
if [ -n "$vm_ipv4" ]; then
vm_des='当前劫持'
else
vm_ipv4=$(ip a 2>&1 | grep -w 'inet' | grep 'global' | grep 'brd' | grep -E 'docker|podman|virbr|vnet|ovs|vmbr|veth|vmnic|vboxnet|lxcbr|xenbr|vEthernet' | sed 's/.*inet.//g' | sed 's/ br.*$//g' | sed 's/metric.*$//g' | tr '\n' ' ')
vm_des='当前获取到'
fi
[ -z "$vm_ipv4" ] && vm_ipv4=$(ip a 2>&1 | grep -w 'inet' | grep 'global' | grep 'brd' | grep -E 'docker|podman|virbr|vnet|ovs|vmbr|veth|vmnic|vboxnet|lxcbr|xenbr|vEthernet' | sed 's/.*inet.//g' | sed 's/ br.*$//g' | sed 's/metric.*$//g' | tr '\n' ' ')
echo "-----------------------------------------------"
echo -e "$VM_DETECT_DESC\033[32m$vm_ipv4\033[0m"
echo "-----------------------------------------------"
@@ -503,11 +465,11 @@ set_firewall_vm(){
if [ -n "$vm_ipv4" ]; then
vm_redir=ON
else
echo -e "\033[33m请先运行容器再运行脚本或者手动设置网段\033[0m"
echo -e "\033[33m$VM_NO_NET_DETECTED\033[0m"
fi
;;
2)
echo -e "多个网段请用空格连接可使用【ip route】命令查看例如"
echo -e "$VM_INPUT_DESC"
echo -e "\033[32m10.88.0.0/16 172.17.0.0/16\033[0m"
read -p "$VM_INPUT_NET > " text
[ -n "$text" ] && vm_ipv4="$text" && vm_redir=ON

View File

@@ -540,8 +540,8 @@ testcommand() {
echo "----------------Redir+DNS---------------------"
iptables -t nat -L PREROUTING --line-numbers
iptables -t nat -L shellcrash_dns --line-numbers
[ -n "$(echo $redir_mod | grep -E 'Redir模式|混合模式')" ] && iptables -t nat -L shellcrash --line-numbers
[ -n "$(echo $redir_mod | grep -E 'Tproxy模式|混合模式|Tun模式')" ] && {
[ -n "$(echo $redir_mod | grep -E 'Redir|Mix')" ] && iptables -t nat -L shellcrash --line-numbers
[ -n "$(echo $redir_mod | grep -E 'Tproxy|Mix|Tun')" ] && {
echo "----------------Tun/Tproxy-------------------"
iptables -t mangle -L PREROUTING --line-numbers
iptables -t mangle -L shellcrash_mark --line-numbers
@@ -551,8 +551,8 @@ testcommand() {
echo "-------------OUTPUT-Redir+DNS----------------"
iptables -t nat -L OUTPUT --line-numbers
iptables -t nat -L shellcrash_dns_out --line-numbers
[ -n "$(echo $redir_mod | grep -E 'Redir模式|混合模式')" ] && iptables -t nat -L shellcrash_out --line-numbers
[ -n "$(echo $redir_mod | grep -E 'Tproxy模式|混合模式|Tun模式')" ] && {
[ -n "$(echo $redir_mod | grep -E 'Redir|Mix')" ] && iptables -t nat -L shellcrash_out --line-numbers
[ -n "$(echo $redir_mod | grep -E 'Tproxy|Mix|Tun')" ] && {
echo "------------OUTPUT-Tun/Tproxy---------------"
iptables -t mangle -L OUTPUT --line-numbers
iptables -t mangle -L shellcrash_mark_out --line-numbers
@@ -564,9 +564,9 @@ testcommand() {
echo "-------------IPV6-Redir+DNS-------------------"
ip6tables -t nat -L PREROUTING --line-numbers
ip6tables -t nat -L shellcrashv6_dns --line-numbers
[ -n "$(echo $redir_mod | grep -E 'Redir模式|混合模式')" ] && ip6tables -t nat -L shellcrashv6 --line-numbers
[ -n "$(echo $redir_mod | grep -E 'Redir|Mix')" ] && ip6tables -t nat -L shellcrashv6 --line-numbers
}
[ -n "$(echo $redir_mod | grep -E 'Tproxy模式|混合模式|Tun模式')" ] && {
[ -n "$(echo $redir_mod | grep -E 'Tproxy|Mix|Tun')" ] && {
echo "-------------IPV6-Tun/Tproxy------------------"
ip6tables -t mangle -L PREROUTING --line-numbers
ip6tables -t mangle -L shellcrashv6_mark --line-numbers

View File

@@ -160,7 +160,7 @@ download_file(){
}
### --- 具体操作函数 --- ###
do_start_fw(){
[ -z "$redir_mod_bf" ] && redir_mod_bf='Redir模式'
[ -z "$redir_mod_bf" ] && redir_mod_bf='Redir'
redir_mod=$redir_mod_bf
setconfig redir_mod $redir_mod
"$CRASHDIR"/start.sh start_firewall
@@ -168,8 +168,8 @@ do_start_fw(){
}
do_stop_fw(){
redir_mod_bf=$redir_mod
redir_mod='纯净模式'
setconfig redir_mod $redir_mod
firewall_area=4
setconfig firewall_area 4
"$CRASHDIR"/start.sh stop_firewall
echo "ShellCrash 已切换到纯净模式!" > "$LOGFILE"
}
@@ -238,7 +238,7 @@ polling(){
[ -n "$FILE_ID" ] && download_file
[ -n "$CALLBACK" ] && case "$CALLBACK" in
"start_redir")
if [ "$redir_mod" = '纯净模式' ];then
if [ "$firewall_area" = 4 ];then
do_start_fw
send_msg "已切换到$redir_mod_bf"
else
@@ -248,7 +248,7 @@ polling(){
continue
;;
"stop_redir")
if [ "$redir_mod" != '纯净模式' ];then
if [ "$firewall_area" != 4 ];then
do_stop_fw
send_msg "已切换到纯净模式"
else

View File

@@ -20,12 +20,12 @@ forwhat() {
case "$num" in
"" | 1)
# 设置运行模式
redir_mod="混合模式"
redir_mod="Mix"
echo "$cputype" | grep -Eq 'linux.*mips.*' && {
if grep -qE '^TPROXY$' /proc/net/ip_tables_targets || modprobe xt_TPROXY >/dev/null 2>&1; then
redir_mod="Tproxy模式"
redir_mod="Tproxy"
else
redir_mod="Redir模式"
redir_mod="Redir"
fi
}
@@ -67,7 +67,7 @@ forwhat() {
break
;;
2)
setconfig redir_mod "Redir模式"
setconfig redir_mod "Redir"
echo "$cputype" | grep -Eq "linux.*mips.*" && setconfig crashcore "clash"
setconfig common_ports "OFF"
setconfig firewall_area '2'