Skip to content

Commit

Permalink
use random ports and fix bug
Browse files Browse the repository at this point in the history
  • Loading branch information
233boy committed Apr 4, 2018
1 parent b0f14a4 commit a7df96d
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 35 deletions.
43 changes: 22 additions & 21 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -114,12 +114,13 @@ v2ray_config() {
}
v2ray_port_config() {
if [[ $v2ray_transport_opt -ne 4 && $v2ray_transport_opt -lt 9 ]]; then
local random=$(shuf -i20001-65535 -n1)
while :; do
echo -e "请输入 "$yellow"V2Ray"$none" 端口 ["$magenta"1-65535"$none"]"
read -p "$(echo -e "(默认端口: ${cyan}2333$none):")" v2ray_port
[ -z "$v2ray_port" ] && v2ray_port="2333"
read -p "$(echo -e "(默认端口: ${cyan}${random}$none):")" v2ray_port
[ -z "$v2ray_port" ] && v2ray_port=$random
case $v2ray_port in
[1-9] | [1-9][0-9] | [1-9][0-9][0-9] | [1-9][0-9][0-9][0-9] | [1-5][0-9][0-9][0-9][0-9] | [1-6][0-5][0-5][0-3][0-5])
[1-9] | [1-9][0-9] | [1-9][0-9][0-9] | [1-9][0-9][0-9][0-9] | [1-5][0-9][0-9][0-9][0-9] | 6[0-4][0-9][0-9][0-9] | 65[0-4][0-9][0-9] | 655[0-3][0-5])
echo
echo
echo -e "$yellow V2Ray 端口 = $cyan$v2ray_port$none"
Expand Down Expand Up @@ -147,13 +148,13 @@ v2ray_port_config() {
v2ray_dynamic_port_config() {

echo

local random=$(shuf -i20001-65535 -n1)
while :; do
echo -e "请输入 "$yellow"V2Ray"$none" 端口 ["$magenta"1-65535"$none"]"
read -p "$(echo -e "(默认端口: ${cyan}2333$none):")" v2ray_port
[ -z "$v2ray_port" ] && v2ray_port="2333"
read -p "$(echo -e "(默认端口: ${cyan}${random}$none):")" v2ray_port
[ -z "$v2ray_port" ] && v2ray_port=$random
case $v2ray_port in
[1-9] | [1-9][0-9] | [1-9][0-9][0-9] | [1-9][0-9][0-9][0-9] | [1-5][0-9][0-9][0-9][0-9] | [1-6][0-5][0-5][0-3][0-5])
[1-9] | [1-9][0-9] | [1-9][0-9][0-9] | [1-9][0-9][0-9][0-9] | [1-5][0-9][0-9][0-9][0-9] | 6[0-4][0-9][0-9][0-9] | 65[0-4][0-9][0-9] | 655[0-3][0-5])
echo
echo
echo -e "$yellow V2Ray 端口 = $cyan$v2ray_port$none"
Expand Down Expand Up @@ -182,7 +183,7 @@ v2ray_dynamic_port_start() {
echo " 不能和 V2Ray 端口一毛一样...."
error
;;
[1-9] | [1-9][0-9] | [1-9][0-9][0-9] | [1-9][0-9][0-9][0-9] | [1-5][0-9][0-9][0-9][0-9] | [1-6][0-5][0-5][0-3][0-5])
[1-9] | [1-9][0-9] | [1-9][0-9][0-9] | [1-9][0-9][0-9][0-9] | [1-5][0-9][0-9][0-9][0-9] | 6[0-4][0-9][0-9][0-9] | 65[0-4][0-9][0-9] | 655[0-3][0-5])
echo
echo
echo -e "$yellow V2Ray 动态端口开始 = $cyan$v2ray_dynamic_port_start_input$none"
Expand Down Expand Up @@ -210,7 +211,7 @@ v2ray_dynamic_port_end() {
read -p "$(echo -e "(默认结束端口: ${cyan}20000$none):")" v2ray_dynamic_port_end_input
[ -z $v2ray_dynamic_port_end_input ] && v2ray_dynamic_port_end_input=20000
case $v2ray_dynamic_port_end_input in
[1-9] | [1-9][0-9] | [1-9][0-9][0-9] | [1-9][0-9][0-9][0-9] | [1-5][0-9][0-9][0-9][0-9] | [1-6][0-5][0-5][0-3][0-5])
[1-9] | [1-9][0-9] | [1-9][0-9][0-9] | [1-9][0-9][0-9][0-9] | [1-5][0-9][0-9][0-9][0-9] | 6[0-4][0-9][0-9][0-9] | 65[0-4][0-9][0-9] | 655[0-3][0-5])

