Check for pinSHA256 before adding it to the URI
This commit is contained in:
@ -59,25 +59,31 @@ show_uri() {
|
||||
if jq -e "has(\"$username\")" "$USERS_FILE" > /dev/null; then
|
||||
authpassword=$(jq -r ".\"$username\".password" "$USERS_FILE")
|
||||
port=$(jq -r '.listen' "$CONFIG_FILE" | cut -d':' -f2)
|
||||
sha256=$(jq -r '.tls.pinSHA256' "$CONFIG_FILE")
|
||||
sha256=$(jq -r '.tls.pinSHA256 // empty' "$CONFIG_FILE")
|
||||
obfspassword=$(jq -r '.obfs.salamander.password // empty' "$CONFIG_FILE")
|
||||
|
||||
generate_uri() {
|
||||
local ip_version=$1
|
||||
local ip=$2
|
||||
if [ -n "$obfspassword" ]; then
|
||||
if [ "$ip_version" -eq 4 ]; then
|
||||
echo "hy2://$username%3A$authpassword@$ip:$port?obfs=salamander&obfs-password=$obfspassword&pinSHA256=$sha256&insecure=1&sni=$SNI#$username-IPv4"
|
||||
elif [ "$ip_version" -eq 6 ]; then
|
||||
echo "hy2://$username%3A$authpassword@[$ip]:$port?obfs=salamander&obfs-password=$obfspassword&pinSHA256=$sha256&insecure=1&sni=$SNI#$username-IPv6"
|
||||
fi
|
||||
else
|
||||
if [ "$ip_version" -eq 4 ]; then
|
||||
echo "hy2://$username%3A$authpassword@$ip:$port?pinSHA256=$sha256&insecure=1&sni=$SNI#$username-IPv4"
|
||||
elif [ "$ip_version" -eq 6 ]; then
|
||||
echo "hy2://$username%3A$authpassword@[$ip]:$port?pinSHA256=$sha256&insecure=1&sni=$SNI#$username-IPv6"
|
||||
fi
|
||||
local uri_base="hy2://$username%3A$authpassword@$ip:$port"
|
||||
|
||||
if [ "$ip_version" -eq 6 ]; then
|
||||
uri_base="hy2://$username%3A$authpassword@[$ip]:$port"
|
||||
fi
|
||||
|
||||
local params=""
|
||||
|
||||
if [ -n "$obfspassword" ]; then
|
||||
params+="obfs=salamander&obfs-password=$obfspassword&"
|
||||
fi
|
||||
|
||||
if [ -n "$sha256" ]; then
|
||||
params+="pinSHA256=$sha256&"
|
||||
fi
|
||||
|
||||
params+="insecure=1&sni=$SNI"
|
||||
|
||||
echo "$uri_base?$params#$username-IPv$ip_version"
|
||||
}
|
||||
|
||||
if [ "$show_all" = true ]; then
|
||||
|
||||
Reference in New Issue
Block a user