Skip to content

feat(subscription): support upstream chaining and detour-aware outbound rebuild#40

Open
imblowsnow wants to merge 1 commit intoResinat:masterfrom
fork-mine:master
Open

feat(subscription): support upstream chaining and detour-aware outbound rebuild#40
imblowsnow wants to merge 1 commit intoResinat:masterfrom
fork-mine:master

Conversation

@imblowsnow
Copy link
Copy Markdown

Summary

  • 新增订阅上游链路能力(upstream_subscription_id),支持创建/更新、持久化、回放与前端配置。
  • 调整订阅刷新与节点更新链路:节点原始配置变更时触发 outbound 重建与即时探测,避免旧 outbound 残留。
  • 增强链式代理下的 detour 处理:下游节点刷新时自动注入 tag/detour,并在 outbound 构建阶段确保 detour 目标优先就绪。

Backend

  • 订阅模型与状态存储新增字段:
    • internal/model/models.go
    • internal/subscription/subscription.go
    • internal/state/repo_state.go
    • internal/state/migrations/state/000005_subscriptions_add_upstream_subscription_id.up.sql
  • 控制面 API 支持并校验 upstream_subscription_id
    • 创建/更新请求与响应透传该字段
    • 校验规则:不可自引用、必须存在、不可形成环
    • 变更上游后触发订阅刷新
    • 涉及 internal/service/control_plane_subscription.go
    • 涉及 internal/service/control_plane_system.go
  • 调度器支持链式刷新与 detour 注入:
    • 解析上游并选定 detour tag
    • 改写下游解析出的 outbound raw(写入统一 tagdetour
    • 上游更新后级联刷新下游订阅
    • 涉及 internal/topology/subscription_scheduler.go
  • 节点池支持“同 hash 配置更新”路径:
    • AddNodeFromSub 检测 RawOptions 变化,清理旧 outbound,并触发 OnNodeUpdated
    • 涉及 internal/topology/pool.go
    • 涉及 cmd/resin/main.go

Outbound / Probe

  • Outbound 构建改为通过共享 manager 创建并按 tag 取回实例,提升 detour 依赖解析一致性:
    • internal/outbound/builder.go
  • OutboundManager 增加 detour 预检查与递归 ensure:
    • 构建前确保 detour 目标 outbound 已存在
    • 增加循环依赖检测与更明确错误
    • 构建成功后清空 LastError
    • internal/outbound/manager.go
  • Probe 增加 outbound 未就绪日志,便于定位时序问题:
    • internal/probe/manager.go
  • 路由链路增加 node/tag/detour 调试日志:
    • internal/proxy/route_outbound.go

Web UI

  • 订阅页新增“上游订阅”选择(创建/编辑)并对接 API 字段:
    • webui/src/features/subscriptions/SubscriptionPage.tsx
    • webui/src/features/subscriptions/types.ts
    • webui/src/features/subscriptions/api.ts
    • webui/src/i18n/translations.ts

@imblowsnow imblowsnow changed the title feat(subscription): support upstream chaining and detour-aware outbou… feat(subscription): support upstream chaining and detour-aware outbound rebuild Apr 10, 2026
@imblowsnow
Copy link
Copy Markdown
Author

@Resinat

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.

1 participant