nebula/udp/conn.go

49 lines
825 B
Go
Raw Normal View History

package udp
import (
"net/netip"
2023-06-14 10:48:52 -05:00
"github.com/slackhq/nebula/config"
)
const MTU = 9001
type EncReader func(
addr netip.AddrPort,
payload []byte,
)
2023-06-14 10:48:52 -05:00
type Conn interface {
Rebind() error
LocalAddr() (netip.AddrPort, error)
ListenOut(r EncReader)
WriteTo(b []byte, addr netip.AddrPort) error
2023-06-14 10:48:52 -05:00
ReloadConfig(c *config.C)
SupportsMultipleReaders() bool
Close() error
2023-06-14 10:48:52 -05:00
}
type NoopConn struct{}
func (NoopConn) Rebind() error {
return nil
}
func (NoopConn) LocalAddr() (netip.AddrPort, error) {
return netip.AddrPort{}, nil
2023-06-14 10:48:52 -05:00
}
func (NoopConn) ListenOut(_ EncReader) {
2023-06-14 10:48:52 -05:00
return
}
func (NoopConn) SupportsMultipleReaders() bool {
return false
}
func (NoopConn) WriteTo(_ []byte, _ netip.AddrPort) error {
2023-06-14 10:48:52 -05:00
return nil
}
func (NoopConn) ReloadConfig(_ *config.C) {
return
}
func (NoopConn) Close() error {
return nil
}