Documentation ¶
Index ¶
- Constants
- Variables
- func AuthFlow(info *nodev1.LoginResponse) (string, error)
- func CompareAddrPort(p1, p2 netip.AddrPort) int
- func CreateHandshake(initiator bool, keypair noise.DHKey, rs []byte) (*noise.HandshakeState, error)
- func DecodeBase64Key(key string) ([]byte, error)
- func GenerateNewKeypair() (noise.DHKey, error)
- func GetPreferredOutboundAddr() (netip.Addr, error)
- func LoadKeyFromDisk() (noise.DHKey, error)
- func NewInboundBuffer() interface{}
- func NewOutboundBuffer() interface{}
- func ParseAddr(addr string) (netip.Addr, error)
- func ParseAddrPort(ap string) (netip.AddrPort, error)
- func PutInboundBuffer(buffer *InboundBuffer)
- func PutOutboundBuffer(buffer *OutboundBuffer)
- func ReportBuffers()
- func StoreKeyToDisk(keyPair noise.DHKey) error
- type ControllerClient
- type InboundBuffer
- type Key
- type Node
- func (node *Node) AddPeer(peerInfo *proto.Peer) (*Peer, error)
- func (n *Node) Down(ctx context.Context, req *nodev1.DownRequest) (*nodev1.DownResponse, error)
- func (node *Node) HandleUpdate(update *controllerv1.UpdateResponse)
- func (n *Node) Login(ctx context.Context, req *nodev1.LoginRequest) (*nodev1.LoginResponse, error)
- func (node *Node) OnTunnelPacket(buffer *OutboundBuffer)
- func (node *Node) OnUDPPacket(buffer *InboundBuffer, index int)
- func (node *Node) ReadTunPackets(callback OnTunnelPacket)
- func (node *Node) ReadUDPPackets(callback OnUDPPacket, index int)
- func (node *Node) RequestPunch(id uint32)
- func (node *Node) Run() error
- func (n *Node) Start() error
- func (node *Node) StartUpdateStream(ctx context.Context)
- func (node *Node) Stop() error
- func (node *Node) StopAllPeers()
- func (n *Node) Up(ctx context.Context, req *nodev1.UpRequest) (*nodev1.UpResponse, error)
- type OnTunnelPacket
- type OnUDPPacket
- type OutboundBuffer
- type Peer
- func (peer *Peer) Handshake()
- func (peer *Peer) HandshakeTimeout()
- func (peer *Peer) Inbound()
- func (peer *Peer) InboundPacket(buffer *InboundBuffer)
- func (peer *Peer) InitHandshake(initiator bool) error
- func (peer *Peer) Outbound()
- func (peer *Peer) OutboundPacket(buffer *OutboundBuffer)
- func (peer *Peer) RXTimeout()
- func (peer *Peer) RequestPunch()
- func (peer *Peer) ResetState()
- func (peer *Peer) Start() error
- func (peer *Peer) Stop()
- func (peer *Peer) TXTimeout()
- func (peer *Peer) TrySendHandshake(retry bool)
- func (peer *Peer) Update(info *controllerv1.Peer) error
- func (peer *Peer) UpdateEndpoint(addr *net.UDPAddr)
- func (peer *Peer) UpdateEndpointLocked(addr *net.UDPAddr)
Constants ¶
View Source
const ( // Timers TimerHandshakeTimeout = time.Second * 5 TimerRxTimeout = time.Second * 15 TimerKeepalive = time.Second * 10 // Counts CountHandshakeRetries = 10 InboundChannelSize = 1024 OutboundChannelSize = 1024 HandshakeChannelSize = 3 )
View Source
const BufferSize = 1600
Variables ¶
View Source
var ( CipherSuite = noise.NewCipherSuite(noise.DH25519, noise.CipherChaChaPoly, noise.HashBLAKE2s) BaseConfig = noise.Config{CipherSuite: CipherSuite, Pattern: noise.HandshakeIK} )
View Source
var ( InboundBuffers = sync.Pool{New: NewInboundBuffer} OutboundBuffers = sync.Pool{New: NewOutboundBuffer} IBuffersInUse atomic.Uint64 OBuffersInUse atomic.Uint64 )
Functions ¶
func CompareAddrPort ¶
func CreateHandshake ¶
func DecodeBase64Key ¶
func GenerateNewKeypair ¶
func LoadKeyFromDisk ¶
func NewInboundBuffer ¶
func NewInboundBuffer() interface{}
func NewOutboundBuffer ¶
func NewOutboundBuffer() interface{}
func PutInboundBuffer ¶
func PutInboundBuffer(buffer *InboundBuffer)
func PutOutboundBuffer ¶
func PutOutboundBuffer(buffer *OutboundBuffer)
func ReportBuffers ¶
func ReportBuffers()
func StoreKeyToDisk ¶
Types ¶
type ControllerClient ¶
type ControllerClient struct {
// contains filtered or unexported fields
}
func NewControllerClient ¶
func NewControllerClient(address string) (*ControllerClient, error)
func (*ControllerClient) Close ¶
func (c *ControllerClient) Close() error
func (*ControllerClient) UpdateEndpoint ¶
func (c *ControllerClient) UpdateEndpoint(id string, endpoint string)
type InboundBuffer ¶
type InboundBuffer struct {
// contains filtered or unexported fields
}
func GetInboundBuffer ¶
func GetInboundBuffer() *InboundBuffer
type Node ¶
type Node struct { nodev1.UnimplementedNodeServiceServer // contains filtered or unexported fields }
TODO: Verify need for mutex for node properties like ip, prefix, id, etc TODO: Handle logged in state and when to refresh TODO: Handle logged in state after running 'down' command
func (*Node) Down ¶
func (n *Node) Down(ctx context.Context, req *nodev1.DownRequest) (*nodev1.DownResponse, error)
func (*Node) HandleUpdate ¶
func (node *Node) HandleUpdate(update *controllerv1.UpdateResponse)
func (*Node) Login ¶
func (n *Node) Login(ctx context.Context, req *nodev1.LoginRequest) (*nodev1.LoginResponse, error)
func (*Node) OnTunnelPacket ¶
func (node *Node) OnTunnelPacket(buffer *OutboundBuffer)
func (*Node) OnUDPPacket ¶
func (node *Node) OnUDPPacket(buffer *InboundBuffer, index int)
func (*Node) ReadTunPackets ¶
func (node *Node) ReadTunPackets(callback OnTunnelPacket)
func (*Node) ReadUDPPackets ¶
func (node *Node) ReadUDPPackets(callback OnUDPPacket, index int)
func (*Node) RequestPunch ¶
func (*Node) StartUpdateStream ¶
TODO: Move some of the stream logic to ControllerClient
func (*Node) StopAllPeers ¶
func (node *Node) StopAllPeers()
type OnTunnelPacket ¶
type OnTunnelPacket func(buffer *OutboundBuffer)
type OnUDPPacket ¶
type OnUDPPacket func(buffer *InboundBuffer, index int)
type OutboundBuffer ¶
type OutboundBuffer struct {
// contains filtered or unexported fields
}
func GetOutboundBuffer ¶
func GetOutboundBuffer() *OutboundBuffer
type Peer ¶
type Peer struct { Hostname string IP netip.Addr ID uint32 // contains filtered or unexported fields }
TODO proper self-contained state machine for noise handshakes
func (*Peer) Handshake ¶
func (peer *Peer) Handshake()
TODO completely rewrite this with proper state tracking and error handling
func (*Peer) HandshakeTimeout ¶
func (peer *Peer) HandshakeTimeout()
func (*Peer) InboundPacket ¶
func (peer *Peer) InboundPacket(buffer *InboundBuffer)
func (*Peer) InitHandshake ¶
TODO Not safe for concurrent use, possibly called from different goroutines. fix with lock inside noise struct
func (*Peer) OutboundPacket ¶
func (peer *Peer) OutboundPacket(buffer *OutboundBuffer)
func (*Peer) RequestPunch ¶
func (peer *Peer) RequestPunch()
func (*Peer) ResetState ¶
func (peer *Peer) ResetState()
func (*Peer) TrySendHandshake ¶
func (*Peer) Update ¶
func (peer *Peer) Update(info *controllerv1.Peer) error
// TODO Fix variable naming and compares
func (*Peer) UpdateEndpoint ¶
func (*Peer) UpdateEndpointLocked ¶
Source Files ¶
Click to show internal directories.
Click to hide internal directories.