1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-12-30 05:56:54 -05:00

Don't random pick if there is only one vnext or user

This commit is contained in:
V2Ray 2015-09-22 00:28:52 +02:00
parent 67f41cb3ba
commit bd35793cf8

View File

@ -44,13 +44,20 @@ func (handler *VMessOutboundHandler) pickVNext() (v2net.Destination, user.User)
if vNextLen == 0 {
panic("VMessOut: Zero vNext is configured.")
}
vNextIndex := mrand.Intn(vNextLen)
vNextIndex := 0
if vNextLen > 1 {
vNextIndex = mrand.Intn(vNextLen)
}
vNext := handler.vNextList[vNextIndex]
vNextUserLen := len(vNext.Users)
if vNextUserLen == 0 {
panic("VMessOut: Zero User account.")
}
vNextUserIndex := mrand.Intn(vNextUserLen)
vNextUserIndex := 0
if vNextUserLen > 1 {
vNextUserIndex = mrand.Intn(vNextUserLen)
}
vNextUser := vNext.Users[vNextUserIndex]
return vNext.Destination, vNextUser
}