config

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2022 License: GPL-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TLSCertificatePoolMaxNonFileEntryReturn int    = 50
	TLSCACertsSystem                        string = "system"
)

Variables

View Source
var (
	ErrMapStructureDecode = errors.New("MapStructureDecode function failed")
	ErrInconsistentLabels = errors.New("Extra Prometheus labels found without defaults set")
)
View Source
var (
	ErrInvalidInputType = errors.New("invalid input type for decoder")
	ErrInvalidPEMFile   = errors.New("PEM file could not be added to certificate pool")
)

Functions

func Decoder

func Decoder(target interface{}, allowUnused bool) (*mapstructure.Decoder, error)

Decoder returns the decoder for config maps.

func DefaultConfigFile

func DefaultConfigFile() []byte

DefaultConfigFile returns the default embedded YAML config which sets the poller_defaults.

func LoadAndSanitizeConfig

func LoadAndSanitizeConfig(configData []byte) (string, error)

LoadAndSanitizeConfig is used purely for displaying the config to users. It removes sensitive keys from the config and provides a reserialized YAML view of it.

func MapStructureDecodeHookFunc

func MapStructureDecodeHookFunc() mapstructure.DecodeHookFuncType

MapStructureDecodeHookFunc returns a DecodeHookFunc that applies output to the UnmarshalYAML function, when the target type implements the yaml.Unmarshaller interface.

Types

type BackendConfig

type BackendConfig struct {
	Target      HostSpec                      `mapstructure:"target"`
	TLS         TLS                           `mapstructure:"tls,omitempty"` // TLS configures TLS connectivity to the backend
	HTTPHeaders `mapstructure:"http_headers"` // HTTPHeaders configures modifications to the HTTP headers
}

type Config

type Config struct {
	Global      GlobalConfig              `mapstructure:"global,omitempty"`
	Proxychains map[string][]Proxy        `mapstructure:"proxychains,omitempty"`
	Listeners   map[string]ListenerConfig `mapstructure:"listeners,omitempty"`
	Sites       []SiteConfig              `mapstructure:"sites,omitempty"`
}

func Load

func Load(configData []byte) (*Config, error)

Load loads a configuration file from the supplied bytes.

type GlobalConfig

type GlobalConfig struct {
}

type HTTPHeaders

type HTTPHeaders struct {
	// SetHeaders are headers to set on outbound requests. A common header to set is
	// Host in order to route the request.
	SetHeaders map[string][]string `mapstructure:"set_headers,omitempty"`
	// DelHeaders are a list of headers which should be explicitly removed. Names here are normalized
	// before removal, so spelling does not need to be exact.
	DelHeaders []string `mapstructure:"del_headers,omitempty"`
}

HTTPHeaders configures HTTP header modifications.

type HostSpec

type HostSpec struct {
	Host    string // Host is the hostname
	Port    uint16 // Port is the port number
	Network string // Network type (default TCP)
}

func (*HostSpec) HostPort

func (u *HostSpec) HostPort() string

func (*HostSpec) MarshalText

func (u *HostSpec) MarshalText() ([]byte, error)

MarshalText implements the TextMarshaller interface for HostSpec.

func (*HostSpec) String

func (u *HostSpec) String() string

func (*HostSpec) UnmarshalText

func (u *HostSpec) UnmarshalText(text []byte) error

UnmarshalText implements the TextMarshaller interface for HostSpec.

type ListenerConfig

type ListenerConfig struct {
	ListenAddr   HostSpec     `mapstructure:"listen_addr"` // ListenAddr is the hostname and port number
	ListenerType ListenerType `mapstructure:"listen_type"` // ListenerType is the type of listener to attach
}

type ListenerType

type ListenerType string
const (
	SiteConfigTypeHTTPEdge ListenerType = "http-edge"
)

type LoggingConfig

type LoggingConfig struct {
	Level  string `mapstructure:"level,omitempty"`
	Format string `mapstructure:"format,omitempty"`
}

type MapStructureDecoder

