configuration

package
v0.0.0-...-53677e4 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2024 License: AGPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Common

type Common struct {
	HostName               string
	SharedKey              string
	Dialer                 network.Dial
	DialTimeout            time.Duration
	Presets                []Preset
	OnlyAllowPresetRemotes bool
}

Common settings shared by mulitple servers

func (Common) DecideDialTimeout

func (c Common) DecideDialTimeout(max time.Duration) time.Duration

DecideDialTimeout will return a reasonable timeout for dialing

type Configuration

type Configuration struct {
	HostName               string
	SharedKey              string
	DialTimeout            time.Duration
	Socks5                 string
	Socks5User             string
	Socks5Password         string
	Servers                []Server
	Presets                []Preset
	OnlyAllowPresetRemotes bool
}

Configuration contains configuration of the application

func (Configuration) Common

func (c Configuration) Common() Common

Common returns common settings

func (Configuration) Dialer

func (c Configuration) Dialer() network.Dial

Dialer builds a Dialer

func (Configuration) Verify

func (c Configuration) Verify() error

Verify verifies current setting

type Loader

type Loader func(log log.Logger) (name string, cfg Configuration, err error)

Loader Configuration loader

func Direct

func Direct(cfg Configuration) Loader

Direct creates a loader that return raw configuration data directly. Good for integration.

func Enviro

func Enviro() Loader

Enviro creates an environment variable based configuration loader

func File

func File(customPath string) Loader

File creates a configuration file loader

func Redundant

func Redundant(loaders ...Loader) Loader

Redundant creates a group of loaders. They will be executed one by one until one of it successfully returned a configuration

type Meta

type Meta map[string]String

Meta contains data of a Key -> Value map which can be use to store dynamically structured configuration options

func (Meta) Concretize

func (m Meta) Concretize() (map[string]string, error)

Concretize returns an concretized Meta as a `map[string]string`

type Preset

type Preset struct {
	Title string
	Type  string
	Host  string
	Meta  map[string]string
}

Preset contains data of a static remote host

type PresetReloader

type PresetReloader func(p Preset) (Preset, error)

PresetReloader reloads preset

type Server

type Server struct {
	ListenInterface       string
	ListenPort            uint16
	InitialTimeout        time.Duration
	ReadTimeout           time.Duration
	WriteTimeout          time.Duration
	HeartbeatTimeout      time.Duration
	ReadDelay             time.Duration
	WriteDelay            time.Duration
	TLSCertificateFile    string
	TLSCertificateKeyFile string
	ServerMessage         string
}

Server contains configuration of a HTTP server

func (Server) IsTLS

func (s Server) IsTLS() bool

IsTLS returns whether or not TLS should be used

func (Server) Verify

func (s Server) Verify() error

Verify verifies current configuration

func (Server) WithDefault

func (s Server) WithDefault() Server

WithDefault build the configuration and fill the blank with default values

type String

type String string

String represents a config string

func (String) Parse

func (s String) Parse() (string, error)

Parse parses current string and return the parsed result

Jump to

Keyboard shortcuts

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