mirror of https://github.com/XTLS/Xray-core
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
22 lines
438 B
22 lines
438 B
package router
|
|
|
|
import (
|
|
"github.com/xtls/xray-core/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)]
|
|
}
|