mirror of
https://github.com/caiwx86/small-packages.git
synced 2026-11-01 16:44:45 +08:00
update 2026-07-23 18:15:05
This commit is contained in:
1 parent
f7b785a2e2
commit
6035fee545
1957 files changed
+1523178
-16
No files matched your search
@@ -244,7 +244,7 @@ local function encode_vless(node)
|
||||
link = link .. "?" .. table.concat(p, "&")
|
||||
end
|
||||
|
||||
return link .. "#" .. urlencode(o.name or "")
|
||||
return 0, link .. "#" .. urlencode(o.name or "")
|
||||
end
|
||||
|
||||
-- Trojan
|
||||
@@ -273,7 +273,7 @@ local function encode_trojan(node)
|
||||
link = link .. "?" .. table.concat(p, "&")
|
||||
end
|
||||
|
||||
return link .. "#" .. urlencode(o.name or "")
|
||||
return 0, link .. "#" .. urlencode(o.name or "")
|
||||
end
|
||||
|
||||
-- VMess
|
||||
@@ -307,11 +307,19 @@ local function encode_vmess(node)
|
||||
obj.path = o.transport.serviceName or ""
|
||||
end
|
||||
|
||||
return "vmess://" .. base64(json.stringify(obj))
|
||||
return 0, "vmess://" .. base64(json.stringify(obj))
|
||||
end
|
||||
|
||||
-- SS
|
||||
local function encode_ss(node)
|
||||
local ss_method = {
|
||||
["none"]=1, ["aes-128-gcm"]=1, ["aes-192-gcm"]=1, ["aes-256-gcm"]=1, ["chacha20-ietf-poly1305"]=1, ["xchacha20-ietf-poly1305"]=1, ["2022-blake3-aes-128-gcm"]=1, ["2022-blake3-aes-256-gcm"]=1, ["2022-blake3-chacha20-poly1305"]=1,
|
||||
["aes-128-ctr"]=1, ["aes-192-ctr"]=1, ["aes-256-ctr"]=1, ["aes-128-cfb"]=1, ["aes-192-cfb"]=1, ["aes-256-cfb"]=1, ["rc4-md5"]=1, ["chacha20-ietf"]=1, ["xchacha20"]=1,
|
||||
}
|
||||
if not ss_method[node.cipher or ""] then
|
||||
return 1, "订阅转换 → 丢弃 SS 节点:" .. (node.name or "") .. ",因 Core 不支持 " .. (node.cipher or "") .. " 加密方式"
|
||||
end
|
||||
|
||||
local userinfo = node.cipher .. ":" .. node.password
|
||||
local base = userinfo .. "@" .. host_format(node.server) .. ":" .. node.port
|
||||
local link = "ss://" .. base64(base)
|
||||
@@ -326,7 +334,7 @@ local function encode_ss(node)
|
||||
if plugin == "shadow-tls" then
|
||||
local shadow_tls = base64(json.stringify(node["plugin-opts"] or {}))
|
||||
table.insert(p, "shadow-tls=" .. urlencode(shadow_tls))
|
||||
else
|
||||
elseif plugin == "obfs-local" or plugin == "v2ray-plugin" then
|
||||
local opts = {}
|
||||
for k, v in pairs(node["plugin-opts"] or {}) do
|
||||
if plugin == "obfs-local" then
|
||||
@@ -341,10 +349,6 @@ local function encode_ss(node)
|
||||
end
|
||||
v = nil
|
||||
end
|
||||
elseif plugin == "gost-plugin" then
|
||||
if k == "mode" and v == "websocket" then v = "ws" end
|
||||
if k == "host" then k = "serverName" end
|
||||
if k == "headers" then v = nil end
|
||||
end
|
||||
if v ~= nil then
|
||||
if type(v) == "boolean" then
|
||||
@@ -355,6 +359,8 @@ local function encode_ss(node)
|
||||
end
|
||||
if #opts > 0 then plugin = plugin .. ";" .. table.concat(opts, ";") end
|
||||
table.insert(p, "plugin=" .. urlencode(plugin))
|
||||
else
|
||||
return 1, "订阅转换 → 丢弃 SS 节点:" .. (node.name or "") .. ",因 Core 不支持 " .. plugin .. " 插件"
|
||||
end
|
||||
end
|
||||
|
||||
@@ -362,7 +368,7 @@ local function encode_ss(node)
|
||||
link = link .. "?" .. table.concat(p, "&")
|
||||
end
|
||||
|
||||
return link .. "#" .. urlencode(node.name or "")
|
||||
return 0, link .. "#" .. urlencode(node.name or "")
|
||||
end
|
||||
|
||||
-- Hysteria
|
||||
@@ -387,7 +393,7 @@ local function encode_hysteria2(node)
|
||||
link = link .. "?" .. table.concat(p, "&")
|
||||
end
|
||||
|
||||
return link .. "#" .. urlencode(node.name or "")
|
||||
return 0, link .. "#" .. urlencode(node.name or "")
|
||||
end
|
||||
|
||||
-- Hysteria2
|
||||
@@ -411,7 +417,7 @@ local function encode_hysteria2(node)
|
||||
link = link .. "?" .. table.concat(p, "&")
|
||||
end
|
||||
|
||||
return link .. "#" .. urlencode(node.name or "")
|
||||
return 0, link .. "#" .. urlencode(node.name or "")
|
||||
end
|
||||
|
||||
-- TUIC
|
||||
@@ -436,11 +442,24 @@ local function encode_tuic(node)
|
||||
link = link .. "?" .. table.concat(p, "&")
|
||||
end
|
||||
|
||||
return link .. "#" .. urlencode(node.name or "")
|
||||
return 0, link .. "#" .. urlencode(node.name or "")
|
||||
end
|
||||
|
||||
-- AnyTLS
|
||||
local function encode_anytls(node)
|
||||
local err_msg
|
||||
if node["shadow-tls-opts"] then
|
||||
err_msg = "ShadowTLS"
|
||||
elseif node["restls-opts"] then
|
||||
err_msg = "ResTLS"
|
||||
elseif node["jls-opts"] then
|
||||
err_msg = "JLS"
|
||||
end
|
||||
if err_msg then
|
||||
err_msg = "订阅转换 → 丢弃 AnyTLS 节点:" .. (node.name or "") .. ",因 Sing-Box 不支持 AnyTLS + " .. err_msg
|
||||
return 1, err_msg
|
||||
end
|
||||
|
||||
local o = build_common(node)
|
||||
|
||||
local link = "anytls://" .. (node.password or "") .. "@" .. host_format(node.server) .. ":" .. node.port
|
||||
@@ -465,7 +484,7 @@ local function encode_anytls(node)
|
||||
link = link .. "?" .. table.concat(p, "&")
|
||||
end
|
||||
|
||||
return link .. "#" .. urlencode(node.name or "")
|
||||
return 0, link .. "#" .. urlencode(node.name or "")
|
||||
end
|
||||
|
||||
-- SSR
|
||||
@@ -482,7 +501,7 @@ local function encode_ssr(node)
|
||||
link = link .. "?" .. table.concat(p, "&")
|
||||
end
|
||||
|
||||
return "ssr://" .. base64(link)
|
||||
return 0, "ssr://" .. base64(link)
|
||||
end
|
||||
|
||||
local function encode_node(node)
|
||||
@@ -516,8 +535,10 @@ function parseClashNode(raw, remark)
|
||||
|
||||
local links = {}
|
||||
for _, node in ipairs(data.proxies) do
|
||||
local link = encode_node(node)
|
||||
if link then
|
||||
local err, link = encode_node(node)
|
||||
if err == 1 and link then
|
||||
api.log(link)
|
||||
elseif link then
|
||||
table.insert(links, link)
|
||||
end
|
||||
end
|
||||
|
||||
Reference in new issue
Block a user