mirror of
https://github.com/kiddin9/op-packages.git
synced 2026-11-05 09:54:06 +08:00
🏅 Sync 2026-06-22 01:15:34
This commit is contained in:
1 parent
6d4cdd8118
commit
4b85448aee
41 files changed
+3203
-1407
No files matched your search
@@ -661,6 +661,8 @@ function index()
|
||||
entry({"admin", "services", "shadowsocksr", "clash_client_policies"}, call("clash_client_policies")).leaf = true
|
||||
entry({"admin", "services", "shadowsocksr", "clash_client_rule_save"}, call("clash_client_rule_save")).leaf = true
|
||||
entry({"admin", "services", "shadowsocksr", "clash_client_rule_clear"}, call("clash_client_rule_clear")).leaf = true
|
||||
entry({"admin", "services", "shadowsocksr", "fetch_certsha256"}, call("fetch_certsha256")).leaf = true
|
||||
entry({"admin", "services", "shadowsocksr", "fetch_certbyname"}, call("fetch_certbyname")).leaf = true
|
||||
--[[Backup]]
|
||||
entry({"admin", "services", "shadowsocksr", "backup"}, call("create_backup")).leaf = true
|
||||
entry({'admin', 'services', "shadowsocksr", 'ip'}, call('check_ip')) -- 获取ip情况
|
||||
@@ -873,6 +875,13 @@ function add_subscribe_item()
|
||||
return
|
||||
end
|
||||
|
||||
local commit_subscribe = luci.sys.call("uci -q commit shadowsocksr >/dev/null 2>&1")
|
||||
if commit_subscribe ~= 0 then
|
||||
luci.http.prepare_content("application/json")
|
||||
luci.http.write_json({ ret = 0, error = "commit failed" })
|
||||
return
|
||||
end
|
||||
|
||||
luci.http.prepare_content("application/json")
|
||||
luci.http.write_json({ ret = 1, sid = sid, alias = alias, enabled = "1" })
|
||||
end
|
||||
@@ -1320,6 +1329,84 @@ function clash_client_rule_clear()
|
||||
})
|
||||
end
|
||||
|
||||
function fetch_certsha256()
|
||||
local 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 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(luci.sys.exec(cmd))
|
||||
|
||||
local fp = out:match("^([0-9a-fA-F]+)")
|
||||
if not fp or fp:lower():match("^e3b0c44298fc1c149afbf4c8996fb924") then
|
||||
return ""
|
||||
end
|
||||
return fp:upper()
|
||||
end
|
||||
|
||||
local sid = luci.http.formvalue("sid") or ""
|
||||
local address = (sid ~= "") and uci:get("shadowsocksr", sid, "server") or ""
|
||||
local port_raw = (sid ~= "") and uci:get("shadowsocksr", sid, "server_port") or ""
|
||||
local port = tonumber(port_raw) or 0
|
||||
local sni = (id ~= "") and uci:get("shadowsocksr", sid, "tls_host") or ""
|
||||
sni = (sni and sni ~= "") and sni or address
|
||||
if address == "" or port == 0 then
|
||||
luci.http.prepare_content("application/json")
|
||||
luci.http.write_json({ code = 0, msg = "Address or Port is invalid" })
|
||||
return
|
||||
end
|
||||
local data = fetch_cert_sha256(address, port, sni, 5)
|
||||
luci.http.prepare_content("application/json")
|
||||
luci.http.write_json(data ~= "" and { code = 1, data = data } or { code = 0 })
|
||||
end
|
||||
|
||||
function fetch_certbyname()
|
||||
local function fetch_cert_byname(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 cmd = string.format(
|
||||
"timeout %d openssl s_client -connect %s:%d -servername %s -showcerts </dev/null 2>/dev/null " ..
|
||||
"| openssl x509 -noout -subject 2>/dev/null " ..
|
||||
"| awk '{gsub(/^.*=[[:space:]]*/, \"\"); gsub(/,.*$/, \"\"); print}'",
|
||||
timeout, host, port, sni
|
||||
)
|
||||
|
||||
local out = trim(luci.sys.exec(cmd))
|
||||
|
||||
if out == "" then
|
||||
return ""
|
||||
end
|
||||
return out
|
||||
end
|
||||
|
||||
local sid = luci.http.formvalue("sid") or ""
|
||||
local address = (sid ~= "") and uci:get("shadowsocksr", sid, "server") or ""
|
||||
local port_raw = (sid ~= "") and uci:get("shadowsocksr", sid, "server_port") or ""
|
||||
local port = tonumber(port_raw) or 0
|
||||
local sni = (id ~= "") and uci:get("shadowsocksr", sid, "tls_host") or ""
|
||||
sni = (sni and sni ~= "") and sni or address
|
||||
if address == "" or port == 0 then
|
||||
luci.http.prepare_content("application/json")
|
||||
luci.http.write_json({ code = 0, msg = "Address or Port is invalid" })
|
||||
return
|
||||
end
|
||||
local data = fetch_cert_byname(address, port, sni, 5)
|
||||
luci.http.prepare_content("application/json")
|
||||
luci.http.write_json(data ~= "" and { code = 1, data = data } or { code = 0 })
|
||||
end
|
||||
|
||||
function act_ping()
|
||||
local e = {}
|
||||
local domain = luci.http.formvalue("domain")
|
||||
|
||||
Reference in new issue
Block a user