if [[ $v2ray_dynamic_port_end_input -le $v2ray_dynamic_port_start_input ]]; then
echo
Expand Down Expand Up @@ -241,11 +242,11 @@ v2ray_dynamic_port_end() {
ws_config() {

echo

local random=$(shuf -i20001-65535 -n1)
while :; do
echo -e "请输入 "$yellow"V2Ray"$none" 端口 ["$magenta"1-65535"$none"],不能选择 "$magenta"80"$none""$magenta"443"$none" 端口"
read -p "$(echo -e "(默认端口: ${cyan}2333$none):")" v2ray_port
[ -z "$v2ray_port" ] && v2ray_port="2333"
read -p "$(echo -e "(默认端口: ${cyan}${random}$none):")" v2ray_port
[ -z "$v2ray_port" ] && v2ray_port=$random
case $v2ray_port in
80)
echo
Expand All @@ -257,7 +258,7 @@ ws_config() {
echo " ..都说了不能选择 433 端口了咯....."
error
;;
[1-9] | [1-9][0-9] | [1-9][0-9][0-9] | [1-9][0-9][0-9][0-9] | [1-5][0-9][0-9][0-9][0-9] | [1-6][0-5][0-5][0-3][0-5])
[1-9] | [1-9][0-9] | [1-9][0-9][0-9] | [1-9][0-9][0-9][0-9] | [1-5][0-9][0-9][0-9][0-9] | 6[0-4][0-9][0-9][0-9] | 65[0-4][0-9][0-9] | 655[0-3][0-5])
echo
echo
echo -e "$yellow V2Ray 端口 = $cyan$v2ray_port$none"
Expand Down Expand Up @@ -492,17 +493,18 @@ shadowsocks_config() {
}

