netchange_generic.go 894 B

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