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