luci-app-ssr-plus: add subscribe keyword filter

This commit is contained in:
lean 2020-03-27 19:46:08 +08:00
parent 08b73fa42d
commit cdf1ae96c3
5 changed files with 31 additions and 13 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:=175 PKG_VERSION:=175
PKG_RELEASE:=1 PKG_RELEASE:=3
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME) PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)

View File

@ -36,6 +36,10 @@ o.rmempty = false
o = s:option(DynamicList, "subscribe_url", translate("Subscribe URL")) o = s:option(DynamicList, "subscribe_url", translate("Subscribe URL"))
o.rmempty = true o.rmempty = true
o = s:option(Value, "filter_words", translate("Subscribe Filter Words"))
o.rmempty = true
o.description = translate("Filter Words splited by /")
o = s:option(Button,"update_Sub",translate("Update Subscribe List")) o = s:option(Button,"update_Sub",translate("Update Subscribe List"))
o.inputstyle = "reload" o.inputstyle = "reload"
o.description = translate("Update subscribe url list first") o.description = translate("Update subscribe url list first")

View File

@ -430,6 +430,12 @@ msgstr "自动更新服务器订阅、GFW列表和 CHN路由表"
msgid "Subscribe URL" msgid "Subscribe URL"
msgstr "SS/SSR/V2/TROJAN订阅URL" msgstr "SS/SSR/V2/TROJAN订阅URL"
msgid "Subscribe Filter Words"
msgstr "订阅节点关键字过滤"
msgid "Filter Words splited by /"
msgstr "命中关键字的节点将被丢弃。多个关键字用 / 分隔"
msgid "Update" msgid "Update"
msgstr "更新" msgstr "更新"
@ -569,7 +575,7 @@ msgid "Update Subscribe List"
msgstr "更新订阅URL列表" msgstr "更新订阅URL列表"
msgid "Update subscribe url list first" msgid "Update subscribe url list first"
msgstr "订阅服务器节点前请先更新订阅URL列表" msgstr "修改订阅URL和节点关键字后请先点击更新"
msgid "Update All Subscribe Severs" msgid "Update All Subscribe Severs"
msgstr "更新所有订阅服务器节点" msgstr "更新所有订阅服务器节点"

View File

@ -40,6 +40,4 @@ config server_subscribe
option proxy '0' option proxy '0'
option auto_update_time '2' option auto_update_time '2'
option auto_update '1' option auto_update '1'
option filter_words '过期时间/剩余流量/QQ群/官网/防失联地址/回国'

View File

@ -23,6 +23,7 @@ local ucic = uci.cursor()
local proxy = ucic:get_first(name, 'server_subscribe', 'proxy', '0') local proxy = ucic:get_first(name, 'server_subscribe', 'proxy', '0')
local switch = ucic:get_first(name, 'server_subscribe', 'switch', '1') local switch = ucic:get_first(name, 'server_subscribe', 'switch', '1')
local subscribe_url = ucic:get_first(name, 'server_subscribe', 'subscribe_url', {}) local subscribe_url = ucic:get_first(name, 'server_subscribe', 'subscribe_url', {})
local filter_words = ucic:get_first(name, 'server_subscribe', 'filter_words', 'QQ群')
local log = function(...) local log = function(...)
print(os.date("%Y-%m-%d %H:%M:%S ") .. table.concat({ ... }, " ")) print(os.date("%Y-%m-%d %H:%M:%S ") .. table.concat({ ... }, " "))
@ -274,10 +275,22 @@ local function processData(szType, content)
end end
-- wget -- wget
local function wget(url) local function wget(url)
local stdout = luci.sys.exec('wget-ssl --user-agent="Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.157 Safari/537.36" --no-check-certificate -t 3 -T 10 -O- "' .. url .. '"') local stdout = luci.sys.exec('wget-ssl -q --user-agent="Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.157 Safari/537.36" --no-check-certificate -t 3 -T 10 -O- "' .. url .. '"')
return trim(stdout) return trim(stdout)
end end
local function check_filer(result)
do
local filter_word = split(filter_words, "/")
for i, v in pairs(filter_word) do
if result.alias:find(v) then
log('订阅节点关键字过滤:“' .. v ..'” ,该节点被丢弃')
return true
end
end
end
end
local execute = function() local execute = function()
-- exec -- exec
do do
@ -335,12 +348,9 @@ local execute = function()
end end
-- log(result) -- log(result)
if result then if result then
if result.alias:find("过期时间") or if
result.alias:find("剩余流量") or
result.alias:find("QQ群") or
result.alias:find("官网") or
result.alias:find("防失联地址") or
not result.server or not result.server or
check_filer(result) or
result.server:match("[^0-9a-zA-Z%-%.%s]") -- 中文做地址的 也没有人拿中文域名搞就算中文域也有Puny Code SB 机场 result.server:match("[^0-9a-zA-Z%-%.%s]") -- 中文做地址的 也没有人拿中文域名搞就算中文域也有Puny Code SB 机场
then then
log('丢弃无效节点: ' .. result.type ..' 节点, ' .. result.alias) log('丢弃无效节点: ' .. result.type ..' 节点, ' .. result.alias)