1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-10-01 16:26:02 -04:00
v2fly/common/protocol/account.go

31 lines
543 B
Go
Raw Normal View History

2016-05-07 14:26:03 -04:00
package protocol
2016-05-28 07:44:11 -04:00
import (
"github.com/v2ray/v2ray-core/common/dice"
)
2016-05-07 14:26:03 -04:00
type Account interface {
2016-07-24 17:22:46 -04:00
Equals(Account) bool
2016-05-07 14:26:03 -04:00
}
2016-05-28 07:44:11 -04:00
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))]
}
2016-07-24 17:22:46 -04:00
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)
}