node

package
v0.0.0-...-8bb18f9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 6, 2024 License: BSD-3-Clause Imports: 41 Imported by: 0

Documentation

Index

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 (
	InboundBuffers  = sync.Pool{New: NewInboundBuffer}
	OutboundBuffers = sync.Pool{New: NewOutboundBuffer}
	IBuffersInUse   atomic.Uint64
	OBuffersInUse   atomic.Uint64
)

Functions

func AuthFlow

func AuthFlow(info *nodev1.LoginResponse) (string, error)

func CompareAddrPort

func CompareAddrPort(p1, p2 netip.AddrPort) int

func DecodeBase64Key

func DecodeBase64Key(key string) ([]byte, error)

func GenerateNewKeypair

func GenerateNewKeypair() (noise.DHKey, error)

func GetPreferredOutboundAddr

func GetPreferredOutboundAddr() (netip.Addr, error)

func LoadKeyFromDisk

func LoadKeyFromDisk() (noise.DHKey, error)

func NewInboundBuffer

func NewInboundBuffer() interface{}

func NewOutboundBuffer

func NewOutboundBuffer() interface{}

func ParseAddr

func ParseAddr(addr string) (netip.Addr, error)

func ParseAddrPort

func ParseAddrPort(ap string) (netip.AddrPort, error)

func PutInboundBuffer

func PutInboundBuffer(buffer *InboundBuffer)

func PutOutboundBuffer

func PutOutboundBuffer(buffer *OutboundBuffer)

func ReportBuffers

func ReportBuffers()

func StoreKeyToDisk

func StoreKeyToDisk(keyPair noise.DHKey) error

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) ConnectStream

func (*ControllerClient) RunUpdateStream

func (c *ControllerClient) RunUpdateStream(ctx context.Context)

func (*ControllerClient) SubmitUpdate

func (c *ControllerClient) SubmitUpdate(update *controllerv1.UpdateRequest)

type IceCreds

type IceCreds struct {
	// contains filtered or unexported fields
}

type InboundBuffer

type InboundBuffer struct {
	// contains filtered or unexported fields
}

func GetInboundBuffer

func GetInboundBuffer() *InboundBuffer

type Key

type Key struct {
	Public  string `yaml:"PublicKey"`
	Private string `yaml:"PrivateKey"`
}

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 NewNode

func NewNode(controller string, port uint16) (*Node, error)

func (*Node) AddPeer

func (node *Node) AddPeer(peerInfo *proto.Peer) (*Peer, error)

TODO: Proper error text for context around the issue

func (*Node) Down

func (n *Node) Down(ctx context.Context, req *nodev1.DownRequest) (*nodev1.DownResponse, error)

func (*Node) HandleUpdates

func (node *Node) HandleUpdates(ctx context.Context)

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) ReadTunPackets

func (node *Node) ReadTunPackets(callback OnTunnelPacket)

func (*Node) Run

func (node *Node) Run() error

func (*Node) Start

func (n *Node) Start() error

func (*Node) StartUpdateStream

func (node *Node) StartUpdateStream(ctx context.Context)

TODO: Fix stream auth

func (*Node) Stop

func (node *Node) Stop() error

func (*Node) StopAllPeers

func (node *Node) StopAllPeers()

func (*Node) Up

func (n *Node) Up(ctx context.Context, req *nodev1.UpRequest) (*nodev1.UpResponse, error)

type OnTunnelPacket

type OnTunnelPacket func(buffer *OutboundBuffer)

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 NewPeer

func NewPeer() *Peer

func (*Peer) InboundPacket

func (peer *Peer) InboundPacket(buffer *InboundBuffer)

func (*Peer) InitiateConnection

func (peer *Peer) InitiateConnection()

TODO: Add retries and counting

func (*Peer) OutboundPacket

func (peer *Peer) OutboundPacket(buffer *OutboundBuffer)

func (*Peer) ResetState

func (peer *Peer) ResetState()

func (*Peer) RespondConnection

func (peer *Peer) RespondConnection(creds IceCreds)

func (*Peer) Start

func (peer *Peer) Start() error

func (*Peer) Stop

func (peer *Peer) Stop()

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL