mirror of
https://github.com/slackhq/nebula.git
synced 2025-11-22 16:34:25 +01:00
Use an interface for udp conns (#901)
This commit is contained in:
27
udp/conn.go
27
udp/conn.go
@@ -1,6 +1,7 @@
|
||||
package udp
|
||||
|
||||
import (
|
||||
"github.com/slackhq/nebula/config"
|
||||
"github.com/slackhq/nebula/firewall"
|
||||
"github.com/slackhq/nebula/header"
|
||||
)
|
||||
@@ -18,3 +19,29 @@ type EncReader func(
|
||||
q int,
|
||||
localCache firewall.ConntrackCache,
|
||||
)
|
||||
|
||||
type Conn interface {
|
||||
Rebind() error
|
||||
LocalAddr() (*Addr, error)
|
||||
ListenOut(r EncReader, lhf LightHouseHandlerFunc, cache *firewall.ConntrackCacheTicker, q int)
|
||||
WriteTo(b []byte, addr *Addr) error
|
||||
ReloadConfig(c *config.C)
|
||||
}
|
||||
|
||||
type NoopConn struct{}
|
||||
|
||||
func (NoopConn) Rebind() error {
|
||||
return nil
|
||||
}
|
||||
func (NoopConn) LocalAddr() (*Addr, error) {
|
||||
return nil, nil
|
||||
}
|
||||
func (NoopConn) ListenOut(_ EncReader, _ LightHouseHandlerFunc, _ *firewall.ConntrackCacheTicker, _ int) {
|
||||
return
|
||||
}
|
||||
func (NoopConn) WriteTo(_ []byte, _ *Addr) error {
|
||||
return nil
|
||||
}
|
||||
func (NoopConn) ReloadConfig(_ *config.C) {
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user