config

package
v1.4.23 Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2018 License: MIT Imports: 13 Imported by: 12

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Version defines the version of the application.
	Version = "unknown"
	// Revision is the hash in VCS (git commit).
	Revision = "unknown"
	// Filename defines the filename of the configuration file.
	// Deprecated: use Place API.
	Filename = "fritzctl.json"

	// Dir defines the directory of the configuration file.
	// Deprecated: use Place API.
	Dir = "."
	// DefaultDir is the default directory where the config file resides.
	// Deprecated: will not be the default in future versions.
	DefaultDir = "/etc/fritzctl"
)

Functions

func DefaultConfigFileAbsolute

func DefaultConfigFileAbsolute() string

DefaultConfigFileAbsolute returns the absolute path of the default configuration file. Deprecated: use Place in combination with Parser.

func FindConfigFile

func FindConfigFile() (string, error)

FindConfigFile returns the path to the config file. Deprecated: use Parser.

Types

type Config

type Config struct {
	*Net
	*Login
	*Pki
}

Config stores client configuration of your FRITZ!Box

func New

func New(path string) (*Config, error)

New creates a new Config by reading from a file given by the path.

func (*Config) GetLoginResponseURL

func (config *Config) GetLoginResponseURL(response string) string

GetLoginResponseURL returns the URL that is queried for the login challenge

func (*Config) GetLoginURL

func (config *Config) GetLoginURL() string

GetLoginURL returns the URL that is queried for the login challenge

type Configurer

type Configurer interface {
	Greet()
	Obtain(r io.Reader) (ExtendedConfig, error)
}

Configurer provides functions to obtain user data from stdin and write the result to a file.

func NewConfigurer

func NewConfigurer() Configurer

NewConfigurer creates a Configurer instance.

type Decode added in v1.4.19

type Decode func(io.Reader, interface{}) error

Decode uses an io.Reader, whose read bytes shall be marshaled into the passed interface. An error is returned if the operation did not work.

func JSON added in v1.4.19

func JSON() Decode

JSON returns a Decode function that uses JSON format.

func YAML added in v1.4.19

func YAML() Decode

YAML returns a Decode function that uses YML format.

type ExtendedConfig

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

ExtendedConfig contains the fritz core config along with other data (like config file location).

func (*ExtendedConfig) Write added in v1.4.13

func (c *ExtendedConfig) Write() error

Write writes the user data to the configured file.

type Login

type Login struct {
	LoginURL string `json:"loginURL" yaml:"url"`      // The URL for the login negotiation.
	Username string `json:"username" yaml:"username"` // Username to log in. In user-agnostic setups this can be left empty.
	Password string `json:"password" yaml:"password"` // The password corresponding to the Username.
}

Login wraps the login data to be used by the client.

type Net

type Net struct {
	Protocol string `json:"protocol" yaml:"protocol"` // The protocol to use when communicating with the FRITZ!Box. "http" or "https".
	Host     string `json:"host"  yaml:"host"`        // Host name or ip address of the FRITZ!Box. In most home setups "fritz.box" can be used. Other possible formats: "192.168.2.200".
	Port     string `json:"port" yaml:"port"`         // Port to use for the HTTP interface. Leave empty for default values.
}

Net wraps the protocol://host:port data to contact the FRITZ!Box.

type Parser added in v1.4.19

type Parser interface {
	Parse() (*Config, error)
}

Parser defines one method, Parse, which reads from 3rd party source(s).

func NewParser added in v1.4.19

func NewParser(places ...Place) Parser

NewParser constructs a Parser that looks for configuration in the passed Places. If multiple Places would spawn correct configurations, the first-without-error is used.

type Pki

type Pki struct {
	SkipTLSVerify   bool   `json:"skipTlsVerify" yaml:"skip_tls_verify"`     // Skip TLS verification when using https.
	CertificateFile string `json:"certificateFile"  yaml:"certificate_file"` // Points to a certificate file (in PEM format) to verify the integrity of the FRITZ!Box.
}

Pki wraps the client-side certificate handling.

type Place added in v1.4.19

type Place func(*parser)

Place is a configuration option for a parser.

func InDir added in v1.4.19

func InDir(dir string, file string, decoder Decode) Place

InDir looks for a file inside a given directory.

func InHomeDir added in v1.4.19

func InHomeDir(u func() (*user.User, error), path string, decoder Decode) Place

InHomeDir looks for a file inside a user's home directory.

Jump to

Keyboard shortcuts

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