Skip to content

Commit

Permalink
Support the latest version of simple-tls
Browse files Browse the repository at this point in the history
  • Loading branch information
loyess committed Apr 10, 2021
1 parent 4dbc1c3 commit c06ae37
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 7 deletions.
56 changes: 53 additions & 3 deletions prepare/simple_tls_prepare.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ improt_package "utils" "gen_certificates.sh"
# simple-tls version
SIMPLE_TLS_VERSION=(
v0.3.4
v0.4.7
LatestRelease
)

Expand All @@ -22,8 +23,8 @@ simple_tls_version(){
echo -e "${Green} ${i}.${suffix} ${hint}"
done
echo
read -e -p "(默认: ${SIMPLE_TLS_VERSION[0]}):" SimpleTlsVer
[ -z "$SimpleTlsVer" ] && SimpleTlsVer=1
read -e -p "(默认: ${SIMPLE_TLS_VERSION[2]}):" SimpleTlsVer
[ -z "$SimpleTlsVer" ] && SimpleTlsVer=3
expr ${SimpleTlsVer} + 1 &>/dev/null
if [ $? -ne 0 ]; then
echo
Expand Down Expand Up @@ -207,6 +208,45 @@ is_enable_padding_data(){
done
}

is_enable_auth(){
while true
do
echo
echo -e "是否启用身份验证密码,以过滤扫描流量(auth)"
read -p "(默认: n) [y/n]: " yn
[ -z "${yn}" ] && yn="N"
case "${yn:0:1}" in
y|Y)
isEnable=enable
;;
n|N)
isEnable=disable
;;
*)
echo
echo -e "${Error} 输入有误,请重新输入!"
echo
continue
;;
esac

echo
echo -e "${Red} isEnableAuth = ${isEnable}${suffix}"
echo
break
done
}

get_input_auth_passwd(){
gen_random_str
echo -e "\n请输入身份验证密码"
read -e -p "(默认: ${ran_str8}):" auth
[ -z "${auth}" ] && auth=${ran_str8}
echo
echo -e "${Red} auth = ${auth}${suffix}"
echo
}

check_port_for_simple_tls(){
shadowsocksport=443

Expand All @@ -224,13 +264,23 @@ install_prepare_libev_simple_tls(){
is_add_random_header
fi

# LatestRelease
# v0.4.7
if [[ ${SimpleTlsVer} = "2" ]]; then
libev_simple_tls=1
get_input_server_name
is_enable_padding_data
fi

# LatestRelease
if [[ ${SimpleTlsVer} = "3" ]]; then
libev_simple_tls=1
get_input_server_name
is_enable_auth
if [[ ${isEnable} = enable ]]; then
get_input_auth_passwd
fi
fi

check_port_for_simple_tls

if [[ ${libev_simple_tls} = "1" ]]; then
Expand Down
8 changes: 5 additions & 3 deletions templates/config/simple_tls_config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,17 @@ ss_simple_tls_wss_config(){
}

config_ss_simple_tls(){
if [[ ${libev_simple_tls} == "1" ]]; then
ss_simple_tls_config
elif [[ ${libev_simple_tls} == "2" ]]; then
if [[ ${libev_simple_tls} == "2" ]]; then
ss_simple_tls_wss_config
else
ss_simple_tls_config
fi

if [[ ${SimpleTlsVer} = "1" ]] && [[ ${isEnable} == enable ]]; then
sed 's/"plugin_opts":"s/"plugin_opts":"s;rh/' -i ${SHADOWSOCKS_CONFIG}
elif [[ ${SimpleTlsVer} = "2" ]] && [[ ${isEnable} == enable ]]; then
sed 's/"plugin_opts":"s/"plugin_opts":"s;pd/' -i ${SHADOWSOCKS_CONFIG}
elif [[ ${SimpleTlsVer} = "3" ]] && [[ ${isEnable} == enable ]]; then
sed "s/\"plugin_opts\":\"s/\"plugin_opts\":\"s;auth=${auth}/" -i ${SHADOWSOCKS_CONFIG}
fi
}
2 changes: 2 additions & 0 deletions templates/links/simple_tls_link.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ ss_simple_tls_link(){
local ataArgs=';rh'
elif [[ ${SimpleTlsVer} = "2" ]] && [[ ${isEnable} == enable ]]; then
local ataArgs=';pd'
elif [[ ${SimpleTlsVer} = "3" ]] && [[ ${isEnable} == enable ]]; then
local ataArgs=";auth=${auth}"
fi
if [[ ${domainType} = DNS-Only ]]; then
local plugin_opts=$(get_str_replace "${ataArgs};n=${serverName}")
Expand Down
2 changes: 2 additions & 0 deletions templates/visible/simple_tls_visible.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ ss_simple_tls_show(){
local ataArgs='rh;'
elif [[ ${SimpleTlsVer} = "2" ]] && [[ ${isEnable} == enable ]]; then
local ataArgs='pd;'
elif [[ ${SimpleTlsVer} = "3" ]] && [[ ${isEnable} == enable ]]; then
local ataArgs="auth=${auth};"
fi
if [[ ${domainType} = DNS-Only ]]; then
echo -e " 插件选项 : ${Red}${ataArgs}n=${serverName}${suffix}" >> ${HUMAN_CONFIG}
Expand Down
2 changes: 2 additions & 0 deletions utils/downloads.sh
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,8 @@ download_plugins_file(){
[ -z ${simple_tls_ver} ] && echo -e "${Error} 获取 simple-tls 最新版本失败." && exit 1
if [[ ${SimpleTlsVer} = "1" ]]; then
simple_tls_ver="0.3.4"
elif [[ ${SimpleTlsVer} = "2" ]]; then
simple_tls_ver="0.4.7"
fi
# wriet version num
if [ ! -d "$(dirname ${SIMPLE_TLS_VERSION_FILE})" ]; then
Expand Down
2 changes: 1 addition & 1 deletion utils/update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ update_simple_tls(){
[ -z ${simple_tls_ver} ] && echo -e "${Error} 获取 simple-tls 最新版本失败." && exit 1
read current_simple_tls_ver < ${SIMPLE_TLS_VERSION_FILE}

if ! check_latest_version "0.3.4" ${current_simple_tls_ver}; then
if ! check_latest_version "0.4.7" ${current_simple_tls_ver}; then
echo -e "${Point} simple-tls当前版本是${current_simple_tls_ver}及以下版本,与最新版本不兼容,脚本不提供更新."
exit 0
fi
Expand Down

0 comments on commit c06ae37

Please sign in to comment.