add socks url and listen string
This commit is contained in:
28
src/core.sh
28
src/core.sh
@@ -321,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
|
||||||
@@ -335,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.
|
||||||
@@ -1242,7 +1249,7 @@ 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
|
||||||
@@ -1280,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
|
||||||
@@ -1443,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://$(base64 -w 0 <<<"${ss_method}:${ss_password}")@${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)
|
||||||
@@ -1486,6 +1493,7 @@ info() {
|
|||||||
is_can_change=(0 1 15 4)
|
is_can_change=(0 1 15 4)
|
||||||
is_info_show=(0 1 2 19 10)
|
is_info_show=(0 1 2 19 10)
|
||||||
is_info_str=($is_protocol $is_addr $port $is_socks_user $is_socks_pass)
|
is_info_str=($is_protocol $is_addr $port $is_socks_user $is_socks_pass)
|
||||||
|
is_url="socks://$(base64 -w 0 <<<"${is_socks_user}:${is_socks_pass}")@${is_addr}:${port}#233boy-socks-${is_addr}"
|
||||||
;;
|
;;
|
||||||
http)
|
http)
|
||||||
is_can_change=(0 1)
|
is_can_change=(0 1)
|
||||||
|
Reference in New Issue
Block a user