Codacy compliant

This commit is contained in:
Samuel Huang
2024-09-30 19:49:06 +10:00
parent ec0e068eb7
commit ae8a1a469a
17 changed files with 227 additions and 307 deletions

42
run.sh
View File

@@ -1,6 +1,6 @@
#!/bin/bash
DIR=`dirname $0`
DIR=$(dirname $0)
DIR="$(cd $DIR; pwd)"
CERTHOME="/opt/cert"
XCONF=/tmp/server-xray.json
@@ -42,7 +42,7 @@ usage() {
Jrules='{"rules":[]}'
TEMP=`getopt -o u:k:r:c:j:di --long lgp:,lgr:,lgt:,lsp:,lst:,ltr:,ltrx:,ltt:,lttx:,lwp:,lwt:,mtt:,mwp:,mwt:,ttt:,twp:,twt:,user:,hook:,request-domain:,cert-home:,ip-block:,domain-block:,cn-block,ng-server:,ng-proxy:,st-server:,st-map:,json:,stdin,debug -n "$0" -- $@`
TEMP=$(getopt -o u:k:r:c:j:di --long lgp:,lgr:,lgt:,lsp:,lst:,ltr:,ltrx:,ltt:,lttx:,lwp:,lwt:,mtt:,mwp:,mwt:,ttt:,twp:,twt:,user:,hook:,request-domain:,cert-home:,ip-block:,domain-block:,cn-block,ng-server:,ng-proxy:,st-server:,st-map:,json:,stdin,debug -n "$0" -- $@)
if [ $? != 0 ] ; then usage; exit 1 ; fi
eval set -- "$TEMP"
@@ -79,33 +79,33 @@ while true ; do
;;
--lgp|--lgr|--lgt|--lsp|--lst|--ltr|--ltt|--lwp|--lwt|--mtt|--mwp|--mwt|--ttt|--twp|--twt)
# Alias options
SVC=`echo $1|tr -d '\-\-'`
SVC=$(echo $1|tr -d '\-\-')
SVCMD+=("${DIR}/server-${SVC}.sh $2")
shift 2
;;
--ltrx|--lttx)
# Alias options
SVC=`echo $1|tr -d '\-\-'|tr -d x`
SVC=$(echo $1|tr -d '\-\-'|tr -d x)
SVCMD+=("${DIR}/server-${SVC}.sh $2,xtls")
shift 2
;;
--domain-block)
Jrules=`echo "${Jrules}" | jq --arg blkdomain "$2" \
'.rules += [{"type":"field","outboundTag":"blocked","domain":[$blkdomain]}]'`
Jrules=$(echo "${Jrules}" | jq --arg blkdomain "$2" \
'.rules += [{"type":"field","outboundTag":"blocked","domain":[$blkdomain]}]')
shift 2
;;
--ip-block)
Jrules=`echo "${Jrules}" | jq --arg blkip "$2" \
'.rules += [{"type":"field","outboundTag":"blocked","ip":[$blkip]}]'`
Jrules=$(echo "${Jrules}" | jq --arg blkip "$2" \
'.rules += [{"type":"field","outboundTag":"blocked","ip":[$blkip]}]')
shift 2
;;
--cn-block)
Jrules=`echo "${Jrules}" | jq --arg igndomain "geosite:geolocation-cn" \
'.rules += [{"type":"field","outboundTag":"blocked","domain":[$igndomain]}]'`
Jrules=`echo "${Jrules}" | jq --arg igndomain "geosite:cn" \
'.rules += [{"type":"field","outboundTag":"blocked","domain":[$igndomain]}]'`
Jrules=`echo "${Jrules}" | jq --arg ignip "geoip:cn" \
'.rules += [{"type":"field","outboundTag":"blocked","ip":[$ignip]}]'`
Jrules=$(echo "${Jrules}" | jq --arg igndomain "geosite:geolocation-cn" \
'.rules += [{"type":"field","outboundTag":"blocked","domain":[$igndomain]}]')
Jrules=$(echo "${Jrules}" | jq --arg igndomain "geosite:cn" \
'.rules += [{"type":"field","outboundTag":"blocked","domain":[$igndomain]}]')
Jrules=$(echo "${Jrules}" | jq --arg ignip "geoip:cn" \
'.rules += [{"type":"field","outboundTag":"blocked","ip":[$ignip]}]')
shift 1
;;
--ng-server)
@@ -214,30 +214,30 @@ Jroot='{"outbounds":[{"tag":"direct","protocol":"freedom"},{"tag":"blocked","pro
# Add routing config
Jrouting='{"routing":{"domainStrategy":"AsIs"}}'
Jrouting=`echo $Jrouting |jq --argjson jrules "${Jrules}" '.routing += $jrules'`
Jrouting=$(echo $Jrouting |jq --argjson jrules "${Jrules}" '.routing += $jrules')
Jroot=`echo $Jroot| jq --argjson jrouting "${Jrouting}" '. += $jrouting'`
Jroot=$(echo $Jroot| jq --argjson jrouting "${Jrouting}" '. += $jrouting')
# Xray service config generation
for svcmd in "${SVCMD[@]}"
do
Jsvc=`$svcmd,$xopt`
Jsvc=$($svcmd,$xopt)
if [[ $? -ne 0 ]]; then
echo "Service creation command failed: $svcmd,$xopt"
exit 1
fi
Jroot=`echo $Jroot| jq --argjson Jsvc "${Jsvc}" '.inbounds += [$Jsvc]'`
Jroot=$(echo $Jroot| jq --argjson Jsvc "${Jsvc}" '.inbounds += [$Jsvc]')
done
if [ -n "${DEBUG}" ]; then loglevel="debug"; else loglevel="warning"; fi
Jroot=`echo $Jroot| jq --arg loglevel "${loglevel}" '.log.loglevel |= $loglevel'`
Jroot=$(echo $Jroot| jq --arg loglevel "${loglevel}" '.log.loglevel |= $loglevel')
if [ -n "${INJECT}" ]; then
for JSON_IN in "${INJECT[@]}"
do
Jmerge=`jq -nc "${JSON_IN}"`
Jmerge=$(jq -nc "${JSON_IN}")
if [[ $? -ne 0 ]]; then echo "Invalid json ${JSON_IN}"; exit 1; fi
Jroot=`jq -n --argjson Jroot "${Jroot}" --argjson Jmerge "${Jmerge}" '$Jroot + $Jmerge'`
Jroot=$(jq -n --argjson Jroot "${Jroot}" --argjson Jmerge "${Jmerge}" '$Jroot + $Jmerge')
done
fi

View File

@@ -1,6 +1,6 @@
#!/bin/bash
DIR=`dirname $0`
DIR=$(dirname $0)
usage() {
>&2 echo "VLESS-GRPC-PLAIN server builder"
@@ -9,10 +9,10 @@ usage() {
>&2 echo "User format: user|u=<uid>[:level:email]"
}
options=(`echo $1 |tr ',' ' '`)
options=($(echo $1 |tr ',' ' '))
for option in "${options[@]}"
do
kv=(`echo $option |tr '=' ' '`)
kv=($(echo $option |tr '=' ' '))
case "${kv[0]}" in
d|domain)
domain="${kv[1]}"
@@ -58,7 +58,7 @@ fi
if ! [ "${port}" -eq "${port}" ] 2>/dev/null; then >&2 echo -e "Error: Port number must be numeric.\n"; exit 1; fi
# inbound frame
inbound=`jq -nc --arg port "${port}" '{"port":($port|tonumber),"protocol":"vless","settings":{"decryption":"none"}}'`
inbound=$(jq -nc --arg port "${port}" '{"port":($port|tonumber),"protocol":"vless","settings":{"decryption":"none"}}')
# User settings
for user in "${xuser[@]}"
@@ -69,20 +69,20 @@ do
if [ -z "${uid}" ]; then >&2 echo "Incorrect user format: $user"; usage; exit 1; fi
if [ -z "${level}" ]; then level=0; fi
if [ -z "${email}" ]; then email="${uid}@lgp.$domain"; fi
inbound=`echo $inbound| jq -c --arg uid "${uid}" --arg flow "${flow}" --arg level "${level}" --arg email "${email}" \
'.settings.clients += [{"id":$uid,"level":($level|tonumber),"email":$email,"flow":$flow}]'`
inbound=$(echo $inbound| jq -c --arg uid "${uid}" --arg flow "${flow}" --arg level "${level}" --arg email "${email}" \
'.settings.clients += [{"id":$uid,"level":($level|tonumber),"email":$email,"flow":$flow}]')
done
# StreamSettings
if [ -n "${acceptProxyProtocol}" ]; then
inbound=`echo $inbound| jq -c '.streamSettings.sockopt += {"acceptProxyProtocol":true}'`
inbound=$(echo $inbound| jq -c '.streamSettings.sockopt += {"acceptProxyProtocol":true}')
fi
# Network settings
inbound=`echo $inbound| jq -c --arg serviceName "${serviceName}" '.streamSettings += {"network":"grpc","grpcSettings":{"serviceName":$serviceName}}'`
inbound=$(echo $inbound| jq -c --arg serviceName "${serviceName}" '.streamSettings += {"network":"grpc","grpcSettings":{"serviceName":$serviceName}}')
# Security settings
inbound=`echo $inbound| jq -c '.streamSettings += {"security":"none"}'`
inbound=$(echo $inbound| jq -c '.streamSettings += {"security":"none"}')
# Fallback settings
for fb in "${fallback[@]}"
@@ -93,8 +93,8 @@ do
if [ -z "${fport}" ]; then >&2 echo "Incorrect fallback format: ${fallback}"; usage; exit 1; fi
if [ -z "${fhost}" ]; then fhost="127.0.0.1"; fi
fdest="$fhost:$fport"
Jfb=`jq -nc --arg fdest "${fdest}" --arg fpath "${fpath}" '. |= {"dest":$fdest,"path":$fpath,"xver":1}'`
inbound=`echo $inbound| jq -c --argjson Jfb "${Jfb}" '.settings.fallbacks += [$Jfb]'`
Jfb=$(jq -nc --arg fdest "${fdest}" --arg fpath "${fpath}" '. |= {"dest":$fdest,"path":$fpath,"xver":1}')
inbound=$(echo $inbound| jq -c --argjson Jfb "${Jfb}" '.settings.fallbacks += [$Jfb]')
done
echo $inbound

