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 #Current folder
cur_dir=`pwd` 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 # Make sure only root can run our script
rootness(){ [[ $EUID -ne 0 ]] && echo -e "[${red}Error${plain}] This script must be run as root!" && exit 1
if [[ $EUID -ne 0 ]]; then
echo "Error:This script must be run as root!" 1>&2
exit 1
fi
}
#Check system #Check system
check_sys(){ check_sys(){
@ -138,7 +150,7 @@ get_char(){
# Pre-installation settings # Pre-installation settings
pre_install(){ pre_install(){
if ! check_sys packageManager yum && ! check_sys packageManager apt; then 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 exit 1
fi fi
# Set shadowsocks-go config password # Set shadowsocks-go config password
@ -166,13 +178,41 @@ pre_install(){
echo echo
break break
else else
echo "Input error, please input correct number" echo -e "[${red}Error${plain}] Input error, please input a number between 1 and 65535"
fi fi
else else
echo "Input error, please input correct number" echo -e "[${red}Error${plain}] Input error, please input a number between 1 and 65535"
fi fi
done 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
echo "Press any key to start...or Press Ctrl+C to cancel" echo "Press any key to start...or Press Ctrl+C to cancel"
char=`get_char` char=`get_char`
@ -192,27 +232,23 @@ download_files(){
cd ${cur_dir} cd ${cur_dir}
if is_64bit; then if is_64bit; then
if ! wget -c http://dl.teddysun.com/shadowsocks/shadowsocks-server-linux64-1.2.1.gz; 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 exit 1
fi fi
gzip -d shadowsocks-server-linux64-1.2.1.gz gzip -d shadowsocks-server-linux64-1.2.1.gz
if [ $? -eq 0 ]; then if [ $? -ne 0 ]; then
echo "Decompress shadowsocks-server-linux64-1.2.1.gz success" echo -e "[${red}Error${plain}] Decompress shadowsocks-server-linux64-1.2.1.gz failed"
else
echo "Decompress shadowsocks-server-linux64-1.2.1.gz failed"
exit 1 exit 1
fi fi
mv -f shadowsocks-server-linux64-1.2.1 /usr/bin/shadowsocks-server mv -f shadowsocks-server-linux64-1.2.1 /usr/bin/shadowsocks-server
else else
if ! wget -c http://dl.teddysun.com/shadowsocks/shadowsocks-server-linux32-1.2.1.gz; then 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 exit 1
fi fi
gzip -d shadowsocks-server-linux32-1.2.1.gz gzip -d shadowsocks-server-linux32-1.2.1.gz
if [ $? -eq 0 ]; then if [ $? -ne 0 ]; then
echo "Decompress shadowsocks-server-linux32-1.2.1.gz success" echo -e "[${red}Error${plain}] Decompress shadowsocks-server-linux32-1.2.1.gz failed"
else
echo "Decompress shadowsocks-server-linux32-1.2.1.gz failed"
exit 1 exit 1
fi fi
mv -f shadowsocks-server-linux32-1.2.1 /usr/bin/shadowsocks-server mv -f shadowsocks-server-linux32-1.2.1 /usr/bin/shadowsocks-server
@ -221,12 +257,12 @@ download_files(){
# Download start script # Download start script
if check_sys packageManager yum; then 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 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 exit 1
fi fi
elif check_sys packageManager apt; then 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 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 exit 1
fi fi
fi fi
@ -243,7 +279,7 @@ config_shadowsocks(){
"server_port":${shadowsocksport}, "server_port":${shadowsocksport},
"local_port":1080, "local_port":1080,
"password":"${shadowsockspwd}", "password":"${shadowsockspwd}",
"method":"aes-256-cfb", "method":"${shadowsockscipher}",
"timeout":600 "timeout":600
} }
EOF EOF
@ -265,7 +301,7 @@ firewall_set(){
echo "port ${shadowsocksport} has been set up." echo "port ${shadowsocksport} has been set up."
fi fi
else 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 fi
elif centosversion 7; then elif centosversion 7; then
systemctl status firewalld > /dev/null 2>&1 systemctl status firewalld > /dev/null 2>&1
@ -281,7 +317,7 @@ firewall_set(){
firewall-cmd --permanent --zone=public --add-port=${shadowsocksport}/udp firewall-cmd --permanent --zone=public --add-port=${shadowsocksport}/udp
firewall-cmd --reload firewall-cmd --reload
else 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 fi
fi fi
@ -292,7 +328,7 @@ firewall_set(){
install(){ install(){
if [ -f /usr/bin/shadowsocks-server ]; then 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 /usr/bin/shadowsocks-server
chmod +x /etc/init.d/shadowsocks chmod +x /etc/init.d/shadowsocks
@ -304,25 +340,22 @@ install(){
fi fi
/etc/init.d/shadowsocks start /etc/init.d/shadowsocks start
if [ $? -eq 0 ]; then if [ $? -ne 0 ]; then
echo "Shadowsocks-go start success!" echo -e "[${red}Error${plain}] Shadowsocks-go server start failed!"
else
echo "Shadowsocks-go start failed!"
fi fi
else else
echo echo
echo "Shadowsocks-go install failed!" echo -e "[${red}Error${plain}] Shadowsocks-go server install failed!"
exit 1 exit 1
fi fi
clear clear
echo echo
echo "Congratulations, Shadowsocks-go install completed!" echo -e "Congratulations, Shadowsocks-go server install completed!"
echo -e "Your Server IP : \033[41;37m $(get_ip) \033[0m" 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 Server Port : \033[41;37m ${shadowsocksport} \033[0m"
echo -e "Your Password : \033[41;37m ${shadowsockspwd} \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 ${shadowsockscipher} \033[0m"
echo -e "Your Encryption Method: \033[41;37m aes-256-cfb \033[0m"
echo echo
echo "Welcome to visit:https://teddysun.com/392.html" echo "Welcome to visit:https://teddysun.com/392.html"
echo "Enjoy it!" echo "Enjoy it!"
@ -360,7 +393,6 @@ uninstall_shadowsocks_go(){
# Install Shadowsocks-go # Install Shadowsocks-go
install_shadowsocks_go(){ install_shadowsocks_go(){
rootness
disable_selinux disable_selinux
pre_install pre_install
download_files download_files

View File

@ -47,7 +47,7 @@ yellow='\033[0;33m'
plain='\033[0m' plain='\033[0m'
# Make sure only root can run our script # 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
disable_selinux(){ disable_selinux(){
@ -151,11 +151,11 @@ pre_install(){
if check_sys packageManager yum || check_sys packageManager apt; then if check_sys packageManager yum || check_sys packageManager apt; then
# Not support CentOS 5 # Not support CentOS 5
if centosversion 5; then 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 exit 1
fi fi
else 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 exit 1
fi fi
# Set shadowsocks config password # Set shadowsocks config password
@ -289,7 +289,7 @@ firewall_set(){
echo "port ${shadowsocksport} has already been set up." echo "port ${shadowsocksport} has already been set up."
fi fi
else 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 fi
elif centosversion 7; then elif centosversion 7; then
systemctl status firewalld > /dev/null 2>&1 systemctl status firewalld > /dev/null 2>&1