precheckClientsAndControllers checks that the set of clients we got is compatible with the configured controllers. These checks will fail if the dialer is incompatible with the set of controllers, or not configured correctly with respect to Tailnet API version.
(clients ControlProtocolClients)
| 1594 | // configured controllers. These checks will fail if the dialer is incompatible with the set of |
| 1595 | // controllers, or not configured correctly with respect to Tailnet API version. |
| 1596 | func (c *Controller) precheckClientsAndControllers(clients ControlProtocolClients) error { |
| 1597 | if clients.Coordinator == nil && c.CoordCtrl != nil { |
| 1598 | return xerrors.New("missing Coordinator client; have controller") |
| 1599 | } |
| 1600 | if clients.DERP == nil && c.DERPCtrl != nil { |
| 1601 | return xerrors.New("missing DERPMap client; have controller") |
| 1602 | } |
| 1603 | if clients.WorkspaceUpdates == nil && c.WorkspaceUpdatesCtrl != nil { |
| 1604 | return xerrors.New("missing WorkspaceUpdates client; have controller") |
| 1605 | } |
| 1606 | |
| 1607 | // Telemetry and ResumeToken support is considered optional, but the clients must be present |
| 1608 | // so that we can call the functions and get an "unimplemented" error. |
| 1609 | if clients.ResumeToken == nil && c.ResumeTokenCtrl != nil { |
| 1610 | return xerrors.New("missing ResumeToken client; have controller") |
| 1611 | } |
| 1612 | if clients.Telemetry == nil && c.TelemetryCtrl != nil { |
| 1613 | return xerrors.New("missing Telemetry client; have controller") |
| 1614 | } |
| 1615 | return nil |
| 1616 | } |
| 1617 | |
| 1618 | // runControllersOnce uses the provided clients to call into the controllers once. It is combined |
| 1619 | // into one function so that a problem with one tears down the other and triggers a retry (if |