ldaptransport.go 833 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. // Copyright (C) 2018 The Syncthing Authors.
  2. //
  3. // This Source Code Form is subject to the terms of the Mozilla Public
  4. // License, v. 2.0. If a copy of the MPL was not distributed with this file,
  5. // You can obtain one at https://mozilla.org/MPL/2.0/.
  6. package config
  7. func (t LDAPTransport) String() string {
  8. switch t {
  9. case LDAPTransportPlain:
  10. return "plain"
  11. case LDAPTransportTLS:
  12. return "tls"
  13. case LDAPTransportStartTLS:
  14. return "starttls"
  15. default:
  16. return "unknown"
  17. }
  18. }
  19. func (t LDAPTransport) MarshalText() ([]byte, error) {
  20. return []byte(t.String()), nil
  21. }
  22. func (t *LDAPTransport) UnmarshalText(bs []byte) error {
  23. switch string(bs) {
  24. case "plain":
  25. *t = LDAPTransportPlain
  26. case "tls":
  27. *t = LDAPTransportTLS
  28. case "starttls":
  29. *t = LDAPTransportStartTLS
  30. default:
  31. *t = LDAPTransportPlain
  32. }
  33. return nil
  34. }