Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
Toyo authored Aug 7, 2017
1 parent 9c25485 commit 56bc90f
Showing 1 changed file with 92 additions and 38 deletions.
130 changes: 92 additions & 38 deletions ssr.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ export PATH
#=================================================
# System Required: CentOS 6+/Debian 6+/Ubuntu 14.04+
# Description: Install the ShadowsocksR server
# Version: 2.0.23
# Version: 2.0.24
# Author: Toyo
# Blog: https://doub.io/ss-jc42/
#=================================================

sh_ver="2.0.23"
sh_ver="2.0.24"
ssr_folder="/usr/local/shadowsocksr"
ssr_ss_file="${ssr_folder}/shadowsocks"
config_file="${ssr_folder}/config.json"
Expand Down Expand Up @@ -724,86 +724,140 @@ Install_Libsodium(){
}
# 显示 连接信息
debian_View_user_connection_info(){
format_1=$1
if [[ -z "${now_mode}" ]]; then
now_mode="单端口" && user_total="1"
IP_total=`netstat -anp |grep 'ESTABLISHED' |grep 'python' |grep 'tcp6' |awk '{print $5}' |awk -F ":" '{print $1}' |sort -u |wc -l`
user_port=`${jq_file} '.server_port' ${config_user_file}`
user_IP=`netstat -anp |grep 'ESTABLISHED' |grep 'python' |grep 'tcp6' |grep "${user_port}" |awk '{print $5}' |awk -F ":" '{print $1}' |sort -u`
if [[ -z ${user_IP} ]]; then
user_IP_1=`netstat -anp |grep 'ESTABLISHED' |grep 'python' |grep 'tcp6' |grep "${user_port}" |awk '{print $5}' |awk -F ":" '{print $1}' |sort -u`
if [[ -z ${user_IP_1} ]]; then
user_IP_total="0"
else
user_IP_total=`echo -e "${user_IP}"|wc -l`
user_IP=`echo ${user_IP}|sed 's/ / | /g'`
user_IP_total=`echo -e "${user_IP_1}"|wc -l`
if [[ ${format_1} == "IP_address" ]]; then
get_IP_address
else
user_IP=`echo -e "\n${user_IP_1}"`
fi
fi
user_list_all="端口: ${Green_font_prefix}"${user_port}"${Font_color_suffix}, 链接IP总数: ${Green_font_prefix}"${user_IP_total}"${Font_color_suffix}, 当前链接IP: ${Green_font_prefix}"${user_IP}"${Font_color_suffix}\n"
user_list_all="端口: ${Green_font_prefix}"${user_port}"${Font_color_suffix}, 链接IP总数: ${Green_font_prefix}"${user_IP_total}"${Font_color_suffix}, 当前链接IP: ${Green_font_prefix}${user_IP}${Font_color_suffix}\n"
user_IP=""
echo -e "当前模式: ${Green_background_prefix} "${now_mode}" ${Font_color_suffix},链接IP总数: ${Green_background_prefix} "${IP_total}" ${Font_color_suffix}"
echo -e ${user_list_all}
echo -e "${user_list_all}"
else
now_mode="多端口" && user_total=`${jq_file} '.port_password' ${config_user_file} |sed '$d;1d' | wc -l`
IP_total=`netstat -anp |grep 'ESTABLISHED' |grep 'python' |grep 'tcp6' |awk '{print $5}' |awk -F ":" '{print $1}' |sort -u |wc -l`
user_list_all=""
for((integer = ${user_total}; integer >= 1; integer--))
do
user_port=`${jq_file} '.port_password' ${config_user_file} |sed '$d;1d' |awk -F ":" '{print $1}' |sed -n "${integer}p" |sed -r 's/.*\"(.+)\".*/\1/'`
user_IP=`netstat -anp |grep 'ESTABLISHED' |grep 'python' |grep 'tcp6' |grep "${user_port}" |awk '{print $5}' |awk -F ":" '{print $1}' |sort -u`
if [[ -z ${user_IP} ]]; then
user_IP_1=`netstat -anp |grep 'ESTABLISHED' |grep 'python' |grep 'tcp6' |grep "${user_port}" |awk '{print $5}' |awk -F ":" '{print $1}' |sort -u`
if [[ -z ${user_IP_1} ]]; then
user_IP_total="0"
else
user_IP_total=`echo -e "${user_IP}"|wc -l`
user_IP=`echo ${user_IP}|sed 's/ / | /g'`
user_IP_total=`echo -e "${user_IP_1}"|wc -l`
if [[ ${format_1} == "IP_address" ]]; then
get_IP_address
else
user_IP=`echo -e "\n${user_IP_1}"`
fi
fi
user_list_all=${user_list_all}"端口: ${Green_font_prefix}"${user_port}"${Font_color_suffix}, 链接IP总数: ${Green_font_prefix}"${user_IP_total}"${Font_color_suffix}, 当前链接IP: ${Green_font_prefix}"${user_IP}"${Font_color_suffix}\n"
user_list_all=${user_list_all}"端口: ${Green_font_prefix}"${user_port}"${Font_color_suffix}, 链接IP总数: ${Green_font_prefix}"${user_IP_total}"${Font_color_suffix}, 当前链接IP: ${Green_font_prefix}${user_IP}${Font_color_suffix}\n"
user_IP=""
done
echo -e "当前模式: ${Green_background_prefix} "${now_mode}" ${Font_color_suffix} ,用户总数: ${Green_background_prefix} "${user_total}" ${Font_color_suffix} ,链接IP总数: ${Green_background_prefix} "${IP_total}" ${Font_color_suffix} "
echo -e ${user_list_all}
echo -e "${user_list_all}"
fi
}
centos_View_user_connection_info(){
format_1=$1
if [[ -z "${now_mode}" ]]; then
now_mode="单端口" && user_total="1"
IP_total=`netstat -anp |grep 'ESTABLISHED' |grep 'python' |grep 'tcp' |grep '::ffff:' |awk '{print $5}' |awk -F ":" '{print $4}' |sort -u |wc -l`
user_port=`${jq_file} '.server_port' ${config_user_file}`
user_IP=`netstat -anp |grep 'ESTABLISHED' |grep 'python' |grep 'tcp' |grep "${user_port}" | grep '::ffff:' |awk '{print $5}' |awk -F ":" '{print $4}' |sort -u`
if [[ -z ${user_IP} ]]; then
user_IP_1=`netstat -anp |grep 'ESTABLISHED' |grep 'python' |grep 'tcp' |grep "${user_port}" | grep '::ffff:' |awk '{print $5}' |awk -F ":" '{print $4}' |sort -u`
if [[ -z ${user_IP_1} ]]; then
user_IP_total="0"
else
user_IP_total=`echo -e "${user_IP}"|wc -l`
user_IP=`echo ${user_IP}|sed 's/ / | /g'`
user_IP_total=`echo -e "${user_IP_1}"|wc -l`
if [[ ${format_1} == "IP_address" ]]; then
get_IP_address
else
user_IP=`echo -e "\n${user_IP_1}"`
fi
fi
user_list_all="端口: ${Green_font_prefix}"${user_port}"${Font_color_suffix}, 链接IP总数: ${Green_font_prefix}"${user_IP_total}"${Font_color_suffix}, 当前链接IP: ${Green_font_prefix}"${user_IP}"${Font_color_suffix}\n"
user_list_all="端口: ${Green_font_prefix}"${user_port}"${Font_color_suffix}, 链接IP总数: ${Green_font_prefix}"${user_IP_total}"${Font_color_suffix}, 当前链接IP: ${Green_font_prefix}${user_IP}${Font_color_suffix}\n"
user_IP=""
echo -e "当前模式: ${Green_background_prefix} "${now_mode}" ${Font_color_suffix},链接IP总数: ${Green_background_prefix} "${IP_total}" ${Font_color_suffix}"
echo -e ${user_list_all}
echo -e "${user_list_all}"
else
now_mode="多端口" && user_total=`${jq_file} '.port_password' ${config_user_file} |sed '$d;1d' | wc -l`
IP_total=`netstat -anp |grep 'ESTABLISHED' |grep 'python' |grep 'tcp' | grep '::ffff:' |awk '{print $5}' |awk -F ":" '{print $4}' |sort -u |wc -l`
user_list_all=""
for((integer = 1; integer <= ${user_total}; integer++))
do
user_port=`${jq_file} '.port_password' ${config_user_file} |sed '$d;1d' |awk -F ":" '{print $1}' |sed -n "${integer}p" |sed -r 's/.*\"(.+)\".*/\1/'`
user_IP=`netstat -anp |grep 'ESTABLISHED' |grep 'python' |grep 'tcp' |grep "${user_port}"|grep '::ffff:' |awk '{print $5}' |awk -F ":" '{print $4}' |sort -u`
if [[ -z ${user_IP} ]]; then
user_IP_1=`netstat -anp |grep 'ESTABLISHED' |grep 'python' |grep 'tcp' |grep "${user_port}"|grep '::ffff:' |awk '{print $5}' |awk -F ":" '{print $4}' |sort -u`
if [[ -z ${user_IP_1} ]]; then
user_IP_total="0"
else
user_IP_total=`echo -e "${user_IP}"|wc -l`
user_IP=`echo ${user_IP}|sed 's/ / | /g'`
user_IP_total=`echo -e "${user_IP_1}"|wc -l`
if [[ ${format_1} == "IP_address" ]]; then
get_IP_address
else
user_IP=`echo -e "\n${user_IP_1}"`
fi
fi
user_list_all=${user_list_all}"端口: ${Green_font_prefix}"${user_port}"${Font_color_suffix}, 链接IP总数: ${Green_font_prefix}"${user_IP_total}"${Font_color_suffix}, 当前链接IP: ${Green_font_prefix}"${user_IP}"${Font_color_suffix}\n"
user_list_all=${user_list_all}"端口: ${Green_font_prefix}"${user_port}"${Font_color_suffix}, 链接IP总数: ${Green_font_prefix}"${user_IP_total}"${Font_color_suffix}, 当前链接IP: ${Green_font_prefix}${user_IP}${Font_color_suffix}\n"
user_IP=""
done
echo -e "当前模式: ${Green_background_prefix} "${now_mode}" ${Font_color_suffix} ,用户总数: ${Green_background_prefix} "${user_total}" ${Font_color_suffix} ,链接IP总数: ${Green_background_prefix} "${IP_total}" ${Font_color_suffix} "
echo -e ${user_list_all}
echo -e "${user_list_all}"
fi
}
View_user_connection_info(){
SSR_installation_status
echo && echo -e "请选择要显示的格式:
${Green_font_prefix}1.${Font_color_suffix} 显示 IP 格式
${Green_font_prefix}2.${Font_color_suffix} 显示 IP+IP归属地 格式" && echo
stty erase '^H' && read -p "(默认: 1):" ssr_connection_info
[[ -z "${ssr_connection_info}" ]] && ssr_connection_info="1"
if [[ ${ssr_connection_info} == "1" ]]; then
View_user_connection_info_1 ""
elif [[ ${ssr_connection_info} == "2" ]]; then
echo -e "${Tip} 检测IP归属地(ipip.net),如果IP较多,可能时间会比较长..."
View_user_connection_info_1 "IP_address"
else
echo -e "${Error} 请输入正确的数字(1-2)" && exit 1
fi
}
View_user_connection_info_1(){
format=$1
if [[ ${release} = "centos" ]]; then
cat /etc/redhat-release |grep 7\..*|grep -i centos>/dev/null
if [[ $? = 0 ]]; then
debian_View_user_connection_info
debian_View_user_connection_info "$format"
else
centos_View_user_connection_info
centos_View_user_connection_info "$format"
fi
else
debian_View_user_connection_info
debian_View_user_connection_info "$format"
fi
}
get_IP_address(){
#echo "user_IP_1=${user_IP_1}"
if [[ ! -z ${user_IP_1} ]]; then
#echo "user_IP_total=${user_IP_total}"
for((integer_1 = ${user_IP_total}; integer_1 >= 1; integer_1--))
do
IP=`echo "${user_IP_1}" |sed -n "$integer_1"p`
#echo "IP=${IP}"
IP_address=`wget -qO- -t1 -T2 http://freeapi.ipip.net/${IP}|sed 's/\"//g;s/,//g;s/\[//g;s/\]//g'`
#echo "IP_address=${IP_address}"
user_IP="${user_IP}\n${IP}(${IP_address})"
#echo "user_IP=${user_IP}"
sleep 1s
done
fi
}
# 修改 用户配置
Expand Down Expand Up @@ -858,16 +912,16 @@ Modify_Config(){
fi
else
echo && echo -e "当前模式: 多端口,你要做什么?
${Green_font_prefix}1.${Font_color_suffix} 添加 用户配置
${Green_font_prefix}2.${Font_color_suffix} 删除 用户配置
${Green_font_prefix}3.${Font_color_suffix} 修改 用户配置
${Green_font_prefix}1.${Font_color_suffix} 添加 用户配置
${Green_font_prefix}2.${Font_color_suffix} 删除 用户配置
${Green_font_prefix}3.${Font_color_suffix} 修改 用户配置
——————————
${Green_font_prefix}4.${Font_color_suffix} 修改 加密方式
${Green_font_prefix}5.${Font_color_suffix} 修改 协议插件
${Green_font_prefix}6.${Font_color_suffix} 修改 混淆插件
${Green_font_prefix}7.${Font_color_suffix} 修改 设备数限制
${Green_font_prefix}8.${Font_color_suffix} 修改 单线程限速
${Green_font_prefix}9.${Font_color_suffix} 修改 端口总限速
${Green_font_prefix}4.${Font_color_suffix} 修改 加密方式
${Green_font_prefix}5.${Font_color_suffix} 修改 协议插件
${Green_font_prefix}6.${Font_color_suffix} 修改 混淆插件
${Green_font_prefix}7.${Font_color_suffix} 修改 设备数限制
${Green_font_prefix}8.${Font_color_suffix} 修改 单线程限速
${Green_font_prefix}9.${Font_color_suffix} 修改 端口总限速
${Green_font_prefix}10.${Font_color_suffix} 修改 全部配置" && echo
stty erase '^H' && read -p "(默认: 取消):" ssr_modify
[[ -z "${ssr_modify}" ]] && echo "已取消..." && exit 1
Expand Down

0 comments on commit 56bc90f

Please sign in to comment.