mirror of
https://github.com/samuelhbne/proxy-xray.git
synced 2025-12-17 12:44:38 +03:00
Initial gRPC support
This commit is contained in:
@@ -30,6 +30,7 @@ ADD run.sh /run.sh
|
|||||||
ADD proxy-ltx.sh /proxy-ltx.sh
|
ADD proxy-ltx.sh /proxy-ltx.sh
|
||||||
ADD proxy-ltt.sh /proxy-ltt.sh
|
ADD proxy-ltt.sh /proxy-ltt.sh
|
||||||
ADD proxy-lttw.sh /proxy-lttw.sh
|
ADD proxy-lttw.sh /proxy-lttw.sh
|
||||||
|
ADD proxy-lttg.sh /proxy-lttg.sh
|
||||||
ADD proxy-mtt.sh /proxy-mtt.sh
|
ADD proxy-mtt.sh /proxy-mtt.sh
|
||||||
ADD proxy-mttw.sh /proxy-mttw.sh
|
ADD proxy-mttw.sh /proxy-mttw.sh
|
||||||
ADD proxy-ttt.sh /proxy-ttt.sh
|
ADD proxy-ttt.sh /proxy-ttt.sh
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ ADD run.sh /run.sh
|
|||||||
ADD proxy-ltx.sh /proxy-ltx.sh
|
ADD proxy-ltx.sh /proxy-ltx.sh
|
||||||
ADD proxy-ltt.sh /proxy-ltt.sh
|
ADD proxy-ltt.sh /proxy-ltt.sh
|
||||||
ADD proxy-lttw.sh /proxy-lttw.sh
|
ADD proxy-lttw.sh /proxy-lttw.sh
|
||||||
|
ADD proxy-lttg.sh /proxy-lttg.sh
|
||||||
ADD proxy-mtt.sh /proxy-mtt.sh
|
ADD proxy-mtt.sh /proxy-mtt.sh
|
||||||
ADD proxy-mttw.sh /proxy-mttw.sh
|
ADD proxy-mttw.sh /proxy-mttw.sh
|
||||||
ADD proxy-ttt.sh /proxy-ttt.sh
|
ADD proxy-ttt.sh /proxy-ttt.sh
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ ADD run.sh /run.sh
|
|||||||
ADD proxy-ltx.sh /proxy-ltx.sh
|
ADD proxy-ltx.sh /proxy-ltx.sh
|
||||||
ADD proxy-ltt.sh /proxy-ltt.sh
|
ADD proxy-ltt.sh /proxy-ltt.sh
|
||||||
ADD proxy-lttw.sh /proxy-lttw.sh
|
ADD proxy-lttw.sh /proxy-lttw.sh
|
||||||
|
ADD proxy-lttg.sh /proxy-lttg.sh
|
||||||
ADD proxy-mtt.sh /proxy-mtt.sh
|
ADD proxy-mtt.sh /proxy-mtt.sh
|
||||||
ADD proxy-mttw.sh /proxy-mttw.sh
|
ADD proxy-mttw.sh /proxy-mttw.sh
|
||||||
ADD proxy-ttt.sh /proxy-ttt.sh
|
ADD proxy-ttt.sh /proxy-ttt.sh
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ proxy-xray --<ltx|ltt|lttw|mtt|mttw|ttt|tttw|ssa|sst|stdin> [options]
|
|||||||
--ltx <VLESS-TCP-XTLS option> uuid@xray-host:port
|
--ltx <VLESS-TCP-XTLS option> uuid@xray-host:port
|
||||||
--ltt <VLESS-TCP-TLS option> uuid@xray-host:port
|
--ltt <VLESS-TCP-TLS option> uuid@xray-host:port
|
||||||
--lttw <VLESS-TCP-TLS-WS option> uuid@xray-host:port:/webpath
|
--lttw <VLESS-TCP-TLS-WS option> uuid@xray-host:port:/webpath
|
||||||
|
--lttg <VLESS-TCP-TLS-GRPC option> uuid@xray-host:port:/svcpath
|
||||||
--mtt <VMESS-TCP-TLS option> uuid@xray-host:port
|
--mtt <VMESS-TCP-TLS option> uuid@xray-host:port
|
||||||
--mttw <VMESS-TCP-TLS-WS option> uuid@xray-host:port:/webpath
|
--mttw <VMESS-TCP-TLS-WS option> uuid@xray-host:port:/webpath
|
||||||
--ttt <TROJAN-TCP-TLS option> password@xray-host:port
|
--ttt <TROJAN-TCP-TLS option> password@xray-host:port
|
||||||
|
|||||||
59
proxy-lttg.sh
Executable file
59
proxy-lttg.sh
Executable file
@@ -0,0 +1,59 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
usage() {
|
||||||
|
>&2 echo "Usage: proxy-lttg <uuid@domain0.com:443:/svcpath>"
|
||||||
|
}
|
||||||
|
|
||||||
|
if [ -z "$1" ]; then
|
||||||
|
>&2 echo "Missing options"
|
||||||
|
usage
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# uuid@domain0.com:443:/svcpath
|
||||||
|
temp=$1
|
||||||
|
options=(`echo $temp |tr '@' ' '`)
|
||||||
|
id="${options[0]}"
|
||||||
|
temp="${options[1]}"
|
||||||
|
options=(`echo $temp |tr ':' ' '`)
|
||||||
|
host="${options[0]}"
|
||||||
|
port="${options[1]}"
|
||||||
|
path="${options[2]}"
|
||||||
|
|
||||||
|
if [ -z "${id}" ]; then
|
||||||
|
>&2 echo "Error: uuid undefined."
|
||||||
|
usage
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z "${host}" ]; then
|
||||||
|
>&2 echo "Error: destination host undefined."
|
||||||
|
usage
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z "${port}" ]; then
|
||||||
|
port=443
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ! [ "${port}" -eq "${port}" ] 2>/dev/null; then >&2 echo "Port number must be numeric"; exit 1; fi
|
||||||
|
|
||||||
|
Jusers=`echo '{}' |jq --arg uuid "${id}" '. += {"id":$uuid, "encryption":"none", "level":0}'`
|
||||||
|
|
||||||
|
Jvnext=`echo '{}' | jq --arg host "${host}" --arg port "${port}" --argjson juser "${Jusers}" \
|
||||||
|
'. += {"address":$host, "port":($port | tonumber), "users":[$juser]}' `
|
||||||
|
|
||||||
|
JstreamSettings=`echo '{}' | jq --arg host "${host}" --arg path "${path}" \
|
||||||
|
'. += {"network":"grpc", "security":"tls", "tlsSettings":{"serverName":$host}, "grpcSettings":{"serviceName":$path}}' `
|
||||||
|
|
||||||
|
Joutbounds=`echo '{}' | jq --arg host "${host}" --argjson jvnext "${Jvnext}" --argjson jstreamSettings "${JstreamSettings}" \
|
||||||
|
'. += { "protocol":"vless", "settings":{"vnext":[$jvnext]}, "streamSettings":$jstreamSettings }' `
|
||||||
|
|
||||||
|
JibSOCKS=`echo '{}' | jq '. +={"port":1080, "listen":"0.0.0.0", "protocol":"socks", "settings":{"udp":true}}' `
|
||||||
|
JibHTTP=`echo '{}' | jq '. +={"port":8123, "listen":"0.0.0.0", "protocol":"http"}' `
|
||||||
|
|
||||||
|
jroot=`echo '{}' | jq --argjson jibsocks "${JibSOCKS}" --argjson jibhttp "${JibHTTP}" --argjson joutbounds "${Joutbounds}" \
|
||||||
|
'. += {"log":{"loglevel":"warning"}, "inbounds":[$jibsocks, $jibhttp], "outbounds":[$joutbounds]}' `
|
||||||
|
|
||||||
|
echo "$jroot"
|
||||||
|
exit 0
|
||||||
10
run.sh
10
run.sh
@@ -9,6 +9,7 @@ usage() {
|
|||||||
echo " --ltx <VLESS-TCP-XTLS option> uuid@xray-host:port"
|
echo " --ltx <VLESS-TCP-XTLS option> uuid@xray-host:port"
|
||||||
echo " --ltt <VLESS-TCP-TLS option> uuid@xray-host:port"
|
echo " --ltt <VLESS-TCP-TLS option> uuid@xray-host:port"
|
||||||
echo " --lttw <VLESS-TCP-TLS-WS option> uuid@xray-host:port:/webpath"
|
echo " --lttw <VLESS-TCP-TLS-WS option> uuid@xray-host:port:/webpath"
|
||||||
|
echo " --lttg <VLESS-TCP-TLS-GRPC option> uuid@xray-host:port:/svcpath"
|
||||||
echo " --mtt <VMESS-TCP-TLS option> uuid@xray-host:port"
|
echo " --mtt <VMESS-TCP-TLS option> uuid@xray-host:port"
|
||||||
echo " --mttw <VMESS-TCP-TLS-WS option> uuid@xray-host:port:/webpath"
|
echo " --mttw <VMESS-TCP-TLS-WS option> uuid@xray-host:port:/webpath"
|
||||||
echo " --ttt <TROJAN-TCP-TLS option> password@xray-host:port"
|
echo " --ttt <TROJAN-TCP-TLS option> password@xray-host:port"
|
||||||
@@ -18,15 +19,15 @@ usage() {
|
|||||||
echo " --stdin Read XRay config from stdin instead of auto generation"
|
echo " --stdin Read XRay config from stdin instead of auto generation"
|
||||||
}
|
}
|
||||||
|
|
||||||
TEMP=`getopt -o d --long ltx:,ltt:,lttw:,mtt:,mttw:,ttt:,tttw:,ssa:,sst:stdin,debug -n "$0" -- $@`
|
TEMP=`getopt -o d --long ltx:,ltt:,lttw:,lttg:,mtt:,mttw:,ttt:,tttw:,ssa:,sst:stdin,debug -n "$0" -- $@`
|
||||||
if [ $? != 0 ] ; then usage; exit 1 ; fi
|
if [ $? != 0 ] ; then usage; exit 1 ; fi
|
||||||
|
|
||||||
eval set -- "$TEMP"
|
eval set -- "$TEMP"
|
||||||
while true ; do
|
while true ; do
|
||||||
case "$1" in
|
case "$1" in
|
||||||
--ltx|--ltt|--lttw|--mtt|--mttw|--ttt|--tttw|--ssa|--sst)
|
--ltx|--ltt|--lttw|--lttg|--mtt|--mttw|--ttt|--tttw|--ssa|--sst)
|
||||||
subcmd=`echo "$1"|tr -d "\-\-"`
|
subcmd=`echo "$1"|tr -d "\-\-"`
|
||||||
echo "$DIR/proxy-${subcmd}.sh $2 >$XCONF"
|
echo "${DIR}proxy-${subcmd}.sh $2 >$XCONF"
|
||||||
$DIR/proxy-${subcmd}.sh $2 >$XCONF
|
$DIR/proxy-${subcmd}.sh $2 >$XCONF
|
||||||
if [ $? != 0 ]; then
|
if [ $? != 0 ]; then
|
||||||
echo "${subcmd} Config failed: $DIR/proxy-${subcmd}.sh $2"
|
echo "${subcmd} Config failed: $DIR/proxy-${subcmd}.sh $2"
|
||||||
@@ -55,8 +56,6 @@ while true ; do
|
|||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
/usr/bin/dnscrypt-proxy -config /etc/dnscrypt-proxy/dnscrypt-proxy.toml &
|
|
||||||
|
|
||||||
if [ "${STDINCONF}" = "1" ]; then
|
if [ "${STDINCONF}" = "1" ]; then
|
||||||
exec /usr/local/bin/xray
|
exec /usr/local/bin/xray
|
||||||
else
|
else
|
||||||
@@ -67,6 +66,7 @@ else
|
|||||||
cat $XCONF
|
cat $XCONF
|
||||||
echo
|
echo
|
||||||
fi
|
fi
|
||||||
|
/usr/bin/dnscrypt-proxy -config /etc/dnscrypt-proxy/dnscrypt-proxy.toml &
|
||||||
exec /usr/local/bin/xray -c $XCONF
|
exec /usr/local/bin/xray -c $XCONF
|
||||||
else
|
else
|
||||||
usage
|
usage
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ case "${PROTOCOL}" in
|
|||||||
XHOST=`cat $XCONF | jq -r '.outbounds[0].settings.vnext[0].address'`
|
XHOST=`cat $XCONF | jq -r '.outbounds[0].settings.vnext[0].address'`
|
||||||
XPORT=`cat $XCONF | jq -r '.outbounds[0].settings.vnext[0].port'`
|
XPORT=`cat $XCONF | jq -r '.outbounds[0].settings.vnext[0].port'`
|
||||||
WPATH=`cat $XCONF | jq -r '.outbounds[0].streamSettings.wsSettings.path'`
|
WPATH=`cat $XCONF | jq -r '.outbounds[0].streamSettings.wsSettings.path'`
|
||||||
|
SVCNAME=`cat $XCONF | jq -r '.outbounds[0].streamSettings.grpcSettings.serviceName'`
|
||||||
UUID=`cat $XCONF | jq -r '.outbounds[0].settings.vnext[0].users[0].id'`
|
UUID=`cat $XCONF | jq -r '.outbounds[0].settings.vnext[0].users[0].id'`
|
||||||
XENCRYPT=`cat $XCONF | jq -r '.outbounds[0].settings.vnext[0].users[0].encryption'`
|
XENCRYPT=`cat $XCONF | jq -r '.outbounds[0].settings.vnext[0].users[0].encryption'`
|
||||||
XSEC=`cat $XCONF | jq -r '.outbounds[0].streamSettings.security'`
|
XSEC=`cat $XCONF | jq -r '.outbounds[0].streamSettings.security'`
|
||||||
@@ -31,6 +32,7 @@ case "${PROTOCOL}" in
|
|||||||
XURL="${PROTOCOL}://${UUID}@${XHOST}:${XPORT}?security=${XSEC}&type=${XNETWORK}"
|
XURL="${PROTOCOL}://${UUID}@${XHOST}:${XPORT}?security=${XSEC}&type=${XNETWORK}"
|
||||||
if [ "${XFLOW}" != "null" ]; then XURL="${XURL}&flow=${XFLOW}"; fi
|
if [ "${XFLOW}" != "null" ]; then XURL="${XURL}&flow=${XFLOW}"; fi
|
||||||
if [ "${WPATH}" != "null" ]; then XURL="${XURL}&path=$(urlencode ${WPATH})"; fi
|
if [ "${WPATH}" != "null" ]; then XURL="${XURL}&path=$(urlencode ${WPATH})"; fi
|
||||||
|
if [ "${SVCNAME}" != "null" ]; then XURL="${XURL}&serviceName=${SVCNAME}&mode=gun"; fi
|
||||||
XURL="${XURL}#${XHOST}:${XPORT}"
|
XURL="${XURL}#${XHOST}:${XPORT}"
|
||||||
;;
|
;;
|
||||||
vmess)
|
vmess)
|
||||||
|
|||||||
Reference in New Issue
Block a user