Skip to content

支持基于 TOML 的声明式配置,实现“一份配置,全平台生成” #549

@zillaos

Description

@zillaos

目前 Sub-Store 已经能做订阅处理并导出多平台配置,但主要依赖 JS 脚本/代码式配置,不是很直观,友好

希望实现“一份配置文件作为单一来源”,在其中声明订阅源、分组、规则、重命名、过滤等,然后 Sub-Store 自动生成各平台可导入的产物。

比如用户写一份profile.toml,描述:订阅源、基础过滤/重命名/去重、策略组/分组/排序、规则集引用/自定义规则等信息

举例:

# profile.toml

[profile]
name = "My Unified Profile"
default_platforms = ["surge", "clash"]  # 默认生成哪些平台产物

# 1) 订阅源:可以多个
[[subscription]]
name = "airportA"
url  = "https://example.com/sub?token=xxx"
enabled = true

[[subscription]]
name = "airportB"
url  = "https://example.com/sub2?token=yyy"
enabled = true

# 2) 通用处理:重命名、过滤等(平台无关)
[transform]
dedup = true
remove_unsupported = true
rename = [
  { from = "香港", to = "HK" },
  { from = "新加坡", to = "SG" }
]
include_keywords = ["HK", "SG", "JP"]
exclude_keywords = ["剩余", "到期", "实验"]

# 3) 代理组(平台无关的“意图描述”,由 Sub-Store 输出到各平台语法)
[[group]]
name = "Auto"
type = "select"
candidates = ["HK", "SG", "JP", "DIRECT"]

[[group]]
name = "HK"
type = "url-test"
filter = "HK"
interval = 300

[[group]]
name = "SG"
type = "url-test"
filter = "SG"
interval = 300

# 4) 规则(平台无关描述)
[rules]
# 规则集引用(示例)
rule_set = [
  { name = "Lan",  behavior = "classical", url = "https://example.com/rules/lan.list" },
  { name = "Proxy",behavior = "classical", url = "https://example.com/rules/proxy.list" }
]

# 简单自定义规则(示例)
custom = [
  "DOMAIN-SUFFIX,google.com,Auto",
  "DOMAIN-SUFFIX,github.com,Auto",
  "GEOIP,CN,DIRECT",
  "MATCH,Auto"
]

# 5) 输出:同一个 TOML 里声明多个平台产物
[output.surge]
artifact_name = "surge_myprofile"
format = "surge"
# 可选平台特化(例如 Surge 特有字段/兼容处理)
compat = { version = 5 }

[output.clash]
artifact_name = "clash_myprofile"
format = "clash-meta"
# 可选平台特化(例如 clash 的 dns/tun 等)
extra = { enable_dns = true }

期望效果:

用户只维护这一个 profile.toml

Sub-Store 自动生成:

surge_myprofile.conf(Surge ),clash_myprofile.yaml,用户增加一条规则/新增一个分组/新增一个订阅源:只改 TOML 一个地方,重新生成即可

现在虽然已经有类似 Surgio 的项目可以生成多平台配置,但其需要为多个平台配置多个tpl文件,需要多多处修改,且不同订阅.js文件也需要自己护,不是很方便,希望能够实现这个功能。

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions