Remove s=sni.com from doc as it needs allowInscure

This commit is contained in:
Samuel Huang
2024-09-21 22:59:00 +10:00
parent 13dbbc547f
commit f5b09715bc
8 changed files with 142 additions and 83 deletions

View File

@@ -11,7 +11,7 @@ if [ -z "$1" ]; then
exit 1 exit 1
fi fi
# id@domain.com:443:/svcpath,serverName=x.org,fingerprint=safari # id@domain.com:443:/svcpath,fingerprint=safari
args=(`echo $1 |tr ',' ' '`) args=(`echo $1 |tr ',' ' '`)
dest="${args[0]}" dest="${args[0]}"
for ext_opt in "${args[@]}" for ext_opt in "${args[@]}"
@@ -36,6 +36,8 @@ host="${options[0]}"
port="${options[1]}" port="${options[1]}"
path="${options[2]}" path="${options[2]}"
if [ -z "${fingerprint}" ]; then fingerprint="safari"; fi
if [ -z "${id}" ]; then if [ -z "${id}" ]; then
>&2 echo "Error: id undefined." >&2 echo "Error: id undefined."
usage usage
@@ -57,7 +59,7 @@ if ! [ "${port}" -eq "${port}" ] 2>/dev/null; then >&2 echo "Port number must be
# User settings # User settings
Jusers=`jq -nc --arg uuid "${id}" '. += {"id":$uuid,"encryption":"none","level":0}'` Jusers=`jq -nc --arg uuid "${id}" '. += {"id":$uuid,"encryption":"none","level":0}'`
# Vnest settings # Vnext settings
Jvnext=`jq -nc --arg host "${host}" --arg port "${port}" --argjson juser "${Jusers}" \ Jvnext=`jq -nc --arg host "${host}" --arg port "${port}" --argjson juser "${Jusers}" \
'. += {"address":$host,"port":($port | tonumber),"users":[$juser]}' ` '. += {"address":$host,"port":($port | tonumber),"users":[$juser]}' `
@@ -67,7 +69,6 @@ for alpn in "${ALPN[@]}"
do do
Jalpn=`echo $Jalpn | jq -c --arg alpn "${alpn}" '. +=[$alpn]'` Jalpn=`echo $Jalpn | jq -c --arg alpn "${alpn}" '. +=[$alpn]'`
done done
JstreamSettings=`jq -nc --arg serverName "${serverName}" --arg fingerprint "${fingerprint}" --arg path "${path}" --argjson jalpn "${Jalpn}" \ JstreamSettings=`jq -nc --arg serverName "${serverName}" --arg fingerprint "${fingerprint}" --arg path "${path}" --argjson jalpn "${Jalpn}" \
'. += {"network":"grpc","security":"tls","tlsSettings":{"serverName":$serverName,"fingerprint":$fingerprint,"alpn":$jalpn},"grpcSettings":{"serviceName":$path}}' ` '. += {"network":"grpc","security":"tls","tlsSettings":{"serverName":$serverName,"fingerprint":$fingerprint,"alpn":$jalpn},"grpcSettings":{"serviceName":$path}}' `

View File

