Stream proxy-protocol support

This commit is contained in:
Samuel Huang
2024-09-16 14:45:57 +10:00
parent 8b8e03ea0c
commit e9ffe7016f
8 changed files with 135 additions and 55 deletions

View File

@@ -4,7 +4,7 @@ DIR=`dirname $0`
usage() {
echo "VLESS-TCP-TLS server builder"
echo "Usage: server-ltt <x=xray-config-file>,<c=cert-home-dir>,<p=listen-port>,[xtls],<d=domain.com>,<u=id0>,<u=id1>..."
echo "Usage: server-ltt <x=xray-config-file>,<c=cert-home-dir>,<p=listen-port>,[xtls],[proxy_acpt],<d=domain.com>,<u=id0>,<u=id1>..."
}
options=(`echo $1 |tr ',' ' '`)
@@ -27,6 +27,9 @@ do
p|port)
port="${kv[1]}"
;;
proxy_acpt)
acceptProxyProtocol=true
;;
u|user)
xuser+=("${kv[1]}")
;;
@@ -106,6 +109,13 @@ do
cat $XCONF |${DIR}/fallback.sh -p $port -f ${fb} | sponge $XCONF
done
# StreamSettings
if [ -n "${acceptProxyProtocol}" ]; then
cat $XCONF |jq --arg port "${port}" \
'( .inbounds[] | select(.port == ($port|tonumber)) | .streamSettings ) += {"sockopt":{"acceptProxyProtocol":true}} ' \
|sponge $XCONF
fi
# Network settings
cat $XCONF |jq --arg port "${port}" \
'( .inbounds[] | select(.port == ($port|tonumber)) | .streamSettings ) += {"network":"tcp"} ' \