mirror of
https://github.com/v2fly/v2ray-core.git
synced 2026-01-06 01:05:35 -05:00
feat: RandomStrategy AliveOnly (#2850)
* feat: strategy_randomalive * feat: RandomStrategy AliveOnly * fix: unobserved candidate not alive * fix: StrategySettings nil panic * fix: TestRouterConfig * fix: alive_only typo
This commit is contained in:
@@ -164,10 +164,22 @@ func (br *BalancingRule) Build(ohm outbound.Manager, dispatcher routing.Dispatch
|
||||
case "random":
|
||||
fallthrough
|
||||
case "":
|
||||
var randomStrategy *RandomStrategy
|
||||
if br.StrategySettings != nil {
|
||||
i, err := serial.GetInstanceOf(br.StrategySettings)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
s, ok := i.(*StrategyRandomConfig)
|
||||
if !ok {
|
||||
return nil, newError("not a StrategyRandomConfig").AtError()
|
||||
}
|
||||
randomStrategy = NewRandomStrategy(s)
|
||||
}
|
||||
return &Balancer{
|
||||
selectors: br.OutboundSelector,
|
||||
ohm: ohm, fallbackTag: br.FallbackTag,
|
||||
strategy: &RandomStrategy{},
|
||||
strategy: randomStrategy,
|
||||
}, nil
|
||||
default:
|
||||
return nil, newError("unrecognized balancer type")
|
||||
|
||||
Reference in New Issue
Block a user