@@ -2,7 +2,7 @@
usage() { usage() {
>&2 echo "VLESS-SPLT-TLS proxy builder" >&2 echo "VLESS-SPLT-TLS proxy builder"
>&2 echo "Usage: proxy-lst <id@domain.com:443:/webpath>[,serverName=x.org][,fingerprint=safari][,alpn=h3]" >&2 echo "Usage: proxy-lst <id@domain.com:443:/webpath>[,fingerprint=safari][,alpn=h3]"
} }
if [ -z "$1" ]; then if [ -z "$1" ]; then
@@ -11,7 +11,7 @@ if [ -z "$1" ]; then
exit 1 exit 1
fi fi
# id@domain.com:443:/webpath,serverName=x.org,fingerprint=safari # id@domain.com:443:/webpath,fingerprint=safari
args=(`echo $1 |tr ',' ' '`) args=(`echo $1 |tr ',' ' '`)
dest="${args[0]}" dest="${args[0]}"
for ext_opt in "${args[@]}" for ext_opt in "${args[@]}"
@@ -36,6 +36,8 @@ host="${options[0]}"
port="${options[1]}" port="${options[1]}"
path="${options[2]}" path="${options[2]}"
if [ -z "${fingerprint}" ]; then fingerprint="safari"; fi
if [ -z "${id}" ]; then if [ -z "${id}" ]; then
>&2 echo "Error: id undefined." >&2 echo "Error: id undefined."
usage usage
@@ -57,7 +59,7 @@ if ! [ "${port}" -eq "${port}" ] 2>/dev/null; then >&2 echo "Port number must be
# User settings # User settings
Jusers=`jq -nc --arg uuid "${id}" '. += {"id":$uuid,"encryption":"none","level":0}'` Jusers=`jq -nc --arg uuid "${id}" '. += {"id":$uuid,"encryption":"none","level":0}'`
# Vnest settings # Vnext settings
Jvnext=`jq -nc --arg host "${host}" --arg port "${port}" --argjson juser "${Jusers}" \ Jvnext=`jq -nc --arg host "${host}" --arg port "${port}" --argjson juser "${Jusers}" \
'. += {"address":$host,"port":($port | tonumber),"users":[$juser]}' ` '. += {"address":$host,"port":($port | tonumber),"users":[$juser]}' `
@@ -67,7 +69,6 @@ for alpn in "${ALPN[@]}"
do do
Jalpn=`echo $Jalpn | jq -c --arg alpn "${alpn}" '. +=[$alpn]'` Jalpn=`echo $Jalpn | jq -c --arg alpn "${alpn}" '. +=[$alpn]'`
done done
JstreamSettings=`jq -nc --arg serverName "${serverName}" --arg fingerprint "${fingerprint}" --arg path "${path}" --argjson jalpn "${Jalpn}" \ JstreamSettings=`jq -nc --arg serverName "${serverName}" --arg fingerprint "${fingerprint}" --arg path "${path}" --argjson jalpn "${Jalpn}" \
'. += {"network":"splithttp","security":"tls","tlsSettings":{"serverName":$serverName,"fingerprint":$fingerprint,"alpn":$jalpn},"splithttpSettings":{"path":$path}}' ` '. += {"network":"splithttp","security":"tls","tlsSettings":{"serverName":$serverName,"fingerprint":$fingerprint,"alpn":$jalpn},"splithttpSettings":{"path":$path}}' `

View File

@@ -2,7 +2,7 @@
usage() { usage() {
>&2 echo "VLESS-TCP-TLS proxy builder" >&2 echo "VLESS-TCP-TLS proxy builder"
>&2 echo "Usage: proxy-ltt <id@domain.com:443>[,xtls][,serverName=x.org][,fingerprint=safari]" >&2 echo "Usage: proxy-ltt <id@domain.com:443>[,xtls][,fingerprint=safari]"
} }
if [ -z "$1" ]; then if [ -z "$1" ]; then
@@ -11,13 +11,16 @@ if [ -z "$1" ]; then
exit 1 exit 1
fi fi
# id@domain.com:443,serverName=x.org,fingerprint=safari # id@domain.com:443,fingerprint=safari
args=(`echo $1 |tr ',' ' '`) args=(`echo $1 |tr ',' ' '`)
dest="${args[0]}" dest="${args[0]}"
for ext_opt in "${args[@]}" for ext_opt in "${args[@]}"
do do
kv=(`echo $ext_opt |tr '=' ' '`) kv=(`echo $ext_opt |tr '=' ' '`)
case "${kv[0]}" in case "${kv[0]}" in
a|alpn)
ALPN+=("${kv[1]}")
;;
s|serverName) s|serverName)
serverName="${kv[1]}" serverName="${kv[1]}"
;; ;;
@@ -35,7 +38,6 @@ options=(`echo ${options[1]} |tr ':' ' '`)
host="${options[0]}" host="${options[0]}"
port="${options[1]}" port="${options[1]}"
if [ -z "${serverName}" ]; then serverName=${host}; fi
if [ -z "${fingerprint}" ]; then fingerprint="safari"; fi if [ -z "${fingerprint}" ]; then fingerprint="safari"; fi
if [ -z "${id}" ]; then if [ -z "${id}" ]; then
@@ -57,15 +59,20 @@ 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 "Port number must be numeric"; exit 1; fi
# User settings # User settings
Jusers=`jq -nc --arg uuid "${id}" --arg flow "${flow}" '. += {"id":$uuid, "flow":$flow, "encryption":"none", "level":0}'` Jusers=`jq -nc --arg uuid "${id}" --arg flow "${flow}" '. += {"flow":$flow,"id":$uuid,"encryption":"none","level":0}'`
# Vnest settings # Vnext settings
Jvnext=`jq -nc --arg host "${host}" --arg port "${port}" --argjson juser "${Jusers}" \ Jvnext=`jq -nc --arg host "${host}" --arg port "${port}" --argjson juser "${Jusers}" \
'. += {"address":$host,"port":($port | tonumber),"users":[$juser]}' ` '. += {"address":$host,"port":($port | tonumber),"users":[$juser]}' `
# Stream Settings # Stream Settings
Jalpn='[]'
for alpn in "${ALPN[@]}"
do
Jalpn=`echo $Jalpn | jq -c --arg alpn "${alpn}" '. +=[$alpn]'`
done
JstreamSettings=`jq -nc --arg serverName "${serverName}" --arg fingerprint "${fingerprint}" \ JstreamSettings=`jq -nc --arg serverName "${serverName}" --arg fingerprint "${fingerprint}" \
'. += {"network":"tcp", "security":"tls", "tlsSettings":{"serverName":$serverName, "fingerprint":$fingerprint}}' ` '. += {"network":"tcp","security":"tls","tlsSettings":{"serverName":$serverName,"fingerprint":$fingerprint,"alpn":$jalpn}}' `
Jproxy=`jq -nc --arg host "${host}" --argjson jvnext "${Jvnext}" --argjson jstreamSettings "${JstreamSettings}" \ Jproxy=`jq -nc --arg host "${host}" --argjson jvnext "${Jvnext}" --argjson jstreamSettings "${JstreamSettings}" \
'. += { "tag":"proxy","protocol":"vless","settings":{"vnext":[$jvnext]},"streamSettings":$jstreamSettings}' ` '. += { "tag":"proxy","protocol":"vless","settings":{"vnext":[$jvnext]},"streamSettings":$jstreamSettings}' `

