Documentation
¶
Index ¶
- Constants
- Variables
- func NewUDPStatsEmitter(udpConns []Conn) func()
- type Conn
- type EncReader
- type NetworkChangeMonitor
- type NoopConn
- func (NoopConn) Close() error
- func (NoopConn) ListenOut(_ EncReader) error
- func (NoopConn) LocalAddr() (netip.AddrPort, error)
- func (NoopConn) Rebind() error
- func (NoopConn) ReloadConfig(_ *config.C)
- func (NoopConn) SupportsMultipleReaders() bool
- func (NoopConn) WriteTo(_ []byte, _ netip.AddrPort) error
- type StdConn
- func (u *StdConn) Close() error
- func (u *StdConn) GetRecvBuffer() (int, error)
- func (u *StdConn) GetSendBuffer() (int, error)
- func (u *StdConn) GetSoMark() (int, error)
- func (u *StdConn) ListenOut(r EncReader) error
- func (u *StdConn) LocalAddr() (netip.AddrPort, error)
- func (u *StdConn) PrepareRawMessages(n int) ([]rawMessage, [][]byte, [][]byte)
- func (u *StdConn) Rebind() error
- func (u *StdConn) ReloadConfig(c *config.C)
- func (u *StdConn) SetRecvBuffer(n int) error
- func (u *StdConn) SetSendBuffer(n int) error
- func (u *StdConn) SetSoMark(mark int) error
- func (u *StdConn) SupportsMultipleReaders() bool
- func (u *StdConn) WriteTo(b []byte, ip netip.AddrPort) error
Constants ¶
const MTU = 9001
Variables ¶
var ErrInvalidIPv6RemoteForSocket = errors.New("listener is IPv4, but writing to IPv6 remote")
Functions ¶
func NewUDPStatsEmitter ¶
func NewUDPStatsEmitter(udpConns []Conn) func()
Types ¶
type Conn ¶
type NetworkChangeMonitor ¶ added in v1.11.0
type NetworkChangeMonitor struct {
// contains filtered or unexported fields
}
NetworkChangeMonitor rebinds the udp listener when the local network moves out from under it.
Detection lives here in the udp package, next to the socket it concerns and the platform matrix that already knows which sockets go stale. What to do about a change — updating the lighthouse, requerying tunnels — is not the udp package's business, so Start takes the reaction as a plain function. Passing it at Start rather than holding it keeps this package from referencing whatever owns the rebind.
On platforms whose sockets do not go stale, watchNetworkChanges hands back a nil channel and Start returns.
func NewNetworkChangeMonitor ¶ added in v1.11.0
func NewNetworkChangeMonitor(ctx context.Context, l *slog.Logger, c *config.C) *NetworkChangeMonitor
NewNetworkChangeMonitor builds a monitor for local network changes. The returned monitor is always usable: Start is safe to call unconditionally, it no-ops when disabled or on a platform that does not need it.
func (*NetworkChangeMonitor) Start ¶ added in v1.11.0
func (m *NetworkChangeMonitor) Start(rebind func())
Start watches for network changes until the context is cancelled, calling rebind once per settled change. It blocks, so callers run it in a goroutine, and it no-ops when disabled, unsupported, or with nothing to rebind.
type NoopConn ¶ added in v1.8.0
type NoopConn struct{}
func (NoopConn) ReloadConfig ¶ added in v1.8.0
func (NoopConn) SupportsMultipleReaders ¶ added in v1.10.0
type StdConn ¶ added in v1.8.0
type StdConn struct {
// contains filtered or unexported fields
}