status.go 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. // Copyright (c) Tailscale Inc & contributors
  2. // SPDX-License-Identifier: BSD-3-Clause
  3. package controlclient
  4. import (
  5. "reflect"
  6. "tailscale.com/types/netmap"
  7. "tailscale.com/types/persist"
  8. "tailscale.com/types/structs"
  9. )
  10. type Status struct {
  11. _ structs.Incomparable
  12. // Err, if non-nil, is an error that occurred while logging in.
  13. //
  14. // If it's of type UserVisibleError then it's meant to be shown to users in
  15. // their Tailscale client. Otherwise it's just logged to tailscaled's logs.
  16. Err error
  17. // URL, if non-empty, is the interactive URL to visit to finish logging in.
  18. URL string
  19. // LoggedIn, if true, indicates that serveRegister has completed and no
  20. // other login change is in progress.
  21. LoggedIn bool
  22. // InMapPoll, if true, indicates that we've received at least one netmap
  23. // and are connected to receive updates.
  24. InMapPoll bool
  25. // NetMap is the latest server-pushed state of the tailnet network.
  26. NetMap *netmap.NetworkMap
  27. // Persist, when Valid, is the locally persisted configuration.
  28. //
  29. // TODO(bradfitz,maisem): clarify this.
  30. Persist persist.PersistView
  31. }
  32. // Equal reports whether s and s2 are equal.
  33. func (s *Status) Equal(s2 *Status) bool {
  34. if s == nil && s2 == nil {
  35. return true
  36. }
  37. return s != nil && s2 != nil &&
  38. s.Err == s2.Err &&
  39. s.URL == s2.URL &&
  40. s.LoggedIn == s2.LoggedIn &&
  41. s.InMapPoll == s2.InMapPoll &&
  42. reflect.DeepEqual(s.Persist, s2.Persist) &&
  43. reflect.DeepEqual(s.NetMap, s2.NetMap)
  44. }