conf

package
v0.0.0-...-e26558c Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2024 License: GPL-3.0 Imports: 3 Imported by: 0

Documentation

Overview

conf defines configuration file parsing for golang

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ValidateDaemonConfiguration

func ValidateDaemonConfiguration(conf *DaemonConfiguration) error

ValidateDaemonConfiguration: validates the dameon configuration that is used.

func ValidateMeshConfiguration

func ValidateMeshConfiguration(conf *WgConfiguration) error

ValdiateMeshConfiguration: validates the mesh configuration

Types

type DaemonConfiguration

type DaemonConfiguration struct {
	// CertificatePath is the path to the certificate to use in mTLS
	CertificatePath string `yaml:"certificatePath" validate:"required"`
	// PrivateKeypath is the path to the clients private key in mTLS
	PrivateKeyPath string `yaml:"privateKeyPath" validate:"required"`
	// CaCeritifcatePath path to the certificate of the trust certificate authority
	CaCertificatePath string `yaml:"caCertificatePath" validate:"required"`
	// SkipCertVerification specify to skip certificate verification. Should only be used
	// in test environments
	SkipCertVerification bool `yaml:"skipCertVerification"`
	// Port to run the GrpcServer on
	GrpcPort int `yaml:"gRPCPort" validate:"required"`
	// Timeout number of seconds without response that a node is considered unreachable by gRPC
	Timeout int `yaml:"timeout" validate:"required,gte=1"`
	// StubWg whether or not to stub the WireGuard types
	StubWg bool `yaml:"stubWg"`
	// SyncInterval specifies how long the minimum time should be between synchronisation
	SyncInterval int `yaml:"syncInterval" validate:"required,gte=1"`
	// PullInterval specifies the interval between checking for configuration changes
	PullInterval int `yaml:"pullInterval" validate:"gte=0"`
	// Heartbeat: number of seconds before the leader of the mesh sends an update to
	// send to every member in the mesh
	Heartbeat int `yaml:"heartbeatInterval" validate:"required,gte=1"`
	// ClusterSize specifies how many neighbours you should synchronise with per round
	ClusterSize int `yaml:"clusterSize" validate:"gte=1"`
	// InterClusterChance specifies the probabilityof inter-cluster communication in a sync round
	InterClusterChance float64 `yaml:"interClusterChance" validate:"gt=0"`
	// Branch specifies the number of nodes to synchronise with when a node has
	// new changes to send to the mesh
	Branch int `yaml:"branch" validate:"required,gte=1"`
	// InfectionCount: number of time to sync before an update can no longer be 'caught'
	InfectionCount int `yaml:"infectionCount" validate:"required,gte=1"`
	// BaseConfiguration base WireGuard configuration to use, this is used when none is provided
	BaseConfiguration WgConfiguration `yaml:"baseConfiguration" validate:"required"`
	// LogLevel specifies the log level to output, defaults is warning
	LogLevel LogLevel `yaml:"logLevel" validate:"eq=info|eq=warning|eq=error"`
}

func ParseDaemonConfiguration

func ParseDaemonConfiguration(filePath string) (*DaemonConfiguration, error)

ParseDaemonConfiguration parses the mesh configuration and validates the configuration

type IPDiscovery

type IPDiscovery string

IPDiscovery: what IPDiscovery service to use

const (
	// Public IP use an IP service to discover your IP
	PUBLIC_IP_DISCOVERY IPDiscovery = "public"
	// Outgonig: Use your labelled packet IP
	OUTGOING_IP_DISCOVERY IPDiscovery = "outgoing"
)

type LogLevel

type LogLevel string

Loglevel: what log level to use either error info or warning

const (
	ERROR   LogLevel = "error"
	WARNING LogLevel = "warning"
	INFO    LogLevel = "info"
)

type NodeType

type NodeType string

NodeType types of the node either peer or client

const (
	PEER_ROLE   NodeType = "peer"
	CLIENT_ROLE NodeType = "client"
)

type WgConfiguration

type WgConfiguration struct {
	// IPDIscovery: how to discover your IP if not specified. Use your outgoing IP or use a public
	// service for IPDiscoverability
	IPDiscovery *IPDiscovery `yaml:"ipDiscovery" validate:"required,eq=public|eq=outgoing"`
	// AdvertiseRoutes: specifies whether the node can act as a router routing packets between meshes
	AdvertiseRoutes *bool `yaml:"advertiseRoute" validate:"required"`
	// AdvertiseDefaultRoute: specifies whether or not this route should advertise a default route
	// for all nodes to route their packets to
	AdvertiseDefaultRoute *bool `yaml:"advertiseDefaults" validate:"required"`
	// Endpoint contains what value should be set as the public endpoint of this node
	Endpoint *string `yaml:"publicEndpoint"`
	// Role specifies whether or not the user is globally accessible.
	// If the user is globaly accessible they specify themselves as a client.
	Role *NodeType `yaml:"role" validate:"required,eq=client|eq=peer"`
	// KeepAliveWg configures the implementation so that we send keep alive packets to peers.
	KeepAliveWg *int `yaml:"keepAliveWg" validate:"omitempty,gte=0"`
	// PreUp are WireGuard commands to run before adding the WG interface
	PreUp []string `yaml:"preUp"`
	// PostUp are WireGuard commands to run after adding the WG interface
	PostUp []string `yaml:"postUp"`
	// PreDown are WireGuard commands to run prior to removing the WG interface
	PreDown []string `yaml:"preDown"`
	// PostDown are WireGuard command to run after removing the WG interface
	PostDown []string `yaml:"postDown"`
}

WgConfiguration contains per-mesh WireGuard configuration. Contains poitner types only so we can tell if the attribute is set

func MergeMeshConfiguration

func MergeMeshConfiguration(cfgs ...WgConfiguration) (WgConfiguration, error)

MergemeshConfiguration: merges the configuration in precedence where the last element in the list takes the most and the first takes the least

Jump to

Keyboard shortcuts

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