View File

@@ -2,7 +2,7 @@
usage() { usage() {
>&2 echo "VLESS-WS-TLS proxy builder" >&2 echo "VLESS-WS-TLS proxy builder"
>&2 echo "Usage: proxy-lsw <id@domain.com:443:/websocket>[,serverName=x.org][,fingerprint=safari]" >&2 echo "Usage: proxy-lwt <id@domain.com:443:/websocket>[,fingerprint=safari]"
} }
if [ -z "$1" ]; then if [ -z "$1" ]; then
@@ -11,13 +11,16 @@ if [ -z "$1" ]; then
exit 1 exit 1
fi fi
# id@domain.com:443:/websocket,serverName=x.org,fingerprint=safari # id@domain.com:443:/websocket,fingerprint=safari
args=(`echo $1 |tr ',' ' '`) args=(`echo $1 |tr ',' ' '`)
dest="${args[0]}" dest="${args[0]}"
for ext_opt in "${args[@]}" for ext_opt in "${args[@]}"
do do
kv=(`echo $ext_opt |tr '=' ' '`) kv=(`echo $ext_opt |tr '=' ' '`)
case "${kv[0]}" in case "${kv[0]}" in
a|alpn)
ALPN+=("${kv[1]}")
;;
s|serverName) s|serverName)
serverName="${kv[1]}" serverName="${kv[1]}"
;; ;;
@@ -33,7 +36,6 @@ host="${options[0]}"
port="${options[1]}" port="${options[1]}"
path="${options[2]}" path="${options[2]}"
if [ -z "${serverName}" ]; then serverName=${host}; fi
if [ -z "${fingerprint}" ]; then fingerprint="safari"; fi if [ -z "${fingerprint}" ]; then fingerprint="safari"; fi
if [ -z "${id}" ]; then if [ -z "${id}" ]; then
@@ -54,13 +56,21 @@ 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 "Port number must be numeric"; exit 1; fi
# User settings
Jusers=`jq -nc --arg uuid "${id}" '. += {"id":$uuid,"encryption":"none","level":0}'` Jusers=`jq -nc --arg uuid "${id}" '. += {"id":$uuid,"encryption":"none","level":0}'`
# Vnext settings
Jvnext=`jq -nc --arg host "${host}" --arg port "${port}" --argjson juser "${Jusers}" \ Jvnext=`jq -nc --arg host "${host}" --arg port "${port}" --argjson juser "${Jusers}" \
'. += {"address":$host,"port":($port | tonumber),"users":[$juser]}' ` '. += {"address":$host,"port":($port | tonumber),"users":[$juser]}' `
JstreamSettings=`jq -nc --arg serverName "${serverName}" --arg fingerprint "${fingerprint}" --arg path "${path}" \ # Stream Settings
'. += {"network":"ws", "security":"tls", "tlsSettings":{"serverName":$serverName, "fingerprint":$fingerprint}, "wsSettings":{"path":$path}}' ` Jalpn='[]'
for alpn in "${ALPN[@]}"
do
Jalpn=`echo $Jalpn | jq -c --arg alpn "${alpn}" '. +=[$alpn]'`
done
JstreamSettings=`jq -nc --arg serverName "${serverName}" --arg fingerprint "${fingerprint}" --arg path "${path}" --argjson jalpn "${Jalpn}" \
'. += {"network":"ws","security":"tls","tlsSettings":{"serverName":$serverName,"fingerprint":$fingerprint,"alpn":$jalpn},"wsSettings":{"path":$path}}' `
Jproxy=`jq -nc --arg host "${host}" --argjson jvnext "${Jvnext}" --argjson jstreamSettings "${JstreamSettings}" \ Jproxy=`jq -nc --arg host "${host}" --argjson jvnext "${Jvnext}" --argjson jstreamSettings "${JstreamSettings}" \
'. += { "tag":"proxy","protocol":"vless","settings":{"vnext":[$jvnext]},"streamSettings":$jstreamSettings}' ` '. += { "tag":"proxy","protocol":"vless","settings":{"vnext":[$jvnext]},"streamSettings":$jstreamSettings}' `

