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