View File

@@ -1,6 +1,6 @@
#!/bin/bash
DIR=`dirname $0`
DIR=$(dirname $0)
usage() {
>&2 echo "VLESS-GRPC-REALITY server builder"
@@ -9,10 +9,10 @@ usage() {
>&2 echo "User format: user|u=<uid>[:level:email]"
}
options=(`echo $1 |tr ',' ' '`)
options=($(echo $1 |tr ',' ' '))
for option in "${options[@]}"
do
kv=(`echo $option |tr '=' ' '`)
kv=($(echo $option |tr '=' ' '))
case "${kv[0]}" in
d|dest)
dest="${kv[1]}"
@@ -65,7 +65,7 @@ fi
if [ -z "${prvkey}" ]; then
>&2 echo "Warning: PrivateKey undefined, Generated new..."
kv=(`/usr/local/bin/xray x25519|cut -d ' ' -f3|tr ' '`)
kv=($(/usr/local/bin/xray x25519|cut -d ' ' -f3|tr ' '))
prvkey="${kv[0]}"
pubkey="${kv[1]}"
>&2 echo "PublicKey: $pubkey"
@@ -84,7 +84,7 @@ fi
if ! [ "${port}" -eq "${port}" ] 2>/dev/null; then >&2 echo -e "Error: Port number must be numeric.\n"; exit 1; fi
# inbound frame
inbound=`jq -nc --arg port "${port}" '{"port":($port|tonumber),"protocol":"vless","settings":{"decryption":"none"}}'`
inbound=$(jq -nc --arg port "${port}" '{"port":($port|tonumber),"protocol":"vless","settings":{"decryption":"none"}}')
# User settings
for user in "${xuser[@]}"
@@ -95,34 +95,34 @@ do
if [ -z "${uid}" ]; then >&2 echo "Incorrect user format: $user"; usage; exit 1; fi
if [ -z "${level}" ]; then level=0; fi
if [ -z "${email}" ]; then email="${uid}@lgr.$dest"; fi
inbound=`echo $inbound| jq -c --arg uid "${uid}" --arg flow "${flow}" --arg level "${level}" --arg email "${email}" \
'.settings.clients += [{"id":$uid,"level":($level|tonumber),"email":$email,"flow":$flow}]'`
inbound=$(echo $inbound| jq -c --arg uid "${uid}" --arg flow "${flow}" --arg level "${level}" --arg email "${email}" \
'.settings.clients += [{"id":$uid,"level":($level|tonumber),"email":$email,"flow":$flow}]')
done
# StreamSettings
if [ -n "${acceptProxyProtocol}" ]; then
inbound=`echo $inbound| jq -c '.streamSettings.sockopt += {"acceptProxyProtocol":true}'`
inbound=$(echo $inbound| jq -c '.streamSettings.sockopt += {"acceptProxyProtocol":true}')
fi
# Network settings
inbound=`echo $inbound| jq -c --arg serviceName "${serviceName}" '.streamSettings += {"network":"grpc","grpcSettings":{"serviceName":$serviceName}}'`
inbound=$(echo $inbound| jq -c --arg serviceName "${serviceName}" '.streamSettings += {"network":"grpc","grpcSettings":{"serviceName":$serviceName}}')
# Security settings
inbound=`echo $inbound| jq -c '.streamSettings += {"security":"reality"}'`
inbound=$(echo $inbound| jq -c '.streamSettings += {"security":"reality"}')
# Reality settings
inbound=`echo $inbound| jq -c --arg dest "${dest}" --arg pubkey "${pubkey}" --arg prvkey "${prvkey}" \
'.streamSettings.realitySettings += {"show":true,"dest":"\($dest):443","serverNames":[$dest],"privateKey":$prvkey,"publicKey":$pubkey}'`
inbound=$(echo $inbound| jq -c --arg dest "${dest}" --arg pubkey "${pubkey}" --arg prvkey "${prvkey}" \
'.streamSettings.realitySettings += {"show":true,"dest":"\($dest):443","serverNames":[$dest],"privateKey":$prvkey,"publicKey":$pubkey}')
# serverNames settings
if [ -n "${serverNames}" ]; then
JserverNames=`printf '%s\n' "${serverNames[@]}"|jq -R|jq -sc`
inbound=`echo $inbound| jq -c --argjson JserverNames "${JserverNames}" '.streamSettings.realitySettings.serverNames += $JserverNames'`
JserverNames=$(printf '%s\n' "${serverNames[@]}"|jq -R|jq -sc)
inbound=$(echo $inbound| jq -c --argjson JserverNames "${JserverNames}" '.streamSettings.realitySettings.serverNames += $JserverNames')
fi
# shortIds settings
JshortIds=`printf '%s\n' "${shortIds[@]}"|jq -R|jq -sc`
inbound=`echo $inbound| jq -c --argjson JshortIds "${JshortIds}" '.streamSettings.realitySettings.shortIds += $JshortIds'`
JshortIds=$(printf '%s\n' "${shortIds[@]}"|jq -R|jq -sc)
inbound=$(echo $inbound| jq -c --argjson JshortIds "${JshortIds}" '.streamSettings.realitySettings.shortIds += $JshortIds')
# Fallback settings
for fb in "${fallback[@]}"
@@ -133,8 +133,8 @@ do
if [ -z "${fport}" ]; then >&2 echo "Incorrect fallback format: ${fallback}"; usage; exit 1; fi
if [ -z "${fhost}" ]; then fhost="127.0.0.1"; fi
fdest="$fhost:$fport"
Jfb=`jq -nc --arg fdest "${fdest}" --arg fpath "${fpath}" '. |= {"dest":$fdest,"path":$fpath,"xver":1}'`
inbound=`echo $inbound| jq -c --argjson Jfb "${Jfb}" '.settings.fallbacks += [$Jfb]'`
Jfb=$(jq -nc --arg fdest "${fdest}" --arg fpath "${fpath}" '. |= {"dest":$fdest,"path":$fpath,"xver":1}')
inbound=$(echo $inbound| jq -c --argjson Jfb "${Jfb}" '.settings.fallbacks += [$Jfb]')
done
echo $inbound

View File

@@ -1,6 +1,6 @@
#!/bin/bash
DIR=`dirname $0`
DIR=$(dirname $0)
usage() {
>&2 echo "VLESS-GRPC-TLS server builder"
@@ -9,10 +9,10 @@ usage() {
>&2 echo "User format: user|u=<uid>[:level:email]"
}
options=(`echo $1 |tr ',' ' '`)
options=($(echo $1 |tr ',' ' '))
for option in "${options[@]}"
do
kv=(`echo $option |tr '=' ' '`)
kv=($(echo $option |tr '=' ' '))
case "${kv[0]}" in
c|certhome)
certhome="${kv[1]}"
@@ -77,7 +77,7 @@ if [ ! -f "${prvkey}" ]; then >&2 echo "Warning, Private key not found: ${prvkey
if ! [ "${port}" -eq "${port}" ] 2>/dev/null; then >&2 echo -e "Error: Port number must be numeric.\n"; exit 1; fi
# inbound frame
inbound=`jq -nc --arg port "${port}" '{"port":($port|tonumber),"protocol":"vless","settings":{"decryption":"none"}}'`
inbound=$(jq -nc --arg port "${port}" '{"port":($port|tonumber),"protocol":"vless","settings":{"decryption":"none"}}')
# User settings
for user in "${xuser[@]}"
@@ -88,22 +88,22 @@ do
if [ -z "${uid}" ]; then >&2 echo "Incorrect user format: $user"; usage; exit 1; fi
if [ -z "${level}" ]; then level=0; fi
if [ -z "${email}" ]; then email="${uid}@lgt.$domain"; fi
inbound=`echo $inbound| jq -c --arg uid "${uid}" --arg flow "${flow}" --arg level "${level}" --arg email "${email}" \
'.settings.clients += [{"id":$uid,"level":($level|tonumber),"email":$email,"flow":$flow}]'`
inbound=$(echo $inbound| jq -c --arg uid "${uid}" --arg flow "${flow}" --arg level "${level}" --arg email "${email}" \
'.settings.clients += [{"id":$uid,"level":($level|tonumber),"email":$email,"flow":$flow}]')
done
# StreamSettings
if [ -n "${acceptProxyProtocol}" ]; then
inbound=`echo $inbound| jq -c '.streamSettings.sockopt += {"acceptProxyProtocol":true}'`
inbound=$(echo $inbound| jq -c '.streamSettings.sockopt += {"acceptProxyProtocol":true}')
fi
# Network settings
inbound=`echo $inbound| jq -c --arg serviceName "${serviceName}" '.streamSettings += {"network":"grpc","grpcSettings":{"serviceName":$serviceName}}'`
inbound=$(echo $inbound| jq -c --arg serviceName "${serviceName}" '.streamSettings += {"network":"grpc","grpcSettings":{"serviceName":$serviceName}}')
# Security settings
inbound=`echo $inbound| jq -c '.streamSettings += {"security":"tls"}'`
inbound=`echo $inbound| jq -c --arg fullchain "${fullchain}" --arg prvkey "${prvkey}" \
'.streamSettings.tlsSettings += {"certificates":[{"certificateFile":$fullchain,"keyFile":$prvkey}]}'`
inbound=$(echo $inbound| jq -c '.streamSettings += {"security":"tls"}')
inbound=$(echo $inbound| jq -c --arg fullchain "${fullchain}" --arg prvkey "${prvkey}" \
'.streamSettings.tlsSettings += {"certificates":[{"certificateFile":$fullchain,"keyFile":$prvkey}]}')
# Fallback settings
for fb in "${fallback[@]}"
@@ -114,8 +114,8 @@ do
if [ -z "${fport}" ]; then >&2 echo "Incorrect fallback format: ${fallback}"; usage; exit 1; fi
if [ -z "${fhost}" ]; then fhost="127.0.0.1"; fi
fdest="$fhost:$fport"
Jfb=`jq -nc --arg fdest "${fdest}" --arg fpath "${fpath}" '. |= {"dest":$fdest,"path":$fpath,"xver":1}'`
inbound=`echo $inbound| jq -c --argjson Jfb "${Jfb}" '.settings.fallbacks += [$Jfb]'`
Jfb=$(jq -nc --arg fdest "${fdest}" --arg fpath "${fpath}" '. |= {"dest":$fdest,"path":$fpath,"xver":1}')
inbound=$(echo $inbound| jq -c --argjson Jfb "${Jfb}" '.settings.fallbacks += [$Jfb]')
done
echo $inbound

