diff --git a/proxy-lgt.sh b/proxy-lgt.sh index 8760801..4331295 100755 --- a/proxy-lgt.sh +++ b/proxy-lgt.sh @@ -11,7 +11,7 @@ if [ -z "$1" ]; then exit 1 fi -# id@domain.com:443:/svcpath,serverName=x.org,fingerprint=safari +# id@domain.com:443:/svcpath,fingerprint=safari args=(`echo $1 |tr ',' ' '`) dest="${args[0]}" for ext_opt in "${args[@]}" @@ -36,6 +36,8 @@ host="${options[0]}" port="${options[1]}" path="${options[2]}" +if [ -z "${fingerprint}" ]; then fingerprint="safari"; fi + if [ -z "${id}" ]; then >&2 echo "Error: id undefined." usage @@ -55,11 +57,11 @@ 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}'` -# Vnest settings +# Vnext settings 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 Jalpn='[]' @@ -67,17 +69,16 @@ 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":"grpc","security":"tls","tlsSettings":{"serverName":$serverName,"fingerprint":$fingerprint,"alpn":$jalpn},"grpcSettings":{"serviceName":$path}}' ` Jproxy=`jq -nc --arg host "${host}" --argjson jvnext "${Jvnext}" --argjson jstreamSettings "${JstreamSettings}" \ -'. += { "tag": "proxy", "protocol":"vless", "settings":{"vnext":[$jvnext]}, "streamSettings":$jstreamSettings }' ` -Jdirect='{"tag": "direct", "protocol": "freedom", "settings": {}}' -Jblocked='{"tag": "blocked", "protocol": "blackhole", "settings": {}}' +'. += { "tag":"proxy","protocol":"vless","settings":{"vnext":[$jvnext]},"streamSettings":$jstreamSettings}' ` +Jdirect='{"tag":"direct","protocol":"freedom","settings":{}}' +Jblocked='{"tag":"blocked","protocol":"blackhole","settings":{}}' jroot=`jq -n --argjson jproxy "${Jproxy}" --argjson jdirect "${Jdirect}" --argjson jblocked "${Jblocked}" \ -'. += {"log":{"loglevel":"warning"}, "outbounds":[$jproxy, $jdirect, $jblocked]}' ` +'. += {"log":{"loglevel":"warning"},"outbounds":[$jproxy,$jdirect,$jblocked]}' ` echo "$jroot" exit 0 diff --git a/proxy-lst.sh b/proxy-lst.sh index 356cf87..252b785 100755 --- a/proxy-lst.sh +++ b/proxy-lst.sh @@ -2,7 +2,7 @@ usage() { >&2 echo "VLESS-SPLT-TLS proxy builder" - >&2 echo "Usage: proxy-lst [,serverName=x.org][,fingerprint=safari][,alpn=h3]" + >&2 echo "Usage: proxy-lst [,fingerprint=safari][,alpn=h3]" } if [ -z "$1" ]; then @@ -11,7 +11,7 @@ if [ -z "$1" ]; then exit 1 fi -# id@domain.com:443:/webpath,serverName=x.org,fingerprint=safari +# id@domain.com:443:/webpath,fingerprint=safari args=(`echo $1 |tr ',' ' '`) dest="${args[0]}" for ext_opt in "${args[@]}" @@ -36,6 +36,8 @@ host="${options[0]}" port="${options[1]}" path="${options[2]}" +if [ -z "${fingerprint}" ]; then fingerprint="safari"; fi + if [ -z "${id}" ]; then >&2 echo "Error: id undefined." usage @@ -55,11 +57,11 @@ 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}'` -# Vnest settings +# Vnext settings 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 Jalpn='[]' @@ -67,17 +69,16 @@ 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":"splithttp","security":"tls","tlsSettings":{"serverName":$serverName,"fingerprint":$fingerprint,"alpn":$jalpn},"splithttpSettings":{"path":$path}}' ` Jproxy=`jq -nc --arg host "${host}" --argjson jvnext "${Jvnext}" --argjson jstreamSettings "${JstreamSettings}" \ -'. += { "tag": "proxy", "protocol":"vless", "settings":{"vnext":[$jvnext]}, "streamSettings":$jstreamSettings }' ` -Jdirect='{"tag": "direct", "protocol": "freedom", "settings": {}}' -Jblocked='{"tag": "blocked", "protocol": "blackhole", "settings": {}}' +'. += { "tag":"proxy","protocol":"vless","settings":{"vnext":[$jvnext]},"streamSettings":$jstreamSettings}' ` +Jdirect='{"tag":"direct","protocol":"freedom","settings":{}}' +Jblocked='{"tag":"blocked","protocol":"blackhole","settings":{}}' jroot=`jq -n --argjson jproxy "${Jproxy}" --argjson jdirect "${Jdirect}" --argjson jblocked "${Jblocked}" \ -'. += {"log":{"loglevel":"warning"}, "outbounds":[$jproxy, $jdirect, $jblocked]}' ` +'. += {"log":{"loglevel":"warning"},"outbounds":[$jproxy,$jdirect,$jblocked]}' ` echo "$jroot" exit 0 diff --git a/proxy-ltt.sh b/proxy-ltt.sh index 420f3cc..402948a 100755 --- a/proxy-ltt.sh +++ b/proxy-ltt.sh @@ -2,7 +2,7 @@ usage() { >&2 echo "VLESS-TCP-TLS proxy builder" - >&2 echo "Usage: proxy-ltt [,xtls][,serverName=x.org][,fingerprint=safari]" + >&2 echo "Usage: proxy-ltt [,xtls][,fingerprint=safari]" } if [ -z "$1" ]; then @@ -11,13 +11,16 @@ if [ -z "$1" ]; then exit 1 fi -# id@domain.com:443,serverName=x.org,fingerprint=safari +# id@domain.com:443,fingerprint=safari args=(`echo $1 |tr ',' ' '`) dest="${args[0]}" for ext_opt in "${args[@]}" do kv=(`echo $ext_opt |tr '=' ' '`) case "${kv[0]}" in + a|alpn) + ALPN+=("${kv[1]}") + ;; s|serverName) serverName="${kv[1]}" ;; @@ -35,7 +38,6 @@ options=(`echo ${options[1]} |tr ':' ' '`) host="${options[0]}" port="${options[1]}" -if [ -z "${serverName}" ]; then serverName=${host}; fi if [ -z "${fingerprint}" ]; then fingerprint="safari"; fi if [ -z "${id}" ]; then @@ -57,23 +59,28 @@ 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}" --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}" \ -'. += {"address":$host, "port":($port | tonumber), "users":[$juser]}' ` +'. += {"address":$host,"port":($port | tonumber),"users":[$juser]}' ` # 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}" \ -'. += {"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}" \ -'. += { "tag": "proxy", "protocol":"vless", "settings":{"vnext":[$jvnext]}, "streamSettings":$jstreamSettings }' ` -Jdirect='{"tag": "direct", "protocol": "freedom", "settings": {}}' -Jblocked='{"tag": "blocked", "protocol": "blackhole", "settings": {}}' +'. += { "tag":"proxy","protocol":"vless","settings":{"vnext":[$jvnext]},"streamSettings":$jstreamSettings}' ` +Jdirect='{"tag":"direct","protocol":"freedom","settings":{}}' +Jblocked='{"tag":"blocked","protocol":"blackhole","settings":{}}' jroot=`jq -n --argjson jproxy "${Jproxy}" --argjson jdirect "${Jdirect}" --argjson jblocked "${Jblocked}" \ -'. += {"log":{"loglevel":"warning"}, "outbounds":[$jproxy, $jdirect, $jblocked]}' ` +'. += {"log":{"loglevel":"warning"},"outbounds":[$jproxy,$jdirect,$jblocked]}' ` echo "$jroot" exit 0 diff --git a/proxy-lwt.sh b/proxy-lwt.sh index 1728381..b5ed1b6 100755 --- a/proxy-lwt.sh +++ b/proxy-lwt.sh @@ -2,7 +2,7 @@ usage() { >&2 echo "VLESS-WS-TLS proxy builder" - >&2 echo "Usage: proxy-lsw [,serverName=x.org][,fingerprint=safari]" + >&2 echo "Usage: proxy-lwt [,fingerprint=safari]" } if [ -z "$1" ]; then @@ -11,13 +11,16 @@ if [ -z "$1" ]; then exit 1 fi -# id@domain.com:443:/websocket,serverName=x.org,fingerprint=safari +# id@domain.com:443:/websocket,fingerprint=safari args=(`echo $1 |tr ',' ' '`) dest="${args[0]}" for ext_opt in "${args[@]}" do kv=(`echo $ext_opt |tr '=' ' '`) case "${kv[0]}" in + a|alpn) + ALPN+=("${kv[1]}") + ;; s|serverName) serverName="${kv[1]}" ;; @@ -33,7 +36,6 @@ host="${options[0]}" port="${options[1]}" path="${options[2]}" -if [ -z "${serverName}" ]; then serverName=${host}; fi if [ -z "${fingerprint}" ]; then fingerprint="safari"; fi if [ -z "${id}" ]; then @@ -54,21 +56,29 @@ fi if ! [ "${port}" -eq "${port}" ] 2>/dev/null; then >&2 echo "Port number must be numeric"; exit 1; fi -Jusers=`jq -nc --arg uuid "${id}" '. += {"id":$uuid, "encryption":"none", "level":0}'` +# User settings +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}" \ -'. += {"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}" \ -'. += {"network":"ws", "security":"tls", "tlsSettings":{"serverName":$serverName, "fingerprint":$fingerprint}, "wsSettings":{"path":$path}}' ` +# 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}" --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}" \ -'. += { "tag": "proxy", "protocol":"vless", "settings":{"vnext":[$jvnext]}, "streamSettings":$jstreamSettings }' ` -Jdirect='{"tag": "direct", "protocol": "freedom", "settings": {}}' -Jblocked='{"tag": "blocked", "protocol": "blackhole", "settings": {}}' +'. += { "tag":"proxy","protocol":"vless","settings":{"vnext":[$jvnext]},"streamSettings":$jstreamSettings}' ` +Jdirect='{"tag":"direct","protocol":"freedom","settings":{}}' +Jblocked='{"tag":"blocked","protocol":"blackhole","settings":{}}' jroot=`jq -n --argjson jproxy "${Jproxy}" --argjson jdirect "${Jdirect}" --argjson jblocked "${Jblocked}" \ -'. += {"log":{"loglevel":"warning"}, "outbounds":[$jproxy, $jdirect, $jblocked]}' ` +'. += {"log":{"loglevel":"warning"},"outbounds":[$jproxy,$jdirect,$jblocked]}' ` echo "$jroot" exit 0 diff --git a/proxy-mtt.sh b/proxy-mtt.sh index dd637cd..4b01091 100755 --- a/proxy-mtt.sh +++ b/proxy-mtt.sh @@ -2,7 +2,7 @@ usage() { >&2 echo "VMESS-TCP-TLS proxy builder" - >&2 echo "Usage: proxy-ms [,serverName=x.org][,fingerprint=safari]" + >&2 echo "Usage: proxy-mtt [,fingerprint=safari]" } if [ -z "$1" ]; then @@ -11,13 +11,16 @@ if [ -z "$1" ]; then exit 1 fi -# id@domain.com:443,serverName=x.org,fingerprint=safari +# id@domain.com:443,fingerprint=safari args=(`echo $1 |tr ',' ' '`) dest="${args[0]}" for ext_opt in "${args[@]}" do kv=(`echo $ext_opt |tr '=' ' '`) case "${kv[0]}" in + a|alpn) + ALPN+=("${kv[1]}") + ;; s|serverName) serverName="${kv[1]}" ;; @@ -32,7 +35,6 @@ options=(`echo ${options[1]} |tr ':' ' '`) host="${options[0]}" port="${options[1]}" -if [ -z "${serverName}" ]; then serverName=${host}; fi if [ -z "${fingerprint}" ]; then fingerprint="safari"; fi if [ -z "${id}" ]; then @@ -53,21 +55,29 @@ fi if ! [ "${port}" -eq "${port}" ] 2>/dev/null; then >&2 echo "Port number must be numeric"; exit 1; fi -Jusers=`jq -nc --arg uuid "${id}" '. += {"id":$uuid, "encryption":"none", "level":0}'` +# User settings +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}" \ -'. += {"address":$host, "port":($port | tonumber), "users":[$juser]}' ` +'. += {"address":$host,"port":($port | tonumber),"users":[$juser]}' ` -JstreamSettings=`jq -nc --arg serverName "${serverName}" --arg fingerprint "${fingerprint}" \ -'. += {"network":"tcp", "security":"tls", "tlsSettings":{"serverName":$serverName, "fingerprint":$fingerprint}}' ` +# 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}" --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}" \ -'. += { "tag": "proxy", "protocol":"vmess", "settings":{"vnext":[$jvnext]}, "streamSettings":$jstreamSettings }' ` -Jdirect='{"tag": "direct", "protocol": "freedom", "settings": {}}' -Jblocked='{"tag": "blocked", "protocol": "blackhole", "settings": {}}' +'. += { "tag":"proxy","protocol":"vmess","settings":{"vnext":[$jvnext]},"streamSettings":$jstreamSettings}' ` +Jdirect='{"tag":"direct","protocol":"freedom","settings":{}}' +Jblocked='{"tag":"blocked","protocol":"blackhole","settings":{}}' jroot=`jq -n --argjson jproxy "${Jproxy}" --argjson jdirect "${Jdirect}" --argjson jblocked "${Jblocked}" \ -'. += {"log":{"loglevel":"warning"}, "outbounds":[$jproxy, $jdirect, $jblocked]}' ` +'. += {"log":{"loglevel":"warning"},"outbounds":[$jproxy,$jdirect,$jblocked]}' ` echo "$jroot" exit 0 diff --git a/proxy-mwt.sh b/proxy-mwt.sh index 85db942..c71f1c5 100755 --- a/proxy-mwt.sh +++ b/proxy-mwt.sh @@ -2,7 +2,7 @@ usage() { >&2 echo "VMESS-WS-TLS proxy builder" - >&2 echo "Usage: proxy-msw [,serverName=x.org][,fingerprint=safari]" + >&2 echo "Usage: proxy-mwt [,fingerprint=safari]" } if [ -z "$1" ]; then @@ -11,13 +11,16 @@ if [ -z "$1" ]; then exit 1 fi -# id@domain.com:443:/websocket,serverName=x.org,fingerprint=safari +# id@domain.com:443:/websocket,fingerprint=safari args=(`echo $1 |tr ',' ' '`) dest="${args[0]}" for ext_opt in "${args[@]}" do kv=(`echo $ext_opt |tr '=' ' '`) case "${kv[0]}" in + a|alpn) + ALPN+=("${kv[1]}") + ;; s|serverName) serverName="${kv[1]}" ;; @@ -33,7 +36,6 @@ host="${options[0]}" port="${options[1]}" path="${options[2]}" -if [ -z "${serverName}" ]; then serverName=${host}; fi if [ -z "${fingerprint}" ]; then fingerprint="safari"; fi if [ -z "${id}" ]; then @@ -54,21 +56,29 @@ fi if ! [ "${port}" -eq "${port}" ] 2>/dev/null; then >&2 echo "Port number must be numeric"; exit 1; fi -Jusers=`jq -nc --arg uuid "${id}" '. += {"id":$uuid, "encryption":"none", "level":0}'` +# User settings +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}" \ -'. += {"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}" \ -'. += {"network":"ws", "security":"tls", "tlsSettings":{"serverName":$serverName, "fingerprint":$fingerprint}, "wsSettings":{"path":$path}}' ` +# 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}" --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}" \ -'. += { "tag": "proxy", "protocol":"vmess", "settings":{"vnext":[$jvnext]}, "streamSettings":$jstreamSettings }' ` -Jdirect='{"tag": "direct", "protocol": "freedom", "settings": {}}' -Jblocked='{"tag": "blocked", "protocol": "blackhole", "settings": {}}' +'. += { "tag":"proxy","protocol":"vmess","settings":{"vnext":[$jvnext]},"streamSettings":$jstreamSettings }' ` +Jdirect='{"tag":"direct","protocol":"freedom","settings":{}}' +Jblocked='{"tag":"blocked","protocol":"blackhole","settings":{}}' jroot=`jq -n --argjson jproxy "${Jproxy}" --argjson jdirect "${Jdirect}" --argjson jblocked "${Jblocked}" \ -'. += {"log":{"loglevel":"warning"}, "outbounds":[$jproxy, $jdirect, $jblocked]}' ` +'. += {"log":{"loglevel":"warning"},"outbounds":[$jproxy,$jdirect,$jblocked]}' ` echo "$jroot" exit 0 diff --git a/proxy-ttt.sh b/proxy-ttt.sh index 07dbdd3..07ffb41 100755 --- a/proxy-ttt.sh +++ b/proxy-ttt.sh @@ -1,7 +1,8 @@ #!/bin/bash usage() { - >&2 echo "Usage: proxy-ts [,serverName=x.org][,fingerprint=safari]" + >&2 echo "TROJAN-TCP-TLS proxy builder" + >&2 echo "Usage: proxy-ttt [,fingerprint=safari]" } if [ -z "$1" ]; then @@ -10,13 +11,16 @@ if [ -z "$1" ]; then exit 1 fi -# password@domain.com:443,serverName=x.org,fingerprint=safari +# password@domain.com:443,fingerprint=safari args=(`echo $1 |tr ',' ' '`) dest="${args[0]}" for ext_opt in "${args[@]}" do kv=(`echo $ext_opt |tr '=' ' '`) case "${kv[0]}" in + a|alpn) + ALPN+=("${kv[1]}") + ;; s|serverName) serverName="${kv[1]}" ;; @@ -32,7 +36,6 @@ host="${options[0]}" port="${options[1]}" passwd="${id}" -if [ -z "${serverName}" ]; then serverName=${host}; fi if [ -z "${fingerprint}" ]; then fingerprint="safari"; fi if [ -z "${passwd}" ]; then @@ -53,19 +56,26 @@ 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}" \ -'. += {"address":$host, "port":($port | tonumber), "password":$passwd}' ` +'. += {"address":$host,"port":($port | tonumber),"password":$passwd}' ` -JstreamSettings=`jq -nc --arg serverName "${serverName}" --arg fingerprint "${fingerprint}" \ -'. += {"network":"tcp", "security":"tls", "tlsSettings":{"serverName":$serverName, "fingerprint":$fingerprint}}' ` +# 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}" --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}" \ -'. += { "tag": "proxy", "protocol":"trojan", "settings":{"servers":[$jservers]}, "streamSettings":$jstreamSettings }' ` -Jdirect='{"tag": "direct", "protocol": "freedom", "settings": {}}' -Jblocked='{"tag": "blocked", "protocol": "blackhole", "settings": {}}' +'. += { "tag":"proxy","protocol":"trojan","settings":{"servers":[$jservers]},"streamSettings":$jstreamSettings }' ` +Jdirect='{"tag":"direct","protocol":"freedom","settings":{}}' +Jblocked='{"tag":"blocked","protocol":"blackhole","settings":{}}' jroot=`jq -n --argjson jproxy "${Jproxy}" --argjson jdirect "${Jdirect}" --argjson jblocked "${Jblocked}" \ -'. += {"log":{"loglevel":"warning"}, "outbounds":[$jproxy, $jdirect, $jblocked]}' ` +'. += {"log":{"loglevel":"warning"},"outbounds":[$jproxy,$jdirect,$jblocked]}' ` echo "$jroot" exit 0 diff --git a/proxy-twt.sh b/proxy-twt.sh index ff609f2..c93f8e3 100755 --- a/proxy-twt.sh +++ b/proxy-twt.sh @@ -1,7 +1,8 @@ #!/bin/bash usage() { - >&2 echo "Usage: proxy-tsw [,serverName=x.org][,fingerprint=safari]" + >&2 echo "TROJAN-WS-TLS proxy builder" + >&2 echo "Usage: proxy-twt [,fingerprint=safari]" } if [ -z "$1" ]; then @@ -10,13 +11,16 @@ if [ -z "$1" ]; then exit 1 fi -# password@domain.com:443:/websocket,serverName=x.org,fingerprint=safari +# password@domain.com:443:/websocket,fingerprint=safari args=(`echo $1 |tr ',' ' '`) dest="${args[0]}" for ext_opt in "${args[@]}" do kv=(`echo $ext_opt |tr '=' ' '`) case "${kv[0]}" in + a|alpn) + ALPN+=("${kv[1]}") + ;; s|serverName) serverName="${kv[1]}" ;; @@ -33,7 +37,6 @@ port="${options[1]}" path="${options[2]}" passwd="${id}" -if [ -z "${serverName}" ]; then serverName=${host}; fi if [ -z "${fingerprint}" ]; then fingerprint="safari"; fi if [ -z "${passwd}" ]; then @@ -54,19 +57,26 @@ 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}" \ -'. += {"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}" \ -'. += {"network":"ws", "security":"tls", "tlsSettings":{"serverName":$serverName, "fingerprint":$fingerprint}, "wsSettings":{"path":$path}}' ` +# 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}" --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}" \ -'. += { "tag": "proxy", "protocol":"trojan", "settings":{"servers":[$jservers]}, "streamSettings":$jstreamSettings }' ` -Jdirect='{"tag": "direct", "protocol": "freedom", "settings": {}}' -Jblocked='{"tag": "blocked", "protocol": "blackhole", "settings": {}}' +'. += { "tag":"proxy","protocol":"trojan","settings":{"servers":[$jservers]},"streamSettings":$jstreamSettings }' ` +Jdirect='{"tag":"direct","protocol":"freedom","settings":{}}' +Jblocked='{"tag":"blocked","protocol":"blackhole","settings":{}}' jroot=`jq -n --argjson jproxy "${Jproxy}" --argjson jdirect "${Jdirect}" --argjson jblocked "${Jblocked}" \ -'. += {"log":{"loglevel":"warning"}, "outbounds":[$jproxy, $jdirect, $jblocked]}' ` +'. += {"log":{"loglevel":"warning"},"outbounds":[$jproxy,$jdirect,$jblocked]}' ` echo "$jroot" exit 0