Compare commits
8 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
d999705479 | ||
![]() |
3af96ec0bc | ||
![]() |
59bc26b457 | ||
![]() |
61cdfc5bbe | ||
![]() |
51ff04fa02 | ||
![]() |
cad75208d0 | ||
![]() |
25c14b8520 | ||
![]() |
463ff482ea |
@@ -86,6 +86,7 @@ Usage: v2ray [options]... [args]...
|
||||
web [name] [domain] 更改伪装网站
|
||||
|
||||
进阶:
|
||||
dns [...] 设置 DNS
|
||||
dd, ddel [name...] 删除多个配置**
|
||||
fix [name] 修复一个配置
|
||||
fix-all 修复全部配置
|
||||
@@ -102,7 +103,7 @@ Usage: v2ray [options]... [args]...
|
||||
reinstall 重装脚本
|
||||
|
||||
测试:
|
||||
client, genc [name] 显示用于客户端 JOSN, 仅供参考
|
||||
client, genc [name] 显示用于客户端 JSON, 仅供参考
|
||||
debug [name] 显示一些 debug 信息, 仅供参考
|
||||
gen [...] 同等于 add, 但只显示 JSON 内容, 不创建文件, 测试使用
|
||||
no-auto-tls [...] 同等于 add, 但禁止自动配置 TLS, 可用于 *TLS 相关协议
|
||||
@@ -117,4 +118,4 @@ Usage: v2ray [options]... [args]...
|
||||
谨慎使用 del, ddel, 此选项会直接删除配置; 无需确认
|
||||
反馈问题) https://github.com/233boy/v2ray/issues
|
||||
文档(doc) https://233boy.com/v2ray/v2ray-script/
|
||||
```
|
||||
```
|
||||
|
@@ -189,8 +189,8 @@ download() {
|
||||
|
||||
# get server ip
|
||||
get_ip() {
|
||||
export "$(_wget -4 -qO- https://cloudflare-dns.com/cdn-cgi/trace | grep ip=)" &>/dev/null
|
||||
[[ -z $ip ]] && export "$(_wget -6 -qO- https://cloudflare-dns.com/cdn-cgi/trace | grep ip=)" &>/dev/null
|
||||
export "$(_wget -4 -qO- https://one.one.one.one/cdn-cgi/trace | grep ip=)" &>/dev/null
|
||||
[[ -z $ip ]] && export "$(_wget -6 -qO- https://one.one.one.one/cdn-cgi/trace | grep ip=)" &>/dev/null
|
||||
}
|
||||
|
||||
# check background tasks status
|
||||
|
47
src/core.sh
47
src/core.sh
@@ -125,8 +125,8 @@ get_uuid() {
|
||||
|
||||
get_ip() {
|
||||
[[ $ip || $is_no_auto_tls || $is_gen ]] && return
|
||||
export "$(_wget -4 -qO- https://cloudflare-dns.com/cdn-cgi/trace | grep ip=)" &>/dev/null
|
||||
[[ ! $ip ]] && export "$(_wget -6 -qO- https://cloudflare-dns.com/cdn-cgi/trace | grep ip=)" &>/dev/null
|
||||
export "$(_wget -4 -qO- https://one.one.one.one/cdn-cgi/trace | grep ip=)" &>/dev/null
|
||||
[[ ! $ip ]] && export "$(_wget -6 -qO- https://one.one.one.one/cdn-cgi/trace | grep ip=)" &>/dev/null
|
||||
[[ ! $ip ]] && {
|
||||
err "获取服务器 IP 失败.."
|
||||
}
|
||||
@@ -409,7 +409,8 @@ create() {
|
||||
is_ban_ad='{type:"field",domain:["geosite:category-ads-all"],marktag:"ban_ad",outboundTag:"block"}'
|
||||
is_ban_bt='{type:"field",protocol:["bittorrent"],marktag:"ban_bt",outboundTag:"block"}'
|
||||
is_ban_cn='{type:"field",ip:["geoip:cn"],marktag:"ban_geoip_cn",outboundTag:"block"}'
|
||||
is_routing='routing:{domainStrategy:"IPIfNonMatch",rules:[{type:"field",inboundTag:["api"],outboundTag:"api"},'"$is_ban_bt"','"$is_ban_cn"',{type:"field",ip:["geoip:private"],outboundTag:"block"}]}'
|
||||
is_openai='{type:"field",domain:["domain:openai.com"],marktag:"fix_openai",outboundTag:"direct"}'
|
||||
is_routing='routing:{domainStrategy:"IPIfNonMatch",rules:[{type:"field",inboundTag:["api"],outboundTag:"api"},'"$is_ban_bt"','"$is_ban_cn"','"$is_openai"',{type:"field",ip:["geoip:private"],outboundTag:"block"}]}'
|
||||
is_inbounds='inbounds:[{tag:"api",port:'"$tmp_port"',listen:"127.0.0.1",protocol:"dokodemo-door",settings:{address:"127.0.0.1"}}]'
|
||||
is_outbounds='outbounds:[{tag:"direct",protocol:"freedom"},{tag:"block",protocol:"blackhole"}]'
|
||||
is_server_config_json=$(jq '{'"$is_log"','"$is_dns"','"$is_api"','"$is_stats"','"$is_policy"','"$is_routing"','"$is_inbounds"','"$is_outbounds"'}' <<<{})
|
||||
@@ -917,6 +918,7 @@ add() {
|
||||
is_use_host=$2
|
||||
is_use_uuid=$3
|
||||
is_use_path=$4
|
||||
is_add_opts="[host] [uuid] [/path]"
|
||||
;;
|
||||
vmess*)
|
||||
is_use_port=$2
|
||||
@@ -925,6 +927,11 @@ add() {
|
||||
is_use_dynamic_port_start=$5
|
||||
is_use_dynamic_port_end=$6
|
||||
[[ $(grep dynamic-port <<<$is_new_protocol) ]] && is_dynamic_port=1
|
||||
if [[ $is_dynamic_port ]]; then
|
||||
is_add_opts="[port] [uuid] [type] [start_port] [end_port]"
|
||||
else
|
||||
is_add_opts="[port] [uuid] [type]"
|
||||
fi
|
||||
;;
|
||||
# *reality*)
|
||||
# is_reality=1
|
||||
@@ -936,24 +943,32 @@ add() {
|
||||
is_use_port=$2
|
||||
is_use_pass=$3
|
||||
is_use_method=$4
|
||||
is_add_opts="[port] [password] [method]"
|
||||
;;
|
||||
*door)
|
||||
is_use_port=$2
|
||||
is_use_door_addr=$3
|
||||
is_use_door_port=$4
|
||||
is_add_opts="[port] [remote_addr] [remote_port]"
|
||||
;;
|
||||
socks)
|
||||
is_socks=1
|
||||
is_use_port=$2
|
||||
is_use_socks_user=$3
|
||||
is_use_socks_pass=$4
|
||||
is_add_opts="[port] [username] [password]"
|
||||
;;
|
||||
*http)
|
||||
is_use_port=$2
|
||||
is_add_opts="[port]"
|
||||
;;
|
||||
esac
|
||||
|
||||
[[ $1 && ! $is_change ]] && msg "\n使用协议: $is_new_protocol"
|
||||
[[ $1 && ! $is_change ]] && {
|
||||
msg "\n使用协议: $is_new_protocol"
|
||||
# err msg tips
|
||||
is_err_tips="\n\n请使用: $(_green $is_core add $1 $is_add_opts) 来添加 $is_new_protocol 配置"
|
||||
}
|
||||
|
||||
# remove old protocol args
|
||||
if [[ $is_set_new_protocol ]]; then
|
||||
@@ -1002,28 +1017,28 @@ add() {
|
||||
|
||||
if [[ $is_use_port ]]; then
|
||||
[[ ! $(is_test port ${is_use_port}) ]] && {
|
||||
err "($is_use_port) 不是一个有效的端口."
|
||||
err "($is_use_port) 不是一个有效的端口. $is_err_tips"
|
||||
}
|
||||
[[ $(is_test port_used $is_use_port) ]] && {
|
||||
err "无法使用 ($is_use_port) 端口."
|
||||
err "无法使用 ($is_use_port) 端口. $is_err_tips"
|
||||
}
|
||||
port=$is_use_port
|
||||
fi
|
||||
if [[ $is_use_door_port ]]; then
|
||||
[[ ! $(is_test port ${is_use_door_port}) ]] && {
|
||||
err "(${is_use_door_port}) 不是一个有效的目标端口."
|
||||
err "(${is_use_door_port}) 不是一个有效的目标端口. $is_err_tips"
|
||||
}
|
||||
door_port=$is_use_door_port
|
||||
fi
|
||||
if [[ $is_use_uuid ]]; then
|
||||
[[ ! $(is_test uuid $is_use_uuid) ]] && {
|
||||
err "($is_use_uuid) 不是一个有效的 UUID."
|
||||
err "($is_use_uuid) 不是一个有效的 UUID. $is_err_tips"
|
||||
}
|
||||
uuid=$is_use_uuid
|
||||
fi
|
||||
if [[ $is_use_path ]]; then
|
||||
[[ ! $(is_test path $is_use_path) ]] && {
|
||||
err "($is_use_path) 不是有效的路径."
|
||||
err "($is_use_path) 不是有效的路径. $is_err_tips"
|
||||
}
|
||||
path=$is_use_path
|
||||
fi
|
||||
@@ -1043,7 +1058,7 @@ add() {
|
||||
for v in ${is_tmp_list[@]}; do
|
||||
msg "\t\t$v"
|
||||
done
|
||||
msg
|
||||
msg "$is_err_tips\n"
|
||||
exit 1
|
||||
}
|
||||
ss_method=$is_tmp_use_type
|
||||
@@ -1388,7 +1403,7 @@ get() {
|
||||
# is_host_dns=$(ping $host $is_ip_type -c 1 -W 2 | head -1)
|
||||
is_dns_type="a"
|
||||
[[ $(grep ":" <<<$ip) ]] && is_dns_type="aaaa"
|
||||
is_host_dns=$(_wget -qO- --header="accept: application/dns-json" "https://cloudflare-dns.com/dns-query?name=$host&type=$is_dns_type")
|
||||
is_host_dns=$(_wget -qO- --header="accept: application/dns-json" "https://one.one.one.one/dns-query?name=$host&type=$is_dns_type")
|
||||
;;
|
||||
log | logerr)
|
||||
msg "\n 提醒: 按 $(_green Ctrl + C) 退出\n"
|
||||
@@ -1685,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
|
||||
@@ -1703,6 +1718,10 @@ is_main_menu() {
|
||||
5)
|
||||
get reinstall
|
||||
;;
|
||||
6)
|
||||
load dns.sh
|
||||
dns_set
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
10)
|
||||
@@ -1780,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
58
src/dns.sh
Normal 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"
|
||||
}
|
@@ -40,6 +40,7 @@ show_help() {
|
||||
" new [name] [...] 更改协议"
|
||||
" web [name] [domain] 更改伪装网站\n"
|
||||
"进阶:"
|
||||
" dns [...] 设置 DNS"
|
||||
" dd, ddel [name...] 删除多个配置**"
|
||||
" fix [name] 修复一个配置"
|
||||
" fix-all 修复全部配置"
|
||||
@@ -54,7 +55,7 @@ show_help() {
|
||||
" t, test 测试运行"
|
||||
" reinstall 重装脚本\n"
|
||||
"测试:"
|
||||
" client, genc [name] 显示用于客户端 JOSN, 仅供参考"
|
||||
" client, genc [name] 显示用于客户端 JSON, 仅供参考"
|
||||
" debug [name] 显示一些 debug 信息, 仅供参考"
|
||||
" gen [...] 同等于 add, 但只显示 JSON 内容, 不创建文件, 测试使用"
|
||||
" no-auto-tls [...] 同等于 add, 但禁止自动配置 TLS, 可用于 *TLS 相关协议"
|
||||
|
Reference in New Issue
Block a user