View File

@@ -1,6 +1,6 @@
#!/bin/bash
DIR=`dirname $0`
DIR=$(dirname $0)
usage() {
>&2 echo "VLESS-SPLT-PLAIN server builder"
@@ -9,10 +9,10 @@ usage() {
>&2 echo "User format: user|u=<uid>[:level:email]"
}
options=(`echo $1 |tr ',' ' '`)
options=($(echo $1 |tr ',' ' '))
for option in "${options[@]}"
do
kv=(`echo $option |tr '=' ' '`)
kv=($(echo $option |tr '=' ' '))
case "${kv[0]}" in
d|domain)
domain="${kv[1]}"
@@ -58,7 +58,7 @@ fi
if ! [ "${port}" -eq "${port}" ] 2>/dev/null; then >&2 echo -e "Error: Port number must be numeric.\n"; exit 1; fi
# inbound frame
inbound=`jq -nc --arg port "${port}" '{"port":($port|tonumber),"protocol":"vless","settings":{"decryption":"none"}}'`
inbound=$(jq -nc --arg port "${port}" '{"port":($port|tonumber),"protocol":"vless","settings":{"decryption":"none"}}')
# User settings
for user in "${xuser[@]}"
@@ -69,20 +69,20 @@ do
if [ -z "${uid}" ]; then >&2 echo "Incorrect user format: $user"; usage; exit 1; fi
if [ -z "${level}" ]; then level=0; fi
if [ -z "${email}" ]; then email="${uid}@lsp.$domain"; fi
inbound=`echo $inbound| jq -c --arg uid "${uid}" --arg flow "${flow}" --arg level "${level}" --arg email "${email}" \
'.settings.clients += [{"id":$uid,"level":($level|tonumber),"email":$email,"flow":$flow}]'`
inbound=$(echo $inbound| jq -c --arg uid "${uid}" --arg flow "${flow}" --arg level "${level}" --arg email "${email}" \
'.settings.clients += [{"id":$uid,"level":($level|tonumber),"email":$email,"flow":$flow}]')
done
# StreamSettings
if [ -n "${acceptProxyProtocol}" ]; then
inbound=`echo $inbound| jq -c '.streamSettings.sockopt += {"acceptProxyProtocol":true}'`
inbound=$(echo $inbound| jq -c '.streamSettings.sockopt += {"acceptProxyProtocol":true}')
fi
# Network settings
inbound=`echo $inbound| jq -c --arg webpath "${webpath}" '.streamSettings += {"network":"splithttp","splithttpSettings":{"path":$webpath}}'`
inbound=$(echo $inbound| jq -c --arg webpath "${webpath}" '.streamSettings += {"network":"splithttp","splithttpSettings":{"path":$webpath}}')
# Security settings
inbound=`echo $inbound| jq -c '.streamSettings += {"security":"none"}'`
inbound=$(echo $inbound| jq -c '.streamSettings += {"security":"none"}')
# Fallback settings
for fb in "${fallback[@]}"
@@ -93,8 +93,8 @@ do
if [ -z "${fport}" ]; then >&2 echo "Incorrect fallback format: ${fallback}"; usage; exit 1; fi
if [ -z "${fhost}" ]; then fhost="127.0.0.1"; fi
fdest="$fhost:$fport"
Jfb=`jq -nc --arg fdest "${fdest}" --arg fpath "${fpath}" '. |= {"dest":$fdest,"path":$fpath,"xver":1}'`
inbound=`echo $inbound| jq -c --argjson Jfb "${Jfb}" '.settings.fallbacks += [$Jfb]'`
Jfb=$(jq -nc --arg fdest "${fdest}" --arg fpath "${fpath}" '. |= {"dest":$fdest,"path":$fpath,"xver":1}')
inbound=$(echo $inbound| jq -c --argjson Jfb "${Jfb}" '.settings.fallbacks += [$Jfb]')
done
echo $inbound

View File

@@ -1,6 +1,6 @@
#!/bin/bash
DIR=`dirname $0`
DIR=$(dirname $0)
usage() {
>&2 echo "VLESS-SPLT-TLS server builder"
@@ -9,10 +9,10 @@ usage() {
>&2 echo "User format: user|u=<uid>[:level:email]"
}
options=(`echo $1 |tr ',' ' '`)
options=($(echo $1 |tr ',' ' '))
for option in "${options[@]}"
do
kv=(`echo $option |tr '=' ' '`)
kv=($(echo $option |tr '=' ' '))
case "${kv[0]}" in
c|certhome)
certhome="${kv[1]}"
@@ -77,7 +77,7 @@ if [ ! -f "${prvkey}" ]; then >&2 echo "Warning, Private key not found: ${prvkey
if ! [ "${port}" -eq "${port}" ] 2>/dev/null; then >&2 echo -e "Error: Port number must be numeric.\n"; exit 1; fi
# inbound frame
inbound=`jq -nc --arg port "${port}" '{"port":($port|tonumber),"protocol":"vless","settings":{"decryption":"none"}}'`
inbound=$(jq -nc --arg port "${port}" '{"port":($port|tonumber),"protocol":"vless","settings":{"decryption":"none"}}')
# User settings
for user in "${xuser[@]}"
@@ -88,22 +88,22 @@ do
if [ -z "${uid}" ]; then >&2 echo "Incorrect user format: $user"; usage; exit 1; fi
if [ -z "${level}" ]; then level=0; fi
if [ -z "${email}" ]; then email="${uid}@lst.$domain"; fi
inbound=`echo $inbound| jq -c --arg uid "${uid}" --arg flow "${flow}" --arg level "${level}" --arg email "${email}" \
'.settings.clients += [{"id":$uid,"level":($level|tonumber),"email":$email,"flow":$flow}]'`
inbound=$(echo $inbound| jq -c --arg uid "${uid}" --arg flow "${flow}" --arg level "${level}" --arg email "${email}" \
'.settings.clients += [{"id":$uid,"level":($level|tonumber),"email":$email,"flow":$flow}]')
done
# StreamSettings
if [ -n "${acceptProxyProtocol}" ]; then
inbound=`echo $inbound| jq -c '.streamSettings.sockopt += {"acceptProxyProtocol":true}'`
inbound=$(echo $inbound| jq -c '.streamSettings.sockopt += {"acceptProxyProtocol":true}')
fi
# Network settings
inbound=`echo $inbound| jq -c --arg webpath "${webpath}" '.streamSettings += {"network":"splithttp","splithttpSettings":{"path":$webpath}}'`
inbound=$(echo $inbound| jq -c --arg webpath "${webpath}" '.streamSettings += {"network":"splithttp","splithttpSettings":{"path":$webpath}}')
# Security settings
inbound=`echo $inbound| jq -c '.streamSettings += {"security":"tls"}'`
inbound=`echo $inbound| jq -c --arg fullchain "${fullchain}" --arg prvkey "${prvkey}" \
'.streamSettings.tlsSettings += {"certificates":[{"certificateFile":$fullchain,"keyFile":$prvkey}]}'`
inbound=$(echo $inbound| jq -c '.streamSettings += {"security":"tls"}')
inbound=$(echo $inbound| jq -c --arg fullchain "${fullchain}" --arg prvkey "${prvkey}" \
'.streamSettings.tlsSettings += {"certificates":[{"certificateFile":$fullchain,"keyFile":$prvkey}]}')
# Fallback settings
for fb in "${fallback[@]}"
@@ -114,8 +114,8 @@ do
if [ -z "${fport}" ]; then >&2 echo "Incorrect fallback format: ${fallback}"; usage; exit 1; fi
if [ -z "${fhost}" ]; then fhost="127.0.0.1"; fi
fdest="$fhost:$fport"
Jfb=`jq -nc --arg fdest "${fdest}" --arg fpath "${fpath}" '. |= {"dest":$fdest,"path":$fpath,"xver":1}'`
inbound=`echo $inbound| jq -c --argjson Jfb "${Jfb}" '.settings.fallbacks += [$Jfb]'`
Jfb=$(jq -nc --arg fdest "${fdest}" --arg fpath "${fpath}" '. |= {"dest":$fdest,"path":$fpath,"xver":1}')
inbound=$(echo $inbound| jq -c --argjson Jfb "${Jfb}" '.settings.fallbacks += [$Jfb]')
done
echo $inbound

