mirror of
https://github.com/v2fly/v2ray-core.git
synced 2026-05-14 08:29:10 -04:00
accounts in protobuf
This commit is contained in:
@@ -9,32 +9,10 @@ import (
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"v2ray.com/core/common/dice"
|
||||
"v2ray.com/core/common/protocol"
|
||||
"v2ray.com/core/common/signal"
|
||||
)
|
||||
|
||||
type Account struct {
|
||||
ID *protocol.ID
|
||||
AlterIDs []*protocol.ID
|
||||
}
|
||||
|
||||
func (this *Account) AnyValidID() *protocol.ID {
|
||||
if len(this.AlterIDs) == 0 {
|
||||
return this.ID
|
||||
}
|
||||
return this.AlterIDs[dice.Roll(len(this.AlterIDs))]
|
||||
}
|
||||
|
||||
func (this *Account) Equals(account protocol.Account) bool {
|
||||
vmessAccount, ok := account.(*Account)
|
||||
if !ok {
|
||||
return false
|
||||
}
|
||||
// TODO: handle AlterIds difference
|
||||
return this.ID.Equals(vmessAccount.ID)
|
||||
}
|
||||
|
||||
const (
|
||||
updateIntervalSec = 10
|
||||
cacheDurationSec = 120
|
||||
@@ -140,7 +118,11 @@ L:
|
||||
func (this *TimedUserValidator) Add(user *protocol.User) error {
|
||||
idx := len(this.validUsers)
|
||||
this.validUsers = append(this.validUsers, user)
|
||||
account := user.Account.(*Account)
|
||||
rawAccount, err := user.GetTypedAccount(&AccountPB{})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
account := rawAccount.(*Account)
|
||||
|
||||
nowSec := time.Now().Unix()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user