config

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2020 License: AGPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const ChattyFlag = "chatty"

ChattyFlag is the name of the setting to enable chatty mode

View Source
const ConfigPathFlag = "config-path"

ConfigPathFlag is the name of the setting for the config file base path

View Source
const DebugFlag = "debug"

DebugFlag enables debug logging

View Source
const DumpConfigFlag = "dump"

DumpConfigFlag is the name of the flag to request config dumping

View Source
const HelpFlag = "help"

HelpFlag is the name of the flag to request printing program usage

View Source
const IfaceFlag = "iface"

IfaceFlag is the name of the flag to set the wireguard interface to use

View Source
const RouterFlag = "router"

RouterFlag is the name of the flag to set router mode

View Source
const VersionFlag = "version"

VersionFlag is the name of the flag to request printing the program version

Variables

This section is empty.

Functions

func CreateTrustEvaluator

func CreateTrustEvaluator(peers Peers) trust.Evaluator

CreateTrustEvaluator maps a peer config map into an evaluator that returns the configured trust levels

func Init added in v0.3.0

func Init() (flags *pflag.FlagSet, vcfg *viper.Viper)

Init sets up the config flags and other parsing setup

Types

type Peer

type Peer struct {
	Name          string
	Trust         *trust.Level
	FactExchanger bool
	Endpoints     []PeerEndpoint
	AllowedIPs    []net.IPNet
	Basic         bool
}

Peer represents the parsed info about a peer read from the config file

func (*Peer) String

func (p *Peer) String() string

type PeerData

type PeerData struct {
	PublicKey     string
	Name          string
	Trust         string
	FactExchanger bool
	Endpoints     []string
	AllowedIPs    []string
	Basic         bool
}

PeerData represents the raw data to configure a peer read from the config file

func (*PeerData) Parse

func (p *PeerData) Parse() (key wgtypes.Key, peer Peer, err error)

Parse validates the info in the PeerData and returns the parsed tuple + error

type PeerEndpoint added in v0.7.1

type PeerEndpoint struct {
	// Host may be either an IP or a hostname
	Host string
	Port int
}

PeerEndpoint represents a single endpoint (possibly by hostname) for a peer

type Peers

type Peers map[wgtypes.Key]*Peer

Peers represents a set of peer configs, with handy access methods that avoid boiler plate for peers that are not configured

func (Peers) AllowedIPs added in v0.7.1

func (p Peers) AllowedIPs(peer wgtypes.Key) []net.IPNet

AllowedIPs returns the array of AllowedIPs explicitly configured for the peer, if any

func (Peers) Endpoints added in v0.7.1

func (p Peers) Endpoints(peer wgtypes.Key) []PeerEndpoint

Endpoints returns the array of Endpoints explicitly configured for the peer, if any

func (Peers) IsBasic added in v0.5.0

func (p Peers) IsBasic(peer wgtypes.Key) bool

IsBasic returns true if the peer is explicitly configured as a basic peer, or false otherwise

func (Peers) IsFactExchanger added in v0.3.1

func (p Peers) IsFactExchanger(peer wgtypes.Key) bool

IsFactExchanger returns true if the peer is configured as a FactExchanger

func (Peers) Name

func (p Peers) Name(peer wgtypes.Key) string

Name returns the name of the peer, if configured, or else its key string

func (Peers) Trust

func (p Peers) Trust(peer wgtypes.Key, def trust.Level) trust.Level

Trust returns the configured trust level (if present and valid) or else the provided default

type Server

type Server struct {
	Iface  string
	Port   int
	Chatty bool

	AutoDetectRouter bool
	IsRouterNow      bool

	ReportIfaces []string
	HideIfaces   []string

	Peers Peers

	Debug bool
}

Server describes the configuration for the server, after parsing from various sources

type ServerData added in v0.3.0

type ServerData struct {
	Iface  string
	Port   int
	Router *bool
	Chatty bool

	Peers []PeerData

	ReportIfaces []string
	HideIfaces   []string

	Debug   bool
	Dump    bool
	Help    bool
	Version bool
	// contains filtered or unexported fields
}

ServerData represents the raw data from the config for the server, before it is cleaned up into a `Server` config object.

func Parse added in v0.3.0

func Parse(flags *pflag.FlagSet, vcfg *viper.Viper) (ret *ServerData, err error)

Parse reads flags and configs

func (*ServerData) Parse added in v0.3.0

func (s *ServerData) Parse(vcfg *viper.Viper, wgc *wgctrl.Client) (ret *Server, err error)

Parse converts the raw configuration data into a ready to use server config.

Jump to

Keyboard shortcuts

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