Skip to content

Commit

Permalink
update luci-ssr-pro to fit in new luci
Browse files Browse the repository at this point in the history
  • Loading branch information
coolsnowwolf committed May 23, 2018
1 parent 690fdd1 commit 715088d
Show file tree
Hide file tree
Showing 17 changed files with 108 additions and 94 deletions.
2 changes: 1 addition & 1 deletion feeds.conf.default
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#src-git packages https://git.openwrt.org/feed/packages.git^1b73f267eae2dedc18969b70ed7c5d9b02288bac
src-git packages https://github.com/openwrt/packages.git
#src-git luci https://git.openwrt.org/project/luci.git^7d55be315d758b2a40494e732d7bdc300ee15c00
src-git luci https://github.com/openwrt/luci.git^80cb4fef8c7db0dadc373fef122d7abb092a7191
src-git luci https://github.com/openwrt/luci.git
#src-git luci https://github.com/openwrt/luci.git;openwrt-18.06
src-git routing https://git.openwrt.org/feed/routing.git;openwrt-18.06
src-git telephony https://github.com/openwrt/telephony.git;openwrt-18.06
Expand Down
2 changes: 1 addition & 1 deletion include/target.mk
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ DEVICE_TYPE?=router
DEFAULT_PACKAGES:=base-files libc libgcc busybox dropbear mtd uci opkg netifd fstools uclient-fetch logd \
iptables-mod-nat-extra kmod-nf-nathelper kmod-nf-nathelper-extra kmod-ipt-raw kmod-macvlan kmod-nft-offload block-mount automount \
default-settings ipset-lists luci luci-app-ddns luci-app-sqm luci-app-upnp luci-app-adbyby-plus luci-app-autoreboot \
luci-app-filetransfer luci-app-shadowsocksr-pro luci-app-usb-printer luci-app-vsftpd ddns-scripts_aliyun luci-app-xlnetacc \
luci-app-filetransfer luci-app-ssr-pro luci-app-usb-printer luci-app-vsftpd ddns-scripts_aliyun luci-app-xlnetacc \
luci-app-pptp-server luci-app-ipsec-vpnd luci-app-vlmcsd luci-app-wifischedule luci-app-wol luci-app-sfe luci-app-flowoffload luci-app-nlbwmon
# For nas targets
DEFAULT_PACKAGES.nas:=block-mount fdisk lsblk mdadm
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@

include $(TOPDIR)/rules.mk

LUCI_TITLE:=LuCI support for Shadowsocksr
LUCI_TITLE:=LuCI support for SSR Pro
LUCI_DEPENDS:=+iptables-mod-tproxy +kmod-ipt-tproxy +ip +ipset-lists +shadowsocksr-libev-alt +pdnsd-alt +coreutils +coreutils-base64 +coreutils-nohup +dnsmasq-full
LUCI_PKGARCH:=all
PKG_VERSION:=2.0
PKG_RELEASE:=21
PKG_VERSION:=2
PKG_RELEASE:=22

include $(TOPDIR)/feeds/luci/luci.mk

Expand Down
9 changes: 9 additions & 0 deletions package/lean/luci-app-ssr-pro/luasrc/controller/ssrpro.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module("luci.controller.ssrpro", package.seeall)
function index()
if not nixio.fs.access("/etc/config/ssrpro") then
return
end
local page
page = entry({"admin", "services", "ssrpro"}, cbi("ssrpro"), _("ShadowsocksR Pro"))
page.dependent = true
end
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ else
Status = translate("<strong><font color=\"red\">ShadowsocksR is Not Running</font></strong>")
end

m = Map("shadowsocksr")
m = Map("ssrpro")
m.title = translate("Shadowsocksr Transparent Proxy")
m.description = translate("A fast secure tunnel proxy that help you get through firewalls on your router")

s = m:section(TypedSection, "shadowsocksr")
s = m:section(TypedSection, "ssrpro")
s.anonymous = true
s.description = translate(string.format("%s<br /><br />", Status))

Expand Down Expand Up @@ -223,9 +223,9 @@ e:value("global",translate("Global Proxy"))
e:value("game",translate("Game Mode"))

-- ---------------------------------------------------
local apply = luci.http.formvalue("cbi.apply")
if apply then
os.execute("/etc/init.d/ssrpro restart >/dev/null 2>&1 &")
end
-- local apply = luci.http.formvalue("cbi.apply")
-- if apply then
-- os.execute("/etc/init.d/ssrpro restart >/dev/null 2>&1 &")
-- end

