1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-06-09 01:10:44 +00:00
v2fly/app/router/strategy_random.go
2021-09-04 11:12:32 +01:00

22 lines
443 B
Go

package router
import (
"github.com/v2fly/v2ray-core/v4/common/dice"
)
// RandomStrategy represents a random balancing strategy
type RandomStrategy struct{}
func (s *RandomStrategy) GetPrincipleTarget(strings []string) []string {
return strings
}
func (s *RandomStrategy) PickOutbound(candidates []string) string {
count := len(candidates)
if count == 0 {
// goes to fallbackTag
return ""
}
return candidates[dice.Roll(count)]
}