shadowsocks_port_config() {
local random=$(shuf -i20001-65535 -n1)
while :; do
echo -e "请输入 "$yellow"Shadowsocks"$none" 端口 ["$magenta"1-65535"$none"],不能和 "$yellow"V2Ray"$none" 端口相同"
read -p "$(echo -e "(默认端口: ${cyan}6666$none):") " ssport
[ -z "$ssport" ] && ssport="6666"
read -p "$(echo -e "(默认端口: ${cyan}${random}$none):") " ssport
[ -z "$ssport" ] && ssport=$random
case $ssport in
$v2ray_port)
echo
echo " 不能和 V2Ray 端口一毛一样...."
error
;;
[1-9] | [1-9][0-9] | [1-9][0-9][0-9] | [1-9][0-9][0-9][0-9] | [1-5][0-9][0-9][0-9][0-9] | [1-6][0-5][0-5][0-3][0-5])
[1-9] | [1-9][0-9] | [1-9][0-9][0-9] | [1-9][0-9][0-9][0-9] | [1-5][0-9][0-9][0-9][0-9] | 6[0-4][0-9][0-9][0-9] | 65[0-4][0-9][0-9] | 655[0-3][0-5])
if [[ $v2ray_transport_opt == "4" && $ssport == "80" ]] || [[ $v2ray_transport_opt == "4" && $ssport == "443" ]]; then
echo
echo -e "由于你选择了 "$green"WebSocket + TLS"$none" 传输协议."
Expand Down Expand Up @@ -825,7 +827,6 @@ install_v2ray() {

rm -rf /tmp/v2ray


if [ $shadowsocks ]; then
if [[ $is_blocked_ad ]]; then
case $v2ray_transport_opt in
Expand Down Expand Up @@ -1021,8 +1022,8 @@ open_port() {
iptables-save >/etc/iptables.rules.v4
ip6tables-save >/etc/iptables.rules.v6
else
service iptables save
service ip6tables save
service iptables save >/dev/null 2>&1
service ip6tables save >/dev/null 2>&1
fi
}
del_port() {
Expand Down Expand Up @@ -1058,8 +1059,8 @@ del_port() {
iptables-save >/etc/iptables.rules.v4
ip6tables-save >/etc/iptables.rules.v6
else
service iptables save
service ip6tables save
service iptables save >/dev/null 2>&1
service ip6tables save >/dev/null 2>&1
fi

}
Expand Down
29 changes: 15 additions & 14 deletions v2ray.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ none='\e[0m'
# Root
[[ $(id -u) != 0 ]] && echo -e " 哎呀……请使用 ${red}root ${none}用户运行 ${yellow}~(^_^) ${none}" && exit 1

_version="v1.58"
_version="v1.60"

cmd="apt-get"

Expand Down Expand Up @@ -477,17 +477,18 @@ shadowsocks_config() {
done
}
shadowsocks_port_config() {
local random=$(shuf -i20001-65535 -n1)
while :; do
echo -e "请输入 "$yellow"Shadowsocks"$none" 端口 ["$magenta"1-65535"$none"],不能和 "$yellow"V2ray"$none" 端口相同"
read -p "$(echo -e "(默认端口: ${cyan}6666$none):") " new_ssport
[ -z "$new_ssport" ] && new_ssport="6666"
read -p "$(echo -e "(默认端口: ${cyan}${random}$none):") " new_ssport
[ -z "$new_ssport" ] && new_ssport=$random
case $new_ssport in
$v2ray_port)
echo
echo -e " 不能和$cyan V2Ray 端口 $none一毛一样...."
error
;;
[1-9] | [1-9][0-9] | [1-9][0-9][0-9] | [1-9][0-9][0-9][0-9] | [1-5][0-9][0-9][0-9][0-9] | [1-6][0-5][0-5][0-3][0-5])
[1-9] | [1-9][0-9] | [1-9][0-9][0-9] | [1-9][0-9][0-9][0-9] | [1-5][0-9][0-9][0-9][0-9] | 6[0-4][0-9][0-9][0-9] | 65[0-4][0-9][0-9] | 655[0-3][0-5])
if [[ $v2ray_transport == "4" && $new_ssport == "80" ]] || [[ $v2ray_transport == "4" && $new_ssport == "443" ]]; then
echo
echo -e "由于你选择了 "$green"WebSocket + TLS"$none" 传输协议."
Expand Down Expand Up @@ -596,7 +597,7 @@ change_shadowsocks_port() {
echo -e " 不能和$cyan V2Ray 端口 $none一毛一样...."
error
;;
[1-9] | [1-9][0-9] | [1-9][0-9][0-9] | [1-9][0-9][0-9][0-9] | [1-5][0-9][0-9][0-9][0-9] | [1-6][0-5][0-5][0-3][0-5])
[1-9] | [1-9][0-9] | [1-9][0-9][0-9] | [1-9][0-9][0-9][0-9] | [1-5][0-9][0-9][0-9][0-9] | 6[0-4][0-9][0-9][0-9] | 65[0-4][0-9][0-9] | 655[0-3][0-5])
if [[ $v2ray_transport == "4" && $new_ssport == "80" ]] || [[ $v2ray_transport == "4" && $new_ssport == "443" ]]; then
echo
echo -e "由于你选择了 "$green"WebSocket + TLS"$none" 传输协议."
Expand Down Expand Up @@ -844,7 +845,7 @@ change_v2ray_port() {
echo " 哎呀...跟当前端口一毛一样呀...修改个鸡鸡哦"
error
;;
[1-9] | [1-9][0-9] | [1-9][0-9][0-9] | [1-9][0-9][0-9][0-9] | [1-5][0-9][0-9][0-9][0-9] | [1-6][0-5][0-5][0-3][0-5])
[1-9] | [1-9][0-9] | [1-9][0-9][0-9] | [1-9][0-9][0-9][0-9] | [1-5][0-9][0-9][0-9][0-9] | 6[0-4][0-9][0-9][0-9] | 65[0-4][0-9][0-9] | 655[0-3][0-5])
if [[ $shadowsocks ]] && [[ $v2ray_port_opt == $ssport ]]; then
echo
echo -e " ...不能跟$cyan Shadowsocks 端口 $none一毛一样..."
Expand Down Expand Up @@ -1385,7 +1386,7 @@ v2ray_dynamic_port_start() {
echo " 不能和 V2Ray 端口一毛一样...."
error
;;
[1-9] | [1-9][0-9] | [1-9][0-9][0-9] | [1-9][0-9][0-9][0-9] | [1-5][0-9][0-9][0-9][0-9] | [1-6][0-5][0-5][0-3][0-5])
[1-9] | [1-9][0-9] | [1-9][0-9][0-9] | [1-9][0-9][0-9][0-9] | [1-5][0-9][0-9][0-9][0-9] | 6[0-4][0-9][0-9][0-9] | 65[0-4][0-9][0-9] | 655[0-3][0-5])
if [[ $shadowsocks ]] && [[ $v2ray_dynamic_port_start_input == $ssport ]]; then
echo
echo " 不能和 Shadowsocks 端口一毛一样...."
Expand Down Expand Up @@ -1423,7 +1424,7 @@ v2ray_dynamic_port_end() {
read -p "$(echo -e "(默认结束端口: ${cyan}20000$none):")" v2ray_dynamic_port_end_input
[ -z $v2ray_dynamic_port_end_input ] && v2ray_dynamic_port_end_input=20000
case $v2ray_dynamic_port_end_input in
[1-9] | [1-9][0-9] | [1-9][0-9][0-9] | [1-9][0-9][0-9][0-9] | [1-5][0-9][0-9][0-9][0-9] | [1-6][0-5][0-5][0-3][0-5])
[1-9] | [1-9][0-9] | [1-9][0-9][0-9] | [1-9][0-9][0-9][0-9] | [1-5][0-9][0-9][0-9][0-9] | 6[0-4][0-9][0-9][0-9] | 65[0-4][0-9][0-9] | 655[0-3][0-5])

