From 9b3b5c8cce2bb13ce36f431e65b529716dddbce0 Mon Sep 17 00:00:00 2001 From: coolsnowwolf Date: Mon, 12 Nov 2018 15:44:25 +0800 Subject: [PATCH] luci ssr plus: splite tcp and udp to 2 instance --- package/lean/luci-app-ssr-plus/Makefile | 2 +- .../root/etc/init.d/shadowsocksr | 48 +++++++------------ 2 files changed, 18 insertions(+), 32 deletions(-) diff --git a/package/lean/luci-app-ssr-plus/Makefile b/package/lean/luci-app-ssr-plus/Makefile index 0584ad395..eed1032a1 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:=48 +PKG_RELEASE:=49 PO2LMO:=$(BUILD_DIR)/luci-base/po2lmo 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 b937d5e95..a496b7331 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 @@ -278,50 +278,37 @@ start_redir() { gen_config_file $GLOBAL_SERVER 0 local stype=$(uci_get_by_name $GLOBAL_SERVER type) - if [ "$stype" == "ss" ] ;then + if [ "$stype" == "ss" ] ;then sscmd="/usr/bin/ss-redir" elif [ "$stype" == "ssr" ] ;then sscmd="/usr/bin/ssr-redir" elif [ "$stype" == "v2ray" ] ;then sscmd="/usr/bin/v2ray/v2ray" - fi + fi - redir_tcp=1 - local utype=$(uci_get_by_name $UDP_RELAY_SERVER type) - if [ "$utype" == "ss" ] ;then + if [ "$utype" == "ss" ] ;then ucmd="/usr/bin/ss-redir" elif [ "$utype" == "ssr" ] ;then ucmd="/usr/bin/ssr-redir" elif [ "$utype" == "v2ray" ] ;then ucmd="/usr/bin/v2ray/v2ray" + fi + + redir_tcp=1 + 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 + elif [ "$stype" == "v2ray" ] ;then + $sscmd -config /var/etc/v2-ssr-retcp.json >/dev/null 2>&1 & fi - if [ "$ARG_UDP" = "-u" ]; then + if [ -n $UDP_RELAY_SERVER ] ;then redir_udp=1 - if [ "$stype" == "ss" -o "$stype" == "ssr" ] ;then - local last_config_file=$CONFIG_FILE - $sscmd \ - -c $CONFIG_FILE $ARG_OTA -u \ - -f /var/run/ssr-retcp-ssr-reudp.pid >/dev/null 2>&1 - elif [ "$utype" == "v2ray" ] ; then - lua /usr/share/shadowsocksr/genv2config.lua $GLOBAL_SERVER 'tcp,udp' $(uci_get_by_name $GLOBAL_SERVER local_port) > /var/etc/v2-ssr-retcp-ssr-reudp.json - $ucmd -config /var/etc/v2-ssr-retcp-ssr-reudp.json >/dev/null 2>&1 & - fi - else - 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 - elif [ "$stype" == "v2ray" ] ;then - $sscmd -config /var/etc/v2-ssr-retcp.json >/dev/null 2>&1 & - fi - - if [ "$ARG_UDP" = "-U" ]; then - redir_udp=1 - if [ "$utype" == "ss" -o "$utype" == "ssr" ] ;then + if [ "$utype" == "ss" -o "$utype" == "ssr" ] ;then case "$(uci_get_by_name $UDP_RELAY_SERVER auth_enable)" in 1|on|true|yes|enabled) ARG_OTA="-A";; *) ARG_OTA="";; @@ -334,10 +321,9 @@ start_redir() { -f $pid_file >/dev/null 2>&1 elif [ "$utype" == "v2ray" ] ; then lua /usr/share/shadowsocksr/genv2config.lua $UDP_RELAY_SERVER udp $(uci_get_by_name $UDP_RELAY_SERVER local_port) > /var/etc/v2-ssr-reudp.json - $ucmd -config /var/etc/v2-ssr-reudp.json >/dev/null 2>&1 & + $ucmd -config /var/etc/v2-ssr-reudp.json >/dev/null 2>&1 & fi fi - fi