return m
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@

config shadowsocksr
config ssrpro
option gfwlist 'china-banned'
option server 'serv-ro.ddns.info'
option server_port '23143'
option password 'test.TEST'
option method 'aes-256-cfb'
option protocol 'origin'
option obfs 'plain'
option enabled '0'
option proxy_mode 'M'
option safe_dns_tcp '1'
option cron_mode '1'
option cron_mode '1'
option method 'none'
option server '4.4.4.4'
option enabled '0'

Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,51 @@
#

START=99
STOP=10

EXTRA_COMMANDS="reload_rule"

SS_REDIR_PORT=7070
SS_REDIR_PIDFILE=/var/run/ssr-redir-go.pid
PDNSD_LOCAL_PORT=7453
SSRCONF=/etc/shadowsocksr.json
CRON_FILE=/etc/crontabs/root
CONFIG=shadowsocksr
CONFIG=ssrpro
KEEP_GFWLIST=Y
vt_np_ipset="china"

get_config()
{
config_get_bool vt_enabled $1 enabled 0
config_get vt_server_addr $1 server
config_get vt_server_port $1 server_port
config_get vt_password $1 password
config_get vt_method $1 method
config_get vt_protocol $1 protocol
config_get vt_protoparam $1 protoparam
config_get vt_obfs $1 obfs
config_get obfs_param $1 obfs_param
config_get vt_proxy_mode $1 proxy_mode
config_get vt_timeout $1 timeout
config_get vt_safe_dns $1 safe_dns
config_get vt_timeout $1 timeout
config_get vt_safe_dns $1 safe_dns
config_get vt_safe_dns_port $1 safe_dns_port
config_get vt_safe_dns_tcp $1 safe_dns_tcp
config_get cron_mode $1 cron_mode 1
}




# -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

# $covered_subnets, $local_addresses are not required
covered_subnets=`uci get shadowsocksr.@shadowsocksr[0].covered_subnets 2>/dev/null`
local_addresses=`uci get shadowsocksr.@shadowsocksr[0].local_addresses 2>/dev/null`
# Get LAN settings as default parameters
[ -f /lib/functions/network.sh ] && . /lib/functions/network.sh
[ -z "$covered_subnets" ] && network_get_subnet covered_subnets lan
[ -z "$local_addresses" ] && network_get_ipaddr local_addresses lan
vt_np_ipset="china" # Must be global variable
network_get_subnet covered_subnets lan
network_get_ipaddr local_addresses lan

# -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

__gfwlist_by_mode()
{
Expand All @@ -31,42 +57,24 @@ __gfwlist_by_mode()
esac
}



# -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

start()
{
local vt_enabled=`uci get shadowsocksr.@shadowsocksr[0].enabled 2>/dev/null`
local vt_server_addr=`uci get shadowsocksr.@shadowsocksr[0].server`
local vt_server_port=`uci get shadowsocksr.@shadowsocksr[0].server_port`
local vt_password=`uci get shadowsocksr.@shadowsocksr[0].password 2>/dev/null`
local vt_method=`uci get shadowsocksr.@shadowsocksr[0].method`
local vt_protocol=`uci get shadowsocksr.@shadowsocksr[0].protocol`
local vt_protoparam=`uci get shadowsocksr.@shadowsocksr[0].protoparam 2>/dev/null`
local vt_obfs=`uci get shadowsocksr.@shadowsocksr[0].obfs`
local vt_timeout=`uci get shadowsocksr.@shadowsocksr[0].timeout 2>/dev/null`
local vt_safe_dns=`uci get shadowsocksr.@shadowsocksr[0].safe_dns 2>/dev/null`
local vt_safe_dns_port=`uci get shadowsocksr.@shadowsocksr[0].safe_dns_port 2>/dev/null`
local vt_safe_dns_tcp=`uci get shadowsocksr.@shadowsocksr[0].safe_dns_tcp 2>/dev/null`
local vt_proxy_mode=`uci get shadowsocksr.@shadowsocksr[0].proxy_mode`
local obfs_param=`uci get shadowsocksr.@shadowsocksr[0].obfs_param 2>/dev/null`
local cron_mode=`uci get shadowsocksr.@shadowsocksr[0].cron_mode 2>/dev/null`
local vt_gfwlist=`__gfwlist_by_mode $vt_proxy_mode`

{
config_load ssrpro
config_foreach get_config ssrpro

[ -f /etc/init.d/pdnsd ] && /etc/init.d/pdnsd disable 2>/dev/null

# -----------------------------------------------------------------

if [ "$vt_enabled" = 0 ]; then
echo "WARNING: Shadowsocksr is disabled."
return 1
exit 0
fi

if [ -z "$vt_server_addr" -o -z "$vt_server_port" ]; then
echo "WARNING: Shadowsocksr not fully configured, not starting."
return 1
exit 0
fi


local vt_gfwlist=`__gfwlist_by_mode $vt_proxy_mode`
[ -z "$vt_proxy_mode" ] && vt_proxy_mode=M
[ -z "$vt_method" ] && vt_method=table
[ -z "$vt_timeout" ] && vt_timeout=60
Expand Down Expand Up @@ -96,6 +104,7 @@ start()
"fast_open": false
}
EOF

/usr/bin/ssr-redir -u -c $SSRCONF -f $SS_REDIR_PIDFILE || return 1

# IPv4 firewall rules
Expand Down Expand Up @@ -133,12 +142,12 @@ EOF
conf-dir=/var/etc/dnsmasq-go.d
EOF
/etc/init.d/dnsmasq restart


fi

add_cron
}


