Skip to content

Commit

Permalink
Add AlternativeNames setting item for cloak.
Browse files Browse the repository at this point in the history
  • Loading branch information
loyess committed Jun 7, 2021
1 parent 44aed3a commit 27c4259
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 2 deletions.
50 changes: 50 additions & 0 deletions prepare/cloak_prepare.sh
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,55 @@ get_cloak_encryption_method(){
done
}

get_input_alternativenames(){
while true
do
echo
echo -e "请为Cloak输入AlternativeNames的值(例:cloudflare.com,github.com 英文逗号分隔)"
read -e -p "(默认:跳过):" altNames
if [ -z "$altNames" ]; then
NumConn=4
AlternativeNames=""

echo
echo -e "${Red} AlternativeNames = 跳过${suffix}"
echo
echo -e "${Tip} 可自行在客户端设置,如自行设置请注意将 ${Red}NumConn${suffix} 设置为 0"
echo
break
else
local domain
local noError=0

altNamesArray=(`echo $altNames | tr ',' ' '`)
if [[ "${#altNamesArray[@]}" -eq 0 ]]; then
echo -e "${Error} 检测到输入的字符${Red}仅存在逗号${suffix},请重新输入。"
continue
fi
for domain in ${altNamesArray[@]}; do
if ! auto_get_ip_of_domain ${domain}; then
noError=$((${noError} + 1))
if [[ "$noError" -eq 1 ]]; then
echo -e "${Error} 输入的字符中存在${Red}无效字符${suffix}${Red}无法获取到ip的域名${suffix}"
fi
echo -e " ${domain}"
fi
done

if [[ "$noError" -ne 0 ]]; then
continue
fi

NumConn=0
AlternativeNames=";AlternativeNames=$(echo $altNames | sed -E 's/^,+//g;s/,+$//g' | sed -E 's/,+/%2C/g')"

echo
echo -e "${Red} AlternativeNames = $(echo $altNames | sed -E 's/^,+//g;s/,+$//g' | sed -E 's/,+/,/g')${suffix}"
echo
break
fi
done
}

install_prepare_libev_cloak(){
if check_port_occupy "443"; then
Expand All @@ -134,4 +183,5 @@ install_prepare_libev_cloak(){
get_input_domain
get_input_rediraddr_of_domain
get_cloak_encryption_method
get_input_alternativenames
}
2 changes: 1 addition & 1 deletion templates/links/cloak_link.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ ss_cloak_link_new(){
local link_head="ss:https://"
local cipher_pwd=$(get_str_base64_encode "${shadowsockscipher}:${shadowsockspwd}")
local ip_port_plugin="@$(get_ip):443/?plugin=${plugin_client_name}"
local plugin_opts=$(get_str_replace ";Transport=direct;ProxyMethod=shadowsocks;EncryptionMethod=${encryptionMethod};UID=${ckauid};PublicKey=${ckpub};ServerName=${domain};NumConn=4;BrowserSig=chrome;StreamTimeout=300")
local plugin_opts=$(get_str_replace ";Transport=direct;ProxyMethod=shadowsocks;EncryptionMethod=${encryptionMethod};UID=${ckauid};PublicKey=${ckpub};ServerName=${domain};NumConn=${NumConn};BrowserSig=chrome;StreamTimeout=300${AlternativeNames}")
ss_link="${link_head}${cipher_pwd}${ip_port_plugin}${plugin_opts}"
}
2 changes: 1 addition & 1 deletion templates/visible/cloak_visible.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ ss_cloak_show_new(){
echo -e " 密码 : ${Red}${shadowsockspwd}${suffix}" >> ${HUMAN_CONFIG}
echo -e " 加密 : ${Red}${shadowsockscipher}${suffix}" >> ${HUMAN_CONFIG}
echo -e " 插件程序 : ${Red}${plugin_client_name}${suffix}" >> ${HUMAN_CONFIG}
echo -e " 插件选项 : ${Red}Transport=direct;ProxyMethod=shadowsocks;EncryptionMethod=${encryptionMethod};UID=${ckauid};PublicKey=${ckpub};ServerName=${domain};NumConn=4;BrowserSig=chrome;StreamTimeout=300${suffix}" >> ${HUMAN_CONFIG}
echo -e " 插件选项 : ${Red}Transport=direct;ProxyMethod=shadowsocks;EncryptionMethod=${encryptionMethod};UID=${ckauid};PublicKey=${ckpub};ServerName=${domain};NumConn=${NumConn};BrowserSig=chrome;StreamTimeout=300${AlternativeNames}${suffix}" >> ${HUMAN_CONFIG}
echo -e " 插件参数 : " >> ${HUMAN_CONFIG}
echo >> ${HUMAN_CONFIG}
echo -e " AdminUID : ${ckauid}" >> ${HUMAN_CONFIG}
Expand Down

0 comments on commit 27c4259

Please sign in to comment.