added select stream cipher option

Signed-off-by: Teddysun <i@teddysun.com>
This commit is contained in:
Teddysun 2017-07-22 08:05:59 +09:00
parent b5da756e20
commit 5436a8fe94
No known key found for this signature in database
GPG Key ID: 09BD4C080AD6C46D
2 changed files with 73 additions and 41 deletions

View File

@ -21,14 +21,26 @@ echo
#Current folder
cur_dir=`pwd`
# Stream Ciphers
ciphers=(
aes-256-cfb
aes-192-cfb
aes-128-cfb
aes-256-ctr
aes-192-ctr
aes-128-ctr
chacha20-ietf
chacha20
rc4-md5
)
# Color
red='\033[0;31m'
green='\033[0;32m'
yellow='\033[0;33m'
plain='\033[0m'
# Make sure only root can run our script
rootness(){
if [[ $EUID -ne 0 ]]; then
echo "Error:This script must be run as root!" 1>&2
exit 1
fi
}
[[ $EUID -ne 0 ]] && echo -e "[${red}Error${plain}] This script must be run as root!" && exit 1
#Check system
check_sys(){
@ -138,7 +150,7 @@ get_char(){
# Pre-installation settings
pre_install(){
if ! check_sys packageManager yum && ! check_sys packageManager apt; then
echo "Error: Your OS is not supported. please change OS to CentOS/Debian/Ubuntu and try again."
echo -e "$[{red}Error${plain}] Your OS is not supported. please change OS to CentOS/Debian/Ubuntu and try again."
exit 1
fi
# Set shadowsocks-go config password
@ -166,13 +178,41 @@ pre_install(){
echo
break
else
echo "Input error, please input correct number"
echo -e "[${red}Error${plain}] Input error, please input a number between 1 and 65535"
fi
else
echo "Input error, please input correct number"
echo -e "[${red}Error${plain}] Input error, please input a number between 1 and 65535"
fi
done
# Set shadowsocks config stream ciphers
while true
do
echo -e "Please select stream cipher for shadowsocks-go:"
for ((i=1;i<=${#ciphers[@]};i++ )); do
hint="${ciphers[$i-1]}"
echo -e "${green}${i}${plain}) ${hint}"
done
read -p "Which cipher you'd select(Default: ${ciphers[0]}):" pick
[ -z "$pick" ] && pick=1
expr ${pick} + 0 &>/dev/null
if [ $? -ne 0 ]; then
echo -e "[${red}Error${plain}] Input error, please input a number"
continue
fi
if [[ "$pick" -lt 1 || "$pick" -gt ${#ciphers[@]} ]]; then
echo -e "[${red}Error${plain}] Input error, please input a number between 1 and ${#ciphers[@]}"
continue
fi
shadowsockscipher=${ciphers[$pick-1]}
echo
echo "---------------------------"
echo "cipher = ${shadowsockscipher}"
echo "---------------------------"
echo
break
done
echo
echo "Press any key to start...or Press Ctrl+C to cancel"
char=`get_char`
@ -192,27 +232,23 @@ download_files(){
cd ${cur_dir}
if is_64bit; then
if ! wget -c http://dl.teddysun.com/shadowsocks/shadowsocks-server-linux64-1.2.1.gz; then
echo "Failed to download shadowsocks-server-linux64-1.2.1.gz"
echo -e "[${red}Error${plain}] Failed to download shadowsocks-server-linux64-1.2.1.gz"
exit 1
fi
gzip -d shadowsocks-server-linux64-1.2.1.gz
if [ $? -eq 0 ]; then
echo "Decompress shadowsocks-server-linux64-1.2.1.gz success"
else
echo "Decompress shadowsocks-server-linux64-1.2.1.gz failed"
if [ $? -ne 0 ]; then
echo -e "[${red}Error${plain}] Decompress shadowsocks-server-linux64-1.2.1.gz failed"
exit 1
fi
mv -f shadowsocks-server-linux64-1.2.1 /usr/bin/shadowsocks-server
else
if ! wget -c http://dl.teddysun.com/shadowsocks/shadowsocks-server-linux32-1.2.1.gz; then
echo "Failed to download shadowsocks-server-linux32-1.2.1.gz"
echo -e "[${red}Error${plain}] Failed to download shadowsocks-server-linux32-1.2.1.gz"
exit 1
fi
gzip -d shadowsocks-server-linux32-1.2.1.gz
if [ $? -eq 0 ]; then
echo "Decompress shadowsocks-server-linux32-1.2.1.gz success"
else
echo "Decompress shadowsocks-server-linux32-1.2.1.gz failed"
if [ $? -ne 0 ]; then
echo -e "[${red}Error${plain}] Decompress shadowsocks-server-linux32-1.2.1.gz failed"
exit 1
fi
mv -f shadowsocks-server-linux32-1.2.1 /usr/bin/shadowsocks-server
@ -221,12 +257,12 @@ download_files(){
# Download start script
if check_sys packageManager yum; then
if ! wget --no-check-certificate -O /etc/init.d/shadowsocks https://raw.githubusercontent.com/teddysun/shadowsocks_install/master/shadowsocks-go; then
echo "Failed to download shadowsocks-go auto start script!"
echo -e "[${red}Error${plain}] Failed to download shadowsocks-go auto start script!"
exit 1
fi
elif check_sys packageManager apt; then
if ! wget --no-check-certificate -O /etc/init.d/shadowsocks https://raw.githubusercontent.com/teddysun/shadowsocks_install/master/shadowsocks-go-debian; then
echo "Failed to download shadowsocks-go auto start script!"
echo -e "[${red}Error${plain}] Failed to download shadowsocks-go auto start script!"
exit 1
fi
fi
@ -243,7 +279,7 @@ config_shadowsocks(){
"server_port":${shadowsocksport},
"local_port":1080,
"password":"${shadowsockspwd}",
"method":"aes-256-cfb",
"method":"${shadowsockscipher}",
"timeout":600
}
EOF
@ -265,7 +301,7 @@ firewall_set(){
echo "port ${shadowsocksport} has been set up."
fi
else
echo "WARNING: iptables looks like shutdown or not installed, please manually set it if necessary."
echo -e "[${yellow}Warning${plain}] iptables looks like shutdown or not installed, please manually set it if necessary."
fi
elif centosversion 7; then
systemctl status firewalld > /dev/null 2>&1
@ -281,7 +317,7 @@ firewall_set(){
firewall-cmd --permanent --zone=public --add-port=${shadowsocksport}/udp
firewall-cmd --reload
else
echo "WARNING: Try to start firewalld failed. please enable port ${shadowsocksport} manually if necessary."
echo -e "[${yellow}Warning${plain}] Try to start firewalld failed. please enable port ${shadowsocksport} manually if necessary."
fi
fi
fi
@ -292,7 +328,7 @@ firewall_set(){
install(){
if [ -f /usr/bin/shadowsocks-server ]; then
echo "shadowsocks-go install success!"
echo "Shadowsocks-go server install success!"
chmod +x /usr/bin/shadowsocks-server
chmod +x /etc/init.d/shadowsocks
@ -304,25 +340,22 @@ install(){
fi
/etc/init.d/shadowsocks start
if [ $? -eq 0 ]; then
echo "Shadowsocks-go start success!"
else
echo "Shadowsocks-go start failed!"
if [ $? -ne 0 ]; then
echo -e "[${red}Error${plain}] Shadowsocks-go server start failed!"
fi
else
echo
echo "Shadowsocks-go install failed!"
echo -e "[${red}Error${plain}] Shadowsocks-go server install failed!"
exit 1
fi
clear
echo
echo "Congratulations, Shadowsocks-go install completed!"
echo -e "Your Server IP: \033[41;37m $(get_ip) \033[0m"
echo -e "Your Server Port: \033[41;37m ${shadowsocksport} \033[0m"
echo -e "Your Password: \033[41;37m ${shadowsockspwd} \033[0m"
echo -e "Your Local Port: \033[41;37m 1080 \033[0m"
echo -e "Your Encryption Method: \033[41;37m aes-256-cfb \033[0m"
echo -e "Congratulations, Shadowsocks-go server install completed!"
echo -e "Your Server IP : \033[41;37m $(get_ip) \033[0m"
echo -e "Your Server Port : \033[41;37m ${shadowsocksport} \033[0m"
echo -e "Your Password : \033[41;37m ${shadowsockspwd} \033[0m"
echo -e "Your Encryption Method: \033[41;37m ${shadowsockscipher} \033[0m"
echo
echo "Welcome to visit:https://teddysun.com/392.html"
echo "Enjoy it!"
@ -360,7 +393,6 @@ uninstall_shadowsocks_go(){
# Install Shadowsocks-go
install_shadowsocks_go(){
rootness
disable_selinux
pre_install
download_files

View File

@ -47,7 +47,7 @@ yellow='\033[0;33m'
plain='\033[0m'
# Make sure only root can run our script
[[ $EUID -ne 0 ]] && echo -e "${red}Error:${plain} This script must be run as root!" && exit 1
[[ $EUID -ne 0 ]] && echo -e "[${red}Error${plain}] This script must be run as root!" && exit 1
# Disable selinux
disable_selinux(){
@ -151,11 +151,11 @@ pre_install(){
if check_sys packageManager yum || check_sys packageManager apt; then
# Not support CentOS 5
if centosversion 5; then
echo -e "${red}Error:${plain} Not supported CentOS 5, please change to CentOS 6+/Debian 7+/Ubuntu 12+ and try again."
echo -e "$[{red}Error${plain}] Not supported CentOS 5, please change to CentOS 6+/Debian 7+/Ubuntu 12+ and try again."
exit 1
fi
else
echo -e "${red}Error:${plain} Your OS is not supported. please change OS to CentOS/Debian/Ubuntu and try again."
echo -e "[${red}Error${plain}] Your OS is not supported. please change OS to CentOS/Debian/Ubuntu and try again."
exit 1
fi
# Set shadowsocks config password
@ -289,7 +289,7 @@ firewall_set(){
echo "port ${shadowsocksport} has already been set up."
fi
else
echo "[${yellow}Warning${plain}] iptables looks like shutdown or not installed, please manually set it if necessary."
echo -e "[${yellow}Warning${plain}] iptables looks like shutdown or not installed, please manually set it if necessary."
fi
elif centosversion 7; then
systemctl status firewalld > /dev/null 2>&1