View File

@@ -2,7 +2,7 @@
usage() { usage() {
>&2 echo "VMESS-TCP-TLS proxy builder" >&2 echo "VMESS-TCP-TLS proxy builder"
>&2 echo "Usage: proxy-ms <id@domain.com:443>[,serverName=x.org][,fingerprint=safari]" >&2 echo "Usage: proxy-mtt <id@domain.com:443>[,fingerprint=safari]"
} }
if [ -z "$1" ]; then if [ -z "$1" ]; then
@@ -11,13 +11,16 @@ if [ -z "$1" ]; then
exit 1 exit 1
fi fi
# id@domain.com:443,serverName=x.org,fingerprint=safari # id@domain.com:443,fingerprint=safari
args=(`echo $1 |tr ',' ' '`) args=(`echo $1 |tr ',' ' '`)
dest="${args[0]}" dest="${args[0]}"
for ext_opt in "${args[@]}" for ext_opt in "${args[@]}"
do do
kv=(`echo $ext_opt |tr '=' ' '`) kv=(`echo $ext_opt |tr '=' ' '`)
case "${kv[0]}" in case "${kv[0]}" in
a|alpn)
ALPN+=("${kv[1]}")
;;
s|serverName) s|serverName)
serverName="${kv[1]}" serverName="${kv[1]}"
;; ;;
@@ -32,7 +35,6 @@ options=(`echo ${options[1]} |tr ':' ' '`)
host="${options[0]}" host="${options[0]}"
port="${options[1]}" port="${options[1]}"
if [ -z "${serverName}" ]; then serverName=${host}; fi
if [ -z "${fingerprint}" ]; then fingerprint="safari"; fi if [ -z "${fingerprint}" ]; then fingerprint="safari"; fi
if [ -z "${id}" ]; then if [ -z "${id}" ]; then
@@ -53,13 +55,21 @@ 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 "Port number must be numeric"; exit 1; fi
# User settings
Jusers=`jq -nc --arg uuid "${id}" '. += {"id":$uuid,"encryption":"none","level":0}'` Jusers=`jq -nc --arg uuid "${id}" '. += {"id":$uuid,"encryption":"none","level":0}'`
# Vnext settings
Jvnext=`jq -nc --arg host "${host}" --arg port "${port}" --argjson juser "${Jusers}" \ Jvnext=`jq -nc --arg host "${host}" --arg port "${port}" --argjson juser "${Jusers}" \
'. += {"address":$host,"port":($port | tonumber),"users":[$juser]}' ` '. += {"address":$host,"port":($port | tonumber),"users":[$juser]}' `
JstreamSettings=`jq -nc --arg serverName "${serverName}" --arg fingerprint "${fingerprint}" \ # Stream Settings
'. += {"network":"tcp", "security":"tls", "tlsSettings":{"serverName":$serverName, "fingerprint":$fingerprint}}' ` Jalpn='[]'
for alpn in "${ALPN[@]}"
do
Jalpn=`echo $Jalpn | jq -c --arg alpn "${alpn}" '. +=[$alpn]'`
done
JstreamSettings=`jq -nc --arg serverName "${serverName}" --arg fingerprint "${fingerprint}" --argjson jalpn "${Jalpn}" \
'. += {"network":"tcp","security":"tls","tlsSettings":{"serverName":$serverName,"fingerprint":$fingerprint,"alpn":$jalpn}}' `
Jproxy=`jq -nc --arg host "${host}" --argjson jvnext "${Jvnext}" --argjson jstreamSettings "${JstreamSettings}" \ Jproxy=`jq -nc --arg host "${host}" --argjson jvnext "${Jvnext}" --argjson jstreamSettings "${JstreamSettings}" \
'. += { "tag":"proxy","protocol":"vmess","settings":{"vnext":[$jvnext]},"streamSettings":$jstreamSettings}' ` '. += { "tag":"proxy","protocol":"vmess","settings":{"vnext":[$jvnext]},"streamSettings":$jstreamSettings}' `