type MapStructureDecoder interface {
	MapStructureDecode(interface{}) error
}

MapStructureDecoder is detected by MapStructureDecodeHookFunc to allow a type to decode itself.

type Proxy

type Proxy struct {
	Proxy ProxyURL `mapstructure:"proxy"`
}

type ProxyURL

type ProxyURL string

ProxyURL is a custom type to validate roxy specifications.

const (
	ProxyEnvironment ProxyURL = "environment"
	ProxyDirect      ProxyURL = "direct"
)

func (*ProxyURL) MarshalText

func (p *ProxyURL) MarshalText() ([]byte, error)

UnmarshalText MarshalText encoding.UnmarshalText.

func (*ProxyURL) UnmarshalText

func (p *ProxyURL) UnmarshalText(text []byte) error

UnmarshalText implements encoding.UnmarshalText.

type SiteConfig

type SiteConfig struct {
	Listener   []string      `mapstructure:"listener"`   // Listener is the name of the listener to attach the site too
	Host       string        `mapstructure:"host"`       // Host is the hostname to respond to
	Backend    BackendConfig `mapstructure:"backend"`    // Backend is the backend for the server
	Proxychain string        `mapstructure:"proxychain"` // Proxychain is the proxychain to use for connections
	Method     string        `mapstructure:"method"`     // Method is the type of proxy to use. Options are "edge"
}

type Sum224

type Sum224 [sha256.Size224]byte

TLSCertificateMap encodes a list of certificates and stores them in a hashmap for easy lookups. It is similar to the standard library CertPool.

type TLS

type TLS struct {
	Enable               bool               `mapstructure:"enable"`              // TLS indicates that the connection should be made with TLS
	NoVerify             bool               `mapstructure:"no_verify,omitempty"` // TLSNoVerify means do not verify certificates
	ServerNameIndication *string            `mapstructure:"sni_name,omitempty"`  // The TLS SNI name to send.
	CACerts              TLSCertificatePool `mapstructure:"ca_certs,omitempty"`  // Path to CAfile to verify the service TLS with
}

type TLSCertificateMap

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

func (*TLSCertificateMap) AddCert

func (t *TLSCertificateMap) AddCert(cert *x509.Certificate) error

AddCert adds a certificate to a pool.

func (*TLSCertificateMap) GetCerts

func (t *TLSCertificateMap) GetCerts() []*x509.Certificate

func (*TLSCertificateMap) HasCert

func (t *TLSCertificateMap) HasCert(cert *x509.Certificate) bool

func (*TLSCertificateMap) HashCert

func (t *TLSCertificateMap) HashCert(cert *x509.Certificate) Sum224

func (*TLSCertificateMap) MapStructureDecode

func (t *TLSCertificateMap) MapStructureDecode(input interface{}) error

MapStructureDecode implements unmarshalling for TLSCertificateMap nolint: funlen,cyclop

type TLSCertificatePool

type TLSCertificatePool struct {
	*x509.CertPool
	// contains filtered or unexported fields
}

TLSCertificatePool is our custom type for decoding a certificate pool out of YAML.

func (*TLSCertificatePool) MapStructureDecode

func (t *TLSCertificatePool) MapStructureDecode(input interface{}) error

MapStructureDecode implements the yaml.Unmarshaler interface for tls_cacerts.

type URL

type URL struct {
	*url.URL
}

URL is a custom URL type that allows validation at configuration load time.

func NewURL

func NewURL(url string) (URL, error)

NewURL initializes a new URL object.

func (*URL) MarshalText

func (u *URL) MarshalText() ([]byte, error)

MarshalText implements the TextMarshaller interface for URLs.

func (*URL) MarshalYAML

func (u *URL) MarshalYAML() ([]byte, error)

MarshalYAML implements the yaml.Marshaller interface for URLs.

func (*URL) UnmarshalText

func (u *URL) UnmarshalText(text []byte) error

UnmarshalText implements the TextMarshaller interface for URLs.

Jump to

Keyboard shortcuts

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