View File

@@ -1,6 +1,6 @@
#!/bin/bash
DIR=`dirname $0`
DIR=$(dirname $0)
usage() {
>&2 echo "VLESS-TCP-REALITY server builder"
@@ -9,10 +9,10 @@ usage() {
>&2 echo "User format: user|u=<uid>[:level:email]"
}
options=(`echo $1 |tr ',' ' '`)
options=($(echo $1 |tr ',' ' '))
for option in "${options[@]}"
do
kv=(`echo $option |tr '=' ' '`)
kv=($(echo $option |tr '=' ' '))
case "${kv[0]}" in
d|dest)
dest="${kv[1]}"
@@ -62,7 +62,7 @@ fi
if [ -z "${prvkey}" ]; then
>&2 echo "Warning: PrivateKey undefined, Generated new..."
kv=(`/usr/local/bin/xray x25519|cut -d ' ' -f3|tr ' '`)
kv=($(/usr/local/bin/xray x25519|cut -d ' ' -f3|tr ' '))
prvkey="${kv[0]}"
pubkey="${kv[1]}"
>&2 echo "PublicKey: $pubkey"
@@ -76,7 +76,7 @@ fi
if ! [ "${port}" -eq "${port}" ] 2>/dev/null; then >&2 echo -e "Error: Port number must be numeric.\n"; exit 1; fi
# inbound frame
inbound=`jq -nc --arg port "${port}" '{"port":($port|tonumber),"protocol":"vless","settings":{"decryption":"none"}}'`
inbound=$(jq -nc --arg port "${port}" '{"port":($port|tonumber),"protocol":"vless","settings":{"decryption":"none"}}')
# User settings
for user in "${xuser[@]}"
@@ -87,34 +87,34 @@ do
if [ -z "${uid}" ]; then >&2 echo "Incorrect user format: $user"; usage; exit 1; fi
if [ -z "${level}" ]; then level=0; fi
if [ -z "${email}" ]; then email="${uid}@ltr.$dest"; fi
inbound=`echo $inbound| jq -c --arg uid "${uid}" --arg flow "${flow}" --arg level "${level}" --arg email "${email}" \
'.settings.clients += [{"id":$uid,"level":($level|tonumber),"email":$email,"flow":$flow}]'`
inbound=$(echo $inbound| jq -c --arg uid "${uid}" --arg flow "${flow}" --arg level "${level}" --arg email "${email}" \
'.settings.clients += [{"id":$uid,"level":($level|tonumber),"email":$email,"flow":$flow}]')
done
# StreamSettings
if [ -n "${acceptProxyProtocol}" ]; then
inbound=`echo $inbound| jq -c '.streamSettings.sockopt += {"acceptProxyProtocol":true}'`
inbound=$(echo $inbound| jq -c '.streamSettings.sockopt += {"acceptProxyProtocol":true}')
fi
# Network settings
inbound=`echo $inbound| jq -c '.streamSettings += {"network":"tcp"}'`
inbound=$(echo $inbound| jq -c '.streamSettings += {"network":"tcp"}')
# Security settings
inbound=`echo $inbound| jq -c '.streamSettings += {"security":"reality"}'`
inbound=$(echo $inbound| jq -c '.streamSettings += {"security":"reality"}')
# Reality settings
inbound=`echo $inbound| jq -c --arg dest "${dest}" --arg pubkey "${pubkey}" --arg prvkey "${prvkey}" \
'.streamSettings.realitySettings += {"show":true,"dest":"\($dest):443","serverNames":[$dest],"privateKey":$prvkey,"publicKey":$pubkey}'`
inbound=$(echo $inbound| jq -c --arg dest "${dest}" --arg pubkey "${pubkey}" --arg prvkey "${prvkey}" \
'.streamSettings.realitySettings += {"show":true,"dest":"\($dest):443","serverNames":[$dest],"privateKey":$prvkey,"publicKey":$pubkey}')
# serverNames settings
if [ -n "${serverNames}" ]; then
JserverNames=`printf '%s\n' "${serverNames[@]}"|jq -R|jq -sc`
inbound=`echo $inbound| jq -c --argjson JserverNames "${JserverNames}" '.streamSettings.realitySettings.serverNames += $JserverNames'`
JserverNames=$(printf '%s\n' "${serverNames[@]}"|jq -R|jq -sc)
inbound=$(echo $inbound| jq -c --argjson JserverNames "${JserverNames}" '.streamSettings.realitySettings.serverNames += $JserverNames')
fi
# shortIds settings
JshortIds=`printf '%s\n' "${shortIds[@]}"|jq -R|jq -sc`
inbound=`echo $inbound| jq -c --argjson JshortIds "${JshortIds}" '.streamSettings.realitySettings.shortIds += $JshortIds'`
JshortIds=$(printf '%s\n' "${shortIds[@]}"|jq -R|jq -sc)
inbound=$(echo $inbound| jq -c --argjson JshortIds "${JshortIds}" '.streamSettings.realitySettings.shortIds += $JshortIds')
# Fallback settings
for fb in "${fallback[@]}"
@@ -125,8 +125,8 @@ do
if [ -z "${fport}" ]; then >&2 echo "Incorrect fallback format: ${fallback}"; usage; exit 1; fi
if [ -z "${fhost}" ]; then fhost="127.0.0.1"; fi
fdest="$fhost:$fport"
Jfb=`jq -nc --arg fdest "${fdest}" --arg fpath "${fpath}" '. |= {"dest":$fdest,"path":$fpath,"xver":1}'`
inbound=`echo $inbound| jq -c --argjson Jfb "${Jfb}" '.settings.fallbacks += [$Jfb]'`
Jfb=$(jq -nc --arg fdest "${fdest}" --arg fpath "${fpath}" '. |= {"dest":$fdest,"path":$fpath,"xver":1}')
inbound=$(echo $inbound| jq -c --argjson Jfb "${Jfb}" '.settings.fallbacks += [$Jfb]')
done
echo $inbound

View File

@@ -1,6 +1,6 @@
#!/bin/bash
DIR=`dirname $0`
DIR=$(dirname $0)
usage() {
>&2 echo "VLESS-TCP-TLS server builder"
@@ -9,10 +9,10 @@ usage() {
>&2 echo "User format: user|u=<uid>[:level:email]"
}
options=(`echo $1 |tr ',' ' '`)
options=($(echo $1 |tr ',' ' '))
for option in "${options[@]}"
do
kv=(`echo $option |tr '=' ' '`)
kv=($(echo $option |tr '=' ' '))
case "${kv[0]}" in
c|certhome)
certhome="${kv[1]}"
@@ -69,7 +69,7 @@ if [ ! -f "${prvkey}" ]; then >&2 echo "Warning, Private key not found: ${prvkey
if ! [ "${port}" -eq "${port}" ] 2>/dev/null; then >&2 echo -e "Error: Port number must be numeric.\n"; exit 1; fi
# inbound frame
inbound=`jq -nc --arg port "${port}" '{"port":($port|tonumber),"protocol":"vless","settings":{"decryption":"none"}}'`
inbound=$(jq -nc --arg port "${port}" '{"port":($port|tonumber),"protocol":"vless","settings":{"decryption":"none"}}')
# User settings
for user in "${xuser[@]}"
@@ -80,22 +80,22 @@ do
if [ -z "${uid}" ]; then >&2 echo "Incorrect user format: $user"; usage; exit 1; fi
if [ -z "${level}" ]; then level=0; fi
if [ -z "${email}" ]; then email="${uid}@ltt.$domain"; fi
inbound=`echo $inbound| jq -c --arg uid "${uid}" --arg flow "${flow}" --arg level "${level}" --arg email "${email}" \
'.settings.clients += [{"id":$uid,"level":($level|tonumber),"email":$email,"flow":$flow}]'`
inbound=$(echo $inbound| jq -c --arg uid "${uid}" --arg flow "${flow}" --arg level "${level}" --arg email "${email}" \
'.settings.clients += [{"id":$uid,"level":($level|tonumber),"email":$email,"flow":$flow}]')
done
# StreamSettings
if [ -n "${acceptProxyProtocol}" ]; then
inbound=`echo $inbound| jq -c '.streamSettings.sockopt += {"acceptProxyProtocol":true}'`
inbound=$(echo $inbound| jq -c '.streamSettings.sockopt += {"acceptProxyProtocol":true}')
fi
# Network settings
inbound=`echo $inbound| jq -c '.streamSettings += {"network":"tcp"}'`
inbound=$(echo $inbound| jq -c '.streamSettings += {"network":"tcp"}')
# Security settings
inbound=`echo $inbound| jq -c '.streamSettings += {"security":"tls"}'`
inbound=`echo $inbound| jq -c --arg fullchain "${fullchain}" --arg prvkey "${prvkey}" \
'.streamSettings.tlsSettings += {"certificates":[{"certificateFile":$fullchain,"keyFile":$prvkey}]}'`
inbound=$(echo $inbound| jq -c '.streamSettings += {"security":"tls"}')
inbound=$(echo $inbound| jq -c --arg fullchain "${fullchain}" --arg prvkey "${prvkey}" \
'.streamSettings.tlsSettings += {"certificates":[{"certificateFile":$fullchain,"keyFile":$prvkey}]}')
# Fallback settings
for fb in "${fallback[@]}"
@@ -106,8 +106,8 @@ do
if [ -z "${fport}" ]; then >&2 echo "Incorrect fallback format: ${fallback}"; usage; exit 1; fi
if [ -z "${fhost}" ]; then fhost="127.0.0.1"; fi
fdest="$fhost:$fport"
Jfb=`jq -nc --arg fdest "${fdest}" --arg fpath "${fpath}" '. |= {"dest":$fdest,"path":$fpath,"xver":1}'`
inbound=`echo $inbound| jq -c --argjson Jfb "${Jfb}" '.settings.fallbacks += [$Jfb]'`
Jfb=$(jq -nc --arg fdest "${fdest}" --arg fpath "${fpath}" '. |= {"dest":$fdest,"path":$fpath,"xver":1}')
inbound=$(echo $inbound| jq -c --argjson Jfb "${Jfb}" '.settings.fallbacks += [$Jfb]')
done
echo $inbound

