update bbr check

pull/242/head
233boy 6 years ago
parent 4555f1ad9a
commit aacf1cf7ab
  1. 25
      install.sh
  2. 20
      src/bbr.sh
  3. 6
      src/init.sh
  4. 25
      v2ray.sh

@ -6,6 +6,11 @@ yellow='\e[93m'
magenta='\e[95m' magenta='\e[95m'
cyan='\e[96m' cyan='\e[96m'
none='\e[0m' none='\e[0m'
_red() { echo -e ${red}$*${none}; }
_green() { echo -e ${green}$*${none}; }
_yellow() { echo -e ${yellow}$*${none}; }
_magenta() { echo -e ${magenta}$*${none}; }
_cyan() { echo -e ${cyan}$*${none}; }
# Root # Root
[[ $(id -u) != 0 ]] && echo -e "\n 哎呀……请使用 ${red}root ${none}用户运行 ${yellow}~(^_^) ${none}\n" && exit 1 [[ $(id -u) != 0 ]] && echo -e "\n 哎呀……请使用 ${red}root ${none}用户运行 ${yellow}~(^_^) ${none}\n" && exit 1
@ -907,20 +912,6 @@ backup_config() {
fi fi
} }
try_enable_bbr() {
if [[ $(uname -r | cut -b 1) -eq 4 ]]; then
case $(uname -r | cut -b 3-4) in
9. | [1-9][0-9])
sed -i '/net.ipv4.tcp_congestion_control/d' /etc/sysctl.conf
sed -i '/net.core.default_qdisc/d' /etc/sysctl.conf
echo "net.ipv4.tcp_congestion_control = bbr" >>/etc/sysctl.conf
echo "net.core.default_qdisc = fq" >>/etc/sysctl.conf
sysctl -p >/dev/null 2>&1
;;
esac
fi
}
get_ip() { get_ip() {
ip=$(curl -s https://ipinfo.io/ip) ip=$(curl -s https://ipinfo.io/ip)
[[ -z $ip ]] && ip=$(curl -s https://api.ip.sb/ip) [[ -z $ip ]] && ip=$(curl -s https://api.ip.sb/ip)
@ -980,7 +971,6 @@ install() {
blocked_hosts blocked_hosts
shadowsocks_config shadowsocks_config
install_info install_info
try_enable_bbr
# [[ $caddy ]] && domain_check # [[ $caddy ]] && domain_check
install_v2ray install_v2ray
if [[ $caddy || $v2ray_port == "80" ]]; then if [[ $caddy || $v2ray_port == "80" ]]; then
@ -993,6 +983,11 @@ install() {
fi fi
fi fi
[[ $caddy ]] && install_caddy [[ $caddy ]] && install_caddy
## bbr
_load bbr.sh
_try_enable_bbr
get_ip get_ip
config config
show_config_info show_config_info

@ -0,0 +1,20 @@
_open_bbr() {
sed -i '/net.ipv4.tcp_congestion_control/d' /etc/sysctl.conf
sed -i '/net.core.default_qdisc/d' /etc/sysctl.conf
echo "net.ipv4.tcp_congestion_control = bbr" >>/etc/sysctl.conf
echo "net.core.default_qdisc = fq" >>/etc/sysctl.conf
sysctl -p >/dev/null 2>&1
echo
_green "..由于你的 VPS 内核支持开启 BBR ...已经为你启用 BBR 优化...."
echo
}
_try_enable_bbr() {
local _test1=$(uname -r | cut -d\. -f1)
local _test2=$(uname -r | cut -d\. -f2)
if [[ $_test1 -eq 4 && $_test2 -ge 9 ]] || [[ $_test1 -ge 5 ]]; then
_open_bbr
enable_bbr=true
fi
}

@ -1,3 +1,9 @@
_red() { echo -e ${red}$*${none}; }
_green() { echo -e ${green}$*${none}; }
_yellow() { echo -e ${yellow}$*${none}; }
_magenta() { echo -e ${magenta}$*${none}; }
_cyan() { echo -e ${cyan}$*${none}; }
_rm() { _rm() {
rm -rf "$@" rm -rf "$@"
} }

@ -2293,33 +2293,14 @@ other() {
install_bbr() { install_bbr() {
local test1=$(sed -n '/net.ipv4.tcp_congestion_control/p' /etc/sysctl.conf) local test1=$(sed -n '/net.ipv4.tcp_congestion_control/p' /etc/sysctl.conf)
local test2=$(sed -n '/net.core.default_qdisc/p' /etc/sysctl.conf) local test2=$(sed -n '/net.core.default_qdisc/p' /etc/sysctl.conf)
if [[ $(uname -r | cut -b 1) -eq 4 ]]; then
case $(uname -r | cut -b 3-4) in
9. | [1-9][0-9])
if [[ $test1 == "net.ipv4.tcp_congestion_control = bbr" && $test2 == "net.core.default_qdisc = fq" ]]; then if [[ $test1 == "net.ipv4.tcp_congestion_control = bbr" && $test2 == "net.core.default_qdisc = fq" ]]; then
local is_bbr=true
else
local try_enable_bbr=true
fi
;;
esac
fi
if [[ $is_bbr ]]; then
echo echo
echo -e "$green BBR 已经启用啦...无需再安装$none" echo -e "$green BBR 已经启用啦...无需再安装$none"
echo echo
elif [[ $try_enable_bbr ]]; then
sed -i '/net.ipv4.tcp_congestion_control/d' /etc/sysctl.conf
sed -i '/net.core.default_qdisc/d' /etc/sysctl.conf
echo "net.ipv4.tcp_congestion_control = bbr" >>/etc/sysctl.conf
echo "net.core.default_qdisc = fq" >>/etc/sysctl.conf
sysctl -p >/dev/null 2>&1
echo
echo -e "$green ..由于你的 VPS 内核支持开启 BBR ...已经为你启用 BBR 优化....$none"
echo
else else
# https://teddysun.com/489.html _load bbr.sh
bash <(curl -s -L https://github.com/teddysun/across/raw/master/bbr.sh) _try_enable_bbr
[[ ! $enable_bbr ]] && bash <(curl -s -L https://github.com/teddysun/across/raw/master/bbr.sh)
fi fi
} }
install_lotserver() { install_lotserver() {

Loading…
Cancel
Save