Skip to content

修复:支持查看 Inline 代理提供者内容 - #342

Open
uclort wants to merge 1 commit into
appshubcc:mainfrom
uclort:codex/support-inline-provider-content
Open

修复:支持查看 Inline 代理提供者内容#342
uclort wants to merge 1 commit into
appshubcc:mainfrom
uclort:codex/support-inline-provider-content

Conversation

@uclort

@uclort uclort commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

功能说明

修复代理提供者内容查看仅支持 HTTP/File、无法查看 Inline 提供者的问题。

Inline provider 没有缓存文件路径,旧逻辑会直接返回 provider path is empty。本改动保留最近一次成功应用的原始配置;查看 Inline provider 时,从对应 proxy-providers.<name>.payload 生成标准 proxies: YAML 内容。

使用位置

在 Bettbox 的代理提供者列表中打开任意提供者内容:

  • HTTP provider:继续读取下载后的缓存文件。
  • File provider:继续读取本地文件。
  • Inline provider:直接展示配置中内联的节点内容。

行为边界

  • 不改变 provider 的加载、更新、健康检查与代理组引用逻辑。
  • HTTP/File 仍走原有路径读取逻辑。
  • Inline 内容只在用户主动查看 provider 时序列化并返回,不创建临时文件。
  • 原始配置仅保存在当前 Core 进程内存中;节点密码等字段的可见范围与原有“查看提供者内容”功能一致,不新增网络接口或后台输出。
  • 原始配置解析失败时不会覆盖最近一次成功配置。

关键逻辑对比

原逻辑仅接受带文件路径的 provider:

ep, err := toExternalProvider(p)
if err != nil || ep.Path == "" {
    fn("provider path is empty")
    return
}

新逻辑先识别 Inline provider,并从原始配置提取 payload

if p.VehicleType() == cp.Inline {
    buf, err := marshalInlineProviderContent(rawConfig, providerName)
    // ...
    fn(string(buf))
    return
}

验证

  • CGO_ENABLED=0 go test .core
  • CGO_ENABLED=0 go build -tags=with_gvisor -o /tmp/bettbox-core-inline-provider-check .core
  • go test ./adapter/provider ./configcore/Clash.Meta
  • 新增单元测试覆盖 Inline payload 序列化与 payload 缺失错误。

@appshubcc

Copy link
Copy Markdown
Owner

@uclort 没啥必要吧,这个主要还是为不能直接查看的文件提供一个入口,inline类型当前直接查看配置和或者运行时配置都是可以的

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants