mirror of
https://github.com/samuelhbne/server-xray.git
synced 2025-12-17 04:14:40 +03:00
Codacy compliant
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user