2 Commits
v4.18 ... v4.20

Author SHA1 Message Date
233boy
4d1279d038 fix caddy run 2024-06-02 17:10:22 +08:00
233boy
d999705479 add dns set 2024-05-08 20:02:55 +08:00
7 changed files with 89 additions and 15 deletions

View File

@@ -86,6 +86,7 @@ Usage: v2ray [options]... [args]...
web [name] [domain] 更改伪装网站
进阶:
dns [...] 设置 DNS
dd, ddel [name...] 删除多个配置**
fix [name] 修复一个配置
fix-all 修复全部配置

View File

@@ -1700,7 +1700,7 @@ is_main_menu() {
show_help
;;
9)
ask list is_do_other "启用BBR 查看日志 查看错误日志 测试运行 重装脚本"
ask list is_do_other "启用BBR 查看日志 查看错误日志 测试运行 重装脚本 设置DNS"
case $REPLY in
1)
load bbr.sh
@@ -1718,6 +1718,10 @@ is_main_menu() {
5)
get reinstall
;;
6)
load dns.sh
dns_set
;;
esac
;;
10)
@@ -1795,6 +1799,10 @@ main() {
[[ $is_api_fail ]] && manage restart &
[[ $is_del_host ]] && manage restart caddy &
;;
dns)
load dns.sh
dns_set ${@:2}
;;
debug)
is_debug=1
get info $2

58
src/dns.sh Normal file
View File

@@ -0,0 +1,58 @@
is_dns_list=(
1.1.1.1
8.8.8.8
https://dns.google/dns-query
https://cloudflare-dns.com/dns-query
https://family.cloudflare-dns.com/dns-query
set
none
)
dns_set() {
if [[ $1 ]]; then
case ${1,,} in
11 | 1111)
is_dns_use=${is_dns_list[0]}
;;
88 | 8888)
is_dns_use=${is_dns_list[1]}
;;
gg | google)
is_dns_use=${is_dns_list[2]}
;;
cf | cloudflare)
is_dns_use=${is_dns_list[3]}
;;
nosex | family)
is_dns_use=${is_dns_list[4]}
;;
set)
if [[ $2 ]]; then
is_dns_use=${2,,}
else
ask string is_dns_use "请输入 DNS: "
fi
;;
none)
is_dns_use=none
;;
*)
err "无法识别 DNS 参数: $@"
;;
esac
else
is_tmp_list=(${is_dns_list[@]})
ask list dns_pick
is_dns_use=${is_dns_list[$REPLY - 1]}
if [[ $is_dns_use == "set" ]]; then
ask string is_dns_use "请输入 DNS: "
fi
fi
is_new_dns=$(sed s/https/https+local/ <<<$is_dns_use)
if [[ $is_new_dns == "none" ]]; then
cat <<<$(jq '.dns={}' $is_config_json) >$is_config_json
else
cat <<<$(jq '.dns.servers=["'$is_new_dns'"]' $is_config_json) >$is_config_json
fi
manage restart &
msg "\n已更新 DNS 为: $(_green $is_new_dns)\n"
}

View File

@@ -40,6 +40,7 @@ show_help() {
" new [name] [...] 更改协议"
" web [name] [domain] 更改伪装网站\n"
"进阶:"
" dns [...] 设置 DNS"
" dd, ddel [name...] 删除多个配置**"
" fix [name] 修复一个配置"
" fix-all 修复全部配置"

View File

@@ -47,6 +47,17 @@ warn() {
echo -e "\n$is_warn $@\n"
}
# load bash script.
load() {
. $is_sh_dir/src/$1
}
# wget add --no-check-certificate
_wget() {
# [[ $proxy ]] && export https_proxy=$proxy
wget --no-check-certificate "$@"
}
# yum or apt-get
cmd=$(type -P apt-get || type -P yum)
@@ -111,6 +122,12 @@ else
fi
if [[ -f $is_caddy_bin && -d $is_caddy_dir && $is_caddy_service ]]; then
is_caddy=1
# fix caddy run; ver >= 2.8.2
[[ ! $(grep '\-\-adapter caddyfile' /lib/systemd/system/caddy.service) ]] && {
load systemd.sh
install_service caddy
systemctl restart caddy &
}
is_caddy_ver=$($is_caddy_bin version | head -n1 | cut -d " " -f1)
if [[ $(pgrep -f $is_caddy_bin) ]]; then
is_caddy_status=$(_green running)
@@ -120,17 +137,6 @@ if [[ -f $is_caddy_bin && -d $is_caddy_dir && $is_caddy_service ]]; then
fi
fi
# load bash script.
load() {
. $is_sh_dir/src/$1
}
# wget add --no-check-certificate
_wget() {
# [[ $proxy ]] && export https_proxy=$proxy
wget --no-check-certificate "$@"
}
load core.sh
# old sh ver
is_old_dir=/etc/v2ray/233boy

View File

@@ -39,8 +39,8 @@ Requires=network-online.target
Type=notify
User=root
Group=root
ExecStart=$is_caddy_bin run --environ --config $is_caddyfile
ExecReload=$is_caddy_bin reload --config $is_caddyfile
ExecStart=$is_caddy_bin run --environ --config $is_caddyfile --adapter caddyfile
ExecReload=$is_caddy_bin reload --config $is_caddyfile --adapter caddyfile
TimeoutStopSec=5s
LimitNPROC=10000
LimitNOFILE=1048576

View File

@@ -1,6 +1,6 @@
#!/bin/bash
args=$@
is_sh_ver=v4.18
is_sh_ver=v4.20
. /etc/v2ray/sh/src/init.sh