mirror of
https://github.com/kiddin9/op-packages.git
synced 2026-10-30 21:15:13 +08:00
🎄 Sync 2026-09-02 23:53:04
This commit is contained in:
1 parent
e27699fe9a
commit
351528cefe
53 files changed
+1219
-1072
No files matched your search
@@ -1039,7 +1039,7 @@ function geo_view()
|
||||
return
|
||||
end
|
||||
local function get_rules(str, type)
|
||||
local rules_id = {}
|
||||
local rules = {}
|
||||
uci_foreach("shunt_rules", function(s)
|
||||
local list
|
||||
if type == "geoip" then list = s.ip_list else list = s.domain_list end
|
||||
@@ -1048,14 +1048,18 @@ function geo_view()
|
||||
local prefix, main = line:match("^(.-):(.*)")
|
||||
if not main then main = line end
|
||||
if type == "geoip" and (api.datatypes.ipaddr(str) or api.datatypes.ip6addr(str)) then
|
||||
if main:find(str, 1, true) then rules_id[#rules_id + 1] = s[".name"] end
|
||||
if main:find(str, 1, true) then
|
||||
table.insert(rules, {id = s[".name"], group = s.group or i18n.translate("default")})
|
||||
end
|
||||
else
|
||||
if main == str then rules_id[#rules_id + 1] = s[".name"] end
|
||||
if main == str then
|
||||
table.insert(rules, {id = s[".name"], group = s.group or i18n.translate("default")})
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end)
|
||||
return rules_id
|
||||
return rules
|
||||
end
|
||||
local geo_dir = (uci_get("@global_rules[0]", "v2ray_location_asset") or "/usr/share/v2ray/"):match("^(.*)/")
|
||||
local geosite_path = geo_dir .. "/geosite.dat"
|
||||
@@ -1076,11 +1080,17 @@ function geo_view()
|
||||
for line in geo_string:gmatch("([^\n]+)") do
|
||||
lines[#lines + 1] = geo_type .. ":" .. line
|
||||
for _, r in ipairs(get_rules(line, geo_type) or {}) do
|
||||
if not seen[r] then seen[r] = true; rules[#rules + 1] = r end
|
||||
if not seen[r.id] then
|
||||
seen[r.id] = true
|
||||
rules[#rules + 1] = string.format("[%s]%s", r.group, r.id)
|
||||
end
|
||||
end
|
||||
end
|
||||
for _, r in ipairs(get_rules(value, geo_type) or {}) do
|
||||
if not seen[r] then seen[r] = true; rules[#rules + 1] = r end
|
||||
if not seen[r.id] then
|
||||
seen[r.id] = true
|
||||
rules[#rules + 1] = string.format("[%s]%s", r.group, r.id)
|
||||
end
|
||||
end
|
||||
geo_string = table.concat(lines, "\n")
|
||||
if #rules > 0 then
|
||||
|
||||
Reference in new issue
Block a user