From 8205b39173e99827f43fe15176beecead4657b6d Mon Sep 17 00:00:00 2001 From: Samuel Huang Date: Sat, 21 Sep 2024 14:09:06 +1000 Subject: [PATCH] Add --lst alpn=h3 support --- proxy-lgt.sh | 18 ++++++++++++------ proxy-lst.sh | 21 +++++++++++++++------ run.sh | 4 ++-- 3 files changed, 29 insertions(+), 14 deletions(-) diff --git a/proxy-lgt.sh b/proxy-lgt.sh index ce64684..8760801 100755 --- a/proxy-lgt.sh +++ b/proxy-lgt.sh @@ -2,7 +2,7 @@ usage() { >&2 echo "VLESS-GRPC-TLS proxy builder" - >&2 echo "Usage: proxy-lgt [,serverName=x.org][,fingerprint=safari]" + >&2 echo "Usage: proxy-lgt [,serverName=x.org][,fingerprint=safari][,alpn=h3]" } if [ -z "$1" ]; then @@ -18,6 +18,9 @@ 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,9 +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 >&2 echo "Error: id undefined." usage @@ -62,8 +62,14 @@ Jvnext=`jq -nc --arg host "${host}" --arg port "${port}" --argjson juser "${Juse '. += {"address":$host, "port":($port | tonumber), "users":[$juser]}' ` # Stream Settings -JstreamSettings=`jq -nc --arg serverName "${serverName}" --arg fingerprint "${fingerprint}" --arg path "${path}" \ -'. += {"network":"grpc", "security":"tls", "tlsSettings":{"serverName":$serverName, "fingerprint":$fingerprint}, "grpcSettings":{"serviceName":$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":"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 }' ` diff --git a/proxy-lst.sh b/proxy-lst.sh index 50d8d76..356cf87 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]" + >&2 echo "Usage: proxy-lst [,serverName=x.org][,fingerprint=safari][,alpn=h3]" } if [ -z "$1" ]; then @@ -18,6 +18,9 @@ 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,9 +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 >&2 echo "Error: id undefined." usage @@ -54,13 +54,22 @@ 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}'` +# Vnest settings Jvnext=`jq -nc --arg host "${host}" --arg port "${port}" --argjson juser "${Jusers}" \ '. += {"address":$host, "port":($port | tonumber), "users":[$juser]}' ` -JstreamSettings=`jq -nc --arg serverName "${serverName}" --arg fingerprint "${fingerprint}" --arg path "${path}" \ -'. += {"network":"splithttp", "security":"tls", "tlsSettings":{"serverName":$serverName, "fingerprint":$fingerprint}, "splithttpSettings":{"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":"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 }' ` diff --git a/run.sh b/run.sh index aeaa68a..7874010 100755 --- a/run.sh +++ b/run.sh @@ -10,7 +10,7 @@ usage() { echo " --lgr id@host:port:svcname,d=dest.com,pub=xxxx[,shortId=abcd]" echo " --lgt id@host:port:svcname[,s=sni.com]" echo " --lsp id@host:port:/webpath" - echo " --lst id@host:port:/webpath[,s=sni.com]" + echo " --lst id@host:port:/webpath[,s=sni.com][,alpn=h3]" echo " --ltr id@host:port,d=dest.com,pub=xxxx[,shortId=abcd][,xtls]" echo " --ltrx id@host:port,d=dest.com,pub=xxxx[,shortId=abcd]" echo " --ltt id@host:port[,s=sni.com][,xtls]" @@ -58,8 +58,8 @@ while true ; do fi shift 2 ;; - # Alias options --ltrx|--lttx) + # Alias options subcmd=`echo $1|tr -d '\-\-'|tr -d x` $DIR/proxy-${subcmd}.sh $2,xtls >$XCONF if [ $? != 0 ]; then