SagerNet / sing-box

The universal proxy platform
https://sing-box.sagernet.org/
Other
20.44k stars 2.44k forks source link

[Feature Request] URLTest based backup group outbound selection #2130

Open se1jaku opened 2 months ago

se1jaku commented 2 months ago

Hi! Currently, the URLTest picks out an outbound by latency and tolerance from a certain group of outbounds.

I suggest a new typeof URLTest based outbound that selects the first available one from a list of outbounds.

Say it like the following structure.

{
  "type": "backup",
  "tag": "auto",
  // select the first available one from the list
  "outbounds": [
    "proxy-a",
    "proxy-b",
    "proxy-c"
  ],
  "url": "",
  "interval": "",
  "tolerance": 50, // takes no effect
  "idle_timeout": "",
  "interrupt_exist_connections": false
  // some extra fields
  //
  // switch_back_policy
  //   n(positive): switch back to the prior outbound only after it passes n times url test
  //   1: always select the first available outbound (a special case of n = 1)
  //   0: as long as the current outbound alive, keep on it
  "switch_back_policy": 0,
}

This will greatly improve the logic of outbound. Makes it more robust. Similar implement could be found here: Fallback proxy groups

Thanks

HaradaKashiwa commented 2 months ago

Wouldn't putting urltest in urltest outbound work?

fouvromenth commented 2 months ago

Wouldn't putting urltest in urltest outbound work?

Could you explain in more detail? I can't imagine the difference between using just one urltest and using two or more.

What if the outbound I tend to use, which has the highest bandwidth and most features (like AI and streaming), isn't the one with the lowest latency?

HaradaKashiwa commented 2 months ago

Wouldn't putting urltest in urltest outbound work?

Could you explain in more detail? I can't imagine the difference between using just one urltest and using two or more.

What if the outbound I tend to use, which has the highest bandwidth and most features (like AI and streaming), isn't the one with the lowest latency?

Maybe you need fallback

se1jaku commented 1 month ago

As @fouvromenth explained, a nested urltest does not help in this situation. It can only filter out outbounds that failed to pass the test.

In reality, different outbounds have different properties. In most cases, I think, a manual sorting will be better than an automatic latency-based sorting.

se1jaku commented 1 month ago

By the way, naming the outbound Fallback is quite ambiguous literally. It sounds like sth really unexpected will take place, meanwhile, the substitutions of selected outbounds in the background is more like a series of expected behaviors.

That is the reason why I think Backup is a better name.