Skip to content

Commit

Permalink
Fix: percent encode error of SS URL
Browse files Browse the repository at this point in the history
  • Loading branch information
loyess committed Sep 9, 2023
1 parent 43e12cb commit 26a5d13
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 7 deletions.
2 changes: 1 addition & 1 deletion prepare/cloak_prepare.sh
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ get_input_alternativenames(){
continue
fi
NumConn=0
AlternativeNames=";AlternativeNames=$(echo $altNames | sed -E 's/\ /,/g;s/,+/,/g;s/^,+//g;s/,+$//g' | sed -E 's/,+/%2C/g')"
AlternativeNames=";AlternativeNames=$(echo $altNames | sed -E 's/\ /,/g;s/,+/,/g;s/^,+//g;s/,+$//g')"
_echo -r " AlternativeNames = $(echo $altNames | sed -E 's/\ /,/g;s/,+/,/g;s/^,+//g;s/,+$//g')"
break
done
Expand Down
19 changes: 15 additions & 4 deletions ss-plugins.sh
Original file line number Diff line number Diff line change
Expand Up @@ -614,6 +614,21 @@ check_script_update(){
fi
}

url_encode() {
local length="${#1}"
for (( i = 0; i < length; i++ )); do
local c="${1:i:1}"
case $c in
[a-zA-Z0-9.~_-])
printf "%s" "$c"
;;
*)
printf "%%%02X" "'$c"
;;
esac
done
}

get_ip(){
local IP=$( ip addr | egrep -o '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}' | egrep -v "^192\.168|^172\.1[6-9]\.|^172\.2[0-9]\.|^172\.3[0-2]\.|^10\.|^127\.|^255\.|^0\." | head -n 1 )
[ -z "${IP}" ] && IP=$( wget -qO- -t1 -T2 ipv4.icanhazip.com )
Expand Down Expand Up @@ -656,10 +671,6 @@ get_domain_ip(){
fi
}

get_str_replace(){
echo -n $1 | sed 's/:/%3A/g;s/;/%3B/g;s/=/%3D/g;s/\//%2F/g'
}

get_str_base64_encode(){
echo -n $1 | base64 -w0
}
Expand Down
2 changes: 1 addition & 1 deletion templates/config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ ss_plugins_client_links(){
cipher=$(get_str_base64_encode "${shadowsockscipher}:${shadowsockspwd}")
ipPort="@${clientIpOrDomain}:${firewallNeedOpenPort}"
pluginName="/?plugin=${clientPluginName}"
plugin_opts=$(get_str_replace ";${clientPluginOpts}")
plugin_opts=$(url_encode ";${clientPluginOpts}")
sslinks="${head}${cipher}${ipPort}${pluginName}${plugin_opts}"
}

Expand Down
2 changes: 1 addition & 1 deletion utils/ck_sslink.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ get_link_of_ck2(){
local link_head="ss:https://"
local cipher_pwd=$(get_str_base64_encode "${shadowsockscipher}:${shadowsockspwd}")
local ip_port_plugin="@$(get_ip):443/?plugin=ck-client"
local plugin_opts=$(get_str_replace ";Transport=direct;ProxyMethod=shadowsocks;EncryptionMethod=${encryptionMethod};UID=${ckauid};PublicKey=${ckpub};ServerName=${ckservername};NumConn=4;BrowserSig=chrome;StreamTimeout=300")
local plugin_opts=$(url_encode ";Transport=direct;ProxyMethod=shadowsocks;EncryptionMethod=${encryptionMethod};UID=${ckauid};PublicKey=${ckpub};ServerName=${ckservername};NumConn=4;BrowserSig=chrome;StreamTimeout=300")
local ss_link="${link_head}${cipher_pwd}${ip_port_plugin}${plugin_opts}"

echo
Expand Down

0 comments on commit 26a5d13

Please sign in to comment.