~优化tg推送设置,恢复自定义输入ChatID功能
~优化mihomo内核基础dns设置,修复部分设备因为证书原因导致的网络问题 ~优化singbox自定义配置文件合并,现在支持certificate、endpoint、services等模块的自定义配置合并 ~修复部分版本curl无法正确配置本机代理密码而导致的407报错问题 ~修复卸载时选择保留配置会导致重新安装后启动报错的bug ~修复docker运行时会报错的bug
This commit is contained in:
@@ -282,7 +282,7 @@ log_pusher() { #日志菜单
|
||||
echo -----------------------------------------------
|
||||
read -p "请输入你获取到的API TOKEN > " TOKEN
|
||||
echo -----------------------------------------------
|
||||
echo -e "请向\033[32m你申请的机器人\033[31m而不是BotFather\033[0m,发送"
|
||||
echo -e "请向\033[32m你申请的机器人\033[33m而不是BotFather!\033[0m"
|
||||
url_tg=https://api.telegram.org/bot${TOKEN}/getUpdates
|
||||
}
|
||||
public_bot(){
|
||||
@@ -304,16 +304,19 @@ log_pusher() { #日志菜单
|
||||
fi
|
||||
[ -n "$chat" ] && chat_ID=$(echo $chat | sed 's/"update_id":/{\n"update_id":/g' | grep "$public_key" | head -n1 |grep -oE '"id":.*,"is_bot' | sed s'/"id"://' | sed s'/,"is_bot//')
|
||||
[ -z "$chat_ID" ] && {
|
||||
echo -e "\033[31m无法获取对话ID,请重新输入!\033[0m"
|
||||
chose_bot
|
||||
echo -e "\033[31m无法获取对话ID,请返回重新设置或手动输入ChatID!\033[0m"
|
||||
echo -e "通常访问 \033[32;4m$url_tg\033[0m \n\033[36m即可看到ChatID\033[0m"
|
||||
read -p "请手动输入ChatID > " chat_ID
|
||||
}
|
||||
if [ -n "$chat_ID" ]; then
|
||||
if echo "$chat_ID" | grep -qE '^[0-9]{8,}$'; then
|
||||
push_TG=$TOKEN
|
||||
setconfig push_TG $TOKEN
|
||||
setconfig chat_ID $chat_ID
|
||||
${CRASHDIR}/start.sh logger "已完成Telegram日志推送设置!" 32
|
||||
else
|
||||
echo -e "\033[31m无法获取对话ID,请重新配置!\033[0m"
|
||||
sleep 1
|
||||
chose_bot
|
||||
fi
|
||||
fi
|
||||
}
|
||||
@@ -321,7 +324,7 @@ log_pusher() { #日志菜单
|
||||
public_key=$(cat /proc/sys/kernel/random/boot_id | sed 's/.*-//')
|
||||
echo -----------------------------------------------
|
||||
echo -e " 1 使用公共机器人 ——不依赖内核服务"
|
||||
echo -e " 2 使用私人机器人 ——需要额外申请"
|
||||
echo -e " 2 使用私人机器人 ——需要额外申请"
|
||||
echo -----------------------------------------------
|
||||
read -p "请输入对应数字 > " num
|
||||
case $num in
|
||||
@@ -1923,13 +1926,13 @@ uninstall() {
|
||||
if [ -n "${CRASHDIR}" ] && [ "${CRASHDIR}" != '/' ];then
|
||||
read -p "是否保留脚本配置及订阅文件?[1/0] > " res
|
||||
if [ "$res" = '1' ]; then
|
||||
mv -f ${CRASHDIR}/configs /tmp/ShellCrash/
|
||||
mv -f ${CRASHDIR}/yamls /tmp/ShellCrash/
|
||||
mv -f ${CRASHDIR}/jsons /tmp/ShellCrash/
|
||||
mv -f ${CRASHDIR}/configs /tmp/ShellCrash/configs_bak
|
||||
mv -f ${CRASHDIR}/yamls /tmp/ShellCrash/yamls_bak
|
||||
mv -f ${CRASHDIR}/jsons /tmp/ShellCrash/jsons_bak
|
||||
rm -rf ${CRASHDIR}/*
|
||||
mv -f /tmp/ShellCrash/configs "${CRASHDIR}/"
|
||||
mv -f /tmp/ShellCrash/yamls "${CRASHDIR}/"
|
||||
mv -f /tmp/ShellCrash/jsons "${CRASHDIR}/"
|
||||
mv -f /tmp/ShellCrash/configs_bak "${CRASHDIR}/configs"
|
||||
mv -f /tmp/ShellCrash/yamls_bak "${CRASHDIR}/yamls"
|
||||
mv -f /tmp/ShellCrash/jsons_bak "${CRASHDIR}/jsons"
|
||||
else
|
||||
rm -rf ${CRASHDIR}
|
||||
fi
|
||||
|
||||
@@ -410,16 +410,15 @@ modify_yaml() { #修饰clash配置文件
|
||||
}
|
||||
#dns配置
|
||||
[ -z "$(cat "$CRASHDIR"/yamls/user.yaml 2>/dev/null | grep '^dns:')" ] && {
|
||||
default_nameserver='223.5.5.5'
|
||||
[ "$crashcore" = 'meta' ] && default_nameserver='https://223.5.5.5/dns-query'
|
||||
[ "$skip_cert" = "已开启" ] && psdns_skip_cert='#skip-cert-verify'
|
||||
cat >"$TMPDIR"/dns.yaml <<EOF
|
||||
dns:
|
||||
enable: true
|
||||
listen: :$dns_port
|
||||
use-hosts: true
|
||||
ipv6: $dns_v6
|
||||
default-nameserver:
|
||||
- $default_nameserver
|
||||
default-nameserver: [ 223.5.5.5 ]
|
||||
proxy-server-nameserver: [ https://223.5.5.5/dns-query$psdns_skip_cert ]
|
||||
enhanced-mode: fake-ip
|
||||
fake-ip-range: 28.0.0.1/8
|
||||
fake-ip-range6: fc00::/16
|
||||
@@ -471,22 +470,26 @@ EOF
|
||||
if [ "$hosts_opt" != "未启用" ] && [ -z "$(grep -aE '^hosts:' "$CRASHDIR"/yamls/user.yaml 2>/dev/null)" ]; then
|
||||
#NTP劫持
|
||||
cat >"$TMPDIR"/hosts.yaml <<EOF
|
||||
use-system-hosts: true
|
||||
hosts:
|
||||
'time.android.com': 203.107.6.88
|
||||
'time.facebook.com': 203.107.6.88
|
||||
EOF
|
||||
[ "$crashcore" = "meta" ] && echo " 'services.googleapis.cn': services.googleapis.com" >>"$TMPDIR"/hosts.yaml
|
||||
#加载本机hosts
|
||||
sys_hosts=/etc/hosts
|
||||
[ -f /data/etc/custom_hosts ] && sys_hosts=/data/etc/custom_hosts
|
||||
while read line; do
|
||||
[ -n "$(echo "$line" | grep -oE "([0-9]{1,3}[\.]){3}")" ] &&
|
||||
[ -z "$(echo "$line" | grep -oE '^#')" ] &&
|
||||
hosts_ip=$(echo $line | awk '{print $1}') &&
|
||||
hosts_domain=$(echo $line | awk '{print $2}') &&
|
||||
[ -z "$(cat "$TMPDIR"/hosts.yaml | grep -oE "$hosts_domain")" ] &&
|
||||
echo " '$hosts_domain': $hosts_ip" >>"$TMPDIR"/hosts.yaml
|
||||
done <$sys_hosts
|
||||
if [ "$crashcore" = "meta" ];then
|
||||
echo " 'services.googleapis.cn': services.googleapis.com" >>"$TMPDIR"/hosts.yaml
|
||||
else
|
||||
#加载本机hosts
|
||||
sys_hosts=/etc/hosts
|
||||
[ -f /data/etc/custom_hosts ] && sys_hosts=/data/etc/custom_hosts
|
||||
while read line; do
|
||||
[ -n "$(echo "$line" | grep -oE "([0-9]{1,3}[\.]){3}")" ] &&
|
||||
[ -z "$(echo "$line" | grep -oE '^#')" ] &&
|
||||
hosts_ip=$(echo $line | awk '{print $1}') &&
|
||||
hosts_domain=$(echo $line | awk '{print $2}') &&
|
||||
[ -z "$(cat "$TMPDIR"/hosts.yaml | grep -oE "$hosts_domain")" ] &&
|
||||
echo " '$hosts_domain': $hosts_ip" >>"$TMPDIR"/hosts.yaml
|
||||
done <$sys_hosts
|
||||
fi
|
||||
fi
|
||||
#分割配置文件
|
||||
yaml_char='proxies proxy-groups proxy-providers rules rule-providers'
|
||||
@@ -935,13 +938,15 @@ EOF
|
||||
done
|
||||
#加载自定义配置文件
|
||||
mkdir -p "$TMPDIR"/jsons_base
|
||||
for char in log dns ntp experimental; do
|
||||
#以下为覆盖脚本的自定义文件
|
||||
for char in log dns ntp certificate experimental; do
|
||||
[ -s "$CRASHDIR"/jsons/${char}.json ] && {
|
||||
ln -sf "$CRASHDIR"/jsons/${char}.json "$TMPDIR"/jsons/cust_${char}.json
|
||||
mv -f "$TMPDIR"/jsons/${char}.json "$TMPDIR"/jsons_base #如果重复则临时备份
|
||||
}
|
||||
done
|
||||
for char in others inbounds outbounds providers route rule-set; do
|
||||
#以下为增量添加的自定义文件
|
||||
for char in others endpoints inbounds outbounds providers route services; do
|
||||
[ -s "$CRASHDIR"/jsons/${char}.json ] && {
|
||||
ln -sf "$CRASHDIR"/jsons/${char}.json "$TMPDIR"/jsons/cust_${char}.json
|
||||
}
|
||||
@@ -1508,9 +1513,9 @@ start_firewall() { #路由规则总入口
|
||||
[ "$firewall_mod" = 'iptables' ] && start_iptables
|
||||
[ "$firewall_mod" = 'nftables' ] && start_nftables
|
||||
#修复部分虚拟机dns查询失败的问题
|
||||
[ "$firewall_area" = 2 -o "$firewall_area" = 3 ] && [ -z "$(grep 'nameserver 127.0.0.1' /etc/resolv.conf 2>/dev/null)" ] && [ -w /etc/resolv.conf ] && {
|
||||
[ "$firewall_area" = 2 -o "$firewall_area" = 3 ] && [ -z "$(grep '127.0.0.1' /etc/resolv.conf 2>/dev/null)" ] && [ -w /etc/resolv.conf ] && {
|
||||
line=$(grep -n 'nameserver' /etc/resolv.conf | awk -F: 'FNR==1{print $1}')
|
||||
sed -i "$line i\nameserver 127.0.0.1 #shellcrash-dns-repair" /etc/resolv.conf 2>/dev/null
|
||||
sed -i "$line i\nameserver 127.0.0.1 #shellcrash-dns-repair" /etc/resolv.conf >/dev/null 2>&1
|
||||
}
|
||||
#openwrt使用dnsmasq转发DNS
|
||||
if [ "$dns_redir" = "已开启" -a "$firewall_area" -le 3 -a "$dns_no" != "已禁用" ]; then
|
||||
@@ -2137,7 +2142,12 @@ webget)
|
||||
[ "$5" = "rediroff" ] && redirect='' || redirect='-L'
|
||||
[ "$6" = "skipceroff" ] && certificate='' || certificate='-k'
|
||||
[ -n "$7" ] && agent="--user-agent \"$7\""
|
||||
result=$(curl $agent -w %{http_code} --connect-timeout 3 $progress $redirect $certificate -o "$2" "$url")
|
||||
if curl --version | grep -q '^curl 8.' ;then
|
||||
auth_b64=$(echo -n "$authentication" | base64)
|
||||
result=$(curl $agent -w %{http_code} --connect-timeout 3 --proxy-header "Proxy-Authorization: Basic $auth_b64" $progress $redirect $certificate -o "$2" "$url")
|
||||
else
|
||||
result=$(curl $agent -w %{http_code} --connect-timeout 3 $progress $redirect $certificate -o "$2" "$url")
|
||||
fi
|
||||
[ "$result" != "200" ] && export all_proxy="" && result=$(curl $agent -w %{http_code} --connect-timeout 5 $progress $redirect $certificate -o "$2" "$3")
|
||||
else
|
||||
if wget --version >/dev/null 2>&1; then
|
||||
|
||||
@@ -620,10 +620,10 @@ setproviders(){ #自定义providers
|
||||
echo -e "本地配置文件请放在\033[32m$CRASHDIR\033[0m目录下,并填写相对路径如【\033[32m./providers/test.yaml\033[0m】"
|
||||
echo -----------------------------------------------
|
||||
read -p "请输入providers订阅地址或本地相对路径 > " link
|
||||
link=$(${link// /})
|
||||
link="$(echo "$link" | tr -d '[:space:]')"
|
||||
[ -n "$(echo $link | grep -E '.*\..*|^\./')" ] && {
|
||||
read -p "请输入代理服务商的名称或者代号(不可重复) > " name
|
||||
name=$(${name// /})
|
||||
name="$(echo "$name" | tr -d '[:space:]')"
|
||||
[ -n "$name" ] && [ -z "$(grep "name" $CRASHDIR/configs/providers.cfg)" ] && {
|
||||
echo -----------------------------------------------
|
||||
echo -e "代理服务商:\033[36m$name\033[0m"
|
||||
@@ -737,9 +737,11 @@ EOF
|
||||
}
|
||||
set_singbox_adv(){ #自定义singbox配置文件
|
||||
echo -----------------------------------------------
|
||||
echo -e "singbox配置文件中,支持自定义的模块有:\033[0m"
|
||||
echo -e "\033[36mlog dns ntp inbounds outbounds outbound_providers route experimental\033[0m"
|
||||
echo -e "将相应json文件放入\033[33m$JSONSDIR\033[0m目录后即可在启动时加载"
|
||||
echo -e "支持覆盖脚本设置的模块有:\033[0m"
|
||||
echo -e "\033[36mlog dns ntp certificate experimental\033[0m"
|
||||
echo -e "支持与内置功能合并(但不可冲突)的模块有:\033[0m"
|
||||
echo -e "\033[36mendpoints inbounds outbounds providers route services\033[0m"
|
||||
echo -e "将相应json文件放入\033[33m$JSONSDIR\033[0m目录后即可在启动时自动加载"
|
||||
echo -----------------------------------------------
|
||||
echo -e "使用前请务必参考配置教程:\033[32;4m https://juewuy.github.io/nWTjEpkSK \033[0m"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user