if [[ $v2ray_dynamic_port_end_input -le $v2ray_dynamic_port_start_input ]]; then
echo
Expand Down Expand Up @@ -1514,7 +1515,7 @@ change_v2ray_dynamic_port_start() {
echo " 不能和 V2Ray 端口一毛一样...."
error
;;
[1-9] | [1-9][0-9] | [1-9][0-9][0-9] | [1-9][0-9][0-9][0-9] | [1-5][0-9][0-9][0-9][0-9] | [1-6][0-5][0-5][0-3][0-5])
[1-9] | [1-9][0-9] | [1-9][0-9][0-9] | [1-9][0-9][0-9][0-9] | [1-5][0-9][0-9][0-9][0-9] | 6[0-4][0-9][0-9][0-9] | 65[0-4][0-9][0-9] | 655[0-3][0-5])
if [[ $shadowsocks ]] && [[ $v2ray_dynamic_port_start_input == $ssport ]]; then
echo
echo " 不能和 Shadowsocks 端口一毛一样...."
Expand Down Expand Up @@ -1552,7 +1553,7 @@ change_v2ray_dynamic_port_end() {
read -p "$(echo -e "(当前动态结束端口: ${cyan}$v2ray_dynamicPort_end$none):")" v2ray_dynamic_port_end_input
[ -z $v2ray_dynamic_port_end_input ] && error && continue
case $v2ray_dynamic_port_end_input in
[1-9] | [1-9][0-9] | [1-9][0-9][0-9] | [1-9][0-9][0-9][0-9] | [1-5][0-9][0-9][0-9][0-9] | [1-6][0-5][0-5][0-3][0-5])
[1-9] | [1-9][0-9] | [1-9][0-9][0-9] | [1-9][0-9][0-9][0-9] | [1-5][0-9][0-9][0-9][0-9] | 6[0-4][0-9][0-9][0-9] | 65[0-4][0-9][0-9] | 655[0-3][0-5])

if [[ $v2ray_dynamic_port_end_input -le $v2ray_dynamic_port_start_input ]]; then
echo
Expand Down Expand Up @@ -2496,8 +2497,8 @@ open_port() {
iptables-save >/etc/iptables.rules.v4
ip6tables-save >/etc/iptables.rules.v6
else
service iptables save
service ip6tables save
service iptables save >/dev/null 2>&1
service ip6tables save >/dev/null 2>&1
fi

}
Expand Down Expand Up @@ -2529,8 +2530,8 @@ del_port() {
iptables-save >/etc/iptables.rules.v4
ip6tables-save >/etc/iptables.rules.v6
else
service iptables save
service ip6tables save
service iptables save >/dev/null 2>&1
service ip6tables save >/dev/null 2>&1
fi
}
update() {
Expand Down

0 comments on commit a7df96d

Please sign in to comment.