mirror of
https://github.com/kiddin9/op-packages.git
synced 2026-11-16 21:43:33 +08:00
🎉 Sync 2026-11-08 01:01:38
This commit is contained in:
1 parent
f7911ea0fb
commit
3d26c9667a
57 files changed
+4016
-1243
No files matched your search
@@ -9,6 +9,8 @@ require 'luci.sys'
|
||||
local api = require "luci.passwall2.api"
|
||||
local c_config = api.c_config
|
||||
|
||||
loadfile("/usr/share/passwall2/clash_subconverter.lua")()
|
||||
|
||||
local datatypes = api.datatypes
|
||||
local split = api.split
|
||||
local base64Decode = api.base64Decode
|
||||
@@ -67,8 +69,6 @@ uci:revert(c_config)
|
||||
math.randomseed(os.time() + math.floor(os.clock() * 1000))
|
||||
local restart_required = false
|
||||
|
||||
local lyaml = require "lyaml"
|
||||
|
||||
local has_ss_rust = api.is_finded("sslocal")
|
||||
local has_ssr = api.is_finded("ssr-local") and api.is_finded("ssr-redir")
|
||||
local has_singbox = api.finded_com("sing-box")
|
||||
@@ -475,6 +475,7 @@ end
|
||||
|
||||
-- Retrieve subscribe information (remaining data allowance, expiration time).
|
||||
local subscribe_info = {}
|
||||
local subscribe_info_from_headers = {}
|
||||
local function get_subscribe_info(cfgid, value)
|
||||
if type(cfgid) ~= "string" or cfgid == "" or type(value) ~= "string" then
|
||||
return
|
||||
@@ -513,346 +514,6 @@ local function set_ss_implementation(ss_type, result)
|
||||
return result
|
||||
end
|
||||
|
||||
local function parseClashNode(node, add_mode, group, sub_cfg)
|
||||
local sub_allowinsecure = DEFAULT_ALLOWINSECURE
|
||||
local sub_ss_type = DEFAULT_SS_TYPE
|
||||
local sub_trojan_type = DEFAULT_TROJAN_TYPE
|
||||
local sub_vmess_type = DEFAULT_VMESS_TYPE
|
||||
local sub_vless_type = DEFAULT_VLESS_TYPE
|
||||
local sub_hysteria2_type = DEFAULT_HYSTERIA2_TYPE
|
||||
local sub_hy_up_mbps, sub_hy_down_mbps
|
||||
if sub_cfg then
|
||||
if sub_cfg.allowInsecure and sub_cfg.allowInsecure ~= "1" then
|
||||
sub_allowinsecure = nil
|
||||
end
|
||||
local ss_type = sub_cfg.ss_type or "global"
|
||||
if ss_type ~= "global" and core_has[ss_type] then
|
||||
sub_ss_type = ss_type
|
||||
end
|
||||
local trojan_type = sub_cfg.trojan_type or "global"
|
||||
if trojan_type ~= "global" and core_has[trojan_type] then
|
||||
sub_trojan_type = trojan_type
|
||||
end
|
||||
local vmess_type = sub_cfg.vmess_type or "global"
|
||||
if vmess_type ~= "global" and core_has[vmess_type] then
|
||||
sub_vmess_type = vmess_type
|
||||
end
|
||||
local vless_type = sub_cfg.vless_type or "global"
|
||||
if vless_type ~= "global" and core_has[vless_type] then
|
||||
sub_vless_type = vless_type
|
||||
end
|
||||
local hysteria2_type = sub_cfg.hysteria2_type or "global"
|
||||
if hysteria2_type ~= "global" and core_has[hysteria2_type] then
|
||||
sub_hysteria2_type = hysteria2_type
|
||||
end
|
||||
sub_hy_up_mbps = sub_cfg.hysteria_up_mbps
|
||||
sub_hy_down_mbps = sub_cfg.hysteria_down_mbps
|
||||
end
|
||||
local result = {
|
||||
timeout = 60,
|
||||
add_mode = add_mode, -- `0` for manual configuration, `1` for import, `2` for subscription
|
||||
group = group
|
||||
}
|
||||
result.remarks = node.name
|
||||
result.address = node.server
|
||||
result.port = node.port
|
||||
|
||||
if node.type == 'ss' then
|
||||
result = set_ss_implementation(sub_ss_type, result)
|
||||
if not result then return nil end
|
||||
result.method = node.cipher
|
||||
result.ss_method = node.cipher
|
||||
result.password = node.password
|
||||
if node.plugin == "obfs" then
|
||||
result.plugin = "obfs-local"
|
||||
elseif node.plugin == "v2ray-plugin" then
|
||||
result.plugin = "v2ray-plugin"
|
||||
end
|
||||
if result.plugin then
|
||||
result.plugin_enabled = "1"
|
||||
if result.type == 'Xray' then
|
||||
if result.plugin ~= "obfs-local" then
|
||||
result.plugin_enabled = nil
|
||||
result.error_msg = i18n.translatef("%s unsupport SS %s plugin.", "Xray", result.plugin)
|
||||
end
|
||||
elseif result.type == 'sing-box' then
|
||||
if result.plugin ~= "obfs-local" and result.plugin ~= "v2ray-plugin" then
|
||||
result.plugin_enabled = nil
|
||||
result.error_msg = i18n.translatef("%s unsupport SS %s plugin.", "Sing-Box", result.plugin)
|
||||
end
|
||||
end
|
||||
if node["plugin-opts"] and result.plugin_enabled == "1" then
|
||||
if node.plugin == "obfs" then
|
||||
local plugin_opts = ""
|
||||
local opts_mode = node["plugin-opts"].mode
|
||||
if opts_mode then
|
||||
plugin_opts = plugin_opts .. "obfs=" .. opts_mode .. ";"
|
||||
end
|
||||
local opts_host = node["plugin-opts"].host
|
||||
if opts_host then
|
||||
plugin_opts = plugin_opts .. "obfs-host=" .. opts_host
|
||||
end
|
||||
result.plugin_opts = plugin_opts
|
||||
elseif node.plugin == "v2ray-plugin" then
|
||||
local plugin_opts = ""
|
||||
local opts_mode = node["plugin-opts"].mode
|
||||
local opts_tls = node["plugin-opts"].tls
|
||||
if opts_tls then
|
||||
plugin_opts = plugin_opts .. "tls;"
|
||||
end
|
||||
local opts_skip_cert_verify = node["plugin-opts"]["skip-cert-verify"]
|
||||
local opts_host = node["plugin-opts"].host
|
||||
if opts_host then
|
||||
plugin_opts = plugin_opts .. "host=" .. opts_host .. ";"
|
||||
end
|
||||
local opts_path = node["plugin-opts"].path
|
||||
local opts_mux = node["plugin-opts"].mux
|
||||
if node["plugin-opts"].headers then
|
||||
--todo
|
||||
end
|
||||
result.plugin_opts = plugin_opts
|
||||
end
|
||||
end
|
||||
end
|
||||
elseif node.type == 'ssr' then
|
||||
if not has_ssr then
|
||||
log(2, i18n.translatef("Skipping the %s node is due to incompatibility with the %s core program or incorrect node usage type settings.", "SSR", "shadowsocksr-libev"))
|
||||
return nil
|
||||
end
|
||||
result.type = "SSR"
|
||||
result.method = node.cipher
|
||||
result.password = node.password
|
||||
result.obfs = node.obfs
|
||||
result.protocol = node.protocol
|
||||
result.obfs_param = node["obfs-param"]
|
||||
result.protocol_param = node["protocol-param"]
|
||||
elseif node.type == 'vmess' then
|
||||
if sub_vmess_type == "sing-box" and has_singbox then
|
||||
result.type = 'sing-box'
|
||||
elseif sub_vmess_type == "xray" and has_xray then
|
||||
result.type = "Xray"
|
||||
else
|
||||
log(2, i18n.translatef("Skipping the %s node is due to incompatibility with the %s core program or incorrect node usage type settings.", "VMess", "VMess"))
|
||||
return nil
|
||||
end
|
||||
result.protocol = 'vmess'
|
||||
result.uuid = node.uuid
|
||||
result.alter_id = node.alterId
|
||||
result.security = node.cipher or "auto"
|
||||
result.tcp_fast_open = node.tfo
|
||||
result.tls = "0"
|
||||
if node.tls then
|
||||
result.tls = "1"
|
||||
result.tls_serverName = node.servername or ""
|
||||
local insecure = node["skip-cert-verify"]
|
||||
result.tls_allowInsecure = insecure and "1" or "0"
|
||||
if sub_allowinsecure then
|
||||
result.tls_allowInsecure = "1"
|
||||
end
|
||||
end
|
||||
result.transport = node.network and string.lower(node.network) or "tcp"
|
||||
if result.type == "sing-box" and result.transport == "raw" then
|
||||
result.transport = "tcp"
|
||||
elseif result.type == "Xray" and result.transport == "tcp" then
|
||||
result.transport = "raw"
|
||||
end
|
||||
if result.transport == 'ws' then
|
||||
local ws_opts = node["ws-opts"]
|
||||
if ws_opts then
|
||||
if ws_opts.headers then
|
||||
result.ws_host = ws_opts.headers.Host or ws_opts.headers.host
|
||||
end
|
||||
if ws_opts.path then
|
||||
result.ws_path = ws_opts.path
|
||||
if ws_opts["max-early-data"] then
|
||||
if result.type == "sing-box" then
|
||||
result.ws_enableEarlyData = "1"
|
||||
result.ws_maxEarlyData = tonumber(ws_opts["max-early-data"])
|
||||
result.ws_earlyDataHeaderName = "Sec-WebSocket-Protocol"
|
||||
elseif result.type == "Xray" then
|
||||
result.ws_path = result.ws_path .. "?ed=" .. ws_opts["max-early-data"]
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
elseif result.transport == 'h2' then
|
||||
local h2_opts = node["h2-opts"]
|
||||
if h2_opts then
|
||||
if result.type == "sing-box" then
|
||||
result.http_path = h2_opts.path
|
||||
result.http_host = h2_opts.host
|
||||
elseif result.type == "Xray" then
|
||||
result.xhttp_mode = "stream-one"
|
||||
result.xhttp_path = h2_opts.path
|
||||
result.xhttp_host = h2_opts.host
|
||||
end
|
||||
end
|
||||
elseif result.transport == 'grpc' then
|
||||
local grpc_opts = node["grpc-opts"]
|
||||
if grpc_opts then
|
||||
result.grpc_serviceName = grpc_opts["grpc-service-name"]
|
||||
end
|
||||
end
|
||||
elseif node.type == 'vless' then
|
||||
if sub_vless_type == "sing-box" and has_singbox then
|
||||
result.type = 'sing-box'
|
||||
elseif sub_vless_type == "xray" and has_xray then
|
||||
result.type = "Xray"
|
||||
else
|
||||
log(2, i18n.translatef("Skipping the %s node is due to incompatibility with the %s core program or incorrect node usage type settings.", "VLESS", "VLESS"))
|
||||
return nil
|
||||
end
|
||||
result.protocol = "vless"
|
||||
result.uuid = node.uuid
|
||||
result.tcp_fast_open = node.tfo
|
||||
result.encryption = node.cipher or "none"
|
||||
result.flow = node.flow
|
||||
result.tls = "0"
|
||||
if node.tls then
|
||||
result.tls = "1"
|
||||
result.tls_serverName = node.servername or ""
|
||||
local insecure = node["skip-cert-verify"]
|
||||
result.tls_allowInsecure = insecure and "1" or "0"
|
||||
if sub_allowinsecure then
|
||||
result.tls_allowInsecure = "1"
|
||||
end
|
||||
end
|
||||
if node.tls and node["reality-opts"] and node["reality-opts"]["public-key"] then
|
||||
result.reality = "1"
|
||||
result.reality_publicKey = (node["reality-opts"] and node["reality-opts"]["public-key"]) or nil
|
||||
result.reality_shortId = (node["reality-opts"] and node["reality-opts"]["short-id"]) or nil
|
||||
end
|
||||
result.transport = node.network and string.lower(node.network) or "tcp"
|
||||
if result.type == "sing-box" and result.transport == "raw" then
|
||||
result.transport = "tcp"
|
||||
elseif result.type == "Xray" and result.transport == "tcp" then
|
||||
result.transport = "raw"
|
||||
end
|
||||
if result.transport == 'ws' then
|
||||
local ws_opts = node["ws-opts"]
|
||||
if ws_opts then
|
||||
if ws_opts.headers then
|
||||
result.ws_host = ws_opts.headers.Host or ws_opts.headers.host
|
||||
end
|
||||
if ws_opts.path then
|
||||
result.ws_path = ws_opts.path
|
||||
if ws_opts["max-early-data"] then
|
||||
if result.type == "sing-box" then
|
||||
result.ws_enableEarlyData = "1"
|
||||
result.ws_maxEarlyData = tonumber(ws_opts["max-early-data"])
|
||||
result.ws_earlyDataHeaderName = "Sec-WebSocket-Protocol"
|
||||
elseif result.type == "Xray" then
|
||||
result.ws_path = result.ws_path .. "?ed=" .. ws_opts["max-early-data"]
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
elseif node.type == 'trojan' then
|
||||
if sub_trojan_type == "sing-box" and has_singbox then
|
||||
result.type = 'sing-box'
|
||||
result.protocol = 'trojan'
|
||||
elseif sub_trojan_type == "xray" and has_xray then
|
||||
result.type = 'Xray'
|
||||
result.protocol = 'trojan'
|
||||
else
|
||||
log(2, i18n.translatef("Skipping the %s node is due to incompatibility with the %s core program or incorrect node usage type settings.", "Trojan", "Trojan"))
|
||||
return nil
|
||||
end
|
||||
result.password = node.password
|
||||
result.tls = '1'
|
||||
result.tls_serverName = node.sni or ""
|
||||
local insecure = node["skip-cert-verify"]
|
||||
result.tls_allowInsecure = insecure and "1" or "0"
|
||||
if sub_allowinsecure then
|
||||
result.tls_allowInsecure = "1"
|
||||
end
|
||||
if node.alpn then
|
||||
--todo
|
||||
end
|
||||
if node.network == "grpc" then
|
||||
if node["grpc-opts"] then
|
||||
result.grpc_serviceName = node["grpc-opts"]["grpc-service-name"]
|
||||
end
|
||||
elseif node.network == "ws" then
|
||||
local ws_opts = node["ws-opts"]
|
||||
if ws_opts then
|
||||
result.ws_path = ws_opts.path
|
||||
if ws_opts.headers then
|
||||
result.ws_host = ws_opts.headers.Host or ws_opts.headers.host
|
||||
end
|
||||
end
|
||||
end
|
||||
elseif node.type == 'anytls' then
|
||||
if has_singbox then
|
||||
result.type = 'sing-box'
|
||||
result.protocol = "anytls"
|
||||
else
|
||||
log(2, i18n.translatef("Skip the %s node because the %s core program is not installed.", "AnyTLS", "Sing-Box 1.12"))
|
||||
return nil
|
||||
end
|
||||
result.password = node.password
|
||||
result.tls = '1'
|
||||
result.tls_serverName = node.sni or ""
|
||||
local insecure = node["skip-cert-verify"]
|
||||
result.tls_allowInsecure = insecure and "1" or "0"
|
||||
if sub_allowinsecure then
|
||||
result.tls_allowInsecure = "1"
|
||||
end
|
||||
if node["client-fingerprint"] then
|
||||
result.utls = "1"
|
||||
result.fingerprint = node["client-fingerprint"]
|
||||
end
|
||||
if node.tls and node["reality-opts"] and node["reality-opts"]["public-key"] then
|
||||
result.reality = "1"
|
||||
result.reality_publicKey = node["reality-opts"]["public-key"]
|
||||
result.reality_shortId = node["reality-opts"]["short-id"]
|
||||
end
|
||||
if node["disable-reuse"] then
|
||||
result.anytls_disable_reuse = "1"
|
||||
end
|
||||
elseif node.type == 'snell' then
|
||||
if has_singbox then
|
||||
result.type = 'sing-box'
|
||||
result.protocol = "snell"
|
||||
else
|
||||
log(2, i18n.translatef("Skip the %s node because the %s core program is not installed.", "Snell", "Sing-Box 1.14"))
|
||||
return nil
|
||||
end
|
||||
result.password = node.password
|
||||
result.snell_psk = node.psk
|
||||
result.snell_version = node.version or "4"
|
||||
if result.snell_version == "4" then
|
||||
local obfs_opts = node["obfs-opts"] or {}
|
||||
result.snell_obfs_mode = obfs_opts.mode or "none"
|
||||
result.snell_obfs_host = obfs_opts.host
|
||||
else
|
||||
result.snell_mode = "default"
|
||||
end
|
||||
result.snell_reuse = node.reuse and "1" or "0"
|
||||
end
|
||||
if not result.remarks or result.remarks == "" then
|
||||
if result.address and result.port then
|
||||
result.remarks = result.address .. ':' .. result.port
|
||||
else
|
||||
result.remarks = "NULL"
|
||||
end
|
||||
end
|
||||
return result
|
||||
end
|
||||
|
||||
-- Processing Clash data
|
||||
local function processClashData(content, add_mode, group, sub_cfg)
|
||||
local results = {}
|
||||
for i, node in ipairs(content.proxies or {}) do
|
||||
local result = parseClashNode(node, add_mode, group, sub_cfg)
|
||||
if result then
|
||||
table.insert(results, result)
|
||||
end
|
||||
end
|
||||
return results
|
||||
end
|
||||
|
||||
-- Split URI hosts and ports, support IPv6 without a port, and strip paths.
|
||||
local function parse_host_port(host_port, default_port)
|
||||
local authority = (host_port or ""):gsub("/.*$", "")
|
||||
@@ -2038,7 +1699,8 @@ end
|
||||
local function curl(url, file, ua, mode, hwid)
|
||||
if not url or url == "" then return 22, 404 end
|
||||
local curl_args = {
|
||||
"-fskL", "-w %{http_code}", "--retry 3", "--connect-timeout 3", "-H 'Accept: */*'", "-H 'Accept-Encoding: identity'"
|
||||
"-fskL", "--retry 3", "--connect-timeout 3", "-H 'Accept: */*'", "-H 'Accept-Encoding: identity'",
|
||||
"--dump-header -", "-w '\\n%{http_code}'"
|
||||
}
|
||||
if ua and ua ~= "" and ua ~= "curl" then
|
||||
ua = (ua == "passwall2") and ("passwall2/" .. (api.get_version():match("^([^-]+)") or "")) or ua
|
||||
@@ -2060,7 +1722,15 @@ local function curl(url, file, ua, mode, hwid)
|
||||
end
|
||||
luci.sys.call('rm -f "%s"' % cookie_file)
|
||||
|
||||
return return_code, tonumber(result)
|
||||
local http_code, headers = 0, ""
|
||||
if result and result ~= "" then
|
||||
local body, code = result:match("^(.-)%s*([0-9]+)$")
|
||||
if code then
|
||||
http_code = tonumber(code) or 0
|
||||
headers = body:gsub("\r", "")
|
||||
end
|
||||
end
|
||||
return return_code, http_code, headers
|
||||
end
|
||||
|
||||
function get_headers()
|
||||
@@ -2366,12 +2036,12 @@ local function update_node(manual)
|
||||
end
|
||||
-- Sing-Box Node Domain resolver
|
||||
if kkk == "type" and (vvv == "Xray" or vvv == "sing-box") then
|
||||
if domain_resolver then
|
||||
if domain_resolver and domain_resolver ~= "" and domain_resolver ~= "disable" then
|
||||
uci_set(cfgid, "domain_resolver", domain_resolver)
|
||||
if domain_resolver_dns then
|
||||
uci_set(cfgid, "domain_resolver_dns", domain_resolver_dns)
|
||||
elseif domain_resolver_dns_https then
|
||||
if domain_resolver == "https" and domain_resolver_dns_https then
|
||||
uci_set(cfgid, "domain_resolver_dns_https", domain_resolver_dns_https)
|
||||
elseif (domain_resolver == "udp" or domain_resolver == "tcp") and domain_resolver_dns then
|
||||
uci_set(cfgid, "domain_resolver_dns", domain_resolver_dns)
|
||||
end
|
||||
end
|
||||
if domain_strategy then
|
||||
@@ -2432,7 +2102,7 @@ local function parse_link(raw, add_mode, group, sub_cfg)
|
||||
cfgid = sub_cfg[".name"]
|
||||
end
|
||||
local keyword_filter = add_mode == "2" and prepare_keyword_filter(sub_cfg)
|
||||
local nodes, szType, clashTable
|
||||
local nodes, szType
|
||||
local node_list = {}
|
||||
-- ssd appear to be in this format, starting with ssd://.
|
||||
if raw:find('ssd://') then
|
||||
@@ -2453,19 +2123,11 @@ local function parse_link(raw, add_mode, group, sub_cfg)
|
||||
end
|
||||
nodes = servers
|
||||
else
|
||||
-- Try parseYAML, if success, is clash.
|
||||
local yamlTable = lyaml.load(raw)
|
||||
if yamlTable and type(yamlTable) == "table" then
|
||||
-- clash
|
||||
szType = "clash"
|
||||
clashTable = yamlTable
|
||||
-- Formats other than SSD are handled by the existing URI parser.
|
||||
if add_mode == "1" then
|
||||
nodes = split(raw, "\n")
|
||||
else
|
||||
-- Formats other than ssd
|
||||
if add_mode == "1" then
|
||||
nodes = split(raw, "\n")
|
||||
else
|
||||
nodes = split(base64Decode(raw):gsub("\r\n", "\n"), "\n")
|
||||
end
|
||||
nodes = split(base64Decode(raw):gsub("\r\n", "\n"), "\n")
|
||||
end
|
||||
end
|
||||
|
||||
@@ -2481,20 +2143,12 @@ local function parse_link(raw, add_mode, group, sub_cfg)
|
||||
else
|
||||
tinsert(node_list, node)
|
||||
end
|
||||
if add_mode == "2" then
|
||||
if add_mode == "2" and not subscribe_info_from_headers[cfgid] then
|
||||
get_subscribe_info(cfgid, node.remarks)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if szType == "clash" and clashTable then
|
||||
nodes = {}
|
||||
local clashNodes = processClashData(clashTable, add_mode, group, sub_cfg)
|
||||
for _, v in ipairs(clashNodes) do
|
||||
nodeFilter(v)
|
||||
end
|
||||
end
|
||||
|
||||
for _, v in ipairs(nodes) do
|
||||
if v and (szType == 'ssd' or not string.match(v, "^%s*$")) then
|
||||
xpcall(function ()
|
||||
@@ -2562,6 +2216,7 @@ local execute = function()
|
||||
local cfgid = value[".name"]
|
||||
local remark = value.remark or ""
|
||||
local url = value.url or ""
|
||||
local headers
|
||||
|
||||
local url_is_local
|
||||
if fs.access(url) then
|
||||
@@ -2576,7 +2231,7 @@ local execute = function()
|
||||
log(1, i18n.translatef("Start subscribing: %s", '【' .. remark .. '】' .. url .. ' [' .. result .. ']'))
|
||||
tmp_file = "/tmp/" .. cfgid
|
||||
local return_code
|
||||
return_code, value.http_code = curl(url, tmp_file, ua, access_mode, value.hwid)
|
||||
return_code, value.http_code, headers = curl(url, tmp_file, ua, access_mode, value.hwid)
|
||||
if return_code ~= 0 then
|
||||
fail_list[#fail_list + 1] = value
|
||||
luci.sys.call("rm -f " .. tmp_file)
|
||||
@@ -2588,11 +2243,36 @@ local execute = function()
|
||||
local stdout = f:read("*all")
|
||||
f:close()
|
||||
local raw_data = api.trim(stdout)
|
||||
local auto_dns = value.domain_resolver == nil or value.domain_resolver == ""
|
||||
local resolver
|
||||
raw_data, resolver = parseClashNode(raw_data, remark, auto_dns)
|
||||
if auto_dns and resolver then
|
||||
-- Only enrich this run's sub_cfg; keep the subscription's Auto setting.
|
||||
value.domain_resolver = resolver.domain_resolver
|
||||
value.domain_resolver_dns = resolver.domain_resolver_dns
|
||||
value.domain_resolver_dns_https = resolver.domain_resolver_dns_https
|
||||
end
|
||||
if headers and headers ~= "" then
|
||||
local info = parse_clash_sub_info(headers)
|
||||
if info then
|
||||
-- Response-header account data takes precedence over node remarks.
|
||||
subscribe_info[cfgid] = info
|
||||
subscribe_info_from_headers[cfgid] = true
|
||||
end
|
||||
end
|
||||
-- Buffer parsing details until the parsed nodes are known to have changed.
|
||||
log_buffer = {}
|
||||
local parsed_nodes = parse_link(raw_data, "2", remark, value)
|
||||
local old_md5 = value.md5 or ""
|
||||
local new_md5 = #parsed_nodes > 0 and api.md5_string(jsonStringify(parsed_nodes)) or ""
|
||||
local md5_content = jsonStringify(parsed_nodes)
|
||||
if value.domain_resolver and value.domain_resolver ~= "" and value.domain_resolver ~= "disable" then
|
||||
local protocol = value.domain_resolver
|
||||
local dns = (protocol == "udp" or protocol == "tcp") and value.domain_resolver_dns or ""
|
||||
local doh = protocol == "https" and value.domain_resolver_dns_https or ""
|
||||
md5_content = md5_content .. jsonStringify({protocol, dns or "", doh or ""})
|
||||
end
|
||||
local new_md5 = #parsed_nodes > 0 and api.md5_string(md5_content) or ""
|
||||
-- Skip rewriting nodes only when both nodes and effective DNS are unchanged.
|
||||
if not manual_sub and new_md5 ~= "" and old_md5 == new_md5 then
|
||||
log_buffer = nil
|
||||
log(1, i18n.translatef("Subscription: [%s] No changes, no update required.", remark))
|
||||
@@ -2656,6 +2336,7 @@ elseif arg[1] == "add" then
|
||||
local f = assert(io.open("/tmp/links.conf", 'r'))
|
||||
local raw = f:read('*all')
|
||||
f:close()
|
||||
raw = parseClashNode(raw, arg[2])
|
||||
parse_link(raw, "1", arg[2])
|
||||
if update_node(1) then uci_save(true) end
|
||||
luci.sys.call("rm -f /tmp/links.conf")
|
||||
|
||||
Reference in new issue
Block a user