mirror of
https://github.com/samuelhbne/proxy-xray.git
synced 2025-12-18 05:04:37 +03:00
sni support
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
#!/bin/bash
|
||||
|
||||
usage() {
|
||||
>&2 echo "Usage: proxy-tttw <uuid@domain0.com:443:/websocket>"
|
||||
>&2 echo "Usage: proxy-tttw <password@domain.com:443:/websocket>[,serverName=x.org][,fingerprint=safari]"
|
||||
}
|
||||
|
||||
if [ -z "$1" ]; then
|
||||
@@ -10,23 +10,34 @@ if [ -z "$1" ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# password:method@domain0.com:443:/websocket
|
||||
temp=$1
|
||||
options=(`echo $temp |tr '@' ' '`)
|
||||
# password@domain.com:443:/websocket,serverName=x.org,fingerprint=safari
|
||||
args=(`echo $1 |tr ',' ' '`)
|
||||
dest="${args[0]}"
|
||||
for ext_opt in "${args[@]}"
|
||||
do
|
||||
kv=(`echo $ext_opt |tr '=' ' '`)
|
||||
case "${kv[0]}" in
|
||||
s|serverName)
|
||||
serverName="${kv[1]}"
|
||||
;;
|
||||
f|fingerprint)
|
||||
fingerprint="${kv[1]}"
|
||||
;;
|
||||
esac
|
||||
done
|
||||
options=(`echo $dest |tr '@' ' '`)
|
||||
id="${options[0]}"
|
||||
temp="${options[1]}"
|
||||
options=(`echo $temp |tr ':' ' '`)
|
||||
options=(`echo ${options[1]} |tr ':' ' '`)
|
||||
host="${options[0]}"
|
||||
port="${options[1]}"
|
||||
path="${options[2]}"
|
||||
passwd="${id}"
|
||||
|
||||
temp=$id
|
||||
options=(`echo $temp |tr ':' ' '`)
|
||||
passwd="${options[0]}"
|
||||
method="${options[1]}"
|
||||
if [ -z "${serverName}" ]; then serverName=${host}; fi
|
||||
if [ -z "${fingerprint}" ]; then fingerprint="safari"; fi
|
||||
|
||||
if [ -z "${passwd}" ]; then
|
||||
>&2 echo "Error: passwd undefined."
|
||||
>&2 echo "Error: password undefined."
|
||||
usage
|
||||
exit 1
|
||||
fi
|
||||
@@ -46,8 +57,8 @@ if ! [ "${port}" -eq "${port}" ] 2>/dev/null; then >&2 echo "Port number must be
|
||||
Jservers=`echo '{}' | jq --arg host "${host}" --arg port "${port}" --arg passwd "${passwd}" \
|
||||
'. += {"address":$host, "port":($port | tonumber), "password":$passwd}' `
|
||||
|
||||
JstreamSettings=`echo '{}' | jq --arg host "${host}" --arg path "${path}" \
|
||||
'. += {"network":"ws", "security":"tls", "tlsSettings":{"serverName":$host}, "wsSettings":{"path":$path}}' `
|
||||
JstreamSettings=`echo '{}' | jq --arg serverName "${serverName}" --arg fingerprint "${fingerprint}" --arg path "${path}" \
|
||||
'. += {"network":"ws", "security":"tls", "tlsSettings":{"serverName":$serverName, "fingerprint":$fingerprint}, "wsSettings":{"path":$path}}' `
|
||||
|
||||
Jproxy=`echo '{}' | jq --arg host "${host}" --argjson jservers "${Jservers}" --argjson jstreamSettings "${JstreamSettings}" \
|
||||
'. += { "tag": "proxy", "protocol":"trojan", "settings":{"servers":[$jservers]}, "streamSettings":$jstreamSettings }' `
|
||||
|
||||
Reference in New Issue
Block a user