3 Commits
v4.01 ... v4.03

Author SHA1 Message Date
233boy
bfff42a4a6 fix URL 2023-05-17 17:31:00 +08:00
233boy
ec504a23d3 add socks url and listen string 2023-05-17 13:50:23 +08:00
233boy
07af4a2adc add socks 2023-05-16 18:37:20 +08:00
5 changed files with 82 additions and 24 deletions

View File

@@ -26,6 +26,20 @@
- 一键更改 (端口/UUID/密码/域名/路径/加密方式/SNI/动态端口/等...) - 一键更改 (端口/UUID/密码/域名/路径/加密方式/SNI/动态端口/等...)
- 还有更多... - 还有更多...
# 设计理念
设计理念为:**高效率,超快速,极易用**
脚本基于作者的自身使用需求,以 **多配置同时运行** 为核心设计
并且专门优化了,添加、更改、查看、删除、这四项常用功能
你只需要一条命令即可完成 添加、更改、查看、删除、等操作
例如,添加一个配置仅需不到 1 秒!瞬间完成添加!其他操作亦是如此!
脚本的参数非常高效率并且超级易用,请掌握参数的使用
# 脚本说明 # 脚本说明
[V2Ray 一键安装脚本](https://github.com/233boy/v2ray/wiki/V2Ray%E4%B8%80%E9%94%AE%E5%AE%89%E8%A3%85%E8%84%9A%E6%9C%AC) [V2Ray 一键安装脚本](https://github.com/233boy/v2ray/wiki/V2Ray%E4%B8%80%E9%94%AE%E5%AE%89%E8%A3%85%E8%84%9A%E6%9C%AC)

View File

@@ -19,6 +19,7 @@ protocol_list=(
VMess-TCP-dynamic-port VMess-TCP-dynamic-port
VMess-mKCP-dynamic-port VMess-mKCP-dynamic-port
VMess-QUIC-dynamic-port VMess-QUIC-dynamic-port
Socks
) )
ss_method_list=( ss_method_list=(
aes-128-gcm aes-128-gcm
@@ -69,6 +70,7 @@ info_list=(
"SNI (serverName)" "SNI (serverName)"
"指纹 (Fingerprint)" "指纹 (Fingerprint)"
"公钥 (Public key)" "公钥 (Public key)"
"用户名 (Username)"
) )
change_list=( change_list=(
"更改协议" "更改协议"
@@ -86,6 +88,7 @@ change_list=(
"更改动态端口" "更改动态端口"
"更改伪装网站" "更改伪装网站"
"更改 mKCP seed" "更改 mKCP seed"
"更改用户名 (Username)"
) )
servername_list=( servername_list=(
www.amazon.com www.amazon.com
@@ -216,7 +219,7 @@ ask() {
set_header_type) set_header_type)
is_tmp_list=(${header_type_list[@]}) is_tmp_list=(${header_type_list[@]})
is_default_arg=$is_random_header_type is_default_arg=$is_random_header_type
[[ $(grep tcp <<<"$is_new_protocol-$net") ]] && { [[ $(grep -i tcp <<<"$is_new_protocol-$net") ]] && {
is_tmp_list=(none http) is_tmp_list=(none http)
is_default_arg=none is_default_arg=none
} }
@@ -318,10 +321,8 @@ ask() {
create() { create() {
case $1 in case $1 in
server) server)
get new
is_sniffing='sniffing:{enabled:true,destOverride:["http","tls"]}'
is_listen_127='"listen": "127.0.0.1"'
is_tls=none is_tls=none
get new
# file name # file name
if [[ $host ]]; then if [[ $host ]]; then
@@ -332,10 +333,19 @@ create() {
is_json_file=$is_conf_dir/$is_config_name is_json_file=$is_conf_dir/$is_config_name
# get json # get json
[[ $is_change || ! $json_str ]] && get protocol $2 [[ $is_change || ! $json_str ]] && get protocol $2
is_new_json=$(jq '{inbounds:[{tag:'\"$is_config_name\"',port:'"$port"',protocol:'\"$is_protocol\"','"$json_str"','"$is_sniffing"'}]}' <<<{}) case $net in
ws | h2 | grpc | http)
is_listen='"listen": "127.0.0.1"'
;;
*)
is_listen='"listen": "0.0.0.0"'
;;
esac
is_sniffing='sniffing:{enabled:true,destOverride:["http","tls"]}'
is_new_json=$(jq '{inbounds:[{tag:'\"$is_config_name\"',port:'"$port"','"$is_listen"',protocol:'\"$is_protocol\"','"$json_str"','"$is_sniffing"'}]}' <<<{})
if [[ $is_dynamic_port ]]; then if [[ $is_dynamic_port ]]; then
[[ ! $is_dynamic_port_range ]] && get dynamic-port [[ ! $is_dynamic_port_range ]] && get dynamic-port
is_new_dynamic_port_json=$(jq '{inbounds:[{tag:'\"$is_config_name-link.json\"',port:'\"$is_dynamic_port_range\"',protocol:"vmess",'"$is_stream"','"$is_sniffing"',allocate:{strategy:"random"}}]}' <<<{}) is_new_dynamic_port_json=$(jq '{inbounds:[{tag:'\"$is_config_name-link.json\"',port:'\"$is_dynamic_port_range\"','"$is_listen"',protocol:"vmess",'"$is_stream"','"$is_sniffing"',allocate:{strategy:"random"}}]}' <<<{})
fi fi
[[ $is_test_json ]] && return # tmp test [[ $is_test_json ]] && return # tmp test
# only show json, dont save to file. # only show json, dont save to file.
@@ -531,7 +541,7 @@ change() {
4) 4)
# new password # new password
is_new_pass=$3 is_new_pass=$3
if [[ $net == 'ss' || $is_trojan ]]; then if [[ $net == 'ss' || $is_trojan || $is_socks_pass ]]; then
[[ $is_auto ]] && get_uuid && is_new_pass=$tmp_uuid [[ $is_auto ]] && get_uuid && is_new_pass=$tmp_uuid
else else
err "($is_config_file) 不支持更改密码." err "($is_config_file) 不支持更改密码."
@@ -539,6 +549,7 @@ change() {
[[ ! $is_new_pass ]] && ask string is_new_pass "请输入新密码:" [[ ! $is_new_pass ]] && ask string is_new_pass "请输入新密码:"
trojan_password=$is_new_pass trojan_password=$is_new_pass
ss_password=$is_new_pass ss_password=$is_new_pass
is_socks_pass=$is_new_pass
add $net add $net
;; ;;
5) 5)
@@ -689,6 +700,12 @@ change() {
kcp_seed=$is_new_kcp_seed kcp_seed=$is_new_kcp_seed
add $net add $net
;; ;;
15)
# new socks user
[[ ! $is_socks_user ]] && err "($is_config_file) 不支持更改用户名 (Username)."
ask string is_socks_user "请输入新用户名 (Username):"
add $net
;;
esac esac
} }
@@ -861,7 +878,10 @@ add() {
door) door)
is_new_protocol=Dokodemo-Door is_new_protocol=Dokodemo-Door
;; ;;
http | socks) socks)
is_new_protocol=Socks
;;
http)
is_new_protocol=local-$is_lower is_new_protocol=local-$is_lower
;; ;;
*) *)
@@ -908,7 +928,13 @@ add() {
is_use_door_addr=$3 is_use_door_addr=$3
is_use_door_port=$4 is_use_door_port=$4
;; ;;
*http | *socks) socks)
is_socks=1
is_use_port=$2
is_use_socks_user=$3
is_use_socks_pass=$4
;;
*http)
is_use_port=$2 is_use_port=$2
;; ;;
esac esac
@@ -1016,6 +1042,8 @@ add() {
[[ $is_use_host ]] && host=$is_use_host [[ $is_use_host ]] && host=$is_use_host
[[ $is_use_door_addr ]] && door_addr=$is_use_door_addr [[ $is_use_door_addr ]] && door_addr=$is_use_door_addr
[[ $is_use_servername ]] && is_servername=$is_use_servername [[ $is_use_servername ]] && is_servername=$is_use_servername
[[ $is_use_socks_user ]] && is_socks_user=$is_use_socks_user
[[ $is_use_socks_pass ]] && is_socks_pass=$is_use_socks_pass
fi fi
if [[ $is_use_tls ]]; then if [[ $is_use_tls ]]; then
@@ -1039,11 +1067,17 @@ add() {
# set port # set port
[[ ! $port ]] && ask string port "请输入端口:" [[ ! $port ]] && ask string port "请输入端口:"
case ${is_new_protocol} in case ${is_new_protocol,,} in
*tcp* | *kcp* | *quic*) *tcp* | *kcp* | *quic*)
[[ ! $header_type ]] && ask set_header_type [[ ! $header_type ]] && ask set_header_type
;; ;;
Shadowsocks) socks)
# set user
[[ ! $is_socks_user ]] && ask string is_socks_user "请设置用户名:"
# set password
[[ ! $is_socks_pass ]] && ask string is_socks_pass "请设置密码:"
;;
shadowsocks)
# set method # set method
[[ ! $ss_method ]] && ask set_ss_method [[ ! $ss_method ]] && ask set_ss_method
# set password # set password
@@ -1130,12 +1164,12 @@ get() {
get file $2 get file $2
if [[ $is_config_file ]]; then if [[ $is_config_file ]]; then
is_json_str=$(cat $is_conf_dir/"$is_config_file") is_json_str=$(cat $is_conf_dir/"$is_config_file")
is_json_data_base=$(jq '.inbounds[0]|.protocol,.port,.settings.clients[0].id,.settings.clients[0].password,.settings.method,.settings.password,.settings.address,.settings.port,.settings.detour.to' <<<$is_json_str) is_json_data_base=$(jq '.inbounds[0]|.protocol,.port,.settings.clients[0].id,.settings.clients[0].password,.settings.method,.settings.password,.settings.address,.settings.port,.settings.detour.to,.settings.accounts[0].user,.settings.accounts[0].pass' <<<$is_json_str)
[[ $? != 0 ]] && err "无法读取此文件: $is_config_file" [[ $? != 0 ]] && err "无法读取此文件: $is_config_file"
is_json_data_more=$(jq '.inbounds[0]|.streamSettings|.network,.security,.tcpSettings.header.type,.kcpSettings.seed,.kcpSettings.header.type,.quicSettings.header.type,.wsSettings.path,.httpSettings.path,.grpcSettings.serviceName' <<<$is_json_str) is_json_data_more=$(jq '.inbounds[0]|.streamSettings|.network,.security,.tcpSettings.header.type,.kcpSettings.seed,.kcpSettings.header.type,.quicSettings.header.type,.wsSettings.path,.httpSettings.path,.grpcSettings.serviceName' <<<$is_json_str)
is_json_data_host=$(jq '.inbounds[0]|.streamSettings|.grpc_host,.wsSettings.headers.Host,.httpSettings.host[0]' <<<$is_json_str) is_json_data_host=$(jq '.inbounds[0]|.streamSettings|.grpc_host,.wsSettings.headers.Host,.httpSettings.host[0]' <<<$is_json_str)
is_json_data_reality=$(jq '.inbounds[0]|.streamSettings|.realitySettings.serverNames[0],.realitySettings.publicKey,.realitySettings.privateKey' <<<$is_json_str) is_json_data_reality=$(jq '.inbounds[0]|.streamSettings|.realitySettings.serverNames[0],.realitySettings.publicKey,.realitySettings.privateKey' <<<$is_json_str)
is_up_var_set=(null is_protocol port uuid trojan_password ss_method ss_password door_addr door_port is_dynamic_port net is_reality tcp_type kcp_seed kcp_type quic_type ws_path h2_path grpc_path grpc_host ws_host h2_host is_servername is_public_key is_private_key) is_up_var_set=(null is_protocol port uuid trojan_password ss_method ss_password door_addr door_port is_dynamic_port is_socks_user is_socks_pass net is_reality tcp_type kcp_seed kcp_type quic_type ws_path h2_path grpc_path grpc_host ws_host h2_host is_servername is_public_key is_private_key)
[[ $is_debug ]] && msg "\n------------- debug: $is_config_file -------------" [[ $is_debug ]] && msg "\n------------- debug: $is_config_file -------------"
i=0 i=0
for v in $(sed 's/""/null/g;s/"//g' <<<"$is_json_data_base $is_json_data_more $is_json_data_host $is_json_data_reality"); do for v in $(sed 's/""/null/g;s/"//g' <<<"$is_json_data_base $is_json_data_more $is_json_data_host $is_json_data_reality"); do
@@ -1215,12 +1249,14 @@ get() {
*http*) *http*)
is_protocol=http is_protocol=http
net=http net=http
json_str=''"$is_listen_127"'' json_str='settings:{"timeout": 233}'
;; ;;
*socks*) *socks*)
is_protocol=socks is_protocol=socks
net=socks net=socks
json_str=''"$is_listen_127"',settings:{udp:true}' [[ ! $is_socks_user ]] && is_socks_user=233boy
[[ ! $is_socks_pass ]] && is_socks_pass=$uuid
json_str='settings:{auth:"password",accounts:[{user:'\"$is_socks_user\"',pass:'\"$is_socks_pass\"'}],udp:true}'
;; ;;
*) *)
err "无法识别协议: $is_config_file" err "无法识别协议: $is_config_file"
@@ -1251,20 +1287,20 @@ get() {
net=ws net=ws
[[ ! $path ]] && path="/$uuid" [[ ! $path ]] && path="/$uuid"
is_stream='streamSettings:{network:"ws",security:'\"$is_tls\"',wsSettings:{path:'\"$path\"',headers:{Host:'\"$host\"'}}}' is_stream='streamSettings:{network:"ws",security:'\"$is_tls\"',wsSettings:{path:'\"$path\"',headers:{Host:'\"$host\"'}}}'
json_str=''"$is_listen_127"','"$is_server_id_json"','"$is_stream"'' json_str=''"$is_server_id_json"','"$is_stream"''
;; ;;
*grpc* | *gun) *grpc* | *gun)
net=grpc net=grpc
[[ ! $path ]] && path="$uuid" [[ ! $path ]] && path="$uuid"
[[ $path ]] && path=$(sed 's#/##g' <<<$path) [[ $path ]] && path=$(sed 's#/##g' <<<$path)
is_stream='streamSettings:{network:"grpc",grpc_host:'\"$host\"',security:'\"$is_tls\"',grpcSettings:{serviceName:'\"$path\"'}}' is_stream='streamSettings:{network:"grpc",grpc_host:'\"$host\"',security:'\"$is_tls\"',grpcSettings:{serviceName:'\"$path\"'}}'
json_str=''"$is_listen_127"','"$is_server_id_json"','"$is_stream"'' json_str=''"$is_server_id_json"','"$is_stream"''
;; ;;
*h2* | *http*) *h2* | *http*)
net=h2 net=h2
[[ ! $path ]] && path="/$uuid" [[ ! $path ]] && path="/$uuid"
is_stream='streamSettings:{network:"h2",security:'\"$is_tls\"',httpSettings:{path:'\"$path\"',host:['\"$host\"']}}' is_stream='streamSettings:{network:"h2",security:'\"$is_tls\"',httpSettings:{path:'\"$path\"',host:['\"$host\"']}}'
json_str=''"$is_listen_127"','"$is_server_id_json"','"$is_stream"'' json_str=''"$is_server_id_json"','"$is_stream"''
;; ;;
*reality*) *reality*)
net=reality net=reality
@@ -1399,7 +1435,7 @@ info() {
is_can_change=(0 1 5 7) is_can_change=(0 1 5 7)
is_info_show=(0 1 2 3 4 5) is_info_show=(0 1 2 3 4 5)
is_vmess_url=$(jq -c '{v:2,ps:'\"233boy-${net}-$is_addr\"',add:'\"$is_addr\"',port:'\"$port\"',id:'\"$uuid\"',net:'\"$net\"',type:'\"$header_type\"',path:'\"$kcp_seed\"'}' <<<{}) is_vmess_url=$(jq -c '{v:2,ps:'\"233boy-${net}-$is_addr\"',add:'\"$is_addr\"',port:'\"$port\"',id:'\"$uuid\"',net:'\"$net\"',type:'\"$header_type\"',path:'\"$kcp_seed\"'}' <<<{})
is_url=vmess://$(base64 -w 0 <<<$is_vmess_url) is_url=vmess://$(echo -n $is_vmess_url | base64 -w 0)
is_tmp_port=$port is_tmp_port=$port
[[ $is_dynamic_port ]] && { [[ $is_dynamic_port ]] && {
is_can_change+=(12) is_can_change+=(12)
@@ -1414,7 +1450,7 @@ info() {
ss) ss)
is_can_change=(0 1 4 6) is_can_change=(0 1 4 6)
is_info_show=(0 1 2 10 11) is_info_show=(0 1 2 10 11)
is_url="ss://$(base64 -w 0 <<<"${ss_method}:${ss_password}")@${ip}:${port}#233boy-ss-${ip}" is_url="ss://$(echo -n ${ss_method}:${ss_password} | base64 -w 0)@${is_addr}:${port}#233boy-ss-${is_addr}"
is_info_str=($is_protocol $is_addr $port $ss_password $ss_method) is_info_str=($is_protocol $is_addr $port $ss_password $ss_method)
;; ;;
ws | h2 | grpc) ws | h2 | grpc)
@@ -1428,7 +1464,7 @@ info() {
} }
[[ $is_protocol == 'vmess' ]] && { [[ $is_protocol == 'vmess' ]] && {
is_vmess_url=$(jq -c '{v:2,ps:'\"233boy-$host\"',add:'\"$is_addr\"',port:'\"443\"',id:'\"$uuid\"',net:'\"$net\"',host:'\"$host\"',path:'\"$path\"',tls:'\"tls\"'}' <<<{}) is_vmess_url=$(jq -c '{v:2,ps:'\"233boy-$host\"',add:'\"$is_addr\"',port:'\"443\"',id:'\"$uuid\"',net:'\"$net\"',host:'\"$host\"',path:'\"$path\"',tls:'\"tls\"'}' <<<{})
is_url=vmess://$(base64 -w 0 <<<$is_vmess_url) is_url=vmess://$(echo -n $is_vmess_url | base64 -w 0)
} || { } || {
[[ $is_trojan ]] && { [[ $is_trojan ]] && {
uuid=$trojan_password uuid=$trojan_password
@@ -1453,7 +1489,13 @@ info() {
is_info_show=(0 1 2 13 14) is_info_show=(0 1 2 13 14)
is_info_str=($is_protocol $is_addr $port $door_addr $door_port) is_info_str=($is_protocol $is_addr $port $door_addr $door_port)
;; ;;
socks | http) socks)
is_can_change=(0 1 15 4)
is_info_show=(0 1 2 19 10)
is_info_str=($is_protocol $is_addr $port $is_socks_user $is_socks_pass)
is_url="socks://$(echo -n ${is_socks_user}:${is_socks_pass} | base64 -w 0)@${is_addr}:${port}#233boy-socks-${is_addr}"
;;
http)
is_can_change=(0 1) is_can_change=(0 1)
is_info_show=(0 1 2) is_info_show=(0 1 2)
is_info_str=($is_protocol 127.0.0.1 $port) is_info_str=($is_protocol 127.0.0.1 $port)
@@ -1568,6 +1610,7 @@ update() {
fi fi
download $is_update_name $is_new_ver download $is_update_name $is_new_ver
msg "更新成功, 当前 $is_show_name 版本: $(_green $is_new_ver)\n" msg "更新成功, 当前 $is_show_name 版本: $(_green $is_new_ver)\n"
msg "$(_green 请查看更新说明: https://github.com/$is_sh_repo/releases/tag/$is_new_ver)\n"
manage restart $is_update_name & manage restart $is_update_name &
} }

View File

@@ -43,6 +43,7 @@ download() {
link="https://github.com/${is_sh_repo}/releases/download/${latest_ver}/code.zip" link="https://github.com/${is_sh_repo}/releases/download/${latest_ver}/code.zip"
download_file download_file
unzip -qo $tmpfile -d $is_sh_dir unzip -qo $tmpfile -d $is_sh_dir
chmod +x $is_sh_bin
;; ;;
caddy) caddy)
name="Caddy" name="Caddy"

View File

@@ -107,7 +107,7 @@ if [[ $is_old_use ]]; then
fi fi
fi fi
if [[ $socks ]]; then if [[ $socks ]]; then
add socks $socks_port add socks $socks_port $socks_username $socks_userpass
fi fi
port=$v2ray_port port=$v2ray_port
uuid=$v2ray_id uuid=$v2ray_id

View File

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