agent

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2021 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
====|===================>
___  ____ ____ ____ ____ 
|  \ |__/ |__| | __ |  | 
|__/ |  \ |  | |__] |__| 
		   
                  {{ .AnsiColor.Cyan }}%s{{ .AnsiColor.Default }}
<===================|====

`, version.GetVersion().VersionNumber())

Banner is a banner to be displayed when the Drago agent is started

Functions

This section is empty.

Types

type ACLConfig

type ACLConfig struct {
	// Enabled controls if the ACLs are managed and enforced
	Enabled bool `hcl:"enabled,optional"`
}

ACLConfig contains configuration for Drago's ACL

func (*ACLConfig) Merge

func (c *ACLConfig) Merge(b *ACLConfig) *ACLConfig

Merge merges two ACLConfig structs, returning the result

type AdvertiseAddrs

type AdvertiseAddrs struct {
	// Peer is the address advertised for the purpose
	// of letting other nodes connect to this node. It
	// will be used as the WireGuard's endpoint configuration.
	Peer string `hcl:"peer,optional"`

	// Server contains the address to be advertised for
	// the purpose of clustering with other servers.
	Server string `hcl:"server,optional"`
}

AdvertiseAddrs is used to control the addresses a Drago node advertises. All are optional and default to BindAddr and their default Port. Expected format is address:port.

func (*AdvertiseAddrs) Merge

Merge merges two AdvertiseAddrs structs, returning the result

type Agent

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

Agent :

func New

func New(config *Config, logger log.Logger) (*Agent, error)

New creates a new Drago agent from the configuration, potentially returning an error

func (*Agent) Config

func (a *Agent) Config() map[string]interface{}

Config returns a copy of the agent's Config struct

func (*Agent) Shutdown

func (a *Agent) Shutdown() error

Shutdown is used to terminate the agent.

func (*Agent) Stats

func (a *Agent) Stats() map[string]map[string]string

Stats returns a map containing relevant stats

type ClientConfig

type ClientConfig struct {
	// Enabled controls if the agent is a client
	Enabled bool `hcl:"enabled,optional"`

	// Server is the address of a known Drago server in "host:port" format
	Servers []string `hcl:"servers,optional"`

	// StateDir is the directory where the client state will be kept
	StateDir string `hcl:"state_dir,optional"`

	// InterfacesPrefix is the prefix that will be added to all WireGuard
	// interfaces managed by Drago
	InterfacesPrefix string `hcl:"interfaces_prefix,optional"`

	// WireguardPath is the path to a userspace WireGuard binary, if available
	WireguardPath string `hcl:"wireguard_path,optional"`

	// Meta contains metadata about the client node
	Meta map[string]string `hcl:"meta,optional"`

	// SyncInterval controls how frequently the client synchronizes its state
	SyncInterval time.Duration `hcl:"sync_interval,optional"`
}

ClientConfig contains configurations for the Drago client

func (*ClientConfig) Merge

func (c *ClientConfig) Merge(b *ClientConfig) *ClientConfig

Merge merges two ClientConfig structs, returning the result

type Config

type Config struct {

	// StaticFS contains UI bundle to be server by the Drago agent.
	StaticFS http.FileSystem

	// UI defines whether or not Drago's web UI will be served
	// by the agent. Defaults to true.
	UI bool `hcl:"ui,optional"`

	// Name is used to identify individual agents.
	Name string `hcl:"name,optional"`

	// DataDir is the directory to store our state in.
	// If not specified, this defaults to /etc/drago.
	DataDir string `hcl:"data_dir,optional"`

	// PluginDir is the directory where plugins are loaded from.
	// If not specified, this defaults to <data_dir>/plugins.
	PluginDir string `hcl:"plugin_dir,optional"`

	// BindAddr is the address on which all of Drago's services will
	// be bound. If not specified, this defaults to 127.0.0.1.
	BindAddr string `hcl:"bind_addr,optional"`

	// AdvertiseAddrs is a struct containing the addresses advertised
	// for each of Drago's network services in host:port format.
	// It is optional, and all addresses default to the bind address
	// with the default port corresponding to each service.
	AdvertiseAddrs *AdvertiseAddrs `hcl:"advertise,block"`

	// LogLevel is the level of the logs to put out
	LogLevel string `hcl:"log_level,optional"`

	// Ports is used to control the network ports we bind to.
	Ports *Ports `hcl:"ports,block"`

	// Server contains all server-specific configurations
	Server *ServerConfig `hcl:"server,block"`

	// Client contains all client-specific configurations
	Client *ClientConfig `hcl:"client,block"`

	// ACL contains all ACL configurations
	ACL *ACLConfig `hcl:"acl,block"`

	// DevMode is set by the --dev CLI flag.
	DevMode *bool

	// Version information (set at compilation time)
	Version *version.VersionInfo
}

Config contains configurations for the Drago agent

func DefaultConfig

func DefaultConfig() *Config

DefaultConfig returns a Config struct populated with sane defaults

func EmptyConfig

func EmptyConfig() *Config

EmptyConfig returns an empty Config struct with all nested structs also initialized to a non-nil empty value.

func (*Config) LoadFromFile

func (c *Config) LoadFromFile(path string) (*Config, error)

LoadFromFile loads the configuration from a given path

func (*Config) Merge

func (c *Config) Merge(b *Config) *Config

Merge merges two Config structs, returning the result

func (*Config) Validate

func (c *Config) Validate() error

Validate returns an error in case a Config struct is invalid.

type Ports

type Ports struct {
	HTTP int `hcl:"http,optional"`
	RPC  int `hcl:"rpc,optional"`
}

Ports encapsulates the various ports we bind to for network services. If any are not specified then the defaults are used instead.

func (*Ports) Merge

func (c *Ports) Merge(b *Ports) *Ports

Merge merges two Ports structs, returning the result

type ServerConfig

type ServerConfig struct {
	// Enabled controls if the agent is a server
	Enabled bool `hcl:"enabled,optional"`
}

ServerConfig contains configurations for the Drago server

func (*ServerConfig) Merge

func (c *ServerConfig) Merge(b *ServerConfig) *ServerConfig

Merge merges two ServerConfig structs, returning the result

Directories

Path Synopsis
adapter

Jump to

Keyboard shortcuts

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