conn.go 734 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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) error
  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. return
  28. }
  29. func (NoopConn) WriteTo(_ []byte, _ netip.AddrPort) error {
  30. return nil
  31. }
  32. func (NoopConn) ReloadConfig(_ *config.C) {
  33. return
  34. }
  35. func (NoopConn) Close() error {
  36. return nil
  37. }