sing-box icon indicating copy to clipboard operation
sing-box copied to clipboard

New Feature: Outbound random selection for urlTest based on best latency.

Open ashly-right opened this issue 11 months ago • 5 comments

This feature provides a simple load balancer with a random/least-latency strategy. This update should be completely backward compatible.

An attribute named "randomize" was added to the urlTest outbound. the default value is false.

Functionality: When randomize is set to true, the application makes a list of the best latency each time and selects one of them randomly for each new connection.

ashly-right avatar Mar 10 '24 04:03 ashly-right

@nekohasekai Dear Could you please review this request whenever you can? Thank you very much.

ashly-right avatar Mar 22 '24 04:03 ashly-right

I do need a random selection outbound for my web crawler. 我比较好奇这里的“based on best latency”能否保证节点列表的充分随机化利用。I have read the source code, found that it will generate the best outbounds list contains a best history delay in tolerance.

CodingMoeButa avatar May 09 '24 19:05 CodingMoeButa

这个random实现目前有一个缺陷,当randomize为true时,从软件启动到interval的间隔时间内,走urltest的出站无法连接,除非把interval调成一个较小的值,才能在一定程度上掩盖这个问题。目前还没有测试这个方案的随机充分性。

建议添加一个新的随机出站类型,而不是在urltest的基础上实现,这样才能做到尽可能的随机化,同时避免奇怪的问题。作为用户,既然已经需要随机选择了,我个人会在保证节点可用的情况下使用随机负载均衡,这个可用性检查不应该由内核来做。

CodingMoeButa avatar May 10 '24 14:05 CodingMoeButa

@CodingMoeButa Thank you very much for your comment and test. You are right, there is a slight problem with the startup regarding the first testing

Pure randomization is a good solution for crawler purposes when you have tested the proxies before. But we need a solution for testing and randomization for an anti-censorship app. because we need to establish a reliable connection within all possible proxies.

I can implement a separate random outbound as well. but the question is whether the repository owner wants these features or not. I couldn't find a contribution rule. I hope one of the repo admins helps me.

ashly-right avatar May 13 '24 20:05 ashly-right