complexorganizations/shadowsocks-manager

Optimize #13

Prajwal-Koirala posted onGitHub

SHADOWSOCKS_TCP_BBR_PATH="/etc/sysctl.conf"

    function sysctl-install() {
        if [ -f "${SHADOWSOCKS_TCP_BBR_PATH}" ]; then
            rm -f ${SHADOWSOCKS_TCP_BBR_PATH}
        fi
        if [ ! -f "${SHADOWSOCKS_TCP_BBR_PATH}" ]; then
            echo \
            "fs.file-max = 51200
net.core.rmem_max = 67108864
net.core.wmem_max = 67108864
net.core.netdev_max_backlog = 250000
net.core.somaxconn = 4096
net.ipv4.tcp_syncookies = 1
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_fin_timeout = 30
net.ipv4.tcp_keepalive_time = 1200
net.ipv4.ip_local_port_range = 10000 65000
net.ipv4.tcp_max_syn_backlog = 8192
net.ipv4.tcp_max_tw_buckets = 5000
net.ipv4.tcp_fastopen = 3
net.ipv4.tcp_mem = 25600 51200 102400
net.ipv4.tcp_rmem = 4096 87380 67108864
net.ipv4.tcp_wmem = 4096 65536 67108864
net.ipv4.tcp_mtu_probing = 1
net.ipv4.tcp_congestion_control = hybla" \
            >>"${SHADOWSOCKS_TCP_BBR_PATH}"
            sysctl -p "${SHADOWSOCKS_TCP_BBR_PATH}"
        fi
        if [ -f "${SYSTEM_LIMITS}" ]; then
            rm -f ${SYSTEM_LIMITS}
        fi
        if [ ! -f "${SYSTEM_LIMITS}" ]; then
            echo "* soft nofile 51200
* hard nofile 51200
root soft nofile 51200
root hard nofile 51200" >>${SYSTEM_LIMITS}
            sysctl -p "${SYSTEM_LIMITS}"
        fi
    }

    sysctl-install

    function install-bbr() {
        if [ "${MODE_CHOICE}" == "tcp_only" ]; then
            read -rp "Do You Want To Install TCP bbr (y/n): " -n 1 -r
            if [[ $REPLY =~ ^[Yy]$ ]]; then
                KERNEL_VERSION_LIMIT=4.1
                KERNEL_CURRENT_VERSION=$(uname -r | cut -c1-3)
                if (($(echo "${KERNEL_CURRENT_VERSION} >= ${KERNEL_VERSION_LIMIT}" | bc -l))); then
                    if [ -f "${SHADOWSOCKS_TCP_BBR_PATH}" ]; then
                        rm -f ${SHADOWSOCKS_TCP_BBR_PATH}
                    fi
                    if [ ! -f "${SHADOWSOCKS_TCP_BBR_PATH}" ]; then
                        echo "net.core.default_qdisc=fq" >>"${SHADOWSOCKS_TCP_BBR_PATH}"
                        echo "net.ipv4.tcp_congestion_control=bbr" >>"${SHADOWSOCKS_TCP_BBR_PATH}"
                    fi
                    if [ -f "${SYSTEM_TCP_BBR_LOAD_PATH}" ]; then
                        rm -f ${SYSTEM_TCP_BBR_LOAD_PATH}
                    fi
                    if [ ! -f "${SYSTEM_TCP_BBR_LOAD_PATH}" ]; then
                        modprobe tcp_bbr
                        echo "tcp_bbr" >>${SYSTEM_TCP_BBR_LOAD_PATH}
                        sysctl -p ${SYSTEM_TCP_BBR_LOAD_PATH}
                    fi
                else
                    echo "Error: Please update your kernel to 4.1 or higher"
                fi
            fi
        fi
    }

    # Install TCP BBR
    install-bbr

Fund this Issue

$0.00
Funded

Pull requests