Skip to content

Commit

Permalink
Don't random pick if there is only one vnext or user
Browse files Browse the repository at this point in the history
  • Loading branch information
DarienRaymond committed Sep 21, 2015
1 parent 67f41cb commit bd35793
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions proxy/vmess/vmessout.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit bd35793

Please sign in to comment.