add SS support in SSR Plus+ luci

This commit is contained in:
505575853 2018-10-06 13:43:49 +08:00 committed by coolsnowwolf
parent d3c89ba7e0
commit 229a42a048
7 changed files with 62 additions and 13 deletions

View File

@ -6,10 +6,10 @@
include $(TOPDIR)/rules.mk
LUCI_TITLE:=LuCI support for SSR Plus
LUCI_DEPENDS:=+shadowsocksr-libev +ipset +ip-full +iptables-mod-tproxy +dnsmasq-full +coreutils +coreutils-base64 +bash +pdnsd-alt +wget
LUCI_DEPENDS:=+shadowsocksr-libev +shadowsocks-libev +ipset +ip-full +iptables-mod-tproxy +dnsmasq-full +coreutils +coreutils-base64 +bash +pdnsd-alt +wget
LUCI_PKGARCH:=all
PKG_VERSION:=1
PKG_RELEASE:=9
PKG_RELEASE:=10
include $(TOPDIR)/feeds/luci/luci.mk

View File

@ -31,7 +31,10 @@ local encrypt_methods = {
"aes-256-cfb",
"aes-128-ctr",
"aes-192-ctr",
"aes-256-ctr",
"aes-256-ctr",
"aes-128-gcm",
"aes-192-gcm",
"aes-256-gcm",
"bf-cfb",
"camellia-128-cfb",
"camellia-192-cfb",
@ -44,6 +47,8 @@ local encrypt_methods = {
"salsa20",
"chacha20",
"chacha20-ietf",
"chacha20-ietf-poly1305",
"xchacha20-ietf-poly1305",
}
local protocol = {
@ -80,6 +85,10 @@ s = m:section(NamedSection, sid, "servers")
s.anonymous = true
s.addremove = false
o = s:option(ListValue, "tool", translate("Proxy Tool"))
o:value("0", translate("ShadowsocksR"))
o:value("1", translate("Shadowsocks"))
o = s:option(Value, "alias", translate("Alias(optional)"))
o = s:option(Flag, "auth_enable", translate("Onetime Authentication"))
@ -117,14 +126,18 @@ o.rmempty = false
o = s:option(ListValue, "protocol", translate("Protocol"))
for _, v in ipairs(protocol) do o:value(v) end
o.rmempty = false
o:depends("tool","0")
o = s:option(Value, "protocol_param", translate("Protocol param(optional)"))
o:depends("tool","0")
o = s:option(ListValue, "obfs", translate("Obfs"))
for _, v in ipairs(obfs) do o:value(v) end
o.rmempty = false
o:depends("tool","0")
o = s:option(Value, "obfs_param", translate("Obfs param(optional)"))
o:depends("tool","0")
o = s:option(Flag, "fast_open", translate("TCP Fast Open"))
o.rmempty = false

View File

@ -10,6 +10,10 @@ m = Map(shadowsocksr, translate("Servers subscription and manage"))
s = m:section(TypedSection, "server_subscribe")
s.anonymous = true
o = s:option(ListValue, "tool", translate("Proxy Tool"))
o:value("0", translate("ShadowsocksR"))
o:value("1", translate("Shadowsocks"))
o = s:option(Flag, "auto_update", translate("Auto Update"))
o.rmempty = false
o.description = translate("Auto Update Server subscription, GFW list and CHN route")

View File

@ -22,6 +22,7 @@ config server_global
option enable_server '0'
config server_subscribe
option tool '0'
option proxy '0'
option auto_update_time '2'
option auto_update '1'

View File

@ -87,6 +87,7 @@ gen_config_file() {
else
fastopen="false";
fi
if [ $(uci_get_by_name $1 tool) = "0" ] ;then
cat <<-EOF >$config_file
{
@ -104,8 +105,32 @@ gen_config_file() {
"fast_open": $fastopen
}
EOF
ln -sf /usr/bin/ssr-redir /usr/sbin/ssr-redir
ln -sf /usr/bin/ssr-local /usr/sbin/ssr-local
ln -sf /usr/bin/ssr-tunnel /usr/sbin/ssr-tunnel
elif [ $(uci_get_by_name $1 tool) = "1" ] ;then
cat <<-EOF >$config_file
{
"server": "$hostip",
"server_port": $(uci_get_by_name $1 server_port),
"local_address": "0.0.0.0",
"local_port": $(uci_get_by_name $1 local_port),
"password": "$(uci_get_by_name $1 password)",
"timeout": $(uci_get_by_name $1 timeout 60),
"method": "$(uci_get_by_name $1 encrypt_method)",
"fast_open": $fastopen
}
EOF
ln -sf /usr/bin/ss-redir /usr/sbin/ssr-redir
ln -sf /usr/bin/ss-local /usr/sbin/ssr-local
ln -sf /usr/bin/ss-tunnel /usr/sbin/ssr-tunnel
fi
}
get_arg_out() {
case "$(uci_get_by_type access_control router_proxy 1)" in
1) echo "-o";;
@ -243,7 +268,7 @@ start_tunnel() {
local_dns_port=5353
fi
/usr/bin/ssr-tunnel \
/usr/sbin/ssr-tunnel \
-c $tunnel_config_file $ARG_OTA -u \
-l $local_dns_port \
-b $(uci_get_by_type global tunnel_address 0.0.0.0) \
@ -284,7 +309,7 @@ start_redir() {
local pid_file="/var/run/ssr-retcp.pid"
if [ "$ARG_UDP" = "-U" ]; then
/usr/bin/ssr-redir \
/usr/sbin/ssr-redir \
-c $CONFIG_FILE $ARG_OTA \
-f /var/run/ssr-retcp.pid
@ -298,7 +323,7 @@ start_redir() {
redir_udp=1
fi
/usr/bin/ssr-redir \
/usr/sbin/ssr-redir \
-c $last_config_file $ARG_OTA $ARG_UDP \
-f $pid_file
@ -403,7 +428,7 @@ start_local() {
[ "$local_server" = "nil" ] && return 1
mkdir -p /var/run /var/etc
gen_config_file $local_server 2
/usr/bin/ssr-local -c $CONFIG_SOCK5_FILE -u \
/usr/sbin/ssr-local -c $CONFIG_SOCK5_FILE -u \
-l $(uci_get_by_type socks5_proxy local_port 1080) \
-b $(uci_get_by_type socks5_proxy local_address 0.0.0.0) \
-f /var/run/ssr-local.pid

View File

@ -49,7 +49,7 @@ if echo $server|grep -E "^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$">/dev/
server=`cat /etc/ssr_ip`
fi
while [ "1" = "1" ] #死循环
while [ "1" = "1" ] #死循环
do
sleep 30
#redir tcp
@ -82,7 +82,7 @@ do
#server
if [ $server_process_count -gt 0 ] ;then
icount=`ps -w | grep ssr-server |grep -v grep| wc -l`
if [ $icount -lt $server_process_count ] #如果进程挂掉就重启它
if [ $icount -lt $server_process_count ] #如果进程挂掉就重启它
then
logger -t "$NAME" "ssr server error.restart!"
killall -q -9 ssr-server
@ -95,7 +95,7 @@ do
#kcptun
if [ $kcp_process -gt 0 ] ;then
icount=`ps -w | grep ssr-kcptun |grep -v grep| wc -l`
if [ $icount -lt $kcp_process ] #如果进程挂掉就重启它
if [ $icount -lt $kcp_process ] #如果进程挂掉就重启它
then
logger -t "$NAME" "ssr kcptun error.restart!"
killall -q -9 ssr-kcptun
@ -106,18 +106,18 @@ do
#local
if [ $local_process -gt 0 ] ;then
icount=`ps -w | grep ssr-local |grep -v grep| wc -l`
if [ $icount -lt $local_process ] #如果进程挂掉就重启它
if [ $icount -lt $local_process ] #如果进程挂掉就重启它
then
logger -t "$NAME" "ssr local error.restart!"
killall -q -9 ssr-local
( /usr/bin/ssr-local -c /var/etc/shadowsocksr_s.json -u -l $sock5_port -f /var/run/ssr-local.pid &)
( /usr/sbin/ssr-local -c /var/etc/shadowsocksr_s.json -u -l $sock5_port -f /var/run/ssr-local.pid &)
fi
fi
#pdnsd
if [ $pdnsd_process -gt 0 ] ;then
icount=`ps -w | grep pdnsd |grep -v grep| wc -l`
if [ $icount -lt $pdnsd_process ] #如果进程挂掉就重启它
if [ $icount -lt $pdnsd_process ] #如果进程挂掉就重启它
then
logger -t "$NAME" "pdnsd tunnel error.restart!"
killall -q -9 pdnsd

View File

@ -21,7 +21,13 @@ CheckIPAddr() {
}
Server_Update() {
tool=($(uci get $name.@server_subscribe[0].tool))
local uci_set="uci -q set $name.$1."
if [ $tool = "0" ] ;then
${uci_set}tool="0"
elif [ $tool = "1" ] ;then
${uci_set}tool="1"
fi
${uci_set}alias="[$ssr_group] $ssr_remarks"
${uci_set}auth_enable="0"
${uci_set}switch_enable="1"