parent
155d0be12b
commit
f64c9a1733
@ -41,6 +41,9 @@ o = s:option(DynamicList, "chnlist_url", translate("China List(Chnlist) Update U
|
|||||||
o:value("https://fastly.jsdelivr.net/gh/felixonmars/dnsmasq-china-list/accelerated-domains.china.conf", translate("felixonmars/domains.china"))
|
o:value("https://fastly.jsdelivr.net/gh/felixonmars/dnsmasq-china-list/accelerated-domains.china.conf", translate("felixonmars/domains.china"))
|
||||||
o:value("https://fastly.jsdelivr.net/gh/felixonmars/dnsmasq-china-list/apple.china.conf", translate("felixonmars/apple.china"))
|
o:value("https://fastly.jsdelivr.net/gh/felixonmars/dnsmasq-china-list/apple.china.conf", translate("felixonmars/apple.china"))
|
||||||
o:value("https://fastly.jsdelivr.net/gh/felixonmars/dnsmasq-china-list/google.china.conf", translate("felixonmars/google.china"))
|
o:value("https://fastly.jsdelivr.net/gh/felixonmars/dnsmasq-china-list/google.china.conf", translate("felixonmars/google.china"))
|
||||||
|
o:value("https://fastly.jsdelivr.net/gh/Loyalsoldier/v2ray-rules-dat@release/china-list.txt", translate("Loyalsoldier/china-list"))
|
||||||
|
o:value("https://fastly.jsdelivr.net/gh/Loyalsoldier/v2ray-rules-dat@release/apple-cn.txt", translate("Loyalsoldier/apple-cn"))
|
||||||
|
o:value("https://fastly.jsdelivr.net/gh/Loyalsoldier/v2ray-rules-dat@release/google-cn.txt", translate("Loyalsoldier/google-cn"))
|
||||||
|
|
||||||
s:append(Template(appname .. "/rule/rule_version"))
|
s:append(Template(appname .. "/rule/rule_version"))
|
||||||
|
|
||||||
|
@ -26,7 +26,7 @@ local comment_pattern = "^[#!\\[@]+"
|
|||||||
local ip_pattern = "^%d+%.%d+%.%d+%.%d+"
|
local ip_pattern = "^%d+%.%d+%.%d+%.%d+"
|
||||||
local ip4_ipset_pattern = "^%d+%.%d+%.%d+%.%d+[%/][%d]+$"
|
local ip4_ipset_pattern = "^%d+%.%d+%.%d+%.%d+[%/][%d]+$"
|
||||||
local ip6_ipset_pattern = ":-[%x]+%:+[%x]-[%/][%d]+$"
|
local ip6_ipset_pattern = ":-[%x]+%:+[%x]-[%/][%d]+$"
|
||||||
local domain_pattern = "([%w%-%_]+%.[%w%.%-%_]+)[%/%*]*"
|
local domain_pattern = "([%w%-]+%.[%w%.%-]+)[%/%*]*"
|
||||||
local excluded_domain = {"apple.com","sina.cn","sina.com.cn","baidu.com","byr.cn","jlike.com","weibo.com","zhongsou.com","youdao.com","sogou.com","so.com","soso.com","aliyun.com","taobao.com","jd.com","qq.com","bing.com"}
|
local excluded_domain = {"apple.com","sina.cn","sina.com.cn","baidu.com","byr.cn","jlike.com","weibo.com","zhongsou.com","youdao.com","sogou.com","so.com","soso.com","aliyun.com","taobao.com","jd.com","qq.com","bing.com"}
|
||||||
|
|
||||||
local gfwlist_url = uci:get(name, "@global_rules[0]", "gfwlist_url") or {"https://fastly.jsdelivr.net/gh/Loyalsoldier/v2ray-rules-dat@release/gfw.txt"}
|
local gfwlist_url = uci:get(name, "@global_rules[0]", "gfwlist_url") or {"https://fastly.jsdelivr.net/gh/Loyalsoldier/v2ray-rules-dat@release/gfw.txt"}
|
||||||
@ -172,9 +172,10 @@ local function fetch_rule(rule_name,rule_type,url,exclude_domain)
|
|||||||
|
|
||||||
if rule_type == "domain" and exclude_domain == true then
|
if rule_type == "domain" and exclude_domain == true then
|
||||||
for line in io.lines(download_file_tmp..k) do
|
for line in io.lines(download_file_tmp..k) do
|
||||||
if not (string.find(line, comment_pattern) or string.find(line, ip_pattern) or check_excluded_domain(line)) then
|
line = line:gsub("full:", "")
|
||||||
local start, finish, match = string.find(line, domain_pattern)
|
if not (string.find(line, comment_pattern) or string.find(line, ip_pattern) or check_excluded_domain(line) or string.find(line, ":")) then
|
||||||
if (start) then
|
local match = string.match(line, domain_pattern)
|
||||||
|
if match then
|
||||||
domains[match] = true
|
domains[match] = true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -182,9 +183,10 @@ local function fetch_rule(rule_name,rule_type,url,exclude_domain)
|
|||||||
|
|
||||||
elseif rule_type == "domain" then
|
elseif rule_type == "domain" then
|
||||||
for line in io.lines(download_file_tmp..k) do
|
for line in io.lines(download_file_tmp..k) do
|
||||||
if not (string.find(line, comment_pattern) or string.find(line, ip_pattern)) then
|
line = line:gsub("full:", "")
|
||||||
local start, finish, match = string.find(line, domain_pattern)
|
if not (string.find(line, comment_pattern) or string.find(line, ip_pattern) or string.find(line, ":")) then
|
||||||
if (start) then
|
local match = string.match(line, domain_pattern)
|
||||||
|
if match then
|
||||||
domains[match] = true
|
domains[match] = true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -193,8 +195,7 @@ local function fetch_rule(rule_name,rule_type,url,exclude_domain)
|
|||||||
elseif rule_type == "ip4" then
|
elseif rule_type == "ip4" then
|
||||||
local out = io.open(unsort_file_tmp, "a")
|
local out = io.open(unsort_file_tmp, "a")
|
||||||
for line in io.lines(download_file_tmp..k) do
|
for line in io.lines(download_file_tmp..k) do
|
||||||
local start, finish, match = string.find(line, ip4_ipset_pattern)
|
if string.match(line, ip4_ipset_pattern) then
|
||||||
if (start) then
|
|
||||||
out:write(string.format("%s\n", line))
|
out:write(string.format("%s\n", line))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -203,8 +204,7 @@ local function fetch_rule(rule_name,rule_type,url,exclude_domain)
|
|||||||
elseif rule_type == "ip6" then
|
elseif rule_type == "ip6" then
|
||||||
local out = io.open(unsort_file_tmp, "a")
|
local out = io.open(unsort_file_tmp, "a")
|
||||||
for line in io.lines(download_file_tmp..k) do
|
for line in io.lines(download_file_tmp..k) do
|
||||||
local start, finish, match = string.find(line, ip6_ipset_pattern)
|
if string.match(line, ip6_ipset_pattern) then
|
||||||
if (start) then
|
|
||||||
out:write(string.format("%s\n", line))
|
out:write(string.format("%s\n", line))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -230,8 +230,8 @@ local function fetch_rule(rule_name,rule_type,url,exclude_domain)
|
|||||||
sys.call("cat " ..unsort_file_tmp.. " | sort -u > "..file_tmp)
|
sys.call("cat " ..unsort_file_tmp.. " | sort -u > "..file_tmp)
|
||||||
os.remove(unsort_file_tmp)
|
os.remove(unsort_file_tmp)
|
||||||
|
|
||||||
local old_md5 = sys.exec("echo -n $(md5sum " .. rule_path .. "/" ..rule_name.. " | awk '{print $1}')")
|
local old_md5 = sys.exec("echo -n $(md5sum " .. rule_path .. "/" ..rule_name.. " | awk '{print $1}')"):gsub("\n", "")
|
||||||
local new_md5 = sys.exec("echo -n $([ -f '" ..file_tmp.. "' ] && md5sum " ..file_tmp.." | awk '{print $1}')")
|
local new_md5 = sys.exec("echo -n $([ -f '" ..file_tmp.. "' ] && md5sum " ..file_tmp.." | awk '{print $1}')"):gsub("\n", "")
|
||||||
if old_md5 ~= new_md5 then
|
if old_md5 ~= new_md5 then
|
||||||
local count = line_count(file_tmp)
|
local count = line_count(file_tmp)
|
||||||
if use_nft == "1" and (rule_type == "ip6" or rule_type == "ip4") then
|
if use_nft == "1" and (rule_type == "ip6" or rule_type == "ip4") then
|
||||||
|
Loading…
Reference in New Issue
Block a user