Documentation
¶
Index ¶
- Constants
- type LinkServer
- func (s *LinkServer) AddHandler(handler func(ctx context.Context) error)
- func (s *LinkServer) Address() net.IP
- func (s *LinkServer) Close()
- func (s *LinkServer) Describe() string
- func (s *LinkServer) Port() int
- func (s *LinkServer) RequestPrint()
- func (s *LinkServer) RequestStop()
- func (s *LinkServer) Start() (err error)
- func (s *LinkServer) Stop()
- func (s *LinkServer) UpdateRouterState(dev *wgtypes.Device, logChanges bool) error
- func (s *LinkServer) Wait() error
- type ReceivedFact
Constants ¶
const AlivePeriod = 30 * time.Second
AlivePeriod is how often we send "I'm here" facts to peers
const ChunkPeriod = 5 * time.Second
ChunkPeriod is the max time to wait between processing chunks of received packets and expiring old ones TODO: set this based on TTL instead
const FactTTL = 255 * time.Second
FactTTL is the TTL we apply to any locally generated Facts This is only meaningful if it is <= 255 seconds, since we encode the TTL as a byte
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 {
// contains filtered or unexported fields
}
LinkServer represents the server component of wirelink sending/receiving on a socket
func Create ¶
Create starts the server up. Have to take a deviceFactory instead of a Device since you can't refresh a device. Will take ownership of the wg client and close it when the server is closed If port <= 0, will use the wireguard device's 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()
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) error
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