github.com/xmplusdev/xray-core@v1.8.10/app/router/strategy_random.go (about) 1 package router 2 3 import ( 4 "github.com/xmplusdev/xray-core/common/dice" 5 ) 6 7 // RandomStrategy represents a random balancing strategy 8 type RandomStrategy struct{} 9 10 func (s *RandomStrategy) GetPrincipleTarget(strings []string) []string { 11 return strings 12 } 13 14 func (s *RandomStrategy) PickOutbound(candidates []string) string { 15 count := len(candidates) 16 if count == 0 { 17 // goes to fallbackTag 18 return "" 19 } 20 return candidates[dice.Roll(count)] 21 }