Skip to content

Commit

Permalink
luci-app-ssr-plus: custom AD block URL (#3092)
Browse files Browse the repository at this point in the history
* v2ray:Add GOPROXY proxy

* luci-app-ssr-plus:Custom AD URL

* luci-app-ssr-plus:Fix bug & optimize
  • Loading branch information
Mattraks authored Feb 15, 2020
1 parent 2c44bad commit 3d775d3
Show file tree
Hide file tree
Showing 28 changed files with 784 additions and 910 deletions.
75 changes: 46 additions & 29 deletions package/lean/luci-app-ssr-plus/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ include $(TOPDIR)/rules.mk

PKG_NAME:=luci-app-ssr-plus
PKG_RELEASE:=142
PKG_VERSION:=1
PKG_VERSION:=2
PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)

include $(INCLUDE_DIR)/package.mk

Expand All @@ -12,12 +13,12 @@ config PACKAGE_$(PKG_NAME)_INCLUDE_Shadowsocks
default y if x86_64

config PACKAGE_$(PKG_NAME)_INCLUDE_Simple_obfs
bool "Include Shadowsocks Simple-obfs Plugin"
default y if x86_64
bool "Include Shadowsocks Simple-obfs Plugin"
default y if x86_64

config PACKAGE_$(PKG_NAME)_INCLUDE_V2ray_plugin
bool "Include Shadowsocks V2ray Plugin"
default y if x86_64
bool "Include Shadowsocks V2ray Plugin"
default y if x86_64

config PACKAGE_$(PKG_NAME)_INCLUDE_V2ray
bool "Include V2ray"
Expand All @@ -40,7 +41,7 @@ config PACKAGE_$(PKG_NAME)_INCLUDE_ShadowsocksR_Socks
default y
endef

define Package/luci-app-ssr-plus
define Package/$(PKG_NAME)
SECTION:=luci
CATEGORY:=LuCI
SUBMENU:=3. Applications
Expand All @@ -64,47 +65,56 @@ endef
define Build/Compile
endef

define Package/luci-app-ssr-plus/conffiles
/etc/ssr_ip
define Package/$(PKG_NAME)/conffiles
/etc/china_ssr.txt
/etc/config/shadowsocksr
/etc/config/white.list
/etc/config/black.list
/etc/dnsmasq.ssr/ad.conf
/etc/dnsmasq.ssr/gfw_list.conf
endef

define Package/luci-app-ssr-plus/install
#lua
$(INSTALL_DIR) $(1)/usr/lib/lua/luci/controller
$(INSTALL_DIR) $(1)/usr/lib/lua/luci/model/cbi/shadowsocksr
$(INSTALL_DIR) $(1)/usr/lib/lua/luci/view/shadowsocksr
$(INSTALL_DIR) $(1)/usr/lib/lua/luci/i18n
#etc
define Package/$(PKG_NAME)/install
$(INSTALL_DIR) $(1)/etc
$(INSTALL_DIR) $(1)/etc/config
$(INSTALL_DIR) $(1)/etc/dnsmasq.oversea
$(INSTALL_DIR) $(1)/etc/dnsmasq.ssr
$(INSTALL_DIR) $(1)/etc/init.d
$(INSTALL_DIR) $(1)/etc/uci-defaults
#usr
$(INSTALL_DIR) $(1)/usr/bin
$(INSTALL_DIR) $(1)/usr/share/shadowsocksr
#root/etc
$(INSTALL_DATA) ./root/etc/china_ssr.txt $(1)/etc/china_ssr.txt

