update 2026-06-04 00:28:20

This commit is contained in:
action committed 2026-06-04 00:28:20 +08:00
1 parent a3dfac28a4
commit 623cdab94c
36 files changed
+468 -228

No files matched your search

@@ -1067,10 +1067,12 @@ function fetch_certsha256()
local id = http.formvalue("id") or ""
local address = (id ~= "") and uci:get(appname, id, "address") or ""
local port = (id ~= "") and uci:get(appname, id, "port") or 0
if id == "" or address == "" or not api.datatypes.hostname(address) or port == 0 then
local sni = (id ~= "") and uci:get(appname, id, "tls_serverName") or ""
sni = (sni ~= "") and sni or address
if address == "" or port == 0 then
http_write_json_error()
return
end
local data = api.fetch_cert_sha256(address, port, 5)
local data = api.fetch_cert_sha256(address, port, sni, 5)
http_write_json(data ~= "" and { code = 1, data = data } or { code = 0 })
end
+13 -21
View File
@@ -1570,31 +1570,23 @@ function cleanEmptyTables(t)
return next(t) and t or nil
end
function fetch_cert_sha256(host, port, timeout)
if not host or not datatypes.hostname(host) then return "" end
function fetch_cert_sha256(host, port, sni, timeout)
if not host then return "" end
port = tonumber(port) or 443
sni = sni or host
timeout = tonumber(timeout) or 5
local xray = finded_com("xray")
local cmd
if xray then
cmd = string.format(
"timeout %d %q tls ping %s:%d 2>/dev/null " ..
"| awk 'tolower($0) ~ /without sni/ {f=1} tolower($0) ~ /with sni/ {f=0} " ..
"f && tolower($0) ~ /cert.*leaf.*sha256/ {sub(/.*:/,\"\"); gsub(/[[:space:]]/,\"\"); print; exit}'",
timeout, xray, host, port
)
else
cmd = string.format(
"timeout %d openssl s_client -connect %s:%d -servername %s -showcerts </dev/null 2>/dev/null " ..
"| awk 'BEGIN{c=0}/BEGIN CERT/{c++} c==1{print} /END CERT/{if(c==1)exit}' " ..
"| openssl x509 -outform der 2>/dev/null " ..
"| sha256sum 2>/dev/null",
timeout, host, port, host
)
end
local cmd = string.format(
"timeout %d openssl s_client -connect %s:%d -servername %s -showcerts </dev/null 2>/dev/null " ..
"| awk 'BEGIN{c=0}/BEGIN CERT/{c++} c==1{print} /END CERT/{if(c==1)exit}' " ..
"| openssl x509 -outform der 2>/dev/null " ..
"| sha256sum 2>/dev/null",
timeout, host, port, sni
)
local out = trim(sys.exec(cmd))
local fp = out:match("^([0-9a-fA-F]+)")
if not fp then return "" end
if not fp or fp:lower():match("^e3b0c44298fc1c149afbf4c8996fb924") then
return ""
end
return fp:upper()
end
@@ -1666,7 +1666,8 @@ function gen_config(var)
invert = e.invert == "1" and true or nil
}
string.gsub(e.domain_list, '[^' .. "\r\n" .. ']+', function(w)
if w:find("#") == 1 then return end
w = api.trim(w)
if w == "" or w:find("#") == 1 then return end
if w:find("geosite:") == 1 then
local _geosite = w:sub(1 + #"geosite:") --适配srs
local t = geo_rule_set("geosite", _geosite)
@@ -1703,7 +1704,7 @@ function gen_config(var)
domain_table.fakedns = true
end
if outboundTag then
if outboundTag and (rule.domain or rule.domain_suffix or rule.domain_keyword or rule.domain_regex or rule.rule_set) then
table.insert(dns_domain_rules, api.clone(domain_table))
end
end
@@ -1712,7 +1713,8 @@ function gen_config(var)
local ip_cidr = {}
local is_private = false
string.gsub(e.ip_list, '[^' .. "\r\n" .. ']+', function(w)
if w:find("#") == 1 then return end
w = api.trim(w)
if w == "" or w:find("#") == 1 then return end
if w:find("geoip:") == 1 then
local _geoip = w:sub(1 + #"geoip:") --适配srs
if _geoip == "private" then
+19 -17
View File
@@ -498,9 +498,9 @@ function gen_config_server(node)
if node.protocol == "vmess" or node.protocol == "vless" then
if node.uuid then
local clients = {}
local users = {}
for i = 1, #node.uuid do
clients[i] = {
users[i] = {
id = node.uuid[i],
flow = (node.protocol == "vless"
and (node.tls == "1" or (node.decryption and node.decryption ~= "" and node.decryption ~= "none"))
@@ -508,7 +508,7 @@ function gen_config_server(node)
}
end
settings = {
clients = clients,
users = users,
decryption = (node.protocol == "vless") and ((node.decryption and node.decryption ~= "") and node.decryption or "none") or nil
}
end
@@ -516,7 +516,7 @@ function gen_config_server(node)
settings = {
udp = ("1" == node.udp_forward) and true or false,
auth = ("1" == node.auth) and "password" or "noauth",
accounts = ("1" == node.auth) and {
users = ("1" == node.auth) and {
{
user = node.username,
pass = node.password
@@ -526,7 +526,7 @@ function gen_config_server(node)
elseif node.protocol == "http" then
settings = {
allowTransparent = false,
accounts = ("1" == node.auth) and {
users = ("1" == node.auth) and {
{
user = node.username,
pass = node.password
@@ -544,20 +544,20 @@ function gen_config_server(node)
}
elseif node.protocol == "trojan" then
if node.uuid then
local clients = {}
local users = {}
for i = 1, #node.uuid do
clients[i] = {
users[i] = {
password = node.uuid[i],
}
end
settings = {
clients = clients
users = users
}
end
elseif node.protocol == "hysteria2" then
settings = {
version = 2,
clients = node.hysteria2_auth_password and {
users = node.hysteria2_auth_password and {
{ auth = node.hysteria2_auth_password }
}
}
@@ -946,7 +946,7 @@ function gen_config(var)
end
if local_socks_username and local_socks_password and local_socks_username ~= "" and local_socks_password ~= "" then
inbound.settings.auth = "password"
inbound.settings.accounts = {
inbound.settings.users = {
{
user = local_socks_username,
pass = local_socks_password
@@ -963,7 +963,7 @@ function gen_config(var)
settings = {allowTransparent = false}
}
if local_http_username and local_http_password and local_http_username ~= "" and local_http_password ~= "" then
inbound.settings.accounts = {
inbound.settings.users = {
{
user = local_http_username,
pass = local_http_password
@@ -1422,7 +1422,8 @@ function gen_config(var)
}
domains = {}
string.gsub(e.domain_list, '[^' .. "\r\n" .. ']+', function(w)
if w:find("#") == 1 then return end
w = api.trim(w)
if w == "" or w:find("#") == 1 then return end
if w:find("rule-set:", 1, true) == 1 or w:find("rs:") == 1 then return end
table.insert(domains, w)
table.insert(domain_table.domain, w)
@@ -1430,16 +1431,17 @@ function gen_config(var)
if inner_fakedns == "1" and node[e[".name"] .. "_fakedns"] == "1" and #domains > 0 then
domain_table.fakedns = true
end
if outbound_tag then
if #domains == 0 then domains = nil end
if outbound_tag and domains then
table.insert(dns_domain_rules, api.clone(domain_table))
end
if #domains == 0 then domains = nil end
end
local ip = nil
if e.ip_list then
ip = {}
string.gsub(e.ip_list, '[^' .. "\r\n" .. ']+', function(w)
if w:find("#") == 1 then return end
w = api.trim(w)
if w == "" or w:find("#") == 1 then return end
if w:find("rule-set:", 1, true) == 1 or w:find("rs:") == 1 then return end
table.insert(ip, w)
end)
@@ -2036,7 +2038,7 @@ function gen_proto_config(var)
}
if local_socks_username and local_socks_password and local_socks_username ~= "" and local_socks_password ~= "" then
inbound.settings.auth = "password"
inbound.settings.accounts = {
inbound.settings.users = {
{
user = local_socks_username,
pass = local_socks_password
@@ -2056,7 +2058,7 @@ function gen_proto_config(var)
}
}
if local_http_username and local_http_password and local_http_username ~= "" and local_http_password ~= "" then
inbound.settings.accounts = {
inbound.settings.users = {
{
user = local_http_username,
pass = local_http_password