Skip to content

Commit

Permalink
add dns set
Browse files Browse the repository at this point in the history
  • Loading branch information
233boy committed May 8, 2024
1 parent 3af96ec commit d999705
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ Usage: v2ray [options]... [args]...
web [name] [domain] 更改伪装网站
进阶:
dns [...] 设置 DNS
dd, ddel [name...] 删除多个配置**
fix [name] 修复一个配置
fix-all 修复全部配置
Expand Down
10 changes: 9 additions & 1 deletion src/core.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -1718,6 +1718,10 @@ is_main_menu() {
5)
get reinstall
;;
6)
load dns.sh
dns_set
;;
esac
;;
10)
Expand Down Expand Up @@ -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
Expand Down
58 changes: 58 additions & 0 deletions src/dns.sh
Original file line number Diff line number Diff line change
@@ -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"
}
1 change: 1 addition & 0 deletions src/help.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ show_help() {
" new [name] [...] 更改协议"
" web [name] [domain] 更改伪装网站\n"
"进阶:"
" dns [...] 设置 DNS"
" dd, ddel [name...] 删除多个配置**"
" fix [name] 修复一个配置"
" fix-all 修复全部配置"
Expand Down
2 changes: 1 addition & 1 deletion v2ray.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

args=$@
is_sh_ver=v4.18
is_sh_ver=v4.19

. /etc/v2ray/sh/src/init.sh

0 comments on commit d999705

Please sign in to comment.