Skip to content

Commit d999705

Browse files
committed
add dns set
1 parent 3af96ec commit d999705

File tree

5 files changed

+70
-2
lines changed

5 files changed

+70
-2
lines changed

Diff for: README.md

+1
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ Usage: v2ray [options]... [args]...
8686
web [name] [domain] 更改伪装网站
8787
8888
进阶:
89+
dns [...] 设置 DNS
8990
dd, ddel [name...] 删除多个配置**
9091
fix [name] 修复一个配置
9192
fix-all 修复全部配置

Diff for: src/core.sh

+9-1
Original file line numberDiff line numberDiff line change
@@ -1700,7 +1700,7 @@ is_main_menu() {
17001700
show_help
17011701
;;
17021702
9)
1703-
ask list is_do_other "启用BBR 查看日志 查看错误日志 测试运行 重装脚本"
1703+
ask list is_do_other "启用BBR 查看日志 查看错误日志 测试运行 重装脚本 设置DNS"
17041704
case $REPLY in
17051705
1)
17061706
load bbr.sh
@@ -1718,6 +1718,10 @@ is_main_menu() {
17181718
5)
17191719
get reinstall
17201720
;;
1721+
6)
1722+
load dns.sh
1723+
dns_set
1724+
;;
17211725
esac
17221726
;;
17231727
10)
@@ -1795,6 +1799,10 @@ main() {
17951799
[[ $is_api_fail ]] && manage restart &
17961800
[[ $is_del_host ]] && manage restart caddy &
17971801
;;
1802+
dns)
1803+
load dns.sh
1804+
dns_set ${@:2}
1805+
;;
17981806
debug)
17991807
is_debug=1
18001808
get info $2

Diff for: src/dns.sh

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
is_dns_list=(
2+
1.1.1.1
3+
8.8.8.8
4+
https://dns.google/dns-query
5+
https://cloudflare-dns.com/dns-query
6+
https://family.cloudflare-dns.com/dns-query
7+
set
8+
none
9+
)
10+
dns_set() {
11+
if [[ $1 ]]; then
12+
case ${1,,} in
13+
11 | 1111)
14+
is_dns_use=${is_dns_list[0]}
15+
;;
16+
88 | 8888)
17+
is_dns_use=${is_dns_list[1]}
18+
;;
19+
gg | google)
20+
is_dns_use=${is_dns_list[2]}
21+
;;
22+
cf | cloudflare)
23+
is_dns_use=${is_dns_list[3]}
24+
;;
25+
nosex | family)
26+
is_dns_use=${is_dns_list[4]}
27+
;;
28+
set)
29+
if [[ $2 ]]; then
30+
is_dns_use=${2,,}
31+
else
32+
ask string is_dns_use "请输入 DNS: "
33+
fi
34+
;;
35+
none)
36+
is_dns_use=none
37+
;;
38+
*)
39+
err "无法识别 DNS 参数: $@"
40+
;;
41+
esac
42+
else
43+
is_tmp_list=(${is_dns_list[@]})
44+
ask list dns_pick
45+
is_dns_use=${is_dns_list[$REPLY - 1]}
46+
if [[ $is_dns_use == "set" ]]; then
47+
ask string is_dns_use "请输入 DNS: "
48+
fi
49+
fi
50+
is_new_dns=$(sed s/https/https+local/ <<<$is_dns_use)
51+
if [[ $is_new_dns == "none" ]]; then
52+
cat <<<$(jq '.dns={}' $is_config_json) >$is_config_json
53+
else
54+
cat <<<$(jq '.dns.servers=["'$is_new_dns'"]' $is_config_json) >$is_config_json
55+
fi
56+
manage restart &
57+
msg "\n已更新 DNS 为: $(_green $is_new_dns)\n"
58+
}

Diff for: src/help.sh

+1
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ show_help() {
4040
" new [name] [...] 更改协议"
4141
" web [name] [domain] 更改伪装网站\n"
4242
"进阶:"
43+
" dns [...] 设置 DNS"
4344
" dd, ddel [name...] 删除多个配置**"
4445
" fix [name] 修复一个配置"
4546
" fix-all 修复全部配置"

Diff for: v2ray.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash
22

33
args=$@
4-
is_sh_ver=v4.18
4+
is_sh_ver=v4.19
55

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

0 commit comments

Comments
 (0)