github.com/xmplusdev/xmcore@v1.8.11-0.20240412132628-5518b55526af/proxy/http/config.go (about)

     1  package http
     2  
     3  import (
     4  	"github.com/xmplusdev/xmcore/common/protocol"
     5  )
     6  
     7  func (a *Account) Equals(another protocol.Account) bool {
     8  	if account, ok := another.(*Account); ok {
     9  		return a.Username == account.Username
    10  	}
    11  	return false
    12  }
    13  
    14  func (a *Account) AsAccount() (protocol.Account, error) {
    15  	return a, nil
    16  }
    17  
    18  func (sc *ServerConfig) HasAccount(username, password string) bool {
    19  	if sc.Accounts == nil {
    20  		return false
    21  	}
    22  
    23  	p, found := sc.Accounts[username]
    24  	if !found {
    25  		return false
    26  	}
    27  	return p == password
    28  }