conn.go 745 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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. release func(),
  11. )
  12. type Conn interface {
  13. Rebind() error
  14. LocalAddr() (netip.AddrPort, error)
  15. ListenOut(r EncReader)
  16. WriteTo(b []byte, addr netip.AddrPort) error
  17. ReloadConfig(c *config.C)
  18. Close() error
  19. }
  20. type NoopConn struct{}
  21. func (NoopConn) Rebind() error {
  22. return nil
  23. }
  24. func (NoopConn) LocalAddr() (netip.AddrPort, error) {
  25. return netip.AddrPort{}, nil
  26. }
  27. func (NoopConn) ListenOut(_ EncReader) {
  28. return
  29. }
  30. func (NoopConn) WriteTo(_ []byte, _ netip.AddrPort) error {
  31. return nil
  32. }
  33. func (NoopConn) ReloadConfig(_ *config.C) {
  34. return
  35. }
  36. func (NoopConn) Close() error {
  37. return nil
  38. }