SagerNet / serenity

The configuration generator for sing-box
https://serenity.sagernet.org
Other
176 stars 36 forks source link

【Feature Request】extra_group can use other extra_groups as it's outbounds #36

Open ningzio opened 1 week ago

ningzio commented 1 week ago

I defined some extra_groups base on territory, like HK, USA...

I want to use different territory on different site, like openAI, I'd like use USA, but HK.

currently, extra_groups can only use "servers" getting from subscription

I don't know how to do this, I've read the documents, and the code.

- tag: "HK",
  outbounds:
    - "HK nodes"
    - "..."

- tag: "US"
  outbounds:
    - "US nodes"
    - "..."

- tag: "OpenAI"
  outbounds:
    - US
ningzio commented 1 week ago

this is my extra_group definition:

[
  {
    "tag": "🤖Claude",
    "type": "selector",
    "target": "global",
    "filter": [
      "^$"
    ],
    "custom_selector": {
      "outbounds": [
        "🇸🇬新加坡",
        "🇭🇰香港"
      ]
    }
  },
  {
    "tag": "🇸🇬新加坡",
    "type": "selector",
    "target": "global",
    "filter": "(?i)(新|sg|singapore)"
  },
  {
    "tag": "🇭🇰香港",
    "type": "selector",
    "target": "global",
    "filter": "(?i)港|hk|hongkong|hong kong"
  }
]

the expected behavior is 🤖Claude's outbounds is 🇸🇬新加坡 and 🇭🇰香港, like

{
  "type": "selector",
  "tag": "🤖Claude",
  "outbounds": [
    "🇸🇬新加坡",
    "🇭🇰香港"
  ]
}

but I found if filter result is empty, It will skip this group. https://github.com/SagerNet/serenity/blob/4dd3530210ceaf2df0f259c2d91ad394fa6553d2/template/render_outbounds.go#L153

I changed the code and it works

image