mirror of
https://github.com/caiwx86/small-packages.git
synced 2026-07-27 08:31:44 +08:00
117 lines
5.0 KiB
Lua
117 lines
5.0 KiB
Lua
local api = require "luci.passwall2.api"
|
|
local appname = api.appname
|
|
|
|
m = Map(appname)
|
|
api.set_apply_on_parse(m)
|
|
|
|
-- [[ Rule Settings ]]--
|
|
s = m:section(TypedSection, "global_rules", translate("Rule status"))
|
|
s.anonymous = true
|
|
|
|
o = s:option(Value, "geoip_url", translate("GeoIP Update URL"))
|
|
o:value("https://github.com/Loyalsoldier/v2ray-rules-dat/releases/latest/download/geoip.dat", translate("Loyalsoldier/geoip"))
|
|
o:value("https://gh-proxy.org/https://github.com/Loyalsoldier/v2ray-rules-dat/releases/latest/download/geoip.dat", translate("Loyalsoldier/geoip (gh-proxy)"))
|
|
o:value("https://cdn.jsdelivr.net/gh/Loyalsoldier/v2ray-rules-dat@release/geoip.dat", translate("Loyalsoldier/geoip (CDN)"))
|
|
o:value("https://github.com/MetaCubeX/meta-rules-dat/releases/latest/download/geoip.dat", translate("MetaCubeX/geoip"))
|
|
o:value("https://gh-proxy.org/https://github.com/MetaCubeX/meta-rules-dat/releases/latest/download/geoip.dat", translate("MetaCubeX/geoip (gh-proxy)"))
|
|
o:value("https://cdn.jsdelivr.net/gh/MetaCubeX/meta-rules-dat@release/geoip.dat", translate("MetaCubeX/geoip (CDN)"))
|
|
o:value("https://github.com/Chocolate4U/Iran-v2ray-rules/releases/latest/download/geoip.dat", translate("Chocolate4U/geoip (IR)"))
|
|
o:value("https://github.com/runetfreedom/russia-v2ray-rules-dat/releases/latest/download/geoip.dat", translate("runetfreedom/geoip (RU)"))
|
|
o.default = o.keylist[1]
|
|
|
|
o = s:option(Value, "geosite_url", translate("Geosite Update URL"))
|
|
o:value("https://github.com/Loyalsoldier/v2ray-rules-dat/releases/latest/download/geosite.dat", translate("Loyalsoldier/geosite"))
|
|
o:value("https://gh-proxy.org/https://github.com/Loyalsoldier/v2ray-rules-dat/releases/latest/download/geosite.dat", translate("Loyalsoldier/geosite (gh-proxy)"))
|
|
o:value("https://cdn.jsdelivr.net/gh/Loyalsoldier/v2ray-rules-dat@release/geosite.dat", translate("Loyalsoldier/geosite (CDN)"))
|
|
o:value("https://github.com/MetaCubeX/meta-rules-dat/releases/latest/download/geosite.dat", translate("MetaCubeX/geosite"))
|
|
o:value("https://gh-proxy.org/https://github.com/MetaCubeX/meta-rules-dat/releases/latest/download/geosite.dat", translate("MetaCubeX/geosite (gh-proxy)"))
|
|
o:value("https://cdn.jsdelivr.net/gh/MetaCubeX/meta-rules-dat@release/geosite.dat", translate("MetaCubeX/geosite (CDN)"))
|
|
o:value("https://github.com/Chocolate4U/Iran-v2ray-rules/releases/latest/download/geosite.dat", translate("Chocolate4U/geosite (IR)"))
|
|
o:value("https://github.com/runetfreedom/russia-v2ray-rules-dat/releases/latest/download/geosite.dat", translate("runetfreedom/geosite (RU)"))
|
|
o.default = o.keylist[1]
|
|
|
|
o = s:option(Value, "v2ray_location_asset", translate("Location of Geo rule files"), translate("This variable specifies a directory where geoip.dat and geosite.dat files are."))
|
|
o.default = "/usr/share/v2ray/"
|
|
o.placeholder = o.default
|
|
o.rmempty = false
|
|
|
|
o = s:option(ListValue, "update_week_mode", translate("Auto Update Mode"))
|
|
o:value("", translate("Disable"))
|
|
o:value(8, translate("Loop Mode"))
|
|
o:value(7, translate("Every day"))
|
|
o:value(1, translate("Every Monday"))
|
|
o:value(2, translate("Every Tuesday"))
|
|
o:value(3, translate("Every Wednesday"))
|
|
o:value(4, translate("Every Thursday"))
|
|
o:value(5, translate("Every Friday"))
|
|
o:value(6, translate("Every Saturday"))
|
|
o:value(0, translate("Every Sunday"))
|
|
|
|
o = s:option(Value, "update_time_mode", translate("Update Time"))
|
|
o:value("0:00")
|
|
for t = 0, 23 do
|
|
if t == 12 then
|
|
o:value(t .. ":30")
|
|
elseif t == 23 then
|
|
o:value(t .. ":59")
|
|
else
|
|
o:value(t .. ":00")
|
|
end
|
|
end
|
|
o.default = "0:00"
|
|
o.validate = function(self, value)
|
|
local b = api.is_timehhmm(value)
|
|
if b then
|
|
return value
|
|
end
|
|
return nil
|
|
end
|
|
o:depends("update_week_mode", "0")
|
|
o:depends("update_week_mode", "1")
|
|
o:depends("update_week_mode", "2")
|
|
o:depends("update_week_mode", "3")
|
|
o:depends("update_week_mode", "4")
|
|
o:depends("update_week_mode", "5")
|
|
o:depends("update_week_mode", "6")
|
|
o:depends("update_week_mode", "7")
|
|
|
|
o = s:option(ListValue, "update_interval_mode", translate("Update Interval(hour)"))
|
|
for t = 1, 24 do o:value(t, t .. " " .. translate("hour")) end
|
|
o.default = 2
|
|
o:depends("update_week_mode", "8")
|
|
o.rmempty = true
|
|
|
|
--- The update option is always hidden by JavaScript.
|
|
local flags = {
|
|
"geoip_update", "geosite_update"
|
|
}
|
|
for _, f in ipairs(flags) do
|
|
o = s:option(Flag, f)
|
|
o.rmempty = false
|
|
end
|
|
|
|
s:append(Template(appname .. "/rule/rule_version"))
|
|
|
|
s = m:section(TypedSection, "shunt_rules", "Sing-Box/Xray " .. translate("Shunt Rule"), "<a style='color: red'>" .. translate("Please note attention to the priority, the higher the order, the higher the priority.") .. "</a>")
|
|
s.template = "cbi/tblsection"
|
|
s.anonymous = false
|
|
s.addremove = true
|
|
s.sortable = true
|
|
s.extedit = api.url("shunt_rules", "%s")
|
|
function s.create(e, t)
|
|
TypedSection.create(e, t)
|
|
luci.http.redirect(e.extedit:format(t))
|
|
end
|
|
function s.remove(e, t)
|
|
m.uci:foreach(appname, "nodes", function(s)
|
|
if s["protocol"] and s["protocol"] == "_shunt" then
|
|
m:del(s[".name"], t)
|
|
end
|
|
end)
|
|
TypedSection.remove(e, t)
|
|
end
|
|
|
|
o = s:option(DummyValue, "remarks", translate("Remarks"))
|
|
|
|
return m
|