github.com/Uhtred009/v2ray-core-1@v4.31.2+incompatible/proxy/vless/account.go (about)

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