netknob.go 791 B

1234567891011121314151617181920212223242526272829
  1. // Copyright (c) Tailscale Inc & AUTHORS
  2. // SPDX-License-Identifier: BSD-3-Clause
  3. // Package netknob has Tailscale network knobs.
  4. package netknob
  5. import (
  6. "runtime"
  7. "time"
  8. )
  9. // PlatformTCPKeepAlive returns the default net.Dialer.KeepAlive
  10. // value for the current runtime.GOOS.
  11. func PlatformTCPKeepAlive() time.Duration {
  12. switch runtime.GOOS {
  13. case "ios", "android":
  14. // Disable TCP keep-alives on mobile platforms.
  15. // See https://github.com/golang/go/issues/48622.
  16. //
  17. // TODO(bradfitz): in 1.17.x, try disabling TCP
  18. // keep-alives on for all platforms.
  19. return -1
  20. }
  21. // Otherwise, default to 30 seconds, which is mostly what we
  22. // used to do. In some places we used the zero value, which Go
  23. // defaults to 15 seconds. But 30 seconds is fine.
  24. return 30 * time.Second
  25. }