View File

@@ -1,6 +1,6 @@
#!/bin/bash
DIR=`dirname $0`
DIR=$(dirname $0)
usage() {
>&2 echo "VLESS-WS-PLAIN server builder"
@@ -9,10 +9,10 @@ usage() {
>&2 echo "User format: user|u=<uid>[:level:email]"
}
options=(`echo $1 |tr ',' ' '`)
options=($(echo $1 |tr ',' ' '))
for option in "${options[@]}"
do
kv=(`echo $option |tr '=' ' '`)
kv=($(echo $option |tr '=' ' '))
case "${kv[0]}" in
d|domain)
domain="${kv[1]}"
@@ -58,7 +58,7 @@ fi
if ! [ "${port}" -eq "${port}" ] 2>/dev/null; then >&2 echo -e "Error: Port number must be numeric.\n"; exit 1; fi
# inbound frame
inbound=`jq -nc --arg port "${port}" '{"port":($port|tonumber),"protocol":"vless","settings":{"decryption":"none"}}'`
inbound=$(jq -nc --arg port "${port}" '{"port":($port|tonumber),"protocol":"vless","settings":{"decryption":"none"}}')
# User settings
for user in "${xuser[@]}"
@@ -69,20 +69,20 @@ do
if [ -z "${uid}" ]; then >&2 echo "Incorrect user format: $user"; usage; exit 1; fi
if [ -z "${level}" ]; then level=0; fi
if [ -z "${email}" ]; then email="${uid}@lwp.$domain"; fi
inbound=`echo $inbound| jq -c --arg uid "${uid}" --arg flow "${flow}" --arg level "${level}" --arg email "${email}" \
'.settings.clients += [{"id":$uid,"level":($level|tonumber),"email":$email,"flow":$flow}]'`
inbound=$(echo $inbound| jq -c --arg uid "${uid}" --arg flow "${flow}" --arg level "${level}" --arg email "${email}" \
'.settings.clients += [{"id":$uid,"level":($level|tonumber),"email":$email,"flow":$flow}]')
done
# StreamSettings
if [ -n "${acceptProxyProtocol}" ]; then
inbound=`echo $inbound| jq -c '.streamSettings.sockopt += {"acceptProxyProtocol":true}'`
inbound=$(echo $inbound| jq -c '.streamSettings.sockopt += {"acceptProxyProtocol":true}')
fi
# Network settings
inbound=`echo $inbound| jq -c --arg wspath "${wspath}" '.streamSettings += {"network":"ws","wsSettings":{"path":$wspath}}'`
inbound=$(echo $inbound| jq -c --arg wspath "${wspath}" '.streamSettings += {"network":"ws","wsSettings":{"path":$wspath}}')
# Security settings
inbound=`echo $inbound| jq -c '.streamSettings += {"security":"none"}'`
inbound=$(echo $inbound| jq -c '.streamSettings += {"security":"none"}')
# Fallback settings
for fb in "${fallback[@]}"
@@ -93,8 +93,8 @@ do
if [ -z "${fport}" ]; then >&2 echo "Incorrect fallback format: ${fallback}"; usage; exit 1; fi
if [ -z "${fhost}" ]; then fhost="127.0.0.1"; fi
fdest="$fhost:$fport"
Jfb=`jq -nc --arg fdest "${fdest}" --arg fpath "${fpath}" '. |= {"dest":$fdest,"path":$fpath,"xver":1}'`
inbound=`echo $inbound| jq -c --argjson Jfb "${Jfb}" '.settings.fallbacks += [$Jfb]'`
Jfb=$(jq -nc --arg fdest "${fdest}" --arg fpath "${fpath}" '. |= {"dest":$fdest,"path":$fpath,"xver":1}')
inbound=$(echo $inbound| jq -c --argjson Jfb "${Jfb}" '.settings.fallbacks += [$Jfb]')
done
echo $inbound

View File

@@ -1,6 +1,6 @@
#!/bin/bash
DIR=`dirname $0`
DIR=$(dirname $0)
usage() {
>&2 echo "VLESS-WS-TLS server builder"
@@ -9,10 +9,10 @@ usage() {
>&2 echo "User format: user|u=<uid>[:level:email]"
}
options=(`echo $1 |tr ',' ' '`)
options=($(echo $1 |tr ',' ' '))
for option in "${options[@]}"
do
kv=(`echo $option |tr '=' ' '`)
kv=($(echo $option |tr '=' ' '))
case "${kv[0]}" in
c|certhome)
certhome="${kv[1]}"
@@ -77,7 +77,7 @@ if [ ! -f "${prvkey}" ]; then >&2 echo "Warning, Private key not found: ${prvkey
if ! [ "${port}" -eq "${port}" ] 2>/dev/null; then >&2 echo -e "Error: Port number must be numeric.\n"; exit 1; fi
# inbound frame
inbound=`jq -nc --arg port "${port}" '{"port":($port|tonumber),"protocol":"vless","settings":{"decryption":"none"}}'`
inbound=$(jq -nc --arg port "${port}" '{"port":($port|tonumber),"protocol":"vless","settings":{"decryption":"none"}}')
# User settings
for user in "${xuser[@]}"
@@ -88,22 +88,22 @@ do
if [ -z "${uid}" ]; then >&2 echo "Incorrect user format: $user"; usage; exit 1; fi
if [ -z "${level}" ]; then level=0; fi
if [ -z "${email}" ]; then email="${uid}@lwt.$domain"; fi
inbound=`echo $inbound| jq -c --arg uid "${uid}" --arg flow "${flow}" --arg level "${level}" --arg email "${email}" \
'.settings.clients += [{"id":$uid,"level":($level|tonumber),"email":$email,"flow":$flow}]'`
inbound=$(echo $inbound| jq -c --arg uid "${uid}" --arg flow "${flow}" --arg level "${level}" --arg email "${email}" \
'.settings.clients += [{"id":$uid,"level":($level|tonumber),"email":$email,"flow":$flow}]')
done
# StreamSettings
if [ -n "${acceptProxyProtocol}" ]; then
inbound=`echo $inbound| jq -c '.streamSettings.sockopt += {"acceptProxyProtocol":true}'`
inbound=$(echo $inbound| jq -c '.streamSettings.sockopt += {"acceptProxyProtocol":true}')
fi
# Network settings
inbound=`echo $inbound| jq -c --arg wspath "${wspath}" '.streamSettings += {"network":"ws","wsSettings":{"path":$wspath}}'`
inbound=$(echo $inbound| jq -c --arg wspath "${wspath}" '.streamSettings += {"network":"ws","wsSettings":{"path":$wspath}}')
# Security settings
inbound=`echo $inbound| jq -c '.streamSettings += {"security":"tls"}'`
inbound=`echo $inbound| jq -c --arg fullchain "${fullchain}" --arg prvkey "${prvkey}" \
'.streamSettings.tlsSettings += {"certificates":[{"certificateFile":$fullchain,"keyFile":$prvkey}]}'`
inbound=$(echo $inbound| jq -c '.streamSettings += {"security":"tls"}')
inbound=$(echo $inbound| jq -c --arg fullchain "${fullchain}" --arg prvkey "${prvkey}" \
'.streamSettings.tlsSettings += {"certificates":[{"certificateFile":$fullchain,"keyFile":$prvkey}]}')
# Fallback settings
for fb in "${fallback[@]}"
@@ -114,8 +114,8 @@ do
if [ -z "${fport}" ]; then >&2 echo "Incorrect fallback format: ${fallback}"; usage; exit 1; fi
if [ -z "${fhost}" ]; then fhost="127.0.0.1"; fi
fdest="$fhost:$fport"
Jfb=`jq -nc --arg fdest "${fdest}" --arg fpath "${fpath}" '. |= {"dest":$fdest,"path":$fpath,"xver":1}'`
inbound=`echo $inbound| jq -c --argjson Jfb "${Jfb}" '.settings.fallbacks += [$Jfb]'`
Jfb=$(jq -nc --arg fdest "${fdest}" --arg fpath "${fpath}" '. |= {"dest":$fdest,"path":$fpath,"xver":1}')
inbound=$(echo $inbound| jq -c --argjson Jfb "${Jfb}" '.settings.fallbacks += [$Jfb]')
done
echo $inbound

View File

