config.go 606 B

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