View File

@@ -2,7 +2,7 @@
usage() { usage() {
>&2 echo "VMESS-WS-TLS proxy builder" >&2 echo "VMESS-WS-TLS proxy builder"
>&2 echo "Usage: proxy-msw <id@domain.com:443:/websocket>[,serverName=x.org][,fingerprint=safari]" >&2 echo "Usage: proxy-mwt <id@domain.com:443:/websocket>[,fingerprint=safari]"
} }
if [ -z "$1" ]; then if [ -z "$1" ]; then
@@ -11,13 +11,16 @@ if [ -z "$1" ]; then
exit 1 exit 1
fi fi
# id@domain.com:443:/websocket,serverName=x.org,fingerprint=safari # id@domain.com:443:/websocket,fingerprint=safari
args=(`echo $1 |tr ',' ' '`) args=(`echo $1 |tr ',' ' '`)
dest="${args[0]}" dest="${args[0]}"
for ext_opt in "${args[@]}" for ext_opt in "${args[@]}"
do do
kv=(`echo $ext_opt |tr '=' ' '`) kv=(`echo $ext_opt |tr '=' ' '`)
case "${kv[0]}" in case "${kv[0]}" in
a|alpn)
ALPN+=("${kv[1]}")
;;
s|serverName) s|serverName)
serverName="${kv[1]}" serverName="${kv[1]}"
;; ;;
@@ -33,7 +36,6 @@ host="${options[0]}"
port="${options[1]}" port="${options[1]}"
path="${options[2]}" path="${options[2]}"
if [ -z "${serverName}" ]; then serverName=${host}; fi
if [ -z "${fingerprint}" ]; then fingerprint="safari"; fi if [ -z "${fingerprint}" ]; then fingerprint="safari"; fi
if [ -z "${id}" ]; then if [ -z "${id}" ]; then
@@ -54,13 +56,21 @@ 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 "Port number must be numeric"; exit 1; fi
# User settings
Jusers=`jq -nc --arg uuid "${id}" '. += {"id":$uuid,"encryption":"none","level":0}'` Jusers=`jq -nc --arg uuid "${id}" '. += {"id":$uuid,"encryption":"none","level":0}'`
# Vnext settings
Jvnext=`jq -nc --arg host "${host}" --arg port "${port}" --argjson juser "${Jusers}" \ Jvnext=`jq -nc --arg host "${host}" --arg port "${port}" --argjson juser "${Jusers}" \
'. += {"address":$host,"port":($port | tonumber),"users":[$juser]}' ` '. += {"address":$host,"port":($port | tonumber),"users":[$juser]}' `
JstreamSettings=`jq -nc --arg serverName "${serverName}" --arg fingerprint "${fingerprint}" --arg path "${path}" \ # Stream Settings
'. += {"network":"ws", "security":"tls", "tlsSettings":{"serverName":$serverName, "fingerprint":$fingerprint}, "wsSettings":{"path":$path}}' ` Jalpn='[]'
for alpn in "${ALPN[@]}"
do
Jalpn=`echo $Jalpn | jq -c --arg alpn "${alpn}" '. +=[$alpn]'`
done
JstreamSettings=`jq -nc --arg serverName "${serverName}" --arg fingerprint "${fingerprint}" --arg path "${path}" --argjson jalpn "${Jalpn}" \
'. += {"network":"ws","security":"tls","tlsSettings":{"serverName":$serverName,"fingerprint":$fingerprint,"alpn":$jalpn},"wsSettings":{"path":$path}}' `
Jproxy=`jq -nc --arg host "${host}" --argjson jvnext "${Jvnext}" --argjson jstreamSettings "${JstreamSettings}" \ Jproxy=`jq -nc --arg host "${host}" --argjson jvnext "${Jvnext}" --argjson jstreamSettings "${JstreamSettings}" \
'. += { "tag":"proxy","protocol":"vmess","settings":{"vnext":[$jvnext]},"streamSettings":$jstreamSettings }' ` '. += { "tag":"proxy","protocol":"vmess","settings":{"vnext":[$jvnext]},"streamSettings":$jstreamSettings }' `

