mirror of
https://github.com/samuelhbne/proxy-xray.git
synced 2025-12-17 20:54:37 +03:00
sni support
This commit is contained in:
38
proxy-mtt.sh
38
proxy-mtt.sh
@@ -1,7 +1,7 @@
|
||||
#!/bin/bash
|
||||
|
||||
usage() {
|
||||
>&2 echo "Usage: proxy-mtt <uuid@domain0.com:443>"
|
||||
>&2 echo "Usage: proxy-mtt <id@domain.com:443>[,serverName=x.org][,fingerprint=safari]"
|
||||
}
|
||||
|
||||
if [ -z "$1" ]; then
|
||||
@@ -10,21 +10,29 @@ if [ -z "$1" ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# password:method@domain0.com:443/websocket
|
||||
temp=$1
|
||||
options=(`echo $temp |tr '@' ' '`)
|
||||
# id@domain.com:443,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 '/' ' '`)
|
||||
path="${options[1]}"
|
||||
temp="${options[0]}"
|
||||
options=(`echo $temp |tr ':' ' '`)
|
||||
options=(`echo ${options[1]} |tr ':' ' '`)
|
||||
host="${options[0]}"
|
||||
port="${options[1]}"
|
||||
temp=$id
|
||||
options=(`echo $temp |tr ':' ' '`)
|
||||
passwd="${options[0]}"
|
||||
method="${options[2]}"
|
||||
|
||||
if [ -z "${serverName}" ]; then serverName=${host}; fi
|
||||
if [ -z "${fingerprint}" ]; then fingerprint="safari"; fi
|
||||
|
||||
if [ -z "${id}" ]; then
|
||||
>&2 echo "Error: uuid undefined."
|
||||
@@ -49,8 +57,8 @@ Jusers=`echo '{}' |jq --arg uuid "${id}" '. += {"id":$uuid, "encryption":"none",
|
||||
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}" \
|
||||
'. += {"network":"tcp", "security":"tls", "tlsSettings":{"serverName":$host}}' `
|
||||
JstreamSettings=`echo '{}' | jq --arg serverName "${serverName}" --arg fingerprint "${fingerprint}" \
|
||||
'. += {"network":"tcp", "security":"tls", "tlsSettings":{"serverName":$serverName, "fingerprint":$fingerprint}}' `
|
||||
|
||||
Jproxy=`echo '{}' | jq --arg host "${host}" --argjson jvnext "${Jvnext}" --argjson jstreamSettings "${JstreamSettings}" \
|
||||
'. += { "tag": "proxy", "protocol":"vmess", "settings":{"vnext":[$jvnext]}, "streamSettings":$jstreamSettings }' `
|
||||
|
||||
Reference in New Issue
Block a user