github.com/slackhq/nebula@v1.9.0/udp/conn.go (about)

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