View File

@@ -1,7 +1,8 @@
#!/bin/bash #!/bin/bash
usage() { usage() {
>&2 echo "Usage: proxy-ts <password@domain.com:443>[,serverName=x.org][,fingerprint=safari]" >&2 echo "TROJAN-TCP-TLS proxy builder"
>&2 echo "Usage: proxy-ttt <password@domain.com:443>[,fingerprint=safari]"
} }
if [ -z "$1" ]; then if [ -z "$1" ]; then
@@ -10,13 +11,16 @@ if [ -z "$1" ]; then
exit 1 exit 1
fi fi
# password@domain.com:443,serverName=x.org,fingerprint=safari # password@domain.com:443,fingerprint=safari
args=(`echo $1 |tr ',' ' '`) args=(`echo $1 |tr ',' ' '`)
dest="${args[0]}" dest="${args[0]}"
for ext_opt in "${args[@]}" for ext_opt in "${args[@]}"
do do
kv=(`echo $ext_opt |tr '=' ' '`) kv=(`echo $ext_opt |tr '=' ' '`)
case "${kv[0]}" in case "${kv[0]}" in
a|alpn)
ALPN+=("${kv[1]}")
;;
s|serverName) s|serverName)
serverName="${kv[1]}" serverName="${kv[1]}"
;; ;;
@@ -32,7 +36,6 @@ host="${options[0]}"
port="${options[1]}" port="${options[1]}"
passwd="${id}" passwd="${id}"
if [ -z "${serverName}" ]; then serverName=${host}; fi
if [ -z "${fingerprint}" ]; then fingerprint="safari"; fi if [ -z "${fingerprint}" ]; then fingerprint="safari"; fi
if [ -z "${passwd}" ]; then if [ -z "${passwd}" ]; then
@@ -53,11 +56,18 @@ 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 "Port number must be numeric"; exit 1; fi
# User settings
Jservers=`jq -nc --arg host "${host}" --arg port "${port}" --arg passwd "${passwd}" \ Jservers=`jq -nc --arg host "${host}" --arg port "${port}" --arg passwd "${passwd}" \
'. += {"address":$host,"port":($port | tonumber),"password":$passwd}' ` '. += {"address":$host,"port":($port | tonumber),"password":$passwd}' `
JstreamSettings=`jq -nc --arg serverName "${serverName}" --arg fingerprint "${fingerprint}" \ # Stream Settings
'. += {"network":"tcp", "security":"tls", "tlsSettings":{"serverName":$serverName, "fingerprint":$fingerprint}}' ` Jalpn='[]'
for alpn in "${ALPN[@]}"
do
Jalpn=`echo $Jalpn | jq -c --arg alpn "${alpn}" '. +=[$alpn]'`
done
JstreamSettings=`jq -nc --arg serverName "${serverName}" --arg fingerprint "${fingerprint}" --argjson jalpn "${Jalpn}" \
'. += {"network":"tcp","security":"tls","tlsSettings":{"serverName":$serverName,"fingerprint":$fingerprint,"alpn":$jalpn}}' `
Jproxy=`jq -nc --arg host "${host}" --argjson jservers "${Jservers}" --argjson jstreamSettings "${JstreamSettings}" \ Jproxy=`jq -nc --arg host "${host}" --argjson jservers "${Jservers}" --argjson jstreamSettings "${JstreamSettings}" \
'. += { "tag":"proxy","protocol":"trojan","settings":{"servers":[$jservers]},"streamSettings":$jstreamSettings }' ` '. += { "tag":"proxy","protocol":"trojan","settings":{"servers":[$jservers]},"streamSettings":$jstreamSettings }' `

