conf

package
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2023 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package conf handles configuration.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AppConfig

type AppConfig struct {
	MaxConfigFiles    int
	Holdtime          time.Duration
	ScanInterval      time.Duration
	MaxConcurrency    int
	MaxConfigLoadSize int64
	LastChange        Change
	Comment           string // free user-defined field
}

AppConfig is persistent global configuration.

func NewAppConfigFromString

func NewAppConfigFromString(str string) (*AppConfig, error)

NewAppConfigFromString creates AppConfig from string.

func (*AppConfig) Dump

func (a *AppConfig) Dump() ([]byte, error)

Dump exports AppConfig as YAML.

type Change

type Change struct {
	When time.Time
	By   string
	From string
}

Change stores info about last config change.

type Config

type Config struct {
	Options AppConfig
	Devices []DevConfig
}

Config is full (global+devices) app configuration.

func Load

func Load(path string, maxSize int64) (*Config, error)

Load loads a Config from file.

func New

func New() *Config

New creates new full app configuration.

func (*Config) Dump

func (c *Config) Dump() ([]byte, error)

Dump exports device properties as YAML.

type DevAttributes

type DevAttributes struct {
	NeedLoginChat                bool          // need login chat
	NeedEnabledMode              bool          // need enabled mode
	NeedPagingOff                bool          // need disabled pager
	EnableCommand                string        // enable
	UsernamePromptPattern        string        // Username:
	PasswordPromptPattern        string        // Password:
	EnablePasswordPromptPattern  string        // Password:
	DisabledPromptPattern        string        // >
	EnabledPromptPattern         string        // # ("" --> look for EOF)
	CommandList                  []string      // "show version", "show run"
	DisablePagerCommand          string        // term len 0
	DisablePagerExtraPromptCount int           // consume N extra prompts
	SupressAutoLF                bool          // do not send auto LF
	QuoteSentCommandsFormat      string        // !![%s] - empty means omitting
	KeepControlChars             bool          // enable if you want to capture control chars (backspace, etc)
	LineFilter                   string        // line filter name - applied to every saved line
	ChangesOnly                  bool          // save new file only if it differs from previous one
	S3ContentType                string        // ""=none "detect"=http.Detect "text/plain" etc
	RunProg                      []string      // "/path/to/external/command", "arg1", "arg2" for the run model
	RunTimeout                   time.Duration // 60s - time allowed for external program to complete
	ErrlogHistSize               int           // max number of lines in errlog history
	PostLoginPromptPattern       string        // mikrotik: Please press "Enter" to continue!
	PostLoginPromptResponse      string        // mikrotik: \r\n
	UsernameAppend               string        // mikrotik: +cte

	// readTimeout: per-read timeout (protection against inactivity)
	// matchTimeout: full match timeout (protection against slow sender -- think 1 byte per second)
	ReadTimeout         time.Duration // protection against inactivity
	MatchTimeout        time.Duration // protection against slow sender
	SendTimeout         time.Duration // protection against inactivity
	CommandReadTimeout  time.Duration // larger timeout for slow responses (slow show running)
	CommandMatchTimeout time.Duration // larger timeout for slow responses (slow show running)
}

DevAttributes is per-model set of default attributes for device.

func NewDevAttr

func NewDevAttr() DevAttributes

NewDevAttr creates a new set of DevAttributes.

type DevConfig

type DevConfig struct {
	Debug           bool
	Deleted         bool
	Model           string
	ID              string
	HostPort        string
	Transports      string
	LoginUser       string
	LoginPassword   string
	EnablePassword  string
	SSHClearCiphers bool
	SSHAddCiphers   []string
	Comment         string // free user-defined field
	LastChange      Change
	Attr            DevAttributes
}

DevConfig is full set of device properties.

func NewDeviceFromString

func NewDeviceFromString(str string) (*DevConfig, error)

NewDeviceFromString creates device configuration from string.

func (*DevConfig) Dump

func (c *DevConfig) Dump() ([]byte, error)

Dump exports device properties as YAML.

type Options

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

Options provides concurrency-safe access to AppConfig.

func NewOptions

func NewOptions() *Options

NewOptions creates a new set of options.

func (*Options) Get

func (o *Options) Get() *AppConfig

Get creates a copy of AppConfig.

func (*Options) Set

func (o *Options) Set(c *AppConfig)

Set updates the AppConfig from a copy.

Jump to

Keyboard shortcuts

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