conn.go 710 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. package udp
  2. import (
  3. "net/netip"
  4. "github.com/slackhq/nebula/config"
  5. )
  6. const MTU = 9001
  7. type EncReader func(
  8. addr netip.AddrPort,
  9. payload []byte,
  10. )
  11. type Conn interface {
  12. Rebind() error
  13. LocalAddr() (netip.AddrPort, error)
  14. ListenOut(r EncReader)
  15. WriteTo(b []byte, addr netip.AddrPort) error
  16. ReloadConfig(c *config.C)
  17. Close() error
  18. }
  19. type NoopConn struct{}
  20. func (NoopConn) Rebind() error {
  21. return nil
  22. }
  23. func (NoopConn) LocalAddr() (netip.AddrPort, error) {
  24. return netip.AddrPort{}, nil
  25. }
  26. func (NoopConn) ListenOut(_ EncReader) {}
  27. func (NoopConn) WriteTo(_ []byte, _ netip.AddrPort) error {
  28. return nil
  29. }
  30. func (NoopConn) ReloadConfig(_ *config.C) {}
  31. func (NoopConn) Close() error {
  32. return nil
  33. }