Codacy compliant

This commit is contained in:
Samuel Huang
2024-09-30 20:40:48 +10:00
parent ae8a1a469a
commit 0c3aa7b69e
21 changed files with 130 additions and 359 deletions

View File

@@ -21,7 +21,7 @@ $ docker run --name server-xtls -p 80:80 -p 443:443 -d samuelhbne/server-xray \
...
```
** NOTE **
**NOTE**
- Port 80 exposure (-p 80:80) is necessary for Letsencrypt domain verification during cert requesting.

View File

@@ -1,74 +0,0 @@
#!/bin/bash
usage() {
echo "Usage: adduser -p <port-num> -u <user> -c <email-comment> -f <flow-type>" >&2
}
TEMP=`getopt -o c:f:p:u: --long comment:flow:port:,user: -n "$0" -- $@`
if [ $? != 0 ] ; then usage; exit 1 ; fi
eval set -- "$TEMP"
while true ; do
case "$1" in
-c|--comment)
comment="$2"
shift 2
;;
-f|flow)
flow="$2"
shift 2
;;
-p|--port)
port="$2"
shift 2
;;
-u|--user)
user="$2"
shift 2
;;
--)
shift
break
;;
*)
echo "Unknown option: $1" >&2
usage;
exit 1
;;
esac
done
if [ -z "${port}" ]; then
echo "Error: port undefined." >&2
usage
exit 1 ;
fi
IFS=':'
uopt=(${user})
uopt=(${uopt[@]})
uid="${uopt[0]}"
level="${uopt[1]}"
email="${uopt[2]}"
if [ -z "${uid}" ]; then
echo "Error: Undefined UID \"$user\"" >&2
echo "Correct user format: user=<uid>[:level:email]" >&2
echo "Like: user=myid:0:me@g.cn" >&2
echo "Like: user=myid::me@g.cn" >&2
echo "Like: user=myid:0" >&2
echo "Like: user=myid" >&2
exit 1
fi
if [ -z "${level}" ]; then
level=0
fi
if [ -z "${email}" ]; then
email="${uid}@${comment}"
fi
jq --arg port "${port}" --arg uid "${uid}" --arg level "${level}" --arg email "${email}" --arg flow "${flow}" \
'( .inbounds[] | select(.port == ($port|tonumber)) | .settings.clients ) += [ {"id":$uid, "flow":$flow, "level":($level|tonumber), "email":$email} ] ' \

View File

@@ -1,74 +0,0 @@
#!/bin/bash
usage() {
echo "Usage: adduser -p <port-num> -u <user> -c <email-comment> -f <flow-type>" >&2
}
TEMP=`getopt -o c:f:p:u: --long comment:flow:port:,user: -n "$0" -- $@`
if [ $? != 0 ] ; then usage; exit 1 ; fi
eval set -- "$TEMP"
while true ; do
case "$1" in
-c|--comment)
comment="$2"
shift 2
;;
-f|flow)
flow="$2"
shift 2
;;
-p|--port)
port="$2"
shift 2
;;
-u|--user)
user="$2"
shift 2
;;
--)
shift
break
;;
*)
echo "Unknown option: $1" >&2
usage;
exit 1
;;
esac
done
if [ -z "${port}" ]; then
echo "Error: port undefined." >&2
usage
exit 1 ;
fi
IFS=':'
uopt=(${user})
uopt=(${uopt[@]})
psw="${uopt[0]}"
level="${uopt[1]}"
email="${uopt[2]}"
if [ -z "${psw}" ]; then
echo "Error: Undefined UID \"$user\"" >&2
echo "Correct user format: user=<password>[:level:email]" >&2
echo "Like: user=mypw:0:me@g.cn" >&2
echo "Like: user=mypw::me@g.cn" >&2
echo "Like: user=mypw:0" >&2
echo "Like: user=mypw" >&2
exit 1
fi
if [ -z "${level}" ]; then
level=0
fi
if [ -z "${email}" ]; then
email="${psw}@${comment}"
fi
jq --arg port "${port}" --arg psw "${psw}" --arg level "${level}" --arg email "${email}" --arg flow "${flow}" \
'( .inbounds[] | select(.port == ($port|tonumber)) | .settings.clients ) += [ {"password":$psw, "flow":$flow, "level":($level|tonumber), "email":$email} ] ' \

View File

@@ -1,79 +0,0 @@
#!/bin/bash
usage() {
echo "Usage: fallback -p <port-num> -f <fallback-dest>" >&2
}
TEMP=`getopt -o f:p: --long port:,fallback: -n "$0" -- $@`
if [ $? != 0 ] ; then usage; exit 1 ; fi
eval set -- "$TEMP"
while true ; do
case "$1" in
-p|--port)
port="$2"
shift 2
;;
-f|--fallback)
fallback="$2"
shift 2
;;
--)
shift
break
;;
*)
echo "Unknown option: $1" >&2
usage;
exit 1
;;
esac
done
if [ -z "${port}" ]; then
echo "Error: port undefined." >&2
usage
exit 1 ;
fi
if [ -z "${fallback}" ]; then
echo "Error: fallback undefined." >&2
usage
exit 1 ;
fi
IFS=':'
fopt=(${fallback})
fopt=(${fopt[@]})
fhost="${fopt[0]}"
fport="${fopt[1]}"
fpath="${fopt[2]}"
fdest=$fhost:$fport
if [ -z "${fport}" ]; then
echo "Incorrect fallback format: ${fallback}"
echo "Correct fallback: fallback=[host]<:port>[:path]"
echo "Like: fallback=baidu.com:443:/path"
echo "Like: fallback=:1443:/path"
echo "Like: fallback=:1443"
exit 1
fi
if [ -z "${fhost}" ]; then
if [ -z "${fpath}" ]; then
Jfallback=`echo '{}' |jq --arg fport "${fport}" --arg fpath "${fpath}" '. += {"dest":($fport|tonumber), "xver":1}'`
else
Jfallback=`echo '{}' |jq --arg fport "${fport}" --arg fpath "${fpath}" '. += {"dest":($fport|tonumber), "path":$fpath, "xver":1}'`
fi
else
if [ -z "${fpath}" ]; then
fdest="${fhost}:${fport}"
Jfallback=`echo '{}' |jq --arg fdest "${fdest}" --arg fpath "${fpath}" '. += {"dest":$fdest, "xver":1}'`
else
Jfallback=`echo '{}' |jq --arg fdest "${fdest}" --arg fpath "${fpath}" '. += {"dest":$fdest, "path":$fpath, "xver":1}'`
fi
fi
jq --arg port "${port}" --argjson jfallback "$Jfallback" \
'( .inbounds[] | select(.port == ($port|tonumber)) | .settings.fallbacks ) += [ $jfallback ] ' \

3
run.sh
View File

@@ -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"
@@ -245,4 +245,3 @@ jq -n "$Jroot"
jq -n "$Jroot">$XCONF
exec /usr/local/bin/xray -c $XCONF
fi

View File

@@ -3,10 +3,10 @@
DIR=$(dirname $0)
usage() {
>&2 echo "VLESS-GRPC-PLAIN server builder"
>&2 echo "Usage: server-lgp <s=svcname>,<d=domain.com>,<p=listen-port>,<u=id0>,<u=id1>...,[proxy_acpt],[fallback=host:port:path]"
>&2 echo "Fallback format: fallback=[host]<:port>[:/path] Like: 'baidu.com:443:/path', ':1443:/path', ':1443'"
>&2 echo "User format: user|u=<uid>[:level:email]"
>&2 echo -e "VLESS-GRPC-PLAIN server builder"
>&2 echo -e "Usage: server-lgp <s=svcname>,<d=domain.com>,<p=listen-port>,<u=id0>,<u=id1>...,[proxy_acpt],[fallback=host:port:path]"
>&2 echo -e "Fallback format: fallback=[host]<:port>[:/path] Like: 'baidu.com:443:/path', ':1443:/path', ':1443'"
>&2 echo -e "User format: user|u=<uid>[:level:email]"
}
options=($(echo $1 |tr ',' ' '))
@@ -66,7 +66,7 @@ do
IFS=':'; uopt=(${user}); uopt=(${uopt[@]})
uid="${uopt[0]}"; level="${uopt[1]}"; email="${uopt[2]}"
unset IFS
if [ -z "${uid}" ]; then >&2 echo "Incorrect user format: $user"; usage; exit 1; fi
if [ -z "${uid}" ]; then >&2 echo -e "Incorrect user format: $user\n"; 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}" \
@@ -90,7 +90,7 @@ do
IFS=':'; fopt=(${fb}); fopt=(${fopt[@]})
fhost="${fopt[0]}"; fport="${fopt[1]}"; fpath="${fopt[2]}"
unset IFS
if [ -z "${fport}" ]; then >&2 echo "Incorrect fallback format: ${fallback}"; usage; exit 1; fi
if [ -z "${fport}" ]; then >&2 echo -e "Incorrect fallback format: ${fallback}\n"; 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}')

View File

@@ -3,10 +3,10 @@
DIR=$(dirname $0)
usage() {
>&2 echo "VLESS-GRPC-REALITY server builder"
>&2 echo "Usage: server-lgr ,<s=svcname>,<d=dest.com>,<prv=yy>,[pub=xx],[shortId=zz],<p=listen-port>,<u=id0>,<u=id1>...,[proxy_acpt],[fallback=host:port:path],[xtls]"
>&2 echo "Fallback format: fallback=[host]<:port>[:/path] Like: 'baidu.com:443:/path', ':1443:/path', ':1443'"
>&2 echo "User format: user|u=<uid>[:level:email]"
>&2 echo -e "VLESS-GRPC-REALITY server builder"
>&2 echo -e "Usage: server-lgr ,<s=svcname>,<d=dest.com>,<prv=yy>,[pub=xx],[shortId=zz],<p=listen-port>,<u=id0>,<u=id1>...,[proxy_acpt],[fallback=host:port:path],[xtls]"
>&2 echo -e "Fallback format: fallback=[host]<:port>[:/path] Like: 'baidu.com:443:/path', ':1443:/path', ':1443'"
>&2 echo -e "User format: user|u=<uid>[:level:email]"
}
options=($(echo $1 |tr ',' ' '))
@@ -64,11 +64,11 @@ if [ -z "${port}" ]; then
fi
if [ -z "${prvkey}" ]; then
>&2 echo "Warning: PrivateKey undefined, Generated new..."
>&2 echo -e "Warning: PrivateKey undefined, Generated new...\n"
kv=($(/usr/local/bin/xray x25519|cut -d ' ' -f3|tr ' '))
prvkey="${kv[0]}"
pubkey="${kv[1]}"
>&2 echo "PublicKey: $pubkey"
>&2 echo -e "PublicKey: $pubkey\n"
fi
if [ -z "${serviceName}" ]; then
@@ -92,7 +92,7 @@ do
IFS=':'; uopt=(${user}); uopt=(${uopt[@]})
uid="${uopt[0]}"; level="${uopt[1]}"; email="${uopt[2]}"
unset IFS
if [ -z "${uid}" ]; then >&2 echo "Incorrect user format: $user"; usage; exit 1; fi
if [ -z "${uid}" ]; then >&2 echo -e "Incorrect user format: $user\n"; 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}" \
@@ -130,7 +130,7 @@ do
IFS=':'; fopt=(${fb}); fopt=(${fopt[@]})
fhost="${fopt[0]}"; fport="${fopt[1]}"; fpath="${fopt[2]}"
unset IFS
if [ -z "${fport}" ]; then >&2 echo "Incorrect fallback format: ${fallback}"; usage; exit 1; fi
if [ -z "${fport}" ]; then >&2 echo -e "Incorrect fallback format: ${fallback}\n"; 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}')

View File

@@ -3,10 +3,10 @@
DIR=$(dirname $0)
usage() {
>&2 echo "VLESS-GRPC-TLS server builder"
>&2 echo "Usage: server-lgt <s=svcname>,<c=certhome-dir>,<d=domain.com>,<p=listen-port>,<u=id0>,<u=id1>...,[proxy_acpt],[fallback=host:port:path],[xtls]"
>&2 echo "Fallback format: fallback=[host]<:port>[:/path] Like: 'baidu.com:443:/path', ':1443:/path', ':1443'"
>&2 echo "User format: user|u=<uid>[:level:email]"
>&2 echo -e "VLESS-GRPC-TLS server builder"
>&2 echo -e "Usage: server-lgt <s=svcname>,<c=certhome-dir>,<d=domain.com>,<p=listen-port>,<u=id0>,<u=id1>...,[proxy_acpt],[fallback=host:port:path],[xtls]"
>&2 echo -e "Fallback format: fallback=[host]<:port>[:/path] Like: 'baidu.com:443:/path', ':1443:/path', ':1443'"
>&2 echo -e "User format: user|u=<uid>[:level:email]"
}
options=($(echo $1 |tr ',' ' '))
@@ -71,8 +71,8 @@ fi
fullchain="${certhome}/${domain}/fullchain.cer"
prvkey="${certhome}/${domain}/${domain}.key"
if [ ! -f "${fullchain}" ]; then >&2 echo "Warning, Fullchain not found: ${fullchain}"; fi
if [ ! -f "${prvkey}" ]; then >&2 echo "Warning, Private key not found: ${prvkey}"; fi
if [ ! -f "${fullchain}" ]; then >&2 echo -e "Warning, Fullchain not found: ${fullchain}\n"; fi
if [ ! -f "${prvkey}" ]; then >&2 echo -e "Warning, Private key not found: ${prvkey}\n"; fi
if ! [ "${port}" -eq "${port}" ] 2>/dev/null; then >&2 echo -e "Error: Port number must be numeric.\n"; exit 1; fi
@@ -85,7 +85,7 @@ do
IFS=':'; uopt=(${user}); uopt=(${uopt[@]})
uid="${uopt[0]}"; level="${uopt[1]}"; email="${uopt[2]}"
unset IFS
if [ -z "${uid}" ]; then >&2 echo "Incorrect user format: $user"; usage; exit 1; fi
if [ -z "${uid}" ]; then >&2 echo -e "Incorrect user format: $user\n"; 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}" \
@@ -111,7 +111,7 @@ do
IFS=':'; fopt=(${fb}); fopt=(${fopt[@]})
fhost="${fopt[0]}"; fport="${fopt[1]}"; fpath="${fopt[2]}"
unset IFS
if [ -z "${fport}" ]; then >&2 echo "Incorrect fallback format: ${fallback}"; usage; exit 1; fi
if [ -z "${fport}" ]; then >&2 echo -e "Incorrect fallback format: ${fallback}\n"; 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}')

View File

@@ -3,10 +3,10 @@
DIR=$(dirname $0)
usage() {
>&2 echo "VLESS-SPLT-PLAIN server builder"
>&2 echo "Usage: server-lsp <w=webpath>,<d=domain.com>,<p=listen-port>,<u=id0>,<u=id1>...,[proxy_acpt],[fallback=host:port:path]"
>&2 echo "Fallback format: fallback=[host]<:port>[:/path] Like: 'baidu.com:443:/path', ':1443:/path', ':1443'"
>&2 echo "User format: user|u=<uid>[:level:email]"
>&2 echo -e "VLESS-SPLT-PLAIN server builder"
>&2 echo -e "Usage: server-lsp <w=webpath>,<d=domain.com>,<p=listen-port>,<u=id0>,<u=id1>...,[proxy_acpt],[fallback=host:port:path]"
>&2 echo -e "Fallback format: fallback=[host]<:port>[:/path] Like: 'baidu.com:443:/path', ':1443:/path', ':1443'"
>&2 echo -e "User format: user|u=<uid>[:level:email]"
}
options=($(echo $1 |tr ',' ' '))
@@ -66,7 +66,7 @@ do
IFS=':'; uopt=(${user}); uopt=(${uopt[@]})
uid="${uopt[0]}"; level="${uopt[1]}"; email="${uopt[2]}"
unset IFS
if [ -z "${uid}" ]; then >&2 echo "Incorrect user format: $user"; usage; exit 1; fi
if [ -z "${uid}" ]; then >&2 echo -e "Incorrect user format: $user\n"; 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}" \
@@ -90,7 +90,7 @@ do
IFS=':'; fopt=(${fb}); fopt=(${fopt[@]})
fhost="${fopt[0]}"; fport="${fopt[1]}"; fpath="${fopt[2]}"
unset IFS
if [ -z "${fport}" ]; then >&2 echo "Incorrect fallback format: ${fallback}"; usage; exit 1; fi
if [ -z "${fport}" ]; then >&2 echo -e "Incorrect fallback format: ${fallback}\n"; 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}')

View File

@@ -3,10 +3,10 @@
DIR=$(dirname $0)
usage() {
>&2 echo "VLESS-SPLT-TLS server builder"
>&2 echo "Usage: server-lst <w=webpath>,<c=certhome-dir>,<d=domain.com>,<p=listen-port>,<u=id0>,<u=id1>...,[proxy_acpt],[fallback=host:port:path],[xtls]"
>&2 echo "Fallback format: fallback=[host]<:port>[:/path] Like: 'baidu.com:443:/path', ':1443:/path', ':1443'"
>&2 echo "User format: user|u=<uid>[:level:email]"
>&2 echo -e "VLESS-SPLT-TLS server builder"
>&2 echo -e "Usage: server-lst <w=webpath>,<c=certhome-dir>,<d=domain.com>,<p=listen-port>,<u=id0>,<u=id1>...,[proxy_acpt],[fallback=host:port:path],[xtls]"
>&2 echo -e "Fallback format: fallback=[host]<:port>[:/path] Like: 'baidu.com:443:/path', ':1443:/path', ':1443'"
>&2 echo -e "User format: user|u=<uid>[:level:email]"
}
options=($(echo $1 |tr ',' ' '))
@@ -71,8 +71,8 @@ fi
fullchain="${certhome}/${domain}/fullchain.cer"
prvkey="${certhome}/${domain}/${domain}.key"
if [ ! -f "${fullchain}" ]; then >&2 echo "Warning, Fullchain not found: ${fullchain}"; fi
if [ ! -f "${prvkey}" ]; then >&2 echo "Warning, Private key not found: ${prvkey}"; fi
if [ ! -f "${fullchain}" ]; then >&2 echo -e "Warning, Fullchain not found: ${fullchain}\n"; fi
if [ ! -f "${prvkey}" ]; then >&2 echo -e "Warning, Private key not found: ${prvkey}\n"; fi
if ! [ "${port}" -eq "${port}" ] 2>/dev/null; then >&2 echo -e "Error: Port number must be numeric.\n"; exit 1; fi
@@ -85,7 +85,7 @@ do
IFS=':'; uopt=(${user}); uopt=(${uopt[@]})
uid="${uopt[0]}"; level="${uopt[1]}"; email="${uopt[2]}"
unset IFS
if [ -z "${uid}" ]; then >&2 echo "Incorrect user format: $user"; usage; exit 1; fi
if [ -z "${uid}" ]; then >&2 echo -e "Incorrect user format: $user\n"; 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}" \
@@ -111,7 +111,7 @@ do
IFS=':'; fopt=(${fb}); fopt=(${fopt[@]})
fhost="${fopt[0]}"; fport="${fopt[1]}"; fpath="${fopt[2]}"
unset IFS
if [ -z "${fport}" ]; then >&2 echo "Incorrect fallback format: ${fallback}"; usage; exit 1; fi
if [ -z "${fport}" ]; then >&2 echo -e "Incorrect fallback format: ${fallback}\n"; 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}')

View File

@@ -3,10 +3,10 @@
DIR=$(dirname $0)
usage() {
>&2 echo "VLESS-TCP-REALITY server builder"
>&2 echo "Usage: server-ltr <d=dest.com>,<prv=yy>,[pub=xx],[shortId=zz],<p=listen-port>,<u=id0>,<u=id1>...,[proxy_acpt],[fallback=host:port:path],[xtls]"
>&2 echo "Fallback format: fallback=[host]<:port>[:/path] Like: 'baidu.com:443:/path', ':1443:/path', ':1443'"
>&2 echo "User format: user|u=<uid>[:level:email]"
>&2 echo -e "VLESS-TCP-REALITY server builder"
>&2 echo -e "Usage: server-ltr <d=dest.com>,<prv=yy>,[pub=xx],[shortId=zz],<p=listen-port>,<u=id0>,<u=id1>...,[proxy_acpt],[fallback=host:port:path],[xtls]"
>&2 echo -e "Fallback format: fallback=[host]<:port>[:/path] Like: 'baidu.com:443:/path', ':1443:/path', ':1443'"
>&2 echo -e "User format: user|u=<uid>[:level:email]"
}
options=($(echo $1 |tr ',' ' '))
@@ -61,11 +61,11 @@ if [ -z "${port}" ]; then
fi
if [ -z "${prvkey}" ]; then
>&2 echo "Warning: PrivateKey undefined, Generated new..."
>&2 echo -e "Warning: PrivateKey undefined, Generated new...\n"
kv=($(/usr/local/bin/xray x25519|cut -d ' ' -f3|tr ' '))
prvkey="${kv[0]}"
pubkey="${kv[1]}"
>&2 echo "PublicKey: $pubkey"
>&2 echo -e "PublicKey: $pubkey\n"
fi
if [ -z "${xuser}" ]; then
@@ -84,7 +84,7 @@ do
IFS=':'; uopt=(${user}); uopt=(${uopt[@]})
uid="${uopt[0]}"; level="${uopt[1]}"; email="${uopt[2]}"
unset IFS
if [ -z "${uid}" ]; then >&2 echo "Incorrect user format: $user"; usage; exit 1; fi
if [ -z "${uid}" ]; then >&2 echo -e "Incorrect user format: $user\n"; 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}" \
@@ -122,7 +122,7 @@ do
IFS=':'; fopt=(${fb}); fopt=(${fopt[@]})
fhost="${fopt[0]}"; fport="${fopt[1]}"; fpath="${fopt[2]}"
unset IFS
if [ -z "${fport}" ]; then >&2 echo "Incorrect fallback format: ${fallback}"; usage; exit 1; fi
if [ -z "${fport}" ]; then >&2 echo -e "Incorrect fallback format: ${fallback}\n"; 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}')

View File

@@ -3,10 +3,10 @@
DIR=$(dirname $0)
usage() {
>&2 echo "VLESS-TCP-TLS server builder"
>&2 echo "Usage: server-ltt <c=certhome-dir>,<d=domain.com>,<p=listen-port>,<u=id0>,<u=id1>...,[proxy_acpt],[fallback=host:port:path],[xtls]"
>&2 echo "Fallback format: fallback=[host]<:port>[:/path] Like: 'baidu.com:443:/path', ':1443:/path', ':1443'"
>&2 echo "User format: user|u=<uid>[:level:email]"
>&2 echo -e "VLESS-TCP-TLS server builder"
>&2 echo -e "Usage: server-ltt <c=certhome-dir>,<d=domain.com>,<p=listen-port>,<u=id0>,<u=id1>...,[proxy_acpt],[fallback=host:port:path],[xtls]"
>&2 echo -e "Fallback format: fallback=[host]<:port>[:/path] Like: 'baidu.com:443:/path', ':1443:/path', ':1443'"
>&2 echo -e "User format: user|u=<uid>[:level:email]"
}
options=($(echo $1 |tr ',' ' '))
@@ -63,8 +63,8 @@ fi
fullchain="${certhome}/${domain}/fullchain.cer"
prvkey="${certhome}/${domain}/${domain}.key"
if [ ! -f "${fullchain}" ]; then >&2 echo "Warning, Fullchain not found: ${fullchain}"; fi
if [ ! -f "${prvkey}" ]; then >&2 echo "Warning, Private key not found: ${prvkey}"; fi
if [ ! -f "${fullchain}" ]; then >&2 echo -e "Warning, Fullchain not found: ${fullchain}\n"; fi
if [ ! -f "${prvkey}" ]; then >&2 echo -e "Warning, Private key not found: ${prvkey}\n"; fi
if ! [ "${port}" -eq "${port}" ] 2>/dev/null; then >&2 echo -e "Error: Port number must be numeric.\n"; exit 1; fi
@@ -77,7 +77,7 @@ do
IFS=':'; uopt=(${user}); uopt=(${uopt[@]})
uid="${uopt[0]}"; level="${uopt[1]}"; email="${uopt[2]}"
unset IFS
if [ -z "${uid}" ]; then >&2 echo "Incorrect user format: $user"; usage; exit 1; fi
if [ -z "${uid}" ]; then >&2 echo -e "Incorrect user format: $user\n"; 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}" \
@@ -103,7 +103,7 @@ do
IFS=':'; fopt=(${fb}); fopt=(${fopt[@]})
fhost="${fopt[0]}"; fport="${fopt[1]}"; fpath="${fopt[2]}"
unset IFS
if [ -z "${fport}" ]; then >&2 echo "Incorrect fallback format: ${fallback}"; usage; exit 1; fi
if [ -z "${fport}" ]; then >&2 echo -e "Incorrect fallback format: ${fallback}\n"; 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}')

View File

@@ -1,12 +1,10 @@
#!/bin/bash
DIR=$(dirname $0)
usage() {
>&2 echo "VLESS-WS-PLAIN server builder"
>&2 echo "Usage: server-lwp <w=wskpath>,<d=domain.com>,<p=listen-port>,<u=id0>,<u=id1>...,[proxy_acpt],[fallback=host:port:path]"
>&2 echo "Fallback format: fallback=[host]<:port>[:/path] Like: 'baidu.com:443:/path', ':1443:/path', ':1443'"
>&2 echo "User format: user|u=<uid>[:level:email]"
>&2 echo -e "VLESS-WS-PLAIN server builder"
>&2 echo -e "Usage: server-lwp <w=wskpath>,<d=domain.com>,<p=listen-port>,<u=id0>,<u=id1>...,[proxy_acpt],[fallback=host:port:path]"
>&2 echo -e "Fallback format: fallback=[host]<:port>[:/path] Like: 'baidu.com:443:/path', ':1443:/path', ':1443'"
>&2 echo -e "User format: user|u=<uid>[:level:email]"
}
options=($(echo $1 |tr ',' ' '))
@@ -66,7 +64,7 @@ do
IFS=':'; uopt=(${user}); uopt=(${uopt[@]})
uid="${uopt[0]}"; level="${uopt[1]}"; email="${uopt[2]}"
unset IFS
if [ -z "${uid}" ]; then >&2 echo "Incorrect user format: $user"; usage; exit 1; fi
if [ -z "${uid}" ]; then >&2 echo -e "Incorrect user format: $user\n"; 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}" \
@@ -90,7 +88,7 @@ do
IFS=':'; fopt=(${fb}); fopt=(${fopt[@]})
fhost="${fopt[0]}"; fport="${fopt[1]}"; fpath="${fopt[2]}"
unset IFS
if [ -z "${fport}" ]; then >&2 echo "Incorrect fallback format: ${fallback}"; usage; exit 1; fi
if [ -z "${fport}" ]; then >&2 echo -e "Incorrect fallback format: ${fallback}\n"; 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}')

View File

@@ -3,10 +3,10 @@
DIR=$(dirname $0)
usage() {
>&2 echo "VLESS-WS-TLS server builder"
>&2 echo "Usage: server-lwt <w=wskpath>,<c=certhome-dir>,<d=domain.com>,<p=listen-port>,<u=id0>,<u=id1>...,[proxy_acpt],[fallback=host:port:path],[xtls]"
>&2 echo "Fallback format: fallback=[host]<:port>[:/path] Like: 'baidu.com:443:/path', ':1443:/path', ':1443'"
>&2 echo "User format: user|u=<uid>[:level:email]"
>&2 echo -e "VLESS-WS-TLS server builder"
>&2 echo -e "Usage: server-lwt <w=wskpath>,<c=certhome-dir>,<d=domain.com>,<p=listen-port>,<u=id0>,<u=id1>...,[proxy_acpt],[fallback=host:port:path],[xtls]"
>&2 echo -e "Fallback format: fallback=[host]<:port>[:/path] Like: 'baidu.com:443:/path', ':1443:/path', ':1443'"
>&2 echo -e "User format: user|u=<uid>[:level:email]"
}
options=($(echo $1 |tr ',' ' '))
@@ -71,8 +71,8 @@ fi
fullchain="${certhome}/${domain}/fullchain.cer"
prvkey="${certhome}/${domain}/${domain}.key"
if [ ! -f "${fullchain}" ]; then >&2 echo "Warning, Fullchain not found: ${fullchain}"; fi
if [ ! -f "${prvkey}" ]; then >&2 echo "Warning, Private key not found: ${prvkey}"; fi
if [ ! -f "${fullchain}" ]; then >&2 echo -e "Warning, Fullchain not found: ${fullchain}\n"; fi
if [ ! -f "${prvkey}" ]; then >&2 echo -e "Warning, Private key not found: ${prvkey}\n"; fi
if ! [ "${port}" -eq "${port}" ] 2>/dev/null; then >&2 echo -e "Error: Port number must be numeric.\n"; exit 1; fi
@@ -85,7 +85,7 @@ do
IFS=':'; uopt=(${user}); uopt=(${uopt[@]})
uid="${uopt[0]}"; level="${uopt[1]}"; email="${uopt[2]}"
unset IFS
if [ -z "${uid}" ]; then >&2 echo "Incorrect user format: $user"; usage; exit 1; fi
if [ -z "${uid}" ]; then >&2 echo -e "Incorrect user format: $user\n"; 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}" \
@@ -111,7 +111,7 @@ do
IFS=':'; fopt=(${fb}); fopt=(${fopt[@]})
fhost="${fopt[0]}"; fport="${fopt[1]}"; fpath="${fopt[2]}"
unset IFS
if [ -z "${fport}" ]; then >&2 echo "Incorrect fallback format: ${fallback}"; usage; exit 1; fi
if [ -z "${fport}" ]; then >&2 echo -e "Incorrect fallback format: ${fallback}\n"; 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}')

View File

@@ -3,10 +3,10 @@
DIR=$(dirname $0)
usage() {
>&2 echo "VMESS-TCP-TLS server builder"
>&2 echo "Usage: server-mtt <c=certhome-dir>,<d=domain.com>,<p=listen-port>,<u=id0>,<u=id1>...,[proxy_acpt],[fallback=host:port:path],[xtls]"
>&2 echo "Fallback format: fallback=[host]<:port>[:/path] Like: 'baidu.com:443:/path', ':1443:/path', ':1443'"
>&2 echo "User format: user|u=<uid>[:level:email]"
>&2 echo -e "VMESS-TCP-TLS server builder"
>&2 echo -e "Usage: server-mtt <c=certhome-dir>,<d=domain.com>,<p=listen-port>,<u=id0>,<u=id1>...,[proxy_acpt],[fallback=host:port:path],[xtls]"
>&2 echo -e "Fallback format: fallback=[host]<:port>[:/path] Like: 'baidu.com:443:/path', ':1443:/path', ':1443'"
>&2 echo -e "User format: user|u=<uid>[:level:email]"
}
options=($(echo $1 |tr ',' ' '))
@@ -63,8 +63,8 @@ fi
fullchain="${certhome}/${domain}/fullchain.cer"
prvkey="${certhome}/${domain}/${domain}.key"
if [ ! -f "${fullchain}" ]; then >&2 echo "Warning, Fullchain not found: ${fullchain}"; fi
if [ ! -f "${prvkey}" ]; then >&2 echo "Warning, Private key not found: ${prvkey}"; fi
if [ ! -f "${fullchain}" ]; then >&2 echo -e "Warning, Fullchain not found: ${fullchain}\n"; fi
if [ ! -f "${prvkey}" ]; then >&2 echo -e "Warning, Private key not found: ${prvkey}\n"; fi
if ! [ "${port}" -eq "${port}" ] 2>/dev/null; then >&2 echo -e "Error: Port number must be numeric.\n"; exit 1; fi
@@ -77,7 +77,7 @@ do
IFS=':'; uopt=(${user}); uopt=(${uopt[@]})
uid="${uopt[0]}"; level="${uopt[1]}"; email="${uopt[2]}"
unset IFS
if [ -z "${uid}" ]; then >&2 echo "Incorrect user format: $user"; usage; exit 1; fi
if [ -z "${uid}" ]; then >&2 echo -e "Incorrect user format: $user\n"; 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}" \
@@ -103,7 +103,7 @@ do
IFS=':'; fopt=(${fb}); fopt=(${fopt[@]})
fhost="${fopt[0]}"; fport="${fopt[1]}"; fpath="${fopt[2]}"
unset IFS
if [ -z "${fport}" ]; then >&2 echo "Incorrect fallback format: ${fallback}"; usage; exit 1; fi
if [ -z "${fport}" ]; then >&2 echo -e "Incorrect fallback format: ${fallback}\n"; 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}')

View File

@@ -3,10 +3,10 @@
DIR=$(dirname $0)
usage() {
>&2 echo "VMESS-WS-PLAIN server builder"
>&2 echo "Usage: server-mwp <w=wskpath>,<d=domain.com>,<p=listen-port>,<u=id0>,<u=id1>...,[proxy_acpt],[fallback=host:port:path]"
>&2 echo "Fallback format: fallback=[host]<:port>[:/path] Like: 'baidu.com:443:/path', ':1443:/path', ':1443'"
>&2 echo "User format: user|u=<uid>[:level:email]"
>&2 echo -e "VMESS-WS-PLAIN server builder"
>&2 echo -e "Usage: server-mwp <w=wskpath>,<d=domain.com>,<p=listen-port>,<u=id0>,<u=id1>...,[proxy_acpt],[fallback=host:port:path]"
>&2 echo -e "Fallback format: fallback=[host]<:port>[:/path] Like: 'baidu.com:443:/path', ':1443:/path', ':1443'"
>&2 echo -e "User format: user|u=<uid>[:level:email]"
}
options=($(echo $1 |tr ',' ' '))
@@ -55,7 +55,7 @@ if [ -z "${xuser}" ]; then
usage; exit 1
fi
if ! [ "${port}" -eq "${port}" ] 2>/dev/null; then >&2 echo "Port number must be numeric.\n"; exit 1; fi
if ! [ "${port}" -eq "${port}" ] 2>/dev/null; then >&2 echo -e "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"}}')
@@ -66,7 +66,7 @@ do
IFS=':'; uopt=(${user}); uopt=(${uopt[@]})
uid="${uopt[0]}"; level="${uopt[1]}"; email="${uopt[2]}"
unset IFS
if [ -z "${uid}" ]; then >&2 echo "Incorrect user format: $user"; usage; exit 1; fi
if [ -z "${uid}" ]; then >&2 echo -e "Incorrect user format: $user\n"; 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}" \
@@ -91,7 +91,7 @@ do
fhost="${fopt[0]}"; fport="${fopt[1]}"; fpath="${fopt[2]}"
unset IFS
if [ -z "${fport}" ]; then
>&2 echo "Incorrect fallback format: ${fallback}"
>&2 echo -e "Incorrect fallback format: ${fallback}\n"
usage; exit 1
fi
if [ -z "${fhost}" ]; then fhost="127.0.0.1"; fi

View File

@@ -3,10 +3,10 @@
DIR=$(dirname $0)
usage() {
>&2 echo "VMESS-WS-TLS server builder"
>&2 echo "Usage: server-mwt <w=wskpath>,<c=certhome-dir>,<d=domain.com>,<p=listen-port>,<u=id0>,<u=id1>...,[proxy_acpt],[fallback=host:port:path],[xtls]"
>&2 echo "Fallback format: fallback=[host]<:port>[:/path] Like: 'baidu.com:443:/path', ':1443:/path', ':1443'"
>&2 echo "User format: user|u=<uid>[:level:email]"
>&2 echo -e "VMESS-WS-TLS server builder"
>&2 echo -e "Usage: server-mwt <w=wskpath>,<c=certhome-dir>,<d=domain.com>,<p=listen-port>,<u=id0>,<u=id1>...,[proxy_acpt],[fallback=host:port:path],[xtls]"
>&2 echo -e "Fallback format: fallback=[host]<:port>[:/path] Like: 'baidu.com:443:/path', ':1443:/path', ':1443'"
>&2 echo -e "User format: user|u=<uid>[:level:email]"
}
options=($(echo $1 |tr ',' ' '))
@@ -71,8 +71,8 @@ fi
fullchain="${certhome}/${domain}/fullchain.cer"
prvkey="${certhome}/${domain}/${domain}.key"
if [ ! -f "${fullchain}" ]; then >&2 echo "Warning, Fullchain not found: ${fullchain}"; fi
if [ ! -f "${prvkey}" ]; then >&2 echo "Warning, Private key not found: ${prvkey}"; fi
if [ ! -f "${fullchain}" ]; then >&2 echo -e "Warning, Fullchain not found: ${fullchain}\n"; fi
if [ ! -f "${prvkey}" ]; then >&2 echo -e "Warning, Private key not found: ${prvkey}\n"; fi
if ! [ "${port}" -eq "${port}" ] 2>/dev/null; then >&2 echo -e "Error: Port number must be numeric.\n"; exit 1; fi
@@ -85,7 +85,7 @@ do
IFS=':'; uopt=(${user}); uopt=(${uopt[@]})
uid="${uopt[0]}"; level="${uopt[1]}"; email="${uopt[2]}"
unset IFS
if [ -z "${uid}" ]; then >&2 echo "Incorrect user format: $user"; usage; exit 1; fi
if [ -z "${uid}" ]; then >&2 echo -e "Incorrect user format: $user\n"; 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}" \
@@ -112,7 +112,7 @@ do
fhost="${fopt[0]}"; fport="${fopt[1]}"; fpath="${fopt[2]}"
unset IFS
if [ -z "${fport}" ]; then
>&2 echo "Incorrect fallback format: ${fallback}"
>&2 echo -e "Incorrect fallback format: ${fallback}\n"
usage; exit 1
fi
if [ -z "${fhost}" ]; then fhost="127.0.0.1"; fi

View File

@@ -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"
@@ -164,10 +164,11 @@ do
# Generating default site config for every --ngserver invocation
# to avoid domain name leaking against bot probing.
default_domain="00_default_${port}"
mkdir "${certhome}/${default_domain}"; cd "${certhome}/${default_domain}"
# Generating self-signed cert for default domain.
openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout "${default_domain}.key" -out fullchain.cer -subj "/C=US/ST=NV/L=Vegas/O=Internic/CN=localhost"
cd -
(
mkdir "${certhome}/${default_domain}"; cd "${certhome}/${default_domain}"
# Generating self-signed cert for default domain.
openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout "${default_domain}.key" -out fullchain.cer -subj "/C=US/ST=NV/L=Vegas/O=Internic/CN=localhost"
)
SITEDOMAINS+=("${default_domain}")
# Generating site config files for each domain including default domain.
for site_domain in "${SITEDOMAINS[@]}"

View File

@@ -3,10 +3,10 @@
DIR=$(dirname $0)
usage() {
>&2 echo "TROJAN-TCP-TLS server builder"
>&2 echo "Usage: server-ttt <c=certhome-dir>,<d=domain.com>,<p=listen-port>,<u=id0>,<u=id1>...,[proxy_acpt],[fallback=host:port:path],[xtls]"
>&2 echo "Fallback format: fallback=[host]<:port>[:/path] Like: 'baidu.com:443:/path', ':1443:/path', ':1443'"
>&2 echo "User format: user|u=<uid>[:level:email]"
>&2 echo -e "TROJAN-TCP-TLS server builder"
>&2 echo -e "Usage: server-ttt <c=certhome-dir>,<d=domain.com>,<p=listen-port>,<u=id0>,<u=id1>...,[proxy_acpt],[fallback=host:port:path],[xtls]"
>&2 echo -e "Fallback format: fallback=[host]<:port>[:/path] Like: 'baidu.com:443:/path', ':1443:/path', ':1443'"
>&2 echo -e "User format: user|u=<uid>[:level:email]"
}
options=($(echo $1 |tr ',' ' '))
@@ -63,8 +63,8 @@ fi
fullchain="${certhome}/${domain}/fullchain.cer"
prvkey="${certhome}/${domain}/${domain}.key"
if [ ! -f "${fullchain}" ]; then >&2 echo "Warning, Fullchain not found: ${fullchain}"; fi
if [ ! -f "${prvkey}" ]; then >&2 echo "Warning, Private key not found: ${prvkey}"; fi
if [ ! -f "${fullchain}" ]; then >&2 echo -e "Warning, Fullchain not found: ${fullchain}\n"; fi
if [ ! -f "${prvkey}" ]; then >&2 echo -e "Warning, Private key not found: ${prvkey}\n"; fi
if ! [ "${port}" -eq "${port}" ] 2>/dev/null; then >&2 echo -e "Error: Port number must be numeric.\n"; exit 1; fi
@@ -77,7 +77,7 @@ do
IFS=':'; uopt=(${user}); uopt=(${uopt[@]})
uid="${uopt[0]}"; level="${uopt[1]}"; email="${uopt[2]}"
unset IFS
if [ -z "${uid}" ]; then >&2 echo "Incorrect user format: $user"; usage; exit 1; fi
if [ -z "${uid}" ]; then >&2 echo -e "Incorrect user format: $user\n"; 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}" \
@@ -103,7 +103,7 @@ do
IFS=':'; fopt=(${fb}); fopt=(${fopt[@]})
fhost="${fopt[0]}"; fport="${fopt[1]}"; fpath="${fopt[2]}"
unset IFS
if [ -z "${fport}" ]; then >&2 echo "Incorrect fallback format: ${fallback}"; usage; exit 1; fi
if [ -z "${fport}" ]; then >&2 echo -e "Incorrect fallback format: ${fallback}\n"; 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}')

View File

@@ -3,10 +3,10 @@
DIR=$(dirname $0)
usage() {
>&2 echo "TROJAN-WS-PLAIN server builder"
>&2 echo "Usage: server-twp <w=wskpath>,<d=domain.com>,<p=listen-port>,<u=id0>,<u=id1>...,[proxy_acpt],[fallback=host:port:path]"
>&2 echo "Fallback format: fallback=[host]<:port>[:/path] Like: 'baidu.com:443:/path', ':1443:/path', ':1443'"
>&2 echo "User format: user=<uid>[:level:email]"
>&2 echo -e "TROJAN-WS-PLAIN server builder"
>&2 echo -e "Usage: server-twp <w=wskpath>,<d=domain.com>,<p=listen-port>,<u=id0>,<u=id1>...,[proxy_acpt],[fallback=host:port:path]"
>&2 echo -e "Fallback format: fallback=[host]<:port>[:/path] Like: 'baidu.com:443:/path', ':1443:/path', ':1443'"
>&2 echo -e "User format: user=<uid>[:level:email]"
}
options=($(echo $1 |tr ',' ' '))
@@ -36,26 +36,26 @@ do
done
if [ -z "${domain}" ]; then
>&2 echo "Error: Domain undefined."
>&2 echo -e "Error: Domain undefined.\n"
usage; exit 1
fi
if [ -z "${port}" ]; then
>&2 echo "Error: Port undefined."
>&2 echo -e "Error: Port undefined.\n"
usage; exit 1 ;
fi
if [ -z "${wspath}" ]; then
>&2 echo "Error: wspath undefined."
>&2 echo -e "Error: wspath undefined.\n"
usage; exit 1
fi
if [ -z "${xuser}" ]; then
>&2 echo "Error: User undefined."
>&2 echo -e "Error: User undefined.\n"
usage; exit 1
fi
if ! [ "${port}" -eq "${port}" ] 2>/dev/null; then >&2 echo "Port number must be numeric"; exit 1; fi
if ! [ "${port}" -eq "${port}" ] 2>/dev/null; then >&2 echo -e "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"}}')
@@ -66,7 +66,7 @@ do
IFS=':'; uopt=(${user}); uopt=(${uopt[@]})
uid="${uopt[0]}"; level="${uopt[1]}"; email="${uopt[2]}"
unset IFS
if [ -z "${uid}" ]; then >&2 echo "Incorrect user format: $user"; usage; exit 1; fi
if [ -z "${uid}" ]; then >&2 echo -e "Incorrect user format: $user\n"; 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}" \
@@ -91,7 +91,7 @@ do
fhost="${fopt[0]}"; fport="${fopt[1]}"; fpath="${fopt[2]}"
unset IFS
if [ -z "${fport}" ]; then
>&2 echo "Incorrect fallback format: ${fallback}"
>&2 echo -e "Incorrect fallback format: ${fallback}\n"
usage; exit 1
fi
if [ -z "${fhost}" ]; then fhost="127.0.0.1"; fi

View File

@@ -3,10 +3,10 @@
DIR=$(dirname $0)
usage() {
>&2 echo "TROJAN-WS-TLS server builder"
>&2 echo "Usage: server-twt <w=wskpath>,<c=certhome-dir>,<d=domain.com>,<p=listen-port>,<u=id0>,<u=id1>...,[proxy_acpt],[fallback=host:port:path],[xtls]"
>&2 echo "Fallback format: fallback=[host]<:port>[:/path] Like: 'baidu.com:443:/path', ':1443:/path', ':1443'"
>&2 echo "User format: user=<uid>[:level:email]"
>&2 echo -e "TROJAN-WS-TLS server builder"
>&2 echo -e "Usage: server-twt <w=wskpath>,<c=certhome-dir>,<d=domain.com>,<p=listen-port>,<u=id0>,<u=id1>...,[proxy_acpt],[fallback=host:port:path],[xtls]"
>&2 echo -e "Fallback format: fallback=[host]<:port>[:/path] Like: 'baidu.com:443:/path', ':1443:/path', ':1443'"
>&2 echo -e "User format: user=<uid>[:level:email]"
}
options=($(echo $1 |tr ',' ' '))
@@ -45,36 +45,36 @@ do
done
if [ -z "${certhome}" ]; then
>&2 echo "Error: Certhome undefined."
>&2 echo -e "Error: Certhome undefined.\n"
usage; exit 1
fi
if [ -z "${domain}" ]; then
>&2 echo "Error: Domain undefined."
>&2 echo -e "Error: Domain undefined.\n"
usage; exit 1
fi
if [ -z "${port}" ]; then
>&2 echo "Error: Port undefined."
>&2 echo -e "Error: Port undefined.\n"
usage; exit 1 ;
fi
if [ -z "${wspath}" ]; then
>&2 echo "Error: wspath undefined."
>&2 echo -e "Error: wspath undefined.\n"
usage; exit 1
fi
if [ -z "${xuser}" ]; then
>&2 echo "Error: User undefined."
>&2 echo -e "Error: User undefined.\n"
usage; exit 1
fi
fullchain="${certhome}/${domain}/fullchain.cer"
prvkey="${certhome}/${domain}/${domain}.key"
if [ ! -f "${fullchain}" ]; then >&2 echo "Warning, Fullchain not found: ${fullchain}"; fi
if [ ! -f "${prvkey}" ]; then >&2 echo "Warning, Private key not found: ${prvkey}"; fi
if [ ! -f "${fullchain}" ]; then >&2 echo -e "Warning, Fullchain not found: ${fullchain}\n"; fi
if [ ! -f "${prvkey}" ]; then >&2 echo -e "Warning, Private key not found: ${prvkey}\n"; fi
if ! [ "${port}" -eq "${port}" ] 2>/dev/null; then >&2 echo "Port number must be numeric"; exit 1; fi
if ! [ "${port}" -eq "${port}" ] 2>/dev/null; then >&2 echo -e "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"}}')
@@ -85,7 +85,7 @@ do
IFS=':'; uopt=(${user}); uopt=(${uopt[@]})
uid="${uopt[0]}"; level="${uopt[1]}"; email="${uopt[2]}"
unset IFS
if [ -z "${uid}" ]; then >&2 echo "Incorrect user format: $user"; usage; exit 1; fi
if [ -z "${uid}" ]; then >&2 echo -e "Incorrect user format: $user\n"; 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}" \
@@ -112,7 +112,7 @@ do
fhost="${fopt[0]}"; fport="${fopt[1]}"; fpath="${fopt[2]}"
unset IFS
if [ -z "${fport}" ]; then
>&2 echo "Incorrect fallback format: ${fallback}"
>&2 echo -e "Incorrect fallback format: ${fallback}\n"
usage; exit 1
fi
if [ -z "${fhost}" ]; then fhost="127.0.0.1"; fi