From a7aa94748f26547e67d82b2aa2727853fe58c2e7 Mon Sep 17 00:00:00 2001 From: coolsnowwolf Date: Wed, 19 Dec 2018 14:49:11 +0800 Subject: [PATCH] luci ssr plus: add multithreading cpu banlance for ss/ssr --- package/lean/luci-app-ssr-plus/Makefile | 2 +- .../luci-app-ssr-plus/root/etc/init.d/shadowsocksr | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/package/lean/luci-app-ssr-plus/Makefile b/package/lean/luci-app-ssr-plus/Makefile index e979ada95..f71fea463 100644 --- a/package/lean/luci-app-ssr-plus/Makefile +++ b/package/lean/luci-app-ssr-plus/Makefile @@ -2,7 +2,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=luci-app-ssr-plus PKG_VERSION:=1 -PKG_RELEASE:=70 +PKG_RELEASE:=71 PKG_CONFIG_DEPENDS:= CONFIG_PACKAGE_$(PKG_NAME)_INCLUDE_Shadowsocks \ CONFIG_PACKAGE_$(PKG_NAME)_INCLUDE_V2ray \ diff --git a/package/lean/luci-app-ssr-plus/root/etc/init.d/shadowsocksr b/package/lean/luci-app-ssr-plus/root/etc/init.d/shadowsocksr index 8b4809513..750520787 100755 --- a/package/lean/luci-app-ssr-plus/root/etc/init.d/shadowsocksr +++ b/package/lean/luci-app-ssr-plus/root/etc/init.d/shadowsocksr @@ -29,6 +29,7 @@ switch_enable=0 switch_server=$1 MAXFD=32768 CRON_FILE=/etc/crontabs/root +threads=$(cat /proc/cpuinfo | grep 'processor' | wc -l) uci_get_by_name() { local ret=$(uci get $NAME.$1.$2 2>/dev/null) @@ -98,6 +99,7 @@ if [ "$stype" == "ss" ] ;then "password": "$(uci_get_by_name $1 password)", "timeout": $(uci_get_by_name $1 timeout 60), "method": "$(uci_get_by_name $1 encrypt_method_ss)", + "reuse_port": true, "fast_open": $fastopen } EOF @@ -116,6 +118,7 @@ EOF "protocol_param": "$(uci_get_by_name $1 protocol_param)", "obfs": "$(uci_get_by_name $1 obfs)", "obfs_param": "$(uci_get_by_name $1 obfs_param)", + "reuse_port": true, "fast_open": $fastopen } EOF @@ -303,9 +306,10 @@ start_redir() { if [ "$stype" == "ss" -o "$stype" == "ssr" ] ;then local last_config_file=$CONFIG_FILE local pid_file="/var/run/ssr-retcp.pid" - $sscmd \ - -c $CONFIG_FILE $ARG_OTA \ - -f /var/run/ssr-retcp.pid >/dev/null 2>&1 + for i in $(seq 1 $threads) + do + $sscmd -c $CONFIG_FILE $ARG_OTA -f /var/run/ssr-retcp.pid >/dev/null 2>&1 + done elif [ "$stype" == "v2ray" ] ;then $sscmd -config /var/etc/v2-ssr-retcp.json >/dev/null 2>&1 & fi