update-10.09

This commit is contained in:
github-actions[bot] 2021-10-09 20:28:29 +08:00
parent c6027c4dfe
commit 01f10d74ec
13 changed files with 291 additions and 169 deletions

View File

@ -313,7 +313,7 @@ aria2_start() {
config_list_foreach "$section" "header" append_header
config_list_foreach "$section" "extra_settings" append_setting
cd /usr/share/aria2 && sh ./tracker.sh
cd /usr/share/aria2 && sh ./tracker.sh >/dev/null 2>&1
cat /usr/share/aria2/aria2.conf > "$config_file"
echo '' >> "$config_file"
sed '/^$/d' "$config_file_tmp" >> "$config_file"

View File

@ -1,8 +1,14 @@
msgid ""
msgstr ""
"PO-Revision-Date: 2021-10-08 17:53+0000\n"
"Last-Translator: Rayhan Nabi <rayhanjanam@gmail.com>\n"
"Language-Team: Bengali (Bangladesh) <https://hosted.weblate.org/projects/"
"openwrt/luciapplicationsnft-qos/bn_BD/>\n"
"Language: bn_BD\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=n != 1;\n"
"X-Generator: Weblate 4.9-dev\n"
#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:136
#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:155
@ -92,12 +98,12 @@ msgstr ""
#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:156
#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:244
msgid "Hostname"
msgstr ""
msgstr "হোস্টনেম"
#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:134
#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:153
msgid "IP Address"
msgstr ""
msgstr "আইপি এড্রেস"
#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:128
#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:161
@ -128,7 +134,7 @@ msgstr ""
#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:248
msgid "MAC Address"
msgstr ""
msgstr "MAC অ্যাড্রেস"
#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:48
msgid "MB"
@ -165,7 +171,7 @@ msgstr ""
#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:197
msgid "Protocol"
msgstr ""
msgstr "প্রোটোকল"
#: applications/luci-app-nft-qos/luasrc/controller/nft-qos.lua:21
#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:24

View File

@ -6,9 +6,9 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=luci-app-passwall
PKG_VERSION:=4.37
PKG_VERSION:=4.38
PKG_RELEASE:=1
#20210928
#20211008
PKG_CONFIG_DEPENDS:= \
CONFIG_PACKAGE_$(PKG_NAME)_INCLUDE_Brook \

View File

@ -38,6 +38,7 @@ function index()
entry({"admin", "services", appname, "app_update"}, cbi(appname .. "/client/app_update"), _("App Update"), 95).leaf = true
entry({"admin", "services", appname, "rule"}, cbi(appname .. "/client/rule"), _("Rule Manage"), 96).leaf = true
entry({"admin", "services", appname, "rule_list"}, cbi(appname .. "/client/rule_list"), _("Rule List Manage"), 97).leaf = true
entry({"admin", "services", appname, "node_subscribe_config"}, cbi(appname .. "/client/node_subscribe_config")).leaf = true
entry({"admin", "services", appname, "node_config"}, cbi(appname .. "/client/node_config")).leaf = true
entry({"admin", "services", appname, "shunt_rules"}, cbi(appname .. "/client/shunt_rules")).leaf = true
entry({"admin", "services", appname, "acl"}, cbi(appname .. "/client/acl"), _("Access control"), 98).leaf = true

View File

@ -40,26 +40,6 @@ o = s:option(Flag, "subscribe_proxy", translate("Subscribe via proxy"))
o.default = 0
o.rmempty = false
---- Enable auto update subscribe
o = s:option(Flag, "auto_update_subscribe",
translate("Enable auto update subscribe"))
o.default = 0
o.rmempty = false
---- Week update rules
o = s:option(ListValue, "week_update_subscribe", translate("Week update rules"))
o:value(7, translate("Every day"))
for e = 1, 6 do o:value(e, translate("Week") .. e) end
o:value(0, translate("Week") .. translate("day"))
o.default = 0
o:depends("auto_update_subscribe", true)
---- Day update rules
o = s:option(ListValue, "time_update_subscribe", translate("Day update rules"))
for e = 0, 23 do o:value(e, e .. translate("oclock")) end
o.default = 0
o:depends("auto_update_subscribe", true)
o = s:option(ListValue, "filter_keyword_mode", translate("Filter keyword Mode"))
o:value("0", translate("Close"))
o:value("1", translate("Discard List"))
@ -69,10 +49,6 @@ o = s:option(DynamicList, "filter_discard_list", translate("Discard List"))
o = s:option(DynamicList, "filter_keep_list", translate("Keep List"))
o = s:option(Flag, "allowInsecure", translate("allowInsecure"), translate("Whether unsafe connections are allowed. When checked, Certificate validation will be skipped."))
o.default = "1"
o.rmempty = false
if #ss_aead_type > 0 then
o = s:option(ListValue, "ss_aead_type", translate("SS AEAD Node Use Type"))
for key, value in pairs(ss_aead_type) do
@ -87,14 +63,6 @@ if #trojan_type > 0 then
end
end
---- Manual subscription
o = s:option(Button, "_update", translate("Manual subscription"))
o.inputstyle = "apply"
function o.write(e, e)
luci.sys.call("lua /usr/share/" .. appname .. "/subscribe.lua start log > /dev/null 2>&1 &")
luci.http.redirect(api.url("log"))
end
---- Subscribe Delete All
o = s:option(Button, "_stop", translate("Delete All Subscribe Node"))
o.inputstyle = "remove"
@ -102,22 +70,30 @@ function o.write(e, e)
luci.sys.call("lua /usr/share/" .. appname .. "/subscribe.lua truncate > /dev/null 2>&1")
end
s = m:section(TypedSection, "subscribe_list", "",
"<font color='red'>" .. translate(
"Please input the subscription url first, save and submit before updating. If you subscribe to update, it is recommended to delete all subscriptions and then re-subscribe.") ..
"</font>")
s = m:section(TypedSection, "subscribe_list", "", "<font color='red'>" .. translate("Please input the subscription url first, save and submit before manual subscription.") .. "</font>")
s.addremove = true
s.anonymous = true
s.sortable = true
s.template = "cbi/tblsection"
s.extedit = api.url("node_subscribe_config", "%s")
o = s:option(Flag, "enabled", translate("Enabled"))
o.default = "1"
o.rmempty = false
o = s:option(Value, "remark", translate("Subscribe Remark"))
o = s:option(Value, "remark", translate("Remarks"))
o.width = "auto"
o.rmempty = false
o.validate = function(self, value, t)
if value then
local count = 0
m.uci:foreach(appname, "subscribe_list", function(e)
if e[".name"] ~= t and e["remark"] == value then
count = count + 1
end
end)
if count > 0 then
return nil, translate("This remark already exists, please change a new remark.")
end
return value
end
end
o = s:option(DummyValue, "_node_count")
o.rawhtml = true
@ -143,4 +119,11 @@ function o.write(t, n)
luci.sys.call("lua /usr/share/" .. appname .. "/subscribe.lua truncate " .. remark .. " > /dev/null 2>&1")
end
o = s:option(Button, "_update", translate("Manual subscription"))
o.inputstyle = "apply"
function o.write(t, n)
luci.sys.call("lua /usr/share/" .. appname .. "/subscribe.lua start " .. n .. " > /dev/null 2>&1 &")
luci.http.redirect(api.url("log"))
end
return m

View File

@ -0,0 +1,103 @@
local api = require "luci.model.cbi.passwall.api.api"
local appname = api.appname
local sys = api.sys
local has_ss = api.is_finded("ss-redir")
local has_ss_rust = api.is_finded("sslocal")
local has_trojan_plus = api.is_finded("trojan-plus")
local has_v2ray = api.is_finded("v2ray")
local has_xray = api.is_finded("xray")
local has_trojan_go = api.is_finded("trojan-go")
local ss_aead_type = {}
local trojan_type = {}
if has_ss then
ss_aead_type[#ss_aead_type + 1] = "shadowsocks-libev"
end
if has_ss_rust then
ss_aead_type[#ss_aead_type + 1] = "shadowsocks-rust"
end
if has_trojan_plus then
trojan_type[#trojan_type + 1] = "trojan-plus"
end
if has_v2ray then
trojan_type[#trojan_type + 1] = "v2ray"
ss_aead_type[#ss_aead_type + 1] = "v2ray"
end
if has_xray then
trojan_type[#trojan_type + 1] = "xray"
ss_aead_type[#ss_aead_type + 1] = "xray"
end
if has_trojan_go then
trojan_type[#trojan_type + 1] = "trojan-go"
end
m = Map(appname)
s = m:section(NamedSection, arg[1])
s.addremove = false
s.dynamic = false
o = s:option(Value, "remark", translate("Subscribe Remark"))
o.rmempty = false
o = s:option(TextValue, "url", translate("Subscribe URL"))
o.rows = 5
o.rmempty = false
o = s:option(Flag, "allowInsecure", translate("allowInsecure"), translate("Whether unsafe connections are allowed. When checked, Certificate validation will be skipped."))
o.default = "1"
o.rmempty = false
o = s:option(ListValue, "filter_keyword_mode", translate("Filter keyword Mode"))
o.default = "3"
o:value("0", translate("Close"))
o:value("1", translate("Discard List"))
o:value("2", translate("Keep List"))
o:value("3", translate("Use global config"))
o = s:option(DynamicList, "filter_discard_list", translate("Discard List"))
o:depends("filter_keyword_mode", "1")
o = s:option(DynamicList, "filter_keep_list", translate("Keep List"))
o:depends("filter_keyword_mode", "2")
if #ss_aead_type > 0 then
o = s:option(ListValue, "ss_aead_type", translate("SS AEAD Node Use Type"))
o.default = "global"
o:value("global", translate("Use global config"))
for key, value in pairs(ss_aead_type) do
o:value(value, translate(value:gsub("^%l",string.upper)))
end
end
if #trojan_type > 0 then
o = s:option(ListValue, "trojan_type", translate("Trojan Node Use Type"))
o.default = "global"
o:value("global", translate("Use global config"))
for key, value in pairs(trojan_type) do
o:value(value, translate(value:gsub("^%l",string.upper)))
end
end
---- Enable auto update subscribe
o = s:option(Flag, "auto_update", translate("Enable auto update subscribe"))
o.default = 0
o.rmempty = false
---- Week update rules
o = s:option(ListValue, "week_update", translate("Week update rules"))
o:value(7, translate("Every day"))
for e = 1, 6 do o:value(e, translate("Week") .. e) end
o:value(0, translate("Week") .. translate("day"))
o.default = 0
o:depends("auto_update", true)
---- Day update rules
o = s:option(ListValue, "time_update", translate("Day update rules"))
for e = 0, 23 do o:value(e, e .. translate("oclock")) end
o.default = 0
o:depends("auto_update", true)
o = s:option(Value, "user_agent", translate("User-Agent"))
o.default = "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.122 Safari/537.36"
return m

File diff suppressed because one or more lines are too long

View File

@ -91,7 +91,7 @@ local status = api.uci_get_type("global_other", "status", "")
<%:Baidu Connection%>
</label>
<div class="cbi-value-field">
<input type="button" class="btn cbi-button cbi-button-apply" value="<%:Check%>" onclick="return check_connect(this, 'baidu', 'www.baidu.com')" />
<input type="button" class="btn cbi-button cbi-button-apply" value="<%:Check%>" onclick="return check_connect(this, 'baidu', 'https://www.baidu.com')" />
<font id="_baidu_status"></font>
</div>
</div>
@ -100,7 +100,7 @@ local status = api.uci_get_type("global_other", "status", "")
<%:Google Connection%>
</label>
<div class="cbi-value-field">
<input type="button" class="btn cbi-button cbi-button-apply" value="<%:Check%>" onclick="return check_connect(this, 'google', 'www.google.com/generate_204')" />
<input type="button" class="btn cbi-button cbi-button-apply" value="<%:Check%>" onclick="return check_connect(this, 'google', 'https://www.google.com/generate_204')" />
<font id="_google_status"></font>
</div>
</div>
@ -118,7 +118,7 @@ local status = api.uci_get_type("global_other", "status", "")
<%:Instagram Connection%>
</label>
<div class="cbi-value-field">
<input type="button" class="btn cbi-button cbi-button-apply" value="<%:Check%>" onclick="return check_connect(this, 'instagram', 'http://www.instagram.com')" />
<input type="button" class="btn cbi-button cbi-button-apply" value="<%:Check%>" onclick="return check_connect(this, 'instagram', 'https://www.instagram.com')" />
<font id="_instagram_status"></font>
</div>
</div>

View File

@ -913,8 +913,8 @@ msgstr "订阅备注(机场)"
msgid "Subscribe URL"
msgstr "订阅网址"
msgid "Please input the subscription url first, save and submit before updating. If you subscribe to update, it is recommended to delete all subscriptions and then re-subscribe."
msgstr "请输入订阅网址保存应用后再更新,如果订阅节点更新了,建议删除所有订阅,然后重新订阅。"
msgid "Please input the subscription url first, save and submit before manual subscription."
msgstr "请输入订阅网址保存应用后再手动订阅。"
msgid "Subscribe via proxy"
msgstr "通过代理订阅"
@ -931,6 +931,9 @@ msgstr "删除所有订阅节点"
msgid "Delete the subscribed node"
msgstr "删除已订阅的节点"
msgid "This remark already exists, please change a new remark."
msgstr "此备注已存在,请改一个新的备注。"
msgid "Filter keyword Mode"
msgstr "过滤关键字模式"
@ -940,6 +943,12 @@ msgstr "丢弃列表"
msgid "Keep List"
msgstr "保留列表"
msgid "Use global config"
msgstr "使用全局配置"
msgid "User-Agent"
msgstr "用户代理(User-Agent)"
msgid "Add"
msgstr "添加"

View File

@ -65,8 +65,6 @@ config global_app
config global_subscribe
option subscribe_proxy '0'
option auto_update_subscribe '0'
option allowInsecure '1'
option filter_keyword_mode '1'
list filter_discard_list '过期时间'
list filter_discard_list '剩余流量'

View File

@ -949,7 +949,7 @@ clean_crontab() {
#sed -i "/${CONFIG}/d" /etc/crontabs/root >/dev/null 2>&1
sed -i "/$(echo "/etc/init.d/${CONFIG}" | sed 's#\/#\\\/#g')/d" /etc/crontabs/root >/dev/null 2>&1
sed -i "/$(echo "lua ${APP_PATH}/rule_update.lua log" | sed 's#\/#\\\/#g')/d" /etc/crontabs/root >/dev/null 2>&1
sed -i "/$(echo "lua ${APP_PATH}/subscribe.lua start log" | sed 's#\/#\\\/#g')/d" /etc/crontabs/root >/dev/null 2>&1
sed -i "/$(echo "lua ${APP_PATH}/subscribe.lua start" | sed 's#\/#\\\/#g')/d" /etc/crontabs/root >/dev/null 2>&1
}
start_crontab() {
@ -986,16 +986,20 @@ start_crontab() {
echo "$t lua $APP_PATH/rule_update.lua log > /dev/null 2>&1 &" >>/etc/crontabs/root
echolog "配置定时任务:自动更新规则。"
fi
autoupdatesubscribe=$(config_t_get global_subscribe auto_update_subscribe)
weekupdatesubscribe=$(config_t_get global_subscribe week_update_subscribe)
dayupdatesubscribe=$(config_t_get global_subscribe time_update_subscribe)
if [ "$autoupdatesubscribe" = "1" ]; then
local t="0 $dayupdatesubscribe * * $weekupdatesubscribe"
[ "$weekupdatesubscribe" = "7" ] && t="0 $dayupdatesubscribe * * *"
echo "$t lua $APP_PATH/subscribe.lua start log > /dev/null 2>&1 &" >>/etc/crontabs/root
echolog "配置定时任务:自动更新节点订阅。"
fi
for item in $(uci show ${CONFIG} | grep "=subscribe_list" | cut -d '.' -sf 2 | cut -d '=' -sf 1); do
cfgid=$(uci show ${CONFIG}.$item | head -n 1 | cut -d '.' -sf 2 | cut -d '=' -sf 1)
remark=$(config_n_get $item remark)
auto_update=$(config_n_get $item auto_update)
week_update=$(config_n_get $item week_update)
time_update=$(config_n_get $item time_update)
if [ "$auto_update" = "1" ]; then
local t="0 $time_update * * $week_update"
[ "$week_update" = "7" ] && t="0 $time_update * * *"
echo "$t lua $APP_PATH/subscribe.lua start $cfgid > /dev/null 2>&1 &" >>/etc/crontabs/root
echolog "配置定时任务:自动更新【$remark】订阅。"
fi
done
if [ "$NO_PROXY" == 0 ]; then
start_daemon=$(config_t_get global_delay start_daemon 0)

View File

@ -19,19 +19,42 @@ local ssub, slen, schar, sbyte, sformat, sgsub = string.sub, string.len, string.
local jsonParse, jsonStringify = luci.jsonc.parse, luci.jsonc.stringify
local b64decode = nixio.bin.b64decode
local uci = luci.model.uci.cursor()
local allowInsecure_default = uci:get_bool(appname, "@global_subscribe[0]", "allowInsecure")
local ss_aead_type = uci:get(appname, "@global_subscribe[0]", "ss_aead_type") or "shadowsocks-libev"
local trojan_type = uci:get(appname, "@global_subscribe[0]", "trojan_type") or "trojan-plus"
uci:revert(appname)
local has_ss = api.is_finded("ss-redir")
local has_ss_rust = api.is_finded("sslocal")
local has_trojan_plus = api.is_finded("trojan-plus")
local has_v2ray = api.is_finded("v2ray")
local has_xray = api.is_finded("xray")
local has_trojan_go = api.is_finded("trojan-go")
uci:revert(appname)
local allowInsecure_default = true
local ss_aead_type_default = uci:get(appname, "@global_subscribe[0]", "ss_aead_type") or "shadowsocks-libev"
local trojan_type_default = uci:get(appname, "@global_subscribe[0]", "trojan_type") or "trojan-plus"
-- 判断是否过滤节点关键字
local filter_keyword_mode_default = uci:get(appname, "@global_subscribe[0]", "filter_keyword_mode") or "0"
local filter_keyword_discard_list_default = uci:get(appname, "@global_subscribe[0]", "filter_discard_list") or {}
local filter_keyword_keep_list_default = uci:get(appname, "@global_subscribe[0]", "filter_keep_list") or {}
local function is_filter_keyword(value)
if filter_keyword_mode_default == "1" then
for k,v in ipairs(filter_keyword_discard_list_default) do
if value:find(v) then
return true
end
end
elseif filter_keyword_mode_default == "2" then
local result = true
for k,v in ipairs(filter_keyword_keep_list_default) do
if value:find(v) then
result = false
end
end
return result
end
return false
end
local nodeResult = {} -- update result
local arg2 = arg[2]
local debug = false
local ss_rust_encrypt_method_list = {
"aes-128-gcm", "aes-256-gcm", "chacha20-ietf-poly1305"
@ -39,7 +62,7 @@ local ss_rust_encrypt_method_list = {
local log = function(...)
local result = os.date("%Y-%m-%d %H:%M:%S: ") .. table.concat({...}, " ")
if arg2 == "print" then
if debug == true then
print(result)
else
local f, err = io.open("/var/log/" .. appname .. ".log", "a")
@ -259,29 +282,6 @@ do
end
end
-- 判断是否过滤节点关键字
local filter_keyword_mode = uci:get(appname, "@global_subscribe[0]", "filter_keyword_mode") or "0"
local filter_keyword_discard_list = uci:get(appname, "@global_subscribe[0]", "filter_discard_list") or {}
local filter_keyword_keep_list = uci:get(appname, "@global_subscribe[0]", "filter_keep_list") or {}
local function is_filter_keyword(value)
if filter_keyword_mode == "1" then
for k,v in ipairs(filter_keyword_discard_list) do
if value:find(v) then
return true
end
end
elseif filter_keyword_mode == "2" then
local result = true
for k,v in ipairs(filter_keyword_keep_list) do
if value:find(v) then
result = false
end
end
return result
end
return false
end
-- 分割字符串
local function split(full, sep)
if full then
@ -490,15 +490,15 @@ local function processData(szType, content, add_mode, add_from)
end
end
if flag then
if ss_aead_type == "shadowsocks-libev" and has_ss then
if ss_aead_type_default == "shadowsocks-libev" and has_ss then
result.type = "SS"
elseif ss_aead_type == "shadowsocks-rust" and has_ss_rust then
elseif ss_aead_type_default == "shadowsocks-rust" and has_ss_rust then
result.type = 'SS-Rust'
elseif ss_aead_type == "v2ray" and has_v2ray and not result.plugin then
elseif ss_aead_type_default == "v2ray" and has_v2ray and not result.plugin then
result.type = 'V2ray'
result.protocol = 'shadowsocks'
result.transport = 'tcp'
elseif ss_aead_type == "xray" and has_xray and not result.plugin then
elseif ss_aead_type_default == "xray" and has_xray and not result.plugin then
result.type = 'Xray'
result.protocol = 'shadowsocks'
result.transport = 'tcp'
@ -568,15 +568,15 @@ local function processData(szType, content, add_mode, add_from)
result.tls_serverName = peer and peer or sni
result.tls_allowInsecure = allowInsecure and "1" or "0"
end
if trojan_type == "trojan-plus" and has_trojan_plus then
if trojan_type_default == "trojan-plus" and has_trojan_plus then
result.type = "Trojan-Plus"
elseif trojan_type == "v2ray" and has_v2ray then
elseif trojan_type_default == "v2ray" and has_v2ray then
result.type = 'V2ray'
result.protocol = 'trojan'
elseif trojan_type == "xray" and has_xray then
elseif trojan_type_default == "xray" and has_xray then
result.type = 'Xray'
result.protocol = 'trojan'
elseif trojan_type == "trojan-go" and has_trojan_go then
elseif trojan_type_default == "trojan-go" and has_trojan_go then
result.type = 'Trojan-Go'
end
elseif szType == "trojan-go" then
@ -758,14 +758,12 @@ local function processData(szType, content, add_mode, add_from)
end
-- curl
local function curl(url, file)
local ua = "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.122 Safari/537.36"
local a = ""
if luci.sys.call('curl --help all | grep "\\-\\-retry-all-errors" > /dev/null') == 0 then
a = "--retry-all-errors"
local function curl(url, file, ua)
if not ua or ua == "" then
ua = "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.122 Safari/537.36"
end
local stdout = ""
local cmd = string.format('curl -skL --user-agent "%s" --retry 3 --connect-timeout 3 %s "%s"', ua, a, url)
local cmd = string.format('curl -skL --user-agent "%s" --retry 3 --connect-timeout 3 "%s"', ua, url)
if file then
cmd = cmd .. " -o " .. file
stdout = luci.sys.call(cmd .. " > /dev/null")
@ -779,7 +777,7 @@ local function curl(url, file)
if uci:get(appname, "@global_subscribe[0]", "subscribe_proxy") or "0" == "1" and uci:get(appname, "@global[0]", "enabled") or "0" == "1" then
log('通过代理订阅失败,尝试关闭代理订阅。')
luci.sys.call("/etc/init.d/" .. appname .. " stop > /dev/null")
stdout = luci.sys.exec(string.format('curl -skL --user-agent "%s" -k --retry 3 --connect-timeout 3 %s "%s"', ua, a, url))
stdout = luci.sys.exec(string.format('curl -skL --user-agent "%s" -k --retry 3 --connect-timeout 3 "%s"', ua, url))
end
end
return trim(stdout)
@ -797,7 +795,13 @@ local function truncate_nodes(add_from)
config.set(config)
else
if config.currentNode.add_mode == "2" then
config.set(config, "nil")
if add_from then
if config.currentNode.add_from and config.currentNode.add_from == add_from then
config.set(config, "nil")
end
else
config.set(config, "nil")
end
if config.id then
uci:delete(appname, config.id)
end
@ -1068,45 +1072,64 @@ end
local execute = function()
do
local subscribe_list = {}
local retry = {}
uci:foreach(appname, "subscribe_list", function(obj)
local enabled = obj.enabled or nil
if enabled and enabled == "1" then
local remark = obj.remark
local url = obj.url
log('正在订阅: ' .. url)
local raw = curl(url, "/tmp/" .. remark)
if raw == 0 then
local f = io.open("/tmp/" .. remark, "r")
local stdout = f:read("*all")
f:close()
raw = trim(stdout)
os.remove("/tmp/" .. remark)
parse_link(raw, "2", remark)
else
retry[#retry + 1] = obj
end
if arg[2] then
subscribe_list[#subscribe_list + 1] = uci:get_all(appname, arg[2]) or {}
end
for index, value in ipairs(subscribe_list) do
local remark = value.remark
local url = value.url
if value.allowInsecure and value.allowInsecure ~= "1" then
allowInsecure_default = nil
end
end)
local filter_keyword_mode = value.filter_keyword_mode or "3"
if filter_keyword_mode == "0" then
filter_keyword_mode_default = "0"
elseif filter_keyword_mode == "1" then
filter_keyword_mode_default = "1"
filter_keyword_discard_list_default = value.filter_discard_list or {}
elseif filter_keyword_mode == "2" then
filter_keyword_mode_default = "2"
filter_keyword_keep_list_default = value.filter_keep_list or {}
end
local ss_aead_type = value.ss_aead_type or "global"
if ss_aead_type ~= "global" then
ss_aead_type_default = ss_aead_type
end
local trojan_type = value.trojan_type or "global"
if trojan_type ~= "global" then
trojan_type_default = trojan_type
end
local ua = value.user_agent
log('正在订阅:【' .. remark .. '' .. url)
local raw = curl(url, "/tmp/" .. remark, ua)
if raw == 0 then
local f = io.open("/tmp/" .. remark, "r")
local stdout = f:read("*all")
f:close()
raw = trim(stdout)
os.remove("/tmp/" .. remark)
parse_link(raw, "2", remark)
else
retry[#retry + 1] = value
end
allowInsecure_default = true
filter_keyword_mode_default = uci:get(appname, "@global_subscribe[0]", "filter_keyword_mode") or "0"
filter_keyword_discard_list_default = uci:get(appname, "@global_subscribe[0]", "filter_discard_list") or {}
filter_keyword_keep_list_default = uci:get(appname, "@global_subscribe[0]", "filter_keep_list") or {}
ss_aead_type_default = uci:get(appname, "@global_subscribe[0]", "ss_aead_type") or "shadowsocks-libev"
trojan_type_default = uci:get(appname, "@global_subscribe[0]", "trojan_type") or "trojan-plus"
end
if #retry > 0 then
if (uci:get(appname, "@global_subscribe[0]", "subscribe_proxy") or "0") == "1" and (uci:get(appname, "@global[0]", "enabled") or "0") == "1" then
log('通过代理订阅失败,尝试关闭代理订阅。')
luci.sys.call("/etc/init.d/" .. appname .. " stop > /dev/null")
for index, value in ipairs(retry) do
log('正在订阅: ' .. value.url)
local raw = curl(value.url, "/tmp/" .. value.remark)
if raw == 0 then
local f = io.open("/tmp/" .. value.remark, "r")
local stdout = f:read("*all")
f:close()
raw = trim(stdout)
os.remove("/tmp/" .. value.remark)
parse_link(raw, "2", value.remark)
else
log(value.remark .. '订阅失败,可能是订阅地址失效,或是网络问题,请检测。')
end
for index, value in ipairs(retry) do
if (uci:get(appname, "@global_subscribe[0]", "subscribe_proxy") or "0") == "1" and (uci:get(appname, "@global[0]", "enabled") or "0") == "1" then
log(value.remark .. '订阅失败,请尝试关闭代理后再订阅。')
else
log(value.remark .. '订阅失败,可能是订阅地址失效,或是网络问题,请诊断!')
end
luci.sys.call("/etc/init.d/" .. appname .. " restart > /dev/null 2>&1 &")
end
end
update_node(0)
@ -1115,18 +1138,13 @@ end
if arg[1] then
if arg[1] == "start" then
local count = luci.sys.exec("echo -n $(uci show " .. appname .. " | grep @subscribe_list | grep -c \"enabled='1'\")")
if count and tonumber(count) > 0 then
log('开始订阅...')
xpcall(execute, function(e)
log(e)
log(debug.traceback())
log('发生错误, 正在恢复服务')
end)
log('订阅完毕...')
else
log('未设置订阅或未启用订阅, 请检查设置...')
end
log('开始订阅...')
xpcall(execute, function(e)
log(e)
log(debug.traceback())
log('发生错误, 正在恢复服务')
end)
log('订阅完毕...')
elseif arg[1] == "add" then
local f = assert(io.open("/tmp/links.conf", 'r'))
local content = f:read('*all')

View File

@ -22,6 +22,7 @@
'require uci';
'require form';
'require rpc';
'require view';
var conf = 'smartdns';
var callServiceList = rpc.declare({
@ -115,7 +116,7 @@ function smartdnsRenderStatus(res) {
return renderHTML;
}
return L.view.extend({
return view.extend({
load: function () {
return Promise.all([
uci.load('smartdns'),