Skip to content

Commit

Permalink
Add v0.3.4 and latestRelease for simple-tls
Browse files Browse the repository at this point in the history
  • Loading branch information
loyess committed Jul 4, 2020
1 parent 1113f0a commit 9ac0c98
Show file tree
Hide file tree
Showing 5 changed files with 113 additions and 24 deletions.
87 changes: 84 additions & 3 deletions prepare/simple_tls_prepare.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,52 @@
improt_package "utils" "gen_certificates.sh"

# simple-tls version
SIMPLE_TLS_VERSION=(
v0.3.4
LatestRelease
)

# simple-tls Transport mode
SIMPLE_TLS_MODE=(
tls
wss
)


simple_tls_version(){
while true
do
echo && echo -e "请选择simple-tls安装版本\n"
for ((i=1;i<=${#SIMPLE_TLS_VERSION[@]};i++ )); do
hint="${SIMPLE_TLS_VERSION[$i-1]}"
echo -e "${Green} ${i}.${suffix} ${hint}"
done
echo
read -e -p "(默认: ${SIMPLE_TLS_VERSION[0]}):" SimpleTlsVer
[ -z "$SimpleTlsVer" ] && SimpleTlsVer=1
expr ${SimpleTlsVer} + 1 &>/dev/null
if [ $? -ne 0 ]; then
echo
echo -e "${Error} 请输入一个数字"
echo
continue
fi
if [[ "$SimpleTlsVer" -lt 1 || "$SimpleTlsVer" -gt ${#SIMPLE_TLS_VERSION[@]} ]]; then
echo
echo -e "${Error} 请输入一个数字在 [1-${#SIMPLE_TLS_VERSION[@]}] 之间"
echo
continue
fi

stVer=${SIMPLE_TLS_VERSION[$SimpleTlsVer-1]}
echo
echo -e "${Red} version = ${stVer}${suffix}"
echo

break
done
}

transport_mode_menu(){
while true
do
Expand Down Expand Up @@ -138,6 +178,35 @@ is_add_random_header(){
done
}

is_enable_padding_data(){
while true
do
echo
echo -e "是否启用 padding-data 模式,以防止流量分析(pd)"
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} pd = ${isEnable}${suffix}"
echo
break
done
}

check_port_for_simple_tls(){
shadowsocksport=443

Expand All @@ -147,9 +216,21 @@ check_port_for_simple_tls(){
}

install_prepare_libev_simple_tls(){
transport_mode_menu
get_input_server_name
is_add_random_header
simple_tls_version
# LatestRelease
if [[ ${SimpleTlsVer} = "1" ]]; then
transport_mode_menu
get_input_server_name
is_add_random_header
fi

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

check_port_for_simple_tls

if [[ ${libev_simple_tls} = "1" ]]; then
Expand Down
6 changes: 4 additions & 2 deletions ss-plugins.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export PATH

# shell version
# ====================
SHELL_VERSION="2.6.0"
SHELL_VERSION="2.6.1"
# ====================


Expand Down Expand Up @@ -749,8 +749,10 @@ config_ss(){
ss_simple_tls_wss_config
fi

if [[ ${isEnable} == enable ]]; then
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}
fi
fi
}
Expand Down
20 changes: 11 additions & 9 deletions templates/sip002_url_templates.sh
Original file line number Diff line number Diff line change
Expand Up @@ -179,14 +179,16 @@ ss_simple_tls_link(){
local cipher_pwd=$(get_str_base64_encode "${shadowsockscipher}:${shadowsockspwd}")
local ip_port_plugin="@$(get_ip):443/?plugin=${plugin_client_name}"
if [[ ${isEnable} == disable ]]; then
local rhArgs=''
elif [[ ${isEnable} == enable ]]; then
local rhArgs=';rh'
local ataArgs=''
elif [[ ${SimpleTlsVer} = "1" ]] && [[ ${isEnable} == enable ]]; then
local ataArgs=';rh'
elif [[ ${SimpleTlsVer} = "2" ]] && [[ ${isEnable} == enable ]]; then
local ataArgs=';pd'
fi
if [[ ${domainType} = DNS-Only ]]; then
local plugin_opts=$(get_str_replace "${rhArgs};n=${serverName}")
local plugin_opts=$(get_str_replace "${ataArgs};n=${serverName}")
elif [[ ${domainType} = Other ]]; then
local plugin_opts=$(get_str_replace "${rhArgs};n=${serverName};cca=${base64Cert}")
local plugin_opts=$(get_str_replace "${ataArgs};n=${serverName};cca=${base64Cert}")
fi
ss_link="${link_head}${cipher_pwd}${ip_port_plugin}${plugin_opts}"
}
Expand All @@ -200,14 +202,14 @@ ss_simple_tls_wss_link(){
local ip_port_plugin="@$(get_ip):443/?plugin=${plugin_client_name}"
fi
if [[ ${isEnable} == disable ]]; then
local rhArgs=''
local ataArgs=''
elif [[ ${isEnable} == enable ]]; then
local rhArgs=';rh'
local ataArgs=';rh'
fi
if [[ ${domainType} = DNS-Only ]] || [[ ${domainType} = CDN ]]; then
local plugin_opts=$(get_str_replace "${rhArgs};wss;path=${wssPath};n=${serverName}")
local plugin_opts=$(get_str_replace "${ataArgs};wss;path=${wssPath};n=${serverName}")
elif [[ ${domainType} = Other ]]; then
local plugin_opts=$(get_str_replace "${rhArgs};wss;path=${wssPath};n=${serverName};cca=${base64Cert}")
local plugin_opts=$(get_str_replace "${ataArgs};wss;path=${wssPath};n=${serverName};cca=${base64Cert}")
fi
ss_link="${link_head}${cipher_pwd}${ip_port_plugin}${plugin_opts}"
}
Expand Down
20 changes: 11 additions & 9 deletions templates/terminal_config_templates.sh
Original file line number Diff line number Diff line change
Expand Up @@ -427,14 +427,16 @@ ss_simple_tls_show(){
echo -e " 加密 : ${Red}${shadowsockscipher}${suffix}" >> ${HUMAN_CONFIG}
echo -e " 插件程序 : ${Red}${plugin_client_name}${suffix}" >> ${HUMAN_CONFIG}
if [[ ${isEnable} == disable ]]; then
local rhArgs=''
elif [[ ${isEnable} == enable ]]; then
local rhArgs='rh;'
local ataArgs=''
elif [[ ${SimpleTlsVer} = "1" ]] && [[ ${isEnable} == enable ]]; then
local ataArgs='rh;'
elif [[ ${SimpleTlsVer} = "2" ]] && [[ ${isEnable} == enable ]]; then
local ataArgs='pd;'
fi
if [[ ${domainType} = DNS-Only ]]; then
echo -e " 插件选项 : ${Red}${rhArgs}n=${serverName}${suffix}" >> ${HUMAN_CONFIG}
echo -e " 插件选项 : ${Red}${ataArgs}n=${serverName}${suffix}" >> ${HUMAN_CONFIG}
elif [[ ${domainType} = Other ]]; then
echo -e " 插件选项 : ${Red}${rhArgs}n=${serverName};cca=${base64Cert}${suffix}" >> ${HUMAN_CONFIG}
echo -e " 插件选项 : ${Red}${ataArgs}n=${serverName};cca=${base64Cert}${suffix}" >> ${HUMAN_CONFIG}
fi
echo -e " 插件参数 : " >> ${HUMAN_CONFIG}
echo >> ${HUMAN_CONFIG}
Expand Down Expand Up @@ -462,14 +464,14 @@ ss_simple_tls_wss_show(){
echo -e " 加密 : ${Red}${shadowsockscipher}${suffix}" >> ${HUMAN_CONFIG}
echo -e " 插件程序 : ${Red}${plugin_client_name}${suffix}" >> ${HUMAN_CONFIG}
if [[ ${isEnable} == disable ]]; then
local rhArgs=''
local ataArgs=''
elif [[ ${isEnable} == enable ]]; then
local rhArgs='rh;'
local ataArgs='rh;'
fi
if [[ ${domainType} = DNS-Only ]] || [[ ${domainType} = CDN ]]; then
echo -e " 插件选项 : ${Red}${rhArgs}wss;path=${wssPath};n=${serverName}${suffix}" >> ${HUMAN_CONFIG}
echo -e " 插件选项 : ${Red}${ataArgs}wss;path=${wssPath};n=${serverName}${suffix}" >> ${HUMAN_CONFIG}
elif [[ ${domainType} = Other ]]; then
echo -e " 插件选项 : ${Red}${rhArgs}wss;path=${wssPath};n=${serverName};cca=${base64Cert}${suffix}" >> ${HUMAN_CONFIG}
echo -e " 插件选项 : ${Red}${ataArgs}wss;path=${wssPath};n=${serverName};cca=${base64Cert}${suffix}" >> ${HUMAN_CONFIG}
fi
echo -e " 插件参数 : " >> ${HUMAN_CONFIG}
echo >> ${HUMAN_CONFIG}
Expand Down
4 changes: 3 additions & 1 deletion utils/downloads.sh
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,9 @@ download_plugins_file(){
# Download simple-tls
simple_tls_ver=$(wget --no-check-certificate -qO- https://api.github.com/repos/IrineSistiana/simple-tls/releases | grep -o '"tag_name": ".*"' | head -n 1| sed 's/"//g;s/v//g' | sed 's/tag_name: //g')
[ -z ${simple_tls_ver} ] && echo -e "${Error} 获取 simple-tls 最新版本失败." && exit 1
simple_tls_ver="0.3.4"
if [[ ${SimpleTlsVer} = "1" ]]; then
simple_tls_ver="0.3.4"
fi
# wriet version num
if [ ! -d "$(dirname ${SIMPLE_TLS_VERSION_FILE})" ]; then
mkdir -p $(dirname ${SIMPLE_TLS_VERSION_FILE})
Expand Down

0 comments on commit 9ac0c98

Please sign in to comment.