Update comments

Enable TCP fast open when Linux kernel > 3.7.0

Signed-off-by: Teddysun <i@teddysun.com>
This commit is contained in:
Teddysun 2017-11-25 20:34:57 +09:00
parent 8bed846b65
commit 2da9d0fa34
No known key found for this signature in database
GPG Key ID: 09BD4C080AD6C46D

View File

@ -204,6 +204,19 @@ version_ge(){
test "$(echo "$@" | tr " " "\n" | sort -rV | head -n 1)" == "$1" test "$(echo "$@" | tr " " "\n" | sort -rV | head -n 1)" == "$1"
} }
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
}
getversion() { getversion() {
if [[ -s /etc/redhat-release ]]; then if [[ -s /etc/redhat-release ]]; then
grep -oE "[0-9.]+" /etc/redhat-release grep -oE "[0-9.]+" /etc/redhat-release
@ -399,6 +412,13 @@ config_firewall() {
} }
config_shadowsocks() { config_shadowsocks() {
if check_kernel_version; then
fast_open="true"
else
fast_open="false"
fi
if [ "${selected}" == "1" ]; then if [ "${selected}" == "1" ]; then
if [ ! -d "$(dirname ${shadowsocks_python_config})" ]; then if [ ! -d "$(dirname ${shadowsocks_python_config})" ]; then
mkdir -p $(dirname ${shadowsocks_python_config}) mkdir -p $(dirname ${shadowsocks_python_config})
@ -412,7 +432,7 @@ if [ "${selected}" == "1" ]; then
"password":"${shadowsockspwd}", "password":"${shadowsockspwd}",
"timeout":300, "timeout":300,
"method":"${shadowsockscipher}", "method":"${shadowsockscipher}",
"fast_open":false "fast_open":${fast_open}
} }
EOF EOF
elif [ "${selected}" == "2" ]; then elif [ "${selected}" == "2" ]; then
@ -435,7 +455,7 @@ elif [ "${selected}" == "2" ]; then
"obfs_param":"", "obfs_param":"",
"redirect":"", "redirect":"",
"dns_ipv6":false, "dns_ipv6":false,
"fast_open":false, "fast_open":${fast_open},
"workers":1 "workers":1
} }
EOF EOF
@ -473,6 +493,7 @@ elif [ "${selected}" == "4" ]; then
"password":"${shadowsockspwd}", "password":"${shadowsockspwd}",
"timeout":300, "timeout":300,
"method":"${shadowsockscipher}", "method":"${shadowsockscipher}",
"fast_open":${fast_open},
"plugin":"obfs-server --obfs ${shadowsocklibev_obfs}" "plugin":"obfs-server --obfs ${shadowsocklibev_obfs}"
} }
EOF EOF
@ -485,7 +506,8 @@ EOF
"local_port":1080, "local_port":1080,
"password":"${shadowsockspwd}", "password":"${shadowsockspwd}",
"timeout":300, "timeout":300,
"method":"${shadowsockscipher}" "method":"${shadowsockscipher}",
"fast_open":${fast_open}
} }
EOF EOF
fi fi