config

package
v0.10.3 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ProtocolRCON    = "rcon"
	ProtocolTELNET  = "telnet"
	ProtocolWebRCON = "web"
)

Allowed protocols.

View Source
const DefaultConfigEnv = "default"

DefaultConfigEnv is the name of the environment, which is taken as default unless another value is passed.

View Source
const DefaultConfigName = "rcon.yaml"

DefaultConfigName sets the default config file name.

View Source
const DefaultProtocol = ProtocolRCON

DefaultProtocol contains the default protocol for connecting to a remote server.

View Source
const DefaultTimeout = 10 * time.Second

DefaultTimeout contains the default dial and execute timeout.

Variables

View Source
var (
	// ErrConfigValidation is when config validation completed with errors.
	ErrConfigValidation = errors.New("config validation error")

	// ErrUnsupportedFileExt is returned when config file has an unsupported
	// extension. Allowed extensions is `.json`, `.yml`, `.yaml`.
	ErrUnsupportedFileExt = errors.New("unsupported file extension")
)

Functions

This section is empty.

Types

type Config

type Config map[string]Session

Config allows to take a remote server address and password from the configuration file. This enables not to specify these flags when running the CLI.

Example: ```yaml default:

address: "127.0.0.1:16260"
password: "password"

```.

func NewConfig added in v0.9.0

func NewConfig(name string) (*Config, error)

NewConfig finds and parses config file with remote server credentials.

func (*Config) ParseFromFile added in v0.9.0

func (cfg *Config) ParseFromFile(name string) error

ParseFromFile reads a configuration file from disk and loads its contents into the application's config structure. YAML and JSON files are supported.

func (*Config) Validate added in v0.9.0

func (cfg *Config) Validate() error

Validate validates the config fields.

type Session added in v0.9.0

type Session struct {
	Address  string `json:"address" yaml:"address"`
	Password string `json:"password" yaml:"password"`
	// Log is the name of the file to which requests will be logged.
	// If not specified, no logging will be performed.
	Log        string        `json:"log" yaml:"log"`
	Type       string        `json:"type" yaml:"type"`
	SkipErrors bool          `json:"skip_errors" yaml:"skip_errors"`
	Timeout    time.Duration `json:"timeout" yaml:"timeout"`
}

Session contains details for making a request on a remote server.

Jump to

Keyboard shortcuts

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