github.com/moqsien/xraycore@v1.8.5/proxy/vless/account.go (about) 1 package vless 2 3 import ( 4 "github.com/moqsien/xraycore/common/protocol" 5 "github.com/moqsien/xraycore/common/uuid" 6 ) 7 8 // AsAccount implements protocol.Account.AsAccount(). 9 func (a *Account) AsAccount() (protocol.Account, error) { 10 id, err := uuid.ParseString(a.Id) 11 if err != nil { 12 return nil, newError("failed to parse ID").Base(err).AtError() 13 } 14 return &MemoryAccount{ 15 ID: protocol.NewID(id), 16 Flow: a.Flow, // needs parser here? 17 Encryption: a.Encryption, // needs parser here? 18 }, nil 19 } 20 21 // MemoryAccount is an in-memory form of VLess account. 22 type MemoryAccount struct { 23 // ID of the account. 24 ID *protocol.ID 25 // Flow of the account. May be "xtls-rprx-vision". 26 Flow string 27 // Encryption of the account. Used for client connections, and only accepts "none" for now. 28 Encryption string 29 } 30 31 // Equals implements protocol.Account.Equals(). 32 func (a *MemoryAccount) Equals(account protocol.Account) bool { 33 vlessAccount, ok := account.(*MemoryAccount) 34 if !ok { 35 return false 36 } 37 return a.ID.Equals(vlessAccount.ID) 38 }