netchange_generic.go 956 B

123456789101112131415161718192021222324
  1. //go:build !darwin || ios || e2e_testing
  2. package udp
  3. import (
  4. "context"
  5. "log/slog"
  6. )
  7. // watchesNetworkChanges is true where Start does anything
  8. const watchesNetworkChanges = false
  9. // watchNetworkChanges is a no-op outside of darwin.
  10. //
  11. // Darwin is the platform that scopes a udp socket to the interface it came up on, so it is the platform whose socket
  12. // goes stale when the local network changes. Everywhere else Rebind has nothing to do, so there is nothing to watch
  13. // for. iOS is excluded on purpose even though it is darwin: the host app already drives the rebind off NWPathMonitor,
  14. // and two things racing to rebind the same socket is worse than one.
  15. //
  16. // A nil channel means "not supported here", which callers must treat as "do not start a watcher" rather than
  17. // selecting on it, since a receive from a nil channel blocks forever.
  18. func watchNetworkChanges(_ context.Context, _ *slog.Logger) (<-chan struct{}, error) {
  19. return nil, nil
  20. }