@@ -1,6 +1,6 @@
#!/bin/bash
DIR=`dirname $0`
DIR=$(dirname $0)
usage() {
>&2 echo "VMESS-TCP-TLS server builder"
@@ -9,10 +9,10 @@ usage() {
>&2 echo "User format: user|u=<uid>[:level:email]"
}
options=(`echo $1 |tr ',' ' '`)
options=($(echo $1 |tr ',' ' '))
for option in "${options[@]}"
do
kv=(`echo $option |tr '=' ' '`)
kv=($(echo $option |tr '=' ' '))
case "${kv[0]}" in
c|certhome)
certhome="${kv[1]}"
@@ -69,7 +69,7 @@ if [ ! -f "${prvkey}" ]; then >&2 echo "Warning, Private key not found: ${prvkey
if ! [ "${port}" -eq "${port}" ] 2>/dev/null; then >&2 echo -e "Error: Port number must be numeric.\n"; exit 1; fi
# inbound frame
inbound=`jq -nc --arg port "${port}" '{"port":($port|tonumber),"protocol":"vmess","settings":{"decryption":"none"}}'`
inbound=$(jq -nc --arg port "${port}" '{"port":($port|tonumber),"protocol":"vmess","settings":{"decryption":"none"}}')
# User settings
for user in "${xuser[@]}"
@@ -80,22 +80,22 @@ do
if [ -z "${uid}" ]; then >&2 echo "Incorrect user format: $user"; usage; exit 1; fi
if [ -z "${level}" ]; then level=0; fi
if [ -z "${email}" ]; then email="${uid}@mtt.$domain"; fi
inbound=`echo $inbound| jq -c --arg uid "${uid}" --arg flow "${flow}" --arg level "${level}" --arg email "${email}" \
'.settings.clients += [{"id":$uid,"level":($level|tonumber),"email":$email,"flow":$flow}]'`
inbound=$(echo $inbound| jq -c --arg uid "${uid}" --arg flow "${flow}" --arg level "${level}" --arg email "${email}" \
'.settings.clients += [{"id":$uid,"level":($level|tonumber),"email":$email,"flow":$flow}]')
done
# StreamSettings
if [ -n "${acceptProxyProtocol}" ]; then
inbound=`echo $inbound| jq -c '.streamSettings.sockopt += {"acceptProxyProtocol":true}'`
inbound=$(echo $inbound| jq -c '.streamSettings.sockopt += {"acceptProxyProtocol":true}')
fi
# Network settings
inbound=`echo $inbound| jq -c '.streamSettings += {"network":"tcp"}'`
inbound=$(echo $inbound| jq -c '.streamSettings += {"network":"tcp"}')
# Security settings
inbound=`echo $inbound| jq -c '.streamSettings += {"security":"tls"}'`
inbound=`echo $inbound| jq -c --arg fullchain "${fullchain}" --arg prvkey "${prvkey}" \
'.streamSettings.tlsSettings += {"certificates":[{"certificateFile":$fullchain,"keyFile":$prvkey}]}'`
inbound=$(echo $inbound| jq -c '.streamSettings += {"security":"tls"}')
inbound=$(echo $inbound| jq -c --arg fullchain "${fullchain}" --arg prvkey "${prvkey}" \
'.streamSettings.tlsSettings += {"certificates":[{"certificateFile":$fullchain,"keyFile":$prvkey}]}')
# Fallback settings
for fb in "${fallback[@]}"
@@ -106,8 +106,8 @@ do
if [ -z "${fport}" ]; then >&2 echo "Incorrect fallback format: ${fallback}"; usage; exit 1; fi
if [ -z "${fhost}" ]; then fhost="127.0.0.1"; fi
fdest="$fhost:$fport"
Jfb=`jq -nc --arg fdest "${fdest}" --arg fpath "${fpath}" '. |= {"dest":$fdest,"path":$fpath,"xver":1}'`
inbound=`echo $inbound| jq -c --argjson Jfb "${Jfb}" '.settings.fallbacks += [$Jfb]'`
Jfb=$(jq -nc --arg fdest "${fdest}" --arg fpath "${fpath}" '. |= {"dest":$fdest,"path":$fpath,"xver":1}')
inbound=$(echo $inbound| jq -c --argjson Jfb "${Jfb}" '.settings.fallbacks += [$Jfb]')
done
echo $inbound

View File

@@ -1,6 +1,6 @@
#!/bin/bash
DIR=`dirname $0`
DIR=$(dirname $0)
usage() {
>&2 echo "VMESS-WS-PLAIN server builder"
@@ -9,10 +9,10 @@ usage() {
>&2 echo "User format: user|u=<uid>[:level:email]"
}
options=(`echo $1 |tr ',' ' '`)
options=($(echo $1 |tr ',' ' '))
for option in "${options[@]}"
do
kv=(`echo $option |tr '=' ' '`)
kv=($(echo $option |tr '=' ' '))
case "${kv[0]}" in
d|domain)
domain="${kv[1]}"
@@ -58,7 +58,7 @@ fi
if ! [ "${port}" -eq "${port}" ] 2>/dev/null; then >&2 echo "Port number must be numeric.\n"; exit 1; fi
# inbound frame
inbound=`jq -nc --arg port "${port}" '{"port":($port|tonumber),"protocol":"vmess","settings":{"decryption":"none"}}'`
inbound=$(jq -nc --arg port "${port}" '{"port":($port|tonumber),"protocol":"vmess","settings":{"decryption":"none"}}')
# User settings
for user in "${xuser[@]}"
@@ -69,20 +69,20 @@ do
if [ -z "${uid}" ]; then >&2 echo "Incorrect user format: $user"; usage; exit 1; fi
if [ -z "${level}" ]; then level=0; fi
if [ -z "${email}" ]; then email="${uid}@mwp.$domain"; fi
inbound=`echo $inbound| jq -c --arg uid "${uid}" --arg flow "${flow}" --arg level "${level}" --arg email "${email}" \
'.settings.clients += [{"id":$uid,"level":($level|tonumber),"email":$email,"flow":$flow}]'`
inbound=$(echo $inbound| jq -c --arg uid "${uid}" --arg flow "${flow}" --arg level "${level}" --arg email "${email}" \
'.settings.clients += [{"id":$uid,"level":($level|tonumber),"email":$email,"flow":$flow}]')
done
# StreamSettings
if [ -n "${acceptProxyProtocol}" ]; then
inbound=`echo $inbound| jq -c '.streamSettings.sockopt += {"acceptProxyProtocol":true}'`
inbound=$(echo $inbound| jq -c '.streamSettings.sockopt += {"acceptProxyProtocol":true}')
fi
# Network settings
inbound=`echo $inbound| jq -c --arg wspath "${wspath}" '.streamSettings += {"network":"ws","wsSettings":{"path":$wspath}}'`
inbound=$(echo $inbound| jq -c --arg wspath "${wspath}" '.streamSettings += {"network":"ws","wsSettings":{"path":$wspath}}')
# Security settings
inbound=`echo $inbound| jq -c '.streamSettings += {"security":"none"}'`
inbound=$(echo $inbound| jq -c '.streamSettings += {"security":"none"}')
# Fallback settings
for fb in "${fallback[@]}"
@@ -96,8 +96,8 @@ do
fi
if [ -z "${fhost}" ]; then fhost="127.0.0.1"; fi
fdest="$fhost:$fport"
Jfb=`jq -nc --arg fdest "${fdest}" --arg fpath "${fpath}" '. |= {"dest":$fdest,"path":$fpath,"xver":1}'`
inbound=`echo $inbound| jq -c --argjson Jfb "${Jfb}" '.settings.fallbacks += [$Jfb]'`
Jfb=$(jq -nc --arg fdest "${fdest}" --arg fpath "${fpath}" '. |= {"dest":$fdest,"path":$fpath,"xver":1}')
inbound=$(echo $inbound| jq -c --argjson Jfb "${Jfb}" '.settings.fallbacks += [$Jfb]')
done
echo $inbound

View File

@@ -1,6 +1,6 @@
#!/bin/bash
DIR=`dirname $0`
DIR=$(dirname $0)
usage() {
>&2 echo "VMESS-WS-TLS server builder"
@@ -9,10 +9,10 @@ usage() {
>&2 echo "User format: user|u=<uid>[:level:email]"
}
options=(`echo $1 |tr ',' ' '`)
options=($(echo $1 |tr ',' ' '))
for option in "${options[@]}"
do
kv=(`echo $option |tr '=' ' '`)
kv=($(echo $option |tr '=' ' '))
case "${kv[0]}" in
c|certhome)
certhome="${kv[1]}"
@@ -77,7 +77,7 @@ if [ ! -f "${prvkey}" ]; then >&2 echo "Warning, Private key not found: ${prvkey
if ! [ "${port}" -eq "${port}" ] 2>/dev/null; then >&2 echo -e "Error: Port number must be numeric.\n"; exit 1; fi
# inbound frame
inbound=`jq -nc --arg port "${port}" '{"port":($port|tonumber),"protocol":"vmess","settings":{"decryption":"none"}}'`
inbound=$(jq -nc --arg port "${port}" '{"port":($port|tonumber),"protocol":"vmess","settings":{"decryption":"none"}}')
# User settings
for user in "${xuser[@]}"
@@ -88,22 +88,22 @@ do
if [ -z "${uid}" ]; then >&2 echo "Incorrect user format: $user"; usage; exit 1; fi
if [ -z "${level}" ]; then level=0; fi
if [ -z "${email}" ]; then email="${uid}@mwt.$domain"; fi
inbound=`echo $inbound| jq -c --arg uid "${uid}" --arg flow "${flow}" --arg level "${level}" --arg email "${email}" \
'.settings.clients += [{"id":$uid,"level":($level|tonumber),"email":$email,"flow":$flow}]'`
inbound=$(echo $inbound| jq -c --arg uid "${uid}" --arg flow "${flow}" --arg level "${level}" --arg email "${email}" \
'.settings.clients += [{"id":$uid,"level":($level|tonumber),"email":$email,"flow":$flow}]')
done
# StreamSettings
if [ -n "${acceptProxyProtocol}" ]; then
inbound=`echo $inbound| jq -c '.streamSettings.sockopt += {"acceptProxyProtocol":true}'`
inbound=$(echo $inbound| jq -c '.streamSettings.sockopt += {"acceptProxyProtocol":true}')
fi
# Network settings
inbound=`echo $inbound| jq -c --arg wspath "${wspath}" '.streamSettings += {"network":"ws","wsSettings":{"path":$wspath}}'`
inbound=$(echo $inbound| jq -c --arg wspath "${wspath}" '.streamSettings += {"network":"ws","wsSettings":{"path":$wspath}}')
# Security settings
inbound=`echo $inbound| jq -c '.streamSettings += {"security":"tls"}'`
inbound=`echo $inbound| jq -c --arg fullchain "${fullchain}" --arg prvkey "${prvkey}" \
'.streamSettings.tlsSettings += {"certificates":[{"certificateFile":$fullchain,"keyFile":$prvkey}]}'`
inbound=$(echo $inbound| jq -c '.streamSettings += {"security":"tls"}')
inbound=$(echo $inbound| jq -c --arg fullchain "${fullchain}" --arg prvkey "${prvkey}" \
'.streamSettings.tlsSettings += {"certificates":[{"certificateFile":$fullchain,"keyFile":$prvkey}]}')
# Fallback settings
for fb in "${fallback[@]}"
@@ -117,8 +117,8 @@ do
fi
if [ -z "${fhost}" ]; then fhost="127.0.0.1"; fi
fdest="$fhost:$fport"
Jfb=`jq -nc --arg fdest "${fdest}" --arg fpath "${fpath}" '. |= {"dest":$fdest,"path":$fpath,"xver":1}'`
inbound=`echo $inbound| jq -c --argjson Jfb "${Jfb}" '.settings.fallbacks += [$Jfb]'`
Jfb=$(jq -nc --arg fdest "${fdest}" --arg fpath "${fpath}" '. |= {"dest":$fdest,"path":$fpath,"xver":1}')
inbound=$(echo $inbound| jq -c --argjson Jfb "${Jfb}" '.settings.fallbacks += [$Jfb]')
done
echo $inbound

