export_test.go 584 B

123456789101112131415161718192021222324
  1. // Copyright (c) Tailscale Inc & AUTHORS
  2. // SPDX-License-Identifier: BSD-3-Clause
  3. package derphttp
  4. func SetTestHookWatchLookConnectResult(f func(connectError error, wasSelfConnect bool) (keepRunning bool)) {
  5. testHookWatchLookConnectResult = f
  6. }
  7. // breakConnection breaks the connection, which should trigger a reconnect.
  8. func (c *Client) BreakConnection(brokenClient *Client) {
  9. c.mu.Lock()
  10. defer c.mu.Unlock()
  11. if c.client != brokenClient.client {
  12. return
  13. }
  14. if c.netConn != nil {
  15. c.netConn.Close()
  16. c.netConn = nil
  17. }
  18. c.client = nil
  19. }
  20. var RetryInterval = &retryInterval