stop()
{

Expand All @@ -163,23 +172,14 @@ stop()
del_cron
}

restart()
{
KEEP_GFWLIST=Y
stop
start
}

reload()
reload_rule()
{
local vt_enabled=`uci get shadowsocksr.@shadowsocksr[0].enabled 2>/dev/null`
local vt_server_addr=`uci get shadowsocksr.@shadowsocksr[0].server`
local vt_server_port=`uci get shadowsocksr.@shadowsocksr[0].server_port`
local vt_safe_dns=`uci get shadowsocksr.@shadowsocksr[0].safe_dns 2>/dev/null`
local vt_safe_dns_port=`uci get shadowsocksr.@shadowsocksr[0].safe_dns_port 2>/dev/null`
local vt_safe_dns_tcp=`uci get shadowsocksr.@shadowsocksr[0].safe_dns_tcp 2>/dev/null`
local vt_proxy_mode=`uci get shadowsocksr.@shadowsocksr[0].proxy_mode`
local vt_gfwlist=`__gfwlist_by_mode $vt_proxy_mode`
config_load ssrpro
config_foreach get_config ssrpro

local vt_gfwlist=`__gfwlist_by_mode $vt_proxy_mode`

KEEP_GFWLIST=Y
del_rule
add_rule
Expand All @@ -189,6 +189,14 @@ reload()
fi
}

restart()
{
KEEP_GFWLIST=Y
stop
start
}


# $1: upstream DNS server
start_pdnsd()
{
Expand Down Expand Up @@ -384,3 +392,4 @@ del_rule()
# -----------------------------------------------------------------
[ "$KEEP_GFWLIST" = Y ] || ipset destroy "$vt_gfwlist" 2>/dev/null
}

Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#!/bin/sh

ssr_enable=$(uci get shadowsocksr.@shadowsocksr[0].enabled 2>/dev/null)
ssr_enable=$(uci get ssrpro.@ssrpro[0].enabled 2>/dev/null)

if [ $ssr_enable -eq 1 ]; then
if pidof ssr-redir>/dev/null; then
/etc/init.d/ssrpro reload
/etc/init.d/ssrpro reload_rule
else
/etc/init.d/ssrpro restart
fi
Expand Down
20 changes: 20 additions & 0 deletions package/lean/luci-app-ssr-pro/root/etc/uci-defaults/ssrpro
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/sh

uci -q batch <<-EOF >/dev/null
delete ucitrack.@ssrpro[-1]
add ucitrack ssrpro
set ucitrack.@ssrpro[-1].init=ssrpro
commit ucitrack
delete firewall.ssrpro
set firewall.ssrpro=include
set firewall.ssrpro.type=script
set firewall.ssrpro.path=/etc/ssrpro.include
set firewall.ssrpro.reload=1
commit firewall
EOF

/etc/init.d/ssrpro stop
/etc/init.d/ssrpro enable

rm -f /tmp/luci-indexcache
exit 0

0 comments on commit 715088d

Please sign in to comment.