parent
6389d05881
commit
3599f53aee
@ -10,6 +10,7 @@ local icount = 0
|
|||||||
local args = arg[1]
|
local args = arg[1]
|
||||||
local uci = luci.model.uci.cursor()
|
local uci = luci.model.uci.cursor()
|
||||||
local TMP_DNSMASQ_PATH = "${DNSMASQ_CONF_DIR%*/}/dnsmasq-ssrplus.d"
|
local TMP_DNSMASQ_PATH = "${DNSMASQ_CONF_DIR%*/}/dnsmasq-ssrplus.d"
|
||||||
|
luci.sys.call("mkdir -p " .. TMP_DNSMASQ_PATH)
|
||||||
local TMP_PATH = "/var/etc/ssrplus"
|
local TMP_PATH = "/var/etc/ssrplus"
|
||||||
-- match comments/title/whitelist/ip address/excluded_domain
|
-- match comments/title/whitelist/ip address/excluded_domain
|
||||||
local comment_pattern = "^[!\\[@]+"
|
local comment_pattern = "^[!\\[@]+"
|
||||||
@ -54,22 +55,23 @@ local function check_excluded_domain(value)
|
|||||||
end
|
end
|
||||||
-- gfwlist转码至dnsmasq格式
|
-- gfwlist转码至dnsmasq格式
|
||||||
local function generate_gfwlist(type)
|
local function generate_gfwlist(type)
|
||||||
local domains = {}
|
local domains, domains_map = {}, {}
|
||||||
local out = io.open("/tmp/ssr-update." .. type, "w")
|
local out = io.open("/tmp/ssr-update." .. type, "w")
|
||||||
for line in io.lines("/tmp/ssr-update.tmp") do
|
for line in io.lines("/tmp/ssr-update.tmp") do
|
||||||
if not (string.find(line, comment_pattern) or string.find(line, ip_pattern) or check_excluded_domain(line)) then
|
if not (string.find(line, comment_pattern) or string.find(line, ip_pattern) or check_excluded_domain(line)) then
|
||||||
local start, finish, match = string.find(line, domain_pattern)
|
local start, finish, match = string.find(line, domain_pattern)
|
||||||
if (start) then
|
if start and not domains_map[match] then
|
||||||
domains[match] = true
|
domains_map[match] = true
|
||||||
end
|
table.insert(domains, match)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
for k, v in pairs(domains) do
|
end
|
||||||
out:write(string.format("server=/%s/%s#%s\n", k, mydnsip, mydnsport))
|
for _, domain in ipairs(domains) do
|
||||||
out:write(string.format("ipset=/%s/%s\n", k, ipsetname))
|
out:write(string.format("server=/%s/%s#%s\n", domain, mydnsip, mydnsport))
|
||||||
end
|
out:write(string.format("ipset=/%s/%s\n", domain, ipsetname))
|
||||||
out:close()
|
end
|
||||||
os.remove("/tmp/ssr-update.tmp")
|
out:close()
|
||||||
|
os.remove("/tmp/ssr-update.tmp")
|
||||||
end
|
end
|
||||||
|
|
||||||
-- adblock转码至dnsmasq格式
|
-- adblock转码至dnsmasq格式
|
||||||
|
Loading…
Reference in New Issue
Block a user