1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-07-01 19:45:24 +00:00
v2fly/common/protocol/account.go
2016-07-24 23:22:46 +02:00

31 lines
543 B
Go

package protocol
import (
"github.com/v2ray/v2ray-core/common/dice"
)
type Account interface {
Equals(Account) bool
}
type VMessAccount struct {
ID *ID
AlterIDs []*ID
}
func (this *VMessAccount) AnyValidID() *ID {
if len(this.AlterIDs) == 0 {
return this.ID
}
return this.AlterIDs[dice.Roll(len(this.AlterIDs))]
}
func (this *VMessAccount) Equals(account Account) bool {
vmessAccount, ok := account.(*VMessAccount)
if !ok {
return false
}
// TODO: handle AlterIds difference
return this.ID.Equals(vmessAccount.ID)
}