View File

@@ -1,6 +1,6 @@
#!/bin/bash
DIR=`dirname $0`
DIR=$(dirname $0)
DIR="$(cd $DIR; pwd)"
SITE_TPL="nginx-site.tpl"
STREAM_TPL="nginx-stream.tpl"
@@ -14,7 +14,7 @@ usage() {
>&2 echo " --st-server [p=443],[proxy_pass]"
}
TEMP=`getopt -o m:n:p:s:x: --long ng-server:,ng-proxy:,st-server:,st-map: -n "$0" -- $@`
TEMP=$(getopt -o m:n:p:s:x: --long ng-server:,ng-proxy:,st-server:,st-map: -n "$0" -- $@)
if [ $? != 0 ] ; then usage; exit 1 ; fi
eval set -- "$TEMP"
@@ -71,10 +71,10 @@ sed -i '/\#STREAM_TAG/d' /etc/nginx/nginx.conf
# Generate Nginx Stream server configuration.
if [ -n "${STSVR}" ]; then
options=(`echo $STSVR |tr ',' ' '`)
options=($(echo $STSVR |tr ',' ' '))
for option in "${options[@]}"
do
kv=(`echo $option |tr '=' ' '`)
kv=($(echo $option |tr '=' ' '))
case "${kv[0]}" in
p|port)
STPORT="${kv[1]}"
@@ -92,10 +92,10 @@ options=(`echo $STSVR |tr ',' ' '`)
cat ${STREAM_TPL} >> /etc/nginx/nginx.conf
for stmap in "${STMAP[@]}"
do
options=(`echo $stmap |tr ',' ' '`)
options=($(echo $stmap |tr ',' ' '))
for option in "${options[@]}"
do
kv=(`echo $option |tr '=' ' '`)
kv=($(echo $option |tr '=' ' '))
case "${kv[0]}" in
sni)
sni="${kv[1]}"
@@ -106,7 +106,7 @@ options=(`echo $STSVR |tr ',' ' '`)
esac
done
# Naming the upstream as yahoo_com_jp for SNI yahoo.com.jp
upsname=`echo $sni|sed 's/\./_/g'`
upsname=$(echo $sni|sed 's/\./_/g')
echo " $sni $upsname;" >>/tmp/stmap.conf
echo " upstream $upsname {" >>/tmp/stups.conf
echo " server $upstream;" >>/tmp/stups.conf
@@ -134,10 +134,10 @@ do
unset certhome NGPROTOCOL
# removing site default config file if any.
rm -rf /etc/nginx/conf.d/00_default_*.conf
options=(`echo $ngsvr |tr ',' ' '`)
options=($(echo $ngsvr |tr ',' ' '))
for option in "${options[@]}"
do
kv=(`echo $option |tr '=' ' '`)
kv=($(echo $option |tr '=' ' '))
case "${kv[0]}" in
c|certhome)
certhome="${kv[1]}"
@@ -200,10 +200,10 @@ done
for ngproxy in "${NGPROXY[@]}"
do
unset XDOMAINS xhost xport xlocation xnetwork
options=(`echo $ngproxy |tr ',' ' '`)
options=($(echo $ngproxy |tr ',' ' '))
for option in "${options[@]}"
do
kv=(`echo $option |tr '=' ' '`)
kv=($(echo $option |tr '=' ' '))
case "${kv[0]}" in
d|domain)
XDOMAINS+=("${kv[1]}")

View File

@@ -1,6 +1,6 @@
#!/bin/bash
DIR=`dirname $0`
DIR=$(dirname $0)
usage() {
>&2 echo "TROJAN-TCP-TLS server builder"
@@ -9,10 +9,10 @@ usage() {
>&2 echo "User format: user|u=<uid>[:level:email]"
}
options=(`echo $1 |tr ',' ' '`)
options=($(echo $1 |tr ',' ' '))
for option in "${options[@]}"
do
kv=(`echo $option |tr '=' ' '`)
kv=($(echo $option |tr '=' ' '))
case "${kv[0]}" in
c|certhome)
certhome="${kv[1]}"
@@ -69,7 +69,7 @@ if [ ! -f "${prvkey}" ]; then >&2 echo "Warning, Private key not found: ${prvkey
if ! [ "${port}" -eq "${port}" ] 2>/dev/null; then >&2 echo -e "Error: Port number must be numeric.\n"; exit 1; fi
# inbound frame
inbound=`jq -nc --arg port "${port}" '{"port":($port|tonumber),"protocol":"trojan","settings":{"decryption":"none"}}'`
inbound=$(jq -nc --arg port "${port}" '{"port":($port|tonumber),"protocol":"trojan","settings":{"decryption":"none"}}')
# User settings
for user in "${xuser[@]}"
@@ -80,22 +80,22 @@ do
if [ -z "${uid}" ]; then >&2 echo "Incorrect user format: $user"; usage; exit 1; fi
if [ -z "${level}" ]; then level=0; fi
if [ -z "${email}" ]; then email="${uid}@ttt.$domain"; fi
inbound=`echo $inbound| jq -c --arg uid "${uid}" --arg flow "${flow}" --arg level "${level}" --arg email "${email}" \
'.settings.clients += [{"password":$uid,"level":($level|tonumber),"email":$email,"flow":$flow}]'`
inbound=$(echo $inbound| jq -c --arg uid "${uid}" --arg flow "${flow}" --arg level "${level}" --arg email "${email}" \
'.settings.clients += [{"password":$uid,"level":($level|tonumber),"email":$email,"flow":$flow}]')
done
# StreamSettings
if [ -n "${acceptProxyProtocol}" ]; then
inbound=`echo $inbound| jq -c '.streamSettings.sockopt += {"acceptProxyProtocol":true}'`
inbound=$(echo $inbound| jq -c '.streamSettings.sockopt += {"acceptProxyProtocol":true}')
fi
# Network settings
inbound=`echo $inbound| jq -c '.streamSettings += {"network":"tcp"}'`
inbound=$(echo $inbound| jq -c '.streamSettings += {"network":"tcp"}')
# Security settings
inbound=`echo $inbound| jq -c '.streamSettings += {"security":"tls"}'`
inbound=`echo $inbound| jq -c --arg fullchain "${fullchain}" --arg prvkey "${prvkey}" \
'.streamSettings.tlsSettings += {"certificates":[{"certificateFile":$fullchain,"keyFile":$prvkey}]}'`
inbound=$(echo $inbound| jq -c '.streamSettings += {"security":"tls"}')
inbound=$(echo $inbound| jq -c --arg fullchain "${fullchain}" --arg prvkey "${prvkey}" \
'.streamSettings.tlsSettings += {"certificates":[{"certificateFile":$fullchain,"keyFile":$prvkey}]}')
# Fallback settings
for fb in "${fallback[@]}"
@@ -106,8 +106,8 @@ do
if [ -z "${fport}" ]; then >&2 echo "Incorrect fallback format: ${fallback}"; usage; exit 1; fi
if [ -z "${fhost}" ]; then fhost="127.0.0.1"; fi
fdest="$fhost:$fport"
Jfb=`jq -nc --arg fdest "${fdest}" --arg fpath "${fpath}" '. |= {"dest":$fdest,"path":$fpath,"xver":1}'`
inbound=`echo $inbound| jq -c --argjson Jfb "${Jfb}" '.settings.fallbacks += [$Jfb]'`
Jfb=$(jq -nc --arg fdest "${fdest}" --arg fpath "${fpath}" '. |= {"dest":$fdest,"path":$fpath,"xver":1}')
inbound=$(echo $inbound| jq -c --argjson Jfb "${Jfb}" '.settings.fallbacks += [$Jfb]')
done
echo $inbound

View File

