luci ssr plus: add multithreading cpu banlance for ss/ssr

This commit is contained in:
coolsnowwolf 2018-12-19 14:49:11 +08:00
parent 866c3b2c9c
commit a7aa94748f
2 changed files with 8 additions and 4 deletions

View File

@ -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 \

View File

@ -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