mirror of
https://github.com/kiddin9/op-packages.git
synced 2026-11-09 21:47:59 +08:00
💐 Sync 2026-10-06 12:33:44
This commit is contained in:
1 parent
8be03ce939
commit
7fe69dbb3a
246 files changed
+50330
-3414
No files matched your search
@@ -6,7 +6,9 @@ local output_uri = require("substore.output_uri")
|
||||
local output_singbox = require("substore.output_singbox")
|
||||
local output_v2ray = require("substore.output_v2ray")
|
||||
local output_formats = require("substore.output_formats")
|
||||
local output_egern = require("substore.output_egern")
|
||||
local output_wgconf = require("substore.output_wireguard_conf")
|
||||
local msg = require("substore.msg")
|
||||
|
||||
local M = {}
|
||||
|
||||
@@ -60,6 +62,10 @@ local CONTENT_TYPES = {
|
||||
surfboard = "text/plain; charset=utf-8",
|
||||
surgemac = "text/plain; charset=utf-8",
|
||||
loon = "text/plain; charset=utf-8",
|
||||
-- Egern 的配置正文是 YAML,但 Content-Type 与其它 YAML 格式(clash /
|
||||
-- clashmeta / stash)保持 text/plain 一致:这三个是本仓库既有的约定,
|
||||
-- 单独把 egern 改成 application/yaml 只会让同一类内容出现两种类型。
|
||||
-- (后缀已按内容改成 .yaml,见 FILENAME_EXT。)
|
||||
egern = "text/plain; charset=utf-8",
|
||||
qx = "text/plain; charset=utf-8",
|
||||
shadowrocket = "text/plain; charset=utf-8",
|
||||
@@ -102,7 +108,9 @@ local FILENAME_EXT = {
|
||||
surfboard = "conf",
|
||||
surgemac = "conf",
|
||||
loon = "conf",
|
||||
egern = "conf",
|
||||
-- Egern 的配置是 YAML(output_egern.lua),后缀必须与内容一致:
|
||||
-- 下游按后缀判断格式的客户端会把 .conf 当成 Surge 的逗号行去解析。
|
||||
egern = "yaml",
|
||||
qx = "conf",
|
||||
shadowrocket = "txt",
|
||||
singbox = "json",
|
||||
@@ -142,12 +150,12 @@ M.FORMAT_OPTIONS = {
|
||||
function M.generate(nodes, format, options)
|
||||
-- 空串 / 纯空白等同于「未指定」。
|
||||
-- `?target=` 会传进来 "",而 "" 在 Lua 里是**真值**,所以 `format or DEFAULT_FORMAT`
|
||||
-- 兜不住它,会一路落到 "unsupported format: "(冒号后面什么都没有)——
|
||||
-- 兜不住它,会一路落到 "Unsupported output format: "(冒号后面什么都没有)——
|
||||
-- 用户拿到的是一个说不出原因的错误页。控制器只在 nil 时兜底,覆盖不到空串。
|
||||
format = normalize_format(format)
|
||||
local norm = M.FORMAT_ALIASES[format:lower():gsub("[-_%s]", "")]
|
||||
if not norm then norm = M.FORMAT_ALIASES[format:lower()] end
|
||||
if not norm then return nil, "unsupported format: " .. tostring(format) end
|
||||
if not norm then return nil, msg.join("Unsupported output format: ", tostring(format)) end
|
||||
|
||||
if norm == "clashmeta" then return clash_meta.generate(nodes, options) end
|
||||
if norm == "clash" then return output_formats.to_clash(nodes, options) end
|
||||
@@ -156,7 +164,7 @@ function M.generate(nodes, format, options)
|
||||
if norm == "surfboard" then return output_formats.to_surfboard(nodes, options) end
|
||||
if norm == "surgemac" then return output_formats.to_surgemac(nodes, options) end
|
||||
if norm == "loon" then return output_formats.to_loon(nodes, options) end
|
||||
if norm == "egern" then return output_formats.to_egern(nodes, options) end
|
||||
if norm == "egern" then return output_egern.generate(nodes, options) end
|
||||
if norm == "shadowrocket" then return output_uri.to_shadowrocket(nodes) end
|
||||
if norm == "qx" then return output_formats.to_qx(nodes, options) end
|
||||
if norm == "singbox" then return output_singbox.generate(nodes) end
|
||||
@@ -165,7 +173,7 @@ function M.generate(nodes, format, options)
|
||||
if norm == "wgconf" then return output_wgconf.generate(nodes, options) end
|
||||
if norm == "plain" then return output_formats.to_plain(nodes) end
|
||||
|
||||
return nil, "unsupported format: " .. tostring(format)
|
||||
return nil, msg.join("Unsupported output format: ", tostring(format))
|
||||
end
|
||||
|
||||
return M
|
||||
Reference in new issue
Block a user