@@ -1,6 +1,6 @@
#!/bin/bash
DIR=`dirname $0`
DIR=$(dirname $0)
usage() {
>&2 echo "TROJAN-WS-PLAIN server builder"
@@ -9,10 +9,10 @@ usage() {
>&2 echo "User format: user=<uid>[:level:email]"
}
options=(`echo $1 |tr ',' ' '`)
options=($(echo $1 |tr ',' ' '))
for option in "${options[@]}"
do
kv=(`echo $option |tr '=' ' '`)
kv=($(echo $option |tr '=' ' '))
case "${kv[0]}" in
d|domain)
domain="${kv[1]}"
@@ -58,7 +58,7 @@ fi
if ! [ "${port}" -eq "${port}" ] 2>/dev/null; then >&2 echo "Port number must be numeric"; exit 1; fi
# inbound frame
inbound=`jq -nc --arg port "${port}" '{"port":($port|tonumber),"protocol":"trojan","settings":{"decryption":"none"}}'`
inbound=$(jq -nc --arg port "${port}" '{"port":($port|tonumber),"protocol":"trojan","settings":{"decryption":"none"}}')
# User settings
for user in "${xuser[@]}"
@@ -69,20 +69,20 @@ do
if [ -z "${uid}" ]; then >&2 echo "Incorrect user format: $user"; usage; exit 1; fi
if [ -z "${level}" ]; then level=0; fi
if [ -z "${email}" ]; then email="${uid}@twp.$domain"; fi
inbound=`echo $inbound| jq -c --arg uid "${uid}" --arg flow "${flow}" --arg level "${level}" --arg email "${email}" \
'.settings.clients += [{"password":$uid,"level":($level|tonumber),"email":$email,"flow":$flow}]'`
inbound=$(echo $inbound| jq -c --arg uid "${uid}" --arg flow "${flow}" --arg level "${level}" --arg email "${email}" \
'.settings.clients += [{"password":$uid,"level":($level|tonumber),"email":$email,"flow":$flow}]')
done
# StreamSettings
if [ -n "${acceptProxyProtocol}" ]; then
inbound=`echo $inbound| jq -c '.streamSettings.sockopt += {"acceptProxyProtocol":true}'`
inbound=$(echo $inbound| jq -c '.streamSettings.sockopt += {"acceptProxyProtocol":true}')
fi
# Network settings
inbound=`echo $inbound| jq -c --arg wspath "${wspath}" '.streamSettings += {"network":"ws","wsSettings":{"path":$wspath}}'`
inbound=$(echo $inbound| jq -c --arg wspath "${wspath}" '.streamSettings += {"network":"ws","wsSettings":{"path":$wspath}}')
# Security settings
inbound=`echo $inbound| jq -c '.streamSettings += {"security":"none"}'`
inbound=$(echo $inbound| jq -c '.streamSettings += {"security":"none"}')
# Fallback settings
for fb in "${fallback[@]}"
@@ -96,89 +96,9 @@ do
fi
if [ -z "${fhost}" ]; then fhost="127.0.0.1"; fi
fdest="$fhost:$fport"
Jfb=`jq -nc --arg fdest "${fdest}" --arg fpath "${fpath}" '. |= {"dest":$fdest,"path":$fpath,"xver":1}'`
inbound=`echo $inbound| jq -c --argjson Jfb "${Jfb}" '.settings.fallbacks += [$Jfb]'`
Jfb=$(jq -nc --arg fdest "${fdest}" --arg fpath "${fpath}" '. |= {"dest":$fdest,"path":$fpath,"xver":1}')
inbound=$(echo $inbound| jq -c --argjson Jfb "${Jfb}" '.settings.fallbacks += [$Jfb]')
done
echo $inbound
exit 0
}
options=(`echo $1 |tr ',' ' '`)
for option in "${options[@]}"
do
kv=(`echo $option |tr '=' ' '`)
case "${kv[0]}" in
d|domain)
domain="${kv[1]}"
;;
p|port)
port="${kv[1]}"
;;
u|user)
xuser+=("${kv[1]}")
;;
w|wpath)
wspath="${kv[1]}"
;;
x|xconf)
xconf="${kv[1]}"
;;
esac
done
if [ -z "${port}" ]; then
echo "Error: port undefined."
usage
exit 1 ;
fi
if [ -z "${wspath}" ]; then
echo "Error: wspath undefined."
usage
exit 1
fi
if [ -z "${xuser}" ]; then
echo "Error: user undefined."
usage
exit 1
fi
if [ -z "${xconf}" ]; then
echo "Error: xconf undefined."
usage
exit 1
fi
if ! [ "${port}" -eq "${port}" ] 2>/dev/null; then >&2 echo "Port number must be numeric"; exit 1; fi
XCONF=$xconf
# Remove existing port number if existing.
cat $XCONF |jq --arg port "${port}" 'del( .inbounds[] | select(.port == ($port|tonumber)) )' |sponge $XCONF
# Add inbound element
cat $XCONF |jq --arg port "${port}" '.inbounds +=[{"port":($port|tonumber),"protocol":"trojan","settings":{"clients":[]}}]' |sponge $XCONF
cat $XCONF |jq --arg port "${port}" '( .inbounds[] | select(.port == ($port|tonumber)) | .settings.decryption ) += "none" ' |sponge $XCONF
# User settings
for xu in "${xuser[@]}"
do
cat $XCONF | ${DIR}/addusertj.sh -p $port -u ${xu} -c twp.$domain $flowopt | sponge $XCONF
done
# Network settings
cat $XCONF |jq --arg port "${port}" --arg wspath "${wspath}" \
'( .inbounds[] | select(.port == ($port|tonumber)) | .streamSettings ) += {"network":"ws","wsSettings":{"path":$wspath}} ' \
|sponge $XCONF
# Plain settings
cat $XCONF |jq --arg port "${port}" \
'( .inbounds[] | select(.port == ($port|tonumber)) | .streamSettings ) += {"security":"none" } ' \
|sponge $XCONF

View File

@@ -1,6 +1,6 @@
#!/bin/bash
DIR=`dirname $0`
DIR=$(dirname $0)
usage() {
>&2 echo "TROJAN-WS-TLS server builder"
@@ -9,10 +9,10 @@ usage() {
>&2 echo "User format: user=<uid>[:level:email]"
}
options=(`echo $1 |tr ',' ' '`)
options=($(echo $1 |tr ',' ' '))
for option in "${options[@]}"
do
kv=(`echo $option |tr '=' ' '`)
kv=($(echo $option |tr '=' ' '))
case "${kv[0]}" in
c|certhome)
certhome="${kv[1]}"
@@ -77,7 +77,7 @@ if [ ! -f "${prvkey}" ]; then >&2 echo "Warning, Private key not found: ${prvkey
if ! [ "${port}" -eq "${port}" ] 2>/dev/null; then >&2 echo "Port number must be numeric"; exit 1; fi
# inbound frame
inbound=`jq -nc --arg port "${port}" '{"port":($port|tonumber),"protocol":"trojan","settings":{"decryption":"none"}}'`
inbound=$(jq -nc --arg port "${port}" '{"port":($port|tonumber),"protocol":"trojan","settings":{"decryption":"none"}}')
# User settings
for user in "${xuser[@]}"
@@ -88,22 +88,22 @@ do
if [ -z "${uid}" ]; then >&2 echo "Incorrect user format: $user"; usage; exit 1; fi
if [ -z "${level}" ]; then level=0; fi
if [ -z "${email}" ]; then email="${uid}@twt.$domain"; fi
inbound=`echo $inbound| jq -c --arg uid "${uid}" --arg flow "${flow}" --arg level "${level}" --arg email "${email}" \
'.settings.clients += [{"password":$uid,"level":($level|tonumber),"email":$email,"flow":$flow}]'`
inbound=$(echo $inbound| jq -c --arg uid "${uid}" --arg flow "${flow}" --arg level "${level}" --arg email "${email}" \
'.settings.clients += [{"password":$uid,"level":($level|tonumber),"email":$email,"flow":$flow}]')
done
# StreamSettings
if [ -n "${acceptProxyProtocol}" ]; then
inbound=`echo $inbound| jq -c '.streamSettings.sockopt += {"acceptProxyProtocol":true}'`
inbound=$(echo $inbound| jq -c '.streamSettings.sockopt += {"acceptProxyProtocol":true}')
fi
# Network settings
inbound=`echo $inbound| jq -c --arg wspath "${wspath}" '.streamSettings += {"network":"ws","wsSettings":{"path":$wspath}}'`
inbound=$(echo $inbound| jq -c --arg wspath "${wspath}" '.streamSettings += {"network":"ws","wsSettings":{"path":$wspath}}')
# Security settings
inbound=`echo $inbound| jq -c '.streamSettings += {"security":"tls"}'`
inbound=`echo $inbound| jq -c --arg fullchain "${fullchain}" --arg prvkey "${prvkey}" \
'.streamSettings.tlsSettings += {"certificates":[{"certificateFile":$fullchain,"keyFile":$prvkey}]}'`
inbound=$(echo $inbound| jq -c '.streamSettings += {"security":"tls"}')
inbound=$(echo $inbound| jq -c --arg fullchain "${fullchain}" --arg prvkey "${prvkey}" \
'.streamSettings.tlsSettings += {"certificates":[{"certificateFile":$fullchain,"keyFile":$prvkey}]}')
# Fallback settings
for fb in "${fallback[@]}"
@@ -117,8 +117,8 @@ do
fi
if [ -z "${fhost}" ]; then fhost="127.0.0.1"; fi
fdest="$fhost:$fport"
Jfb=`jq -nc --arg fdest "${fdest}" --arg fpath "${fpath}" '. |= {"dest":$fdest,"path":$fpath,"xver":1}'`
inbound=`echo $inbound| jq -c --argjson Jfb "${Jfb}" '.settings.fallbacks += [$Jfb]'`
Jfb=$(jq -nc --arg fdest "${fdest}" --arg fpath "${fpath}" '. |= {"dest":$fdest,"path":$fpath,"xver":1}')
inbound=$(echo $inbound| jq -c --argjson Jfb "${Jfb}" '.settings.fallbacks += [$Jfb]')
done
echo $inbound