Enabled TCP fast open when Linux kernel > 3.7.0

Signed-off-by: Teddysun <i@teddysun.com>
This commit is contained in:
Teddysun 2018-06-01 21:49:46 +09:00
parent 65ec894195
commit 15b14181c7
No known key found for this signature in database
GPG Key ID: 09BD4C080AD6C46D
2 changed files with 42 additions and 20 deletions

View File

@ -177,6 +177,19 @@ check_sys(){
fi
}
version_gt(){
test "$(echo "$@" | tr " " "\n" | sort -V | head -n 1)" != "$1"
}
check_kernel_version() {
local kernel_version=$(uname -r | cut -d- -f1)
if version_gt ${kernel_version} 3.7.0; then
return 0
else
return 1
fi
}
debianversion(){
if check_sys sysRelease debian;then
local version=$( get_opsy )
@ -355,6 +368,12 @@ config_shadowsocks(){
server_value="[\"[::0]\",\"0.0.0.0\"]"
fi
if check_kernel_version; then
fast_open="true"
else
fast_open="false"
fi
if [ ! -d /etc/shadowsocks-libev ]; then
mkdir -p /etc/shadowsocks-libev
fi
@ -365,7 +384,8 @@ config_shadowsocks(){
"local_port":1080,
"password":"${shadowsockspwd}",
"timeout":600,
"method":"${shadowsockscipher}"
"method":"${shadowsockscipher}",
"fast_open":${fast_open}
}
EOF
}

View File

@ -171,6 +171,19 @@ check_sys(){
fi
}
version_gt(){
test "$(echo "$@" | tr " " "\n" | sort -V | head -n 1)" != "$1"
}
check_kernel_version() {
local kernel_version=$(uname -r | cut -d- -f1)
if version_gt ${kernel_version} 3.7.0; then
return 0
else
return 1
fi
}
# Get version
getversion(){
if [[ -s /etc/redhat-release ]]; then
@ -196,24 +209,6 @@ centosversion(){
fi
}
version_ge(){
test "$(echo "$@" | tr " " "\n" | sort -rV | head -n 1)" == "$1"
}
# autoconf version
autoconfversion(){
if [ "$(command -v "autoconf")" ]; then
local version=$(autoconf --version | grep autoconf | awk '{print $4}')
if version_ge ${version} 2.67; then
return 0
else
return 1
fi
else
return 1
fi
}
# Pre-installation settings
pre_install(){
# Check OS system
@ -390,6 +385,12 @@ config_shadowsocks(){
server_value="[\"[::0]\",\"0.0.0.0\"]"
fi
if check_kernel_version; then
fast_open="true"
else
fast_open="false"
fi
if [ ! -d /etc/shadowsocks-libev ]; then
mkdir -p /etc/shadowsocks-libev
fi
@ -400,7 +401,8 @@ config_shadowsocks(){
"local_port":1080,
"password":"${shadowsockspwd}",
"timeout":600,
"method":"${shadowsockscipher}"
"method":"${shadowsockscipher}",
"fast_open":${fast_open}
}
EOF
}