luci ssr plus: script optimization

This commit is contained in:
coolsnowwolf 2018-11-12 11:43:13 +08:00
parent 78986783c1
commit 8816df5e44
3 changed files with 15 additions and 9 deletions

View File

@ -2,7 +2,7 @@ include $(TOPDIR)/rules.mk
PKG_NAME:=luci-app-ssr-plus PKG_NAME:=luci-app-ssr-plus
PKG_VERSION:=1 PKG_VERSION:=1
PKG_RELEASE:=45 PKG_RELEASE:=46
PO2LMO:=$(BUILD_DIR)/luci-base/po2lmo PO2LMO:=$(BUILD_DIR)/luci-base/po2lmo

View File

@ -121,7 +121,7 @@ EOF
} }
EOF EOF
elif [ "$stype" == "v2ray" ] ;then elif [ "$stype" == "v2ray" ] ;then
lua /usr/share/shadowsocksr/genv2config.lua $GLOBAL_SERVER tcp > /var/etc/v2-ssr-retcp.json lua /usr/share/shadowsocksr/genv2config.lua $GLOBAL_SERVER tcp $(uci_get_by_name $1 local_port) > /var/etc/v2-ssr-retcp.json
fi fi
} }
@ -276,7 +276,7 @@ start_redir() {
kcp_enable_flag=1 kcp_enable_flag=1
fi fi
gen_config_file $GLOBAL_SERVER 0 gen_config_file $GLOBAL_SERVER 0
local stype=$(uci_get_by_name $GLOBAL_SERVER type) local stype=$(uci_get_by_name $GLOBAL_SERVER type)
if [ "$stype" == "ss" ] ;then if [ "$stype" == "ss" ] ;then
sscmd="/usr/bin/ss-redir" sscmd="/usr/bin/ss-redir"
@ -302,7 +302,7 @@ start_redir() {
local pid_file="/var/run/ssr-retcp.pid" local pid_file="/var/run/ssr-retcp.pid"
$sscmd \ $sscmd \
-c $CONFIG_FILE $ARG_OTA \ -c $CONFIG_FILE $ARG_OTA \
-f /var/run/ssr-retcp.pid -f /var/run/ssr-retcp.pid >/dev/null 2>&1
elif [ "$stype" == "v2ray" ] ;then elif [ "$stype" == "v2ray" ] ;then
$sscmd -config /var/etc/v2-ssr-retcp.json >/dev/null 2>&1 & $sscmd -config /var/etc/v2-ssr-retcp.json >/dev/null 2>&1 &
fi fi
@ -318,13 +318,14 @@ start_redir() {
redir_udp=1 redir_udp=1
$ucmd \ $ucmd \
-c $last_config_file $ARG_OTA -U \ -c $last_config_file $ARG_OTA -U \
-f $pid_file -f $pid_file >/dev/null 2>&1
elif [ "$utype" == "v2ray" ] ; then elif [ "$utype" == "v2ray" ] ; then
lua /usr/share/shadowsocksr/genv2config.lua $UDP_RELAY_SERVER udp > /var/etc/v2-ssr-reudp.json lua /usr/share/shadowsocksr/genv2config.lua $UDP_RELAY_SERVER udp > /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
#deal with dns #deal with dns
if [ "$(uci_get_by_type global pdnsd_enable)" = "1" ] ;then if [ "$(uci_get_by_type global pdnsd_enable)" = "1" ] ;then
@ -459,7 +460,7 @@ start() {
cat > /tmp/dnsmasq.d/dnsmasq-ssr.conf <<EOF cat > /tmp/dnsmasq.d/dnsmasq-ssr.conf <<EOF
conf-dir=/etc/dnsmasq.ssr conf-dir=/etc/dnsmasq.ssr
EOF EOF
/etc/init.d/dnsmasq restart /etc/init.d/dnsmasq restart >/dev/null 2>&1
fi fi
fi fi
@ -491,11 +492,15 @@ stop() {
killall -q -9 ssr-server killall -q -9 ssr-server
killall -q -9 ssr-kcptun killall -q -9 ssr-kcptun
killall -q -9 ssr-local killall -q -9 ssr-local
kill $(cat /var/run/pdnsd.pid) >/dev/null 2>&1 || kill -9 $(ps | grep pdnsd | grep -v grep | awk '{print $1}') >/dev/null 2>&1 if [ -f /var/run/pdnsd.pid ] ;then
kill $(cat /var/run/pdnsd.pid) >/dev/null 2>&1
else
kill -9 $(ps | grep pdnsd | grep -v grep | awk '{print $1}') >/dev/null 2>&1
fi
if [ -f "/tmp/dnsmasq.d/dnsmasq-ssr.conf" ]; then if [ -f "/tmp/dnsmasq.d/dnsmasq-ssr.conf" ]; then
rm -f /tmp/dnsmasq.d/dnsmasq-ssr.conf rm -f /tmp/dnsmasq.d/dnsmasq-ssr.conf
/etc/init.d/dnsmasq restart /etc/init.d/dnsmasq restart >/dev/null 2>&1
fi fi
del_cron del_cron
} }

View File

@ -2,13 +2,14 @@ local ucursor = require "luci.model.uci"
local json = require "luci.jsonc" local json = require "luci.jsonc"
local server_section = arg[1] local server_section = arg[1]
local proto = arg[2] local proto = arg[2]
local local_port = arg[3]
local server = ucursor:get_all("shadowsocksr", server_section) local server = ucursor:get_all("shadowsocksr", server_section)
local v2ray = { local v2ray = {
-- 传入连接 -- 传入连接
inbound = { inbound = {
port = 1234, port = local_port,
protocol = "dokodemo-door", protocol = "dokodemo-door",
settings = { settings = {
network = proto, network = proto,