conn.go 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. package udp
  2. import (
  3. "net/netip"
  4. "github.com/slackhq/nebula/config"
  5. "github.com/slackhq/nebula/firewall"
  6. "github.com/slackhq/nebula/header"
  7. )
  8. const MTU = 9001
  9. type EncReader func(
  10. addr netip.AddrPort,
  11. out []byte,
  12. packet []byte,
  13. header *header.H,
  14. fwPacket *firewall.Packet,
  15. lhh LightHouseHandlerFunc,
  16. nb []byte,
  17. q int,
  18. localCache firewall.ConntrackCache,
  19. )
  20. type Conn interface {
  21. Rebind() error
  22. LocalAddr() (netip.AddrPort, error)
  23. ListenOut(r EncReader, lhf LightHouseHandlerFunc, cache *firewall.ConntrackCacheTicker, q int)
  24. WriteTo(b []byte, addr netip.AddrPort) error
  25. ReloadConfig(c *config.C)
  26. Close() error
  27. }
  28. type NoopConn struct{}
  29. func (NoopConn) Rebind() error {
  30. return nil
  31. }
  32. func (NoopConn) LocalAddr() (netip.AddrPort, error) {
  33. return netip.AddrPort{}, nil
  34. }
  35. func (NoopConn) ListenOut(_ EncReader, _ LightHouseHandlerFunc, _ *firewall.ConntrackCacheTicker, _ int) {
  36. return
  37. }
  38. func (NoopConn) WriteTo(_ []byte, _ netip.AddrPort) error {
  39. return nil
  40. }
  41. func (NoopConn) ReloadConfig(_ *config.C) {
  42. return
  43. }
  44. func (NoopConn) Close() error {
  45. return nil
  46. }