c2ntypes.go 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. // Copyright (c) Tailscale Inc & contributors
  2. // SPDX-License-Identifier: BSD-3-Clause
  3. // c2n (control-to-node) API types.
  4. package tailcfg
  5. import (
  6. "encoding/json"
  7. "net/netip"
  8. )
  9. // C2NSSHUsernamesRequest is the request for the /ssh/usernames.
  10. // A GET request without a request body is equivalent to the zero value of this type.
  11. // Otherwise, a POST request with a JSON-encoded request body is expected.
  12. type C2NSSHUsernamesRequest struct {
  13. // Exclude optionally specifies usernames to exclude
  14. // from the response.
  15. Exclude map[string]bool `json:",omitempty"`
  16. // Max is the maximum number of usernames to return.
  17. // If zero, a default limit is used.
  18. Max int `json:",omitempty"`
  19. }
  20. // C2NSSHUsernamesResponse is the response (from node to control) from the
  21. // /ssh/usernames handler.
  22. //
  23. // It returns username auto-complete suggestions for a user to SSH to this node.
  24. // It's only shown to people who already have SSH access to the node. If this
  25. // returns multiple usernames, only the usernames that would have access per the
  26. // tailnet's ACLs are shown to the user so as to not leak the existence of
  27. // usernames.
  28. type C2NSSHUsernamesResponse struct {
  29. // Usernames is the list of usernames to suggest. If the machine has many
  30. // users, this list may be truncated. If getting the list of usernames might
  31. // be too slow or unavailable, this list might be empty. This is effectively
  32. // just a best effort set of hints.
  33. Usernames []string
  34. }
  35. // C2NUpdateResponse is the response (from node to control) from the /update
  36. // handler. It tells control the status of its request for the node to update
  37. // its Tailscale installation.
  38. type C2NUpdateResponse struct {
  39. // Err is the error message, if any.
  40. Err string `json:",omitempty"`
  41. // Enabled indicates whether the user has opted in to updates triggered from
  42. // control.
  43. Enabled bool
  44. // Supported indicates whether remote updates are supported on this
  45. // OS/platform.
  46. Supported bool
  47. // Started indicates whether the update has started.
  48. Started bool
  49. }
  50. // C2NPostureIdentityResponse contains either a set of identifying serial
  51. // numbers and hardware addresses from the client, or a boolean flag
  52. // indicating that the machine has opted out of posture collection.
  53. type C2NPostureIdentityResponse struct {
  54. // SerialNumbers is a list of serial numbers of the client machine.
  55. SerialNumbers []string `json:",omitempty"`
  56. // IfaceHardwareAddrs is a list of hardware addresses (MAC addresses)
  57. // of the client machine's network interfaces.
  58. IfaceHardwareAddrs []string `json:",omitempty"`
  59. // PostureDisabled indicates if the machine has opted out of
  60. // device posture collection.
  61. PostureDisabled bool `json:",omitempty"`
  62. }
  63. // C2NAppConnectorDomainRoutesResponse contains a map of domains to
  64. // slice of addresses, indicating what IP addresses have been resolved
  65. // for each domain.
  66. type C2NAppConnectorDomainRoutesResponse struct {
  67. // Domains is a map of lower case domain names with no trailing dot,
  68. // to a list of resolved IP addresses.
  69. Domains map[string][]netip.Addr
  70. }
  71. // C2NTLSCertInfo describes the state of a cached TLS certificate.
  72. type C2NTLSCertInfo struct {
  73. // Valid means that the node has a cached and valid (not expired)
  74. // certificate.
  75. Valid bool `json:",omitempty"`
  76. // Error is the error string if the certificate is not valid. If error is
  77. // non-empty, the other booleans below might say why.
  78. Error string `json:",omitempty"`
  79. // Missing is whether the error string indicates a missing certificate
  80. // that's never been fetched or isn't on disk.
  81. Missing bool `json:",omitempty"`
  82. // Expired is whether the error string indicates an expired certificate.
  83. Expired bool `json:",omitempty"`
  84. NotBefore string `json:",omitempty"` // RFC3339, if Valid
  85. NotAfter string `json:",omitempty"` // RFC3339, if Valid
  86. // TODO(bradfitz): add fields for whether an ACME fetch is currently in
  87. // process and when it started, etc.
  88. }
  89. // C2NVIPServicesResponse is the response (from node to control) from the
  90. // /vip-services handler.
  91. //
  92. // It returns the list of VIPServices that the node is currently serving with
  93. // their port info and whether they are active or not. It also returns a hash of
  94. // the response to allow the control server to detect changes.
  95. type C2NVIPServicesResponse struct {
  96. // VIPServices is the list of VIP services that the node is currently serving.
  97. VIPServices []*VIPService `json:",omitempty"`
  98. // ServicesHash is the hash of VIPServices to allow the control server to detect
  99. // changes. This value matches what is reported in latest [Hostinfo.ServicesHash].
  100. ServicesHash string
  101. }
  102. // C2NDebugNetmapRequest is the request (from control to node) for the
  103. // /debug/netmap handler.
  104. type C2NDebugNetmapRequest struct {
  105. // Candidate is an optional full MapResponse to be used for generating a candidate
  106. // network map. If unset, only the current network map is returned.
  107. Candidate *MapResponse `json:"candidate,omitzero"`
  108. // OmitFields is an optional list of netmap fields to omit from the response.
  109. // If unset, no fields are omitted.
  110. OmitFields []string `json:"omitFields,omitzero"`
  111. }
  112. // C2NDebugNetmapResponse is the response (from node to control) from the
  113. // /debug/netmap handler. It contains the current network map and, if a
  114. // candidate full MapResponse was provided in the request, a candidate network
  115. // map generated from it.
  116. // To avoid import cycles, and reflect the non-stable nature of
  117. // netmap.NetworkMap values, they are returned as json.RawMessage.
  118. type C2NDebugNetmapResponse struct {
  119. // Current is the current network map (netmap.NetworkMap).
  120. Current json.RawMessage `json:"current"`
  121. // Candidate is a network map produced based on the candidate MapResponse.
  122. Candidate json.RawMessage `json:"candidate,omitzero"`
  123. }