mirror of
https://github.com/v2fly/v2ray-core.git
synced 2024-07-05 13:35:23 +00:00
18 lines
351 B
Go
18 lines
351 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) PickOutbound(candidates []string) string {
|
|
count := len(candidates)
|
|
if count == 0 {
|
|
// goes to fallbackTag
|
|
return ""
|
|
}
|
|
return candidates[dice.Roll(count)]
|
|
}
|