server

package
v0.14.3 Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2024 License: AGPL-3.0 Imports: 27 Imported by: 0

Documentation

Overview

Package server provides the core class that implements the wirelink server, exchanging UDP packets with other peers on the same wireguard network.

Index

Constants

View Source
const DefaultAlivePeriod = 30 * time.Second

DefaultAlivePeriod is how often we send "I'm here" facts to peers

View Source
const DefaultChunkPeriod = 5 * time.Second

DefaultChunkPeriod is the default max time to wait between processing chunks of received packets and expiring old ones TODO: set this based on TTL instead

View Source
const DefaultFactTTL = 255 * time.Second

DefaultFactTTL is the default TTL we apply to any locally generated Facts

View Source
const MaxChunk = 100

MaxChunk is the max number of packets to receive before processing them

Variables

This section is empty.

Functions

This section is empty.

Types

type LinkServer

type LinkServer struct {
	FactTTL     time.Duration
	ChunkPeriod time.Duration
	AlivePeriod time.Duration
	// contains filtered or unexported fields
}

LinkServer represents the server component of wirelink sending/receiving on a socket

func Create

func Create(
	env networking.Environment,
	ctrl internal.WgClient,
	config *config.Server,
) (*LinkServer, error)

Create prepares a new server object, but does not start it yet. Will take ownership of the wg client and close it when the server is closed. The default listen port is the wireguard listen port plus one.

func (*LinkServer) AddHandler added in v0.8.0

func (s *LinkServer) AddHandler(handler func(ctx context.Context) error)

AddHandler adds additional handler helpers to the server lifetime, such as for signal handling, which are the domain of the main application

func (*LinkServer) Address

func (s *LinkServer) Address() net.IP

Address returns the local IP address on which the server listens

func (*LinkServer) Close

func (s *LinkServer) Close()

Close stops the server and closes all resources

func (*LinkServer) Describe added in v0.8.0

func (s *LinkServer) Describe() string

Describe returns a textual summary of the server

func (*LinkServer) Port

func (s *LinkServer) Port() int

Port returns the local UDP port on which the server listens and sends

func (*LinkServer) RequestPrint

func (s *LinkServer) RequestPrint(wait bool)

RequestPrint asks the packet receiver to print out the full set of known facts (local and remote)

func (*LinkServer) RequestStop added in v0.8.0

func (s *LinkServer) RequestStop()

RequestStop asks the server to stop, but does not wait for this process to complete

func (*LinkServer) Start added in v0.8.0

func (s *LinkServer) Start() (err error)

Start makes the server open its listen socket and start all the goroutines to receive and process packets

func (*LinkServer) Stop

func (s *LinkServer) Stop()

Stop halts the background goroutines and releases resources associated with them, but leaves open some resources associated with the local device so that final state can be inspected

func (*LinkServer) UpdateRouterState added in v0.8.0

func (s *LinkServer) UpdateRouterState(dev *wgtypes.Device, logChanges bool)

UpdateRouterState will update `s.config.IsRouterNow` based on the device state, if `s.config.AutoDetectRouter` is true. The possible error return is for future use cases, it always returns `nil` for now

func (*LinkServer) Wait added in v0.8.0

func (s *LinkServer) Wait() error

Wait waits for a running server to end, returning any error if it ended prematurely

type ReceivedFact

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

ReceivedFact is a tuple of a fact and its source. It is used for the queue of parsed packets received over the network, to hold them in a batch before evaluating them for acceptance

func (*ReceivedFact) String

func (rf *ReceivedFact) String() string

Jump to

Keyboard shortcuts

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