$(INSTALL_DIR) $(1)/etc/config
$(INSTALL_CONF) ./root/etc/config/shadowsocksr $(1)/etc/config/shadowsocksr
$(INSTALL_DATA) ./root/etc/config/*.list $(1)/etc/config/

$(INSTALL_DIR) $(1)/etc/dnsmasq.oversea
$(INSTALL_DATA) ./root/etc/dnsmasq.oversea/* $(1)/etc/dnsmasq.oversea/

$(INSTALL_DIR) $(1)/etc/dnsmasq.ssr
$(INSTALL_DATA) ./root/etc/dnsmasq.ssr/* $(1)/etc/dnsmasq.ssr/

$(INSTALL_DIR) $(1)/etc/init.d
$(INSTALL_BIN) ./root/etc/init.d/* $(1)/etc/init.d/

$(INSTALL_DIR) $(1)/etc/uci-defaults
$(INSTALL_BIN) ./root/etc/uci-defaults/* $(1)/etc/uci-defaults/
#root/usr

$(INSTALL_DIR) $(1)/usr/bin
$(INSTALL_BIN) ./root/usr/bin/* $(1)/usr/bin/

$(INSTALL_DIR) $(1)/usr/share/shadowsocksr
$(INSTALL_BIN) ./root/usr/share/shadowsocksr/*.sh $(1)/usr/share/shadowsocksr/
$(INSTALL_DATA) ./root/usr/share/shadowsocksr/*.lua $(1)/usr/share/shadowsocksr/
#luasrc

$(INSTALL_DIR) $(1)/usr/lib/lua/luci/controller
$(INSTALL_DATA) ./luasrc/controller/*.lua $(1)/usr/lib/lua/luci/controller/

$(INSTALL_DIR) $(1)/usr/lib/lua/luci/model/cbi/shadowsocksr
$(INSTALL_DATA) ./luasrc/model/cbi/shadowsocksr/*.lua $(1)/usr/lib/lua/luci/model/cbi/shadowsocksr/

$(INSTALL_DIR) $(1)/usr/lib/lua/luci/view/shadowsocksr
$(INSTALL_DATA) ./luasrc/view/shadowsocksr/* $(1)/usr/lib/lua/luci/view/shadowsocksr/

$(INSTALL_DIR) $(1)/usr/lib/lua/luci/i18n
po2lmo ./po/zh-cn/ssr-plus.po $(1)/usr/lib/lua/luci/i18n/ssr-plus.zh-cn.lmo
endef

define Package/luci-app-ssr-plus/postinst
define Package/$(PKG_NAME)/postinst
#!/bin/sh
if [ -z "$${IPKG_INSTROOT}" ]; then
( . /etc/uci-defaults/luci-ssr-plus ) && rm -f /etc/uci-defaults/luci-ssr-plus
Expand All @@ -114,7 +124,7 @@ fi
exit 0
endef

define Package/luci-app-ssr-plus/prerm
define Package/$(PKG_NAME)/prerm
#!/bin/sh
if [ -z "$${IPKG_INSTROOT}" ]; then
/etc/init.d/shadowsocksr disable
Expand All @@ -123,4 +133,11 @@ fi
exit 0
endef

$(eval $(call BuildPackage,luci-app-ssr-plus))
define Package/$(PKG_NAME)/postrm
#!/bin/sh
rm -rf /etc/china_ssr.txt /etc/dnsmasq.ssr /etc/dnsmasq.oversea /etc/config/shadowsocksr /etc/config/black.list \
/etc/config/gfw.list /etc/config/white.list >/dev/null 2>&1
exit 0
endef

$(eval $(call BuildPackage,$(PKG_NAME)))
13 changes: 3 additions & 10 deletions package/lean/luci-app-ssr-plus/luasrc/controller/shadowsocksr.lua
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ function index()
entry({"admin", "services", "shadowsocksr", "client"}, cbi("shadowsocksr/client"),_("SSR Client"), 10).leaf = true
entry({"admin", "services", "shadowsocksr", "servers"}, arcombine(cbi("shadowsocksr/servers", {autoapply=true}), cbi("shadowsocksr/client-config")),_("Severs Nodes"), 20).leaf = true
entry({"admin", "services", "shadowsocksr", "control"},cbi("shadowsocksr/control"), _("Access Control"), 30).leaf = true
-- entry({"admin", "services", "shadowsocksr", "list"},form("shadowsocksr/list"),_("GFW List"), 40).leaf = true
entry({"admin", "services", "shadowsocksr", "advanced"},cbi("shadowsocksr/advanced"),_("Advanced Settings"), 50).leaf = true
if nixio.fs.access("/usr/bin/ssr-server") then
entry({"admin", "services", "shadowsocksr", "server"},arcombine(cbi("shadowsocksr/server"), cbi("shadowsocksr/server-config")),_("SSR Server"), 60).leaf = true
Expand Down Expand Up @@ -116,18 +115,12 @@ else
end
luci.sys.exec("rm -f /tmp/china_ssr.txt ")
else
local need_process = 0
if nixio.fs.access("/usr/bin/wget-ssl") then
refresh_cmd="wget-ssl --no-check-certificate -O - https://easylist-downloads.adblockplus.org/easylistchina+easylist.txt > /tmp/adnew.conf"
need_process = 1
else
refresh_cmd="wget -O /tmp/ad.conf http://iytc.net/tools/ad.conf"
if nixio.fs.access("/usr/bin/wget-ssl") then
refresh_cmd="wget-ssl --no-check-certificate -O - ".. luci.model.uci.cursor():get_first(shadowsocksr, 'global', 'adblock_url','https://easylist-downloads.adblockplus.org/easylistchina+easylist.txt') .." > /tmp/adnew.conf"
end
sret=luci.sys.call(refresh_cmd .. " 2>/dev/null")
if sret== 0 then
if need_process == 1 then
luci.sys.call("/usr/bin/ssr-ad")
end
luci.sys.call("/usr/bin/ssr-ad")
icount = luci.sys.exec("cat /tmp/ad.conf | wc -l")
if tonumber(icount)>1000 then
if nixio.fs.access("/etc/dnsmasq.ssr/ad.conf") then
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,16 @@ s.anonymous = true

o = s:option(Flag, "monitor_enable", translate("Enable Process Deamon"))
o.rmempty = false
o.default = "1"

o = s:option(Flag, "enable_switch", translate("Enable Auto Switch"))
o.rmempty = false
o.default = "1"

o = s:option(Value, "switch_time", translate("Switch check cycly(second)"))
o.datatype = "uinteger"
o:depends("enable_switch", "1")
o.default = 3600
o.default = 667

o = s:option(Value, "switch_timeout", translate("Check timout(second)"))
o.datatype = "uinteger"
Expand All @@ -49,6 +51,9 @@ s.anonymous = true
o = s:option(Flag, "adblock", translate("Enable adblock"))
o.rmempty = false

o = s:option(Value, "adblock_url", translate("adblock_url"))
o.default = "https://easylist-downloads.adblockplus.org/easylistchina+easylist.txt"

-- [[ SOCKS Proxy ]]--
if nixio.fs.access("/usr/bin/srelay") then
s = m:section(TypedSection, "socks5_proxy", translate("SOCKS Proxy"))
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,7 @@ local udpspeeder_run=0
local gfw_count=0
local ad_count=0
local ip_count=0
local gfwmode=0
local ucic = luci.model.uci.cursor()

if nixio.fs.access("/etc/dnsmasq.ssr/gfw_list.conf") then
gfwmode=1
end

local shadowsocksr = "shadowsocksr"
-- html constants
font_blue = [[<font color="green">]]
Expand All @@ -45,12 +39,13 @@ end

end

if gfwmode == 1 then
if nixio.fs.access("/etc/dnsmasq.ssr/gfw_list.conf") then
gfw_count = tonumber(sys.exec("cat /etc/dnsmasq.ssr/gfw_list.conf | wc -l"))/2
end

if nixio.fs.access("/etc/dnsmasq.ssr/ad.conf") then
ad_count=tonumber(sys.exec("cat /etc/dnsmasq.ssr/ad.conf | wc -l"))
end
end

if nixio.fs.access("/etc/china_ssr.txt") then
ip_count = sys.exec("cat /etc/china_ssr.txt | wc -l")
Expand Down Expand Up @@ -160,14 +155,12 @@ s=m:field(DummyValue,"baidu",translate("Baidu Connectivity"))
s.value = translate("No Check")
s.template = "shadowsocksr/check"

if gfwmode == 1 then
s=m:field(DummyValue,"gfw_data",translate("GFW List Data"))
s.rawhtml = true
s.template = "shadowsocksr/refresh"
s.value =tostring(math.ceil(gfw_count)) .. " " .. translate("Records")
end

if ucic:get_first(shadowsocksr, 'global', 'adblock', '') == '1' then
if ucic:get_first(shadowsocksr, 'global', 'adblock', '0') == '1' then
s=m:field(DummyValue,"ad_data",translate("Advertising Data"))
s.rawhtml = true
s.template = "shadowsocksr/refresh"
Expand All @@ -179,8 +172,4 @@ s.rawhtml = true
s.template = "shadowsocksr/refresh"
s.value =ip_count .. " " .. translate("Records")

-- s=m:field(DummyValue,"check_port",translate("Check Server Port"))
-- s.template = "shadowsocksr/checkport"
-- s.value =translate("No Check")

return m
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<%+cbi/valueheader%>
<input class="cbi-input-file" style="width: 400px" type="file" id="ulfile" name="ulfile" />
<input type="submit" class="cbi-button cbi-input-apply" name="upload" value="<%:Upload%>" />
<%+cbi/valuefooter%>
<input class="cbi-input-file" style="width: 400px" type="file" id="ulfile" name="ulfile" />
<input type="submit" class="cbi-button cbi-input-apply" name="upload" value="<%:Upload%>" />
<%+cbi/valuefooter%>
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@
<input type="button" class="cbi-button cbi-button-apply" value="<%:Check Connect%>" onclick="return check_connect(this,'<%=self.option%>')" />
<span id="<%=self.option%>-status"><em><%=self.value%></em></span>

<%+cbi/valuefooter%>
<%+cbi/valuefooter%>
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@
//]]></script>
<input type="button" class="cbi-button cbi-button-apply" value="<%:Check Server%>" onclick="return check_port(this)" />
<span id="<%=self.option%>-status"><em><%=self.value%></em></span>
<%+cbi/valuefooter%>
<%+cbi/valuefooter%>
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<%+cbi/valueheader%>
<span class="pingtime" hint="<%=self:cfgvalue(section)%>">-- ms</span>
<%+cbi/valuefooter%>
<%+cbi/valuefooter%>
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
else if(rv.ret=="-1")
{
s.innerHTML ="<font color='red'>"+"<%:Refresh Error!%> "+"</font>";
}
}
else
{
s.innerHTML ="<font color='green'>"+"<%:Refresh OK!%> "+"<%:Total Records:%>"+rv.ret+"</font>";
Expand All @@ -32,4 +32,4 @@
//]]></script>
<input type="button" class="cbi-button cbi-input-reload" value="<%:Refresh Data%> " onclick="return refresh_data(this,'<%=self.option%>')" />
<span id="<%=self.option%>-status"><em><%=self.value%></em></span>
<%+cbi/valuefooter%>
<%+cbi/valuefooter%>
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
//<![CDATA[
const doms = document.getElementsByClassName('pingtime');
const ports = document.getElementsByClassName("socket-connected")
// 这也是卡的原罪 CGI 一下子处理不这么多
const xhr = (index) => {
return new Promise((res) => {
const dom = doms[index];
Expand Down Expand Up @@ -48,15 +47,5 @@
])
}
})()
// for(var i = 0; i < pings.length; i++) {
// XHR.get('<%=dsp.build_url("admin/services/shadowsocksr/ping")%>', {
// index: i,
// domain: pings[i].getAttribute("hint")
// },
// function(x, result) {
// pings[result.index].innerHTML = (result.ping ? result.ping : "--") + " ms";
// }
// );
// }
//]]>
</script>
</script>
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@
//]]></script>
<input type="button" class="cbi-button cbi-input-apply" value="<%:Update All Subscribe Severs%> " onclick="return subscribe(this,'<%=self.option%>')" />
<!-- <span id="<%=self.option%>-status"><em><%=self.value%></em></span> -->
<%+cbi/valuefooter%>
<%+cbi/valuefooter%>
3 changes: 3 additions & 0 deletions package/lean/luci-app-ssr-plus/po/zh-cn/ssr-plus.po
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,9 @@ msgstr "切换检查重试次数"
msgid "Enable adblock"
msgstr "启用广告屏蔽"

msgid "adblock_url"
msgstr "广告屏蔽订阅"

msgid "Enable Process Deamon"
msgstr "启用进程自动守护"

Expand Down
6 changes: 3 additions & 3 deletions package/lean/luci-app-ssr-plus/root/etc/china_ssr.txt
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,6 @@
43.230.84.0/22
43.230.124.0/22
43.230.136.0/22
43.230.168.0/22
43.230.220.0/22
43.230.224.0/22
43.230.228.0/22
Expand Down Expand Up @@ -2731,7 +2730,6 @@
103.49.176.0/22
103.49.180.0/22
103.49.196.0/22
103.49.248.0/22
103.50.36.0/22
103.50.44.0/22
103.50.48.0/22
Expand Down Expand Up @@ -6219,7 +6217,9 @@
180.178.112.0/22
180.178.116.0/22
180.178.192.0/18
180.184.0.0/14
180.184.0.0/15
180.186.0.0/16
180.187.0.0/16
180.188.0.0/17
180.189.148.0/22
180.200.252.0/22
Expand Down
Loading

1 comment on commit 3d775d3

@kongzheng333
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

package/lean/luci-app-ssr-plus/root/usr/share/shadowsocksr/subscribe.lua 文件中
-- result.mux = 1
-- result.concurrency = 8
这两行的修改是解决了订阅后默认打开mux的问题么?

Please sign in to comment.