Compare commits
3 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
4d1279d038 | ||
![]() |
d999705479 | ||
![]() |
3af96ec0bc |
@@ -86,6 +86,7 @@ Usage: v2ray [options]... [args]...
|
|||||||
web [name] [domain] 更改伪装网站
|
web [name] [domain] 更改伪装网站
|
||||||
|
|
||||||
进阶:
|
进阶:
|
||||||
|
dns [...] 设置 DNS
|
||||||
dd, ddel [name...] 删除多个配置**
|
dd, ddel [name...] 删除多个配置**
|
||||||
fix [name] 修复一个配置
|
fix [name] 修复一个配置
|
||||||
fix-all 修复全部配置
|
fix-all 修复全部配置
|
||||||
|
38
src/core.sh
38
src/core.sh
@@ -918,6 +918,7 @@ add() {
|
|||||||
is_use_host=$2
|
is_use_host=$2
|
||||||
is_use_uuid=$3
|
is_use_uuid=$3
|
||||||
is_use_path=$4
|
is_use_path=$4
|
||||||
|
is_add_opts="[host] [uuid] [/path]"
|
||||||
;;
|
;;
|
||||||
vmess*)
|
vmess*)
|
||||||
is_use_port=$2
|
is_use_port=$2
|
||||||
@@ -926,6 +927,11 @@ add() {
|
|||||||
is_use_dynamic_port_start=$5
|
is_use_dynamic_port_start=$5
|
||||||
is_use_dynamic_port_end=$6
|
is_use_dynamic_port_end=$6
|
||||||
[[ $(grep dynamic-port <<<$is_new_protocol) ]] && is_dynamic_port=1
|
[[ $(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*)
|
# *reality*)
|
||||||
# is_reality=1
|
# is_reality=1
|
||||||
@@ -937,24 +943,32 @@ add() {
|
|||||||
is_use_port=$2
|
is_use_port=$2
|
||||||
is_use_pass=$3
|
is_use_pass=$3
|
||||||
is_use_method=$4
|
is_use_method=$4
|
||||||
|
is_add_opts="[port] [password] [method]"
|
||||||
;;
|
;;
|
||||||
*door)
|
*door)
|
||||||
is_use_port=$2
|
is_use_port=$2
|
||||||
is_use_door_addr=$3
|
is_use_door_addr=$3
|
||||||
is_use_door_port=$4
|
is_use_door_port=$4
|
||||||
|
is_add_opts="[port] [remote_addr] [remote_port]"
|
||||||
;;
|
;;
|
||||||
socks)
|
socks)
|
||||||
is_socks=1
|
is_socks=1
|
||||||
is_use_port=$2
|
is_use_port=$2
|
||||||
is_use_socks_user=$3
|
is_use_socks_user=$3
|
||||||
is_use_socks_pass=$4
|
is_use_socks_pass=$4
|
||||||
|
is_add_opts="[port] [username] [password]"
|
||||||
;;
|
;;
|
||||||
*http)
|
*http)
|
||||||
is_use_port=$2
|
is_use_port=$2
|
||||||
|
is_add_opts="[port]"
|
||||||
;;
|
;;
|
||||||
esac
|
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
|
# remove old protocol args
|
||||||
if [[ $is_set_new_protocol ]]; then
|
if [[ $is_set_new_protocol ]]; then
|
||||||
@@ -1003,28 +1017,28 @@ add() {
|
|||||||
|
|
||||||
if [[ $is_use_port ]]; then
|
if [[ $is_use_port ]]; then
|
||||||
[[ ! $(is_test port ${is_use_port}) ]] && {
|
[[ ! $(is_test port ${is_use_port}) ]] && {
|
||||||
err "($is_use_port) 不是一个有效的端口."
|
err "($is_use_port) 不是一个有效的端口. $is_err_tips"
|
||||||
}
|
}
|
||||||
[[ $(is_test port_used $is_use_port) ]] && {
|
[[ $(is_test port_used $is_use_port) ]] && {
|
||||||
err "无法使用 ($is_use_port) 端口."
|
err "无法使用 ($is_use_port) 端口. $is_err_tips"
|
||||||
}
|
}
|
||||||
port=$is_use_port
|
port=$is_use_port
|
||||||
fi
|
fi
|
||||||
if [[ $is_use_door_port ]]; then
|
if [[ $is_use_door_port ]]; then
|
||||||
[[ ! $(is_test port ${is_use_door_port}) ]] && {
|
[[ ! $(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
|
door_port=$is_use_door_port
|
||||||
fi
|
fi
|
||||||
if [[ $is_use_uuid ]]; then
|
if [[ $is_use_uuid ]]; then
|
||||||
[[ ! $(is_test uuid $is_use_uuid) ]] && {
|
[[ ! $(is_test uuid $is_use_uuid) ]] && {
|
||||||
err "($is_use_uuid) 不是一个有效的 UUID."
|
err "($is_use_uuid) 不是一个有效的 UUID. $is_err_tips"
|
||||||
}
|
}
|
||||||
uuid=$is_use_uuid
|
uuid=$is_use_uuid
|
||||||
fi
|
fi
|
||||||
if [[ $is_use_path ]]; then
|
if [[ $is_use_path ]]; then
|
||||||
[[ ! $(is_test path $is_use_path) ]] && {
|
[[ ! $(is_test path $is_use_path) ]] && {
|
||||||
err "($is_use_path) 不是有效的路径."
|
err "($is_use_path) 不是有效的路径. $is_err_tips"
|
||||||
}
|
}
|
||||||
path=$is_use_path
|
path=$is_use_path
|
||||||
fi
|
fi
|
||||||
@@ -1044,7 +1058,7 @@ add() {
|
|||||||
for v in ${is_tmp_list[@]}; do
|
for v in ${is_tmp_list[@]}; do
|
||||||
msg "\t\t$v"
|
msg "\t\t$v"
|
||||||
done
|
done
|
||||||
msg
|
msg "$is_err_tips\n"
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
ss_method=$is_tmp_use_type
|
ss_method=$is_tmp_use_type
|
||||||
@@ -1686,7 +1700,7 @@ is_main_menu() {
|
|||||||
show_help
|
show_help
|
||||||
;;
|
;;
|
||||||
9)
|
9)
|
||||||
ask list is_do_other "启用BBR 查看日志 查看错误日志 测试运行 重装脚本"
|
ask list is_do_other "启用BBR 查看日志 查看错误日志 测试运行 重装脚本 设置DNS"
|
||||||
case $REPLY in
|
case $REPLY in
|
||||||
1)
|
1)
|
||||||
load bbr.sh
|
load bbr.sh
|
||||||
@@ -1704,6 +1718,10 @@ is_main_menu() {
|
|||||||
5)
|
5)
|
||||||
get reinstall
|
get reinstall
|
||||||
;;
|
;;
|
||||||
|
6)
|
||||||
|
load dns.sh
|
||||||
|
dns_set
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
;;
|
;;
|
||||||
10)
|
10)
|
||||||
@@ -1781,6 +1799,10 @@ main() {
|
|||||||
[[ $is_api_fail ]] && manage restart &
|
[[ $is_api_fail ]] && manage restart &
|
||||||
[[ $is_del_host ]] && manage restart caddy &
|
[[ $is_del_host ]] && manage restart caddy &
|
||||||
;;
|
;;
|
||||||
|
dns)
|
||||||
|
load dns.sh
|
||||||
|
dns_set ${@:2}
|
||||||
|
;;
|
||||||
debug)
|
debug)
|
||||||
is_debug=1
|
is_debug=1
|
||||||
get info $2
|
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] [...] 更改协议"
|
" new [name] [...] 更改协议"
|
||||||
" web [name] [domain] 更改伪装网站\n"
|
" web [name] [domain] 更改伪装网站\n"
|
||||||
"进阶:"
|
"进阶:"
|
||||||
|
" dns [...] 设置 DNS"
|
||||||
" dd, ddel [name...] 删除多个配置**"
|
" dd, ddel [name...] 删除多个配置**"
|
||||||
" fix [name] 修复一个配置"
|
" fix [name] 修复一个配置"
|
||||||
" fix-all 修复全部配置"
|
" fix-all 修复全部配置"
|
||||||
|
28
src/init.sh
28
src/init.sh
@@ -47,6 +47,17 @@ warn() {
|
|||||||
echo -e "\n$is_warn $@\n"
|
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
|
# yum or apt-get
|
||||||
cmd=$(type -P apt-get || type -P yum)
|
cmd=$(type -P apt-get || type -P yum)
|
||||||
|
|
||||||
@@ -111,6 +122,12 @@ else
|
|||||||
fi
|
fi
|
||||||
if [[ -f $is_caddy_bin && -d $is_caddy_dir && $is_caddy_service ]]; then
|
if [[ -f $is_caddy_bin && -d $is_caddy_dir && $is_caddy_service ]]; then
|
||||||
is_caddy=1
|
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)
|
is_caddy_ver=$($is_caddy_bin version | head -n1 | cut -d " " -f1)
|
||||||
if [[ $(pgrep -f $is_caddy_bin) ]]; then
|
if [[ $(pgrep -f $is_caddy_bin) ]]; then
|
||||||
is_caddy_status=$(_green running)
|
is_caddy_status=$(_green running)
|
||||||
@@ -120,17 +137,6 @@ if [[ -f $is_caddy_bin && -d $is_caddy_dir && $is_caddy_service ]]; then
|
|||||||
fi
|
fi
|
||||||
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
|
load core.sh
|
||||||
# old sh ver
|
# old sh ver
|
||||||
is_old_dir=/etc/v2ray/233boy
|
is_old_dir=/etc/v2ray/233boy
|
||||||
|
@@ -39,8 +39,8 @@ Requires=network-online.target
|
|||||||
Type=notify
|
Type=notify
|
||||||
User=root
|
User=root
|
||||||
Group=root
|
Group=root
|
||||||
ExecStart=$is_caddy_bin run --environ --config $is_caddyfile
|
ExecStart=$is_caddy_bin run --environ --config $is_caddyfile --adapter caddyfile
|
||||||
ExecReload=$is_caddy_bin reload --config $is_caddyfile
|
ExecReload=$is_caddy_bin reload --config $is_caddyfile --adapter caddyfile
|
||||||
TimeoutStopSec=5s
|
TimeoutStopSec=5s
|
||||||
LimitNPROC=10000
|
LimitNPROC=10000
|
||||||
LimitNOFILE=1048576
|
LimitNOFILE=1048576
|
||||||
|
Reference in New Issue
Block a user