View File

@@ -1,7 +1,8 @@
#!/bin/bash #!/bin/bash
usage() { usage() {
>&2 echo "Usage: proxy-tsw <password@domain.com:443:/websocket>[,serverName=x.org][,fingerprint=safari]" >&2 echo "TROJAN-WS-TLS proxy builder"
>&2 echo "Usage: proxy-twt <password@domain.com:443:/websocket>[,fingerprint=safari]"
} }
if [ -z "$1" ]; then if [ -z "$1" ]; then
@@ -10,13 +11,16 @@ if [ -z "$1" ]; then
exit 1 exit 1
fi fi
# password@domain.com:443:/websocket,serverName=x.org,fingerprint=safari # password@domain.com:443:/websocket,fingerprint=safari
args=(`echo $1 |tr ',' ' '`) args=(`echo $1 |tr ',' ' '`)
dest="${args[0]}" dest="${args[0]}"
for ext_opt in "${args[@]}" for ext_opt in "${args[@]}"
do do
kv=(`echo $ext_opt |tr '=' ' '`) kv=(`echo $ext_opt |tr '=' ' '`)
case "${kv[0]}" in case "${kv[0]}" in
a|alpn)
ALPN+=("${kv[1]}")
;;
s|serverName) s|serverName)
serverName="${kv[1]}" serverName="${kv[1]}"
;; ;;
@@ -33,7 +37,6 @@ port="${options[1]}"
path="${options[2]}" path="${options[2]}"
passwd="${id}" passwd="${id}"
if [ -z "${serverName}" ]; then serverName=${host}; fi
if [ -z "${fingerprint}" ]; then fingerprint="safari"; fi if [ -z "${fingerprint}" ]; then fingerprint="safari"; fi
if [ -z "${passwd}" ]; then if [ -z "${passwd}" ]; then
@@ -54,11 +57,18 @@ 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 "Port number must be numeric"; exit 1; fi
# User settings
Jservers=`jq -nc --arg host "${host}" --arg port "${port}" --arg passwd "${passwd}" \ Jservers=`jq -nc --arg host "${host}" --arg port "${port}" --arg passwd "${passwd}" \
'. += {"address":$host,"port":($port | tonumber),"password":$passwd}' ` '. += {"address":$host,"port":($port | tonumber),"password":$passwd}' `
JstreamSettings=`jq -nc --arg serverName "${serverName}" --arg fingerprint "${fingerprint}" --arg path "${path}" \ # Stream Settings
'. += {"network":"ws", "security":"tls", "tlsSettings":{"serverName":$serverName, "fingerprint":$fingerprint}, "wsSettings":{"path":$path}}' ` Jalpn='[]'
for alpn in "${ALPN[@]}"
do
Jalpn=`echo $Jalpn | jq -c --arg alpn "${alpn}" '. +=[$alpn]'`
done
JstreamSettings=`jq -nc --arg serverName "${serverName}" --arg fingerprint "${fingerprint}" --arg path "${path}" --argjson jalpn "${Jalpn}" \
'. += {"network":"ws","security":"tls","tlsSettings":{"serverName":$serverName,"fingerprint":$fingerprint,"alpn":$jalpn},"wsSettings":{"path":$path}}' `
Jproxy=`jq -nc --arg host "${host}" --argjson jservers "${Jservers}" --argjson jstreamSettings "${JstreamSettings}" \ Jproxy=`jq -nc --arg host "${host}" --argjson jservers "${Jservers}" --argjson jstreamSettings "${JstreamSettings}" \
'. += { "tag":"proxy","protocol":"trojan","settings":{"servers":[$jservers]},"streamSettings":$jstreamSettings }' ` '. += { "tag":"proxy","protocol":"trojan","settings":{"servers":[$jservers]},"streamSettings":$jstreamSettings }' `