config

package
v2.1.6 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2022 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// TypePreferIPPreferIPv4 states that you prefer to use IPv4 addresses
	// but IPv6 is also possible.
	TypePreferIPPreferIPv4 = "prefer-ipv4"

	// TypePreferIPPreferIPv6 states that you prefer to use IPv6 addresses
	// but IPv4 is also possible.
	TypePreferIPPreferIPv6 = "prefer-ipv6"

	// TypePreferOnlyIPv4 states that you prefer to use IPv4 addresses
	// only.
	TypePreferOnlyIPv4 = "only-ipv4"

	// TypePreferOnlyIPv6 states that you prefer to use IPv6 addresses
	// only.
	TypePreferOnlyIPv6 = "only-ipv6"
)
View Source
const (
	// TypeStatsdTagFormatInfluxdb defines a tag format compatible with
	// InfluxDB.
	TypeStatsdTagFormatInfluxdb = "influxdb"

	// TypeStatsdTagFormatDatadog defines a tag format compatible with
	// DataDog.
	TypeStatsdTagFormatDatadog = "datadog"

	// TypeStatsdTagFormatGraphite defines a tag format compatible with
	// Graphite.
	TypeStatsdTagFormatGraphite = "graphite"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Debug                    TypeBool        `json:"debug"`
	AllowFallbackOnUnknownDC TypeBool        `json:"allowFallbackOnUnknownDc"`
	Secret                   mtglib.Secret   `json:"secret"`
	BindTo                   TypeHostPort    `json:"bindTo"`
	PreferIP                 TypePreferIP    `json:"preferIp"`
	DomainFrontingPort       TypePort        `json:"domainFrontingPort"`
	TolerateTimeSkewness     TypeDuration    `json:"tolerateTimeSkewness"`
	Concurrency              TypeConcurrency `json:"concurrency"`
	Defense                  struct {
		AntiReplay struct {
			Optional

			MaxSize   TypeBytes     `json:"maxSize"`
			ErrorRate TypeErrorRate `json:"errorRate"`
		} `json:"antiReplay"`
		Blocklist ListConfig `json:"blocklist"`
		Allowlist ListConfig `json:"allowlist"`
	} `json:"defense"`
	Network struct {
		Timeout struct {
			TCP  TypeDuration `json:"tcp"`
			HTTP TypeDuration `json:"http"`
			Idle TypeDuration `json:"idle"`
		} `json:"timeout"`
		DOHIP   TypeIP         `json:"dohIp"`
		Proxies []TypeProxyURL `json:"proxies"`
	} `json:"network"`
	Stats struct {
		StatsD struct {
			Optional

			Address      TypeHostPort        `json:"address"`
			MetricPrefix TypeMetricPrefix    `json:"metricPrefix"`
			TagFormat    TypeStatsdTagFormat `json:"tagFormat"`
		} `json:"statsd"`
		Prometheus struct {
			Optional

			BindTo       TypeHostPort     `json:"bindTo"`
			HTTPPath     TypeHTTPPath     `json:"httpPath"`
			MetricPrefix TypeMetricPrefix `json:"metricPrefix"`
		} `json:"prometheus"`
	} `json:"stats"`
}

func Parse

func Parse(rawData []byte) (*Config, error)

func (*Config) String

func (c *Config) String() string

func (*Config) Validate

func (c *Config) Validate() error

type ListConfig added in v2.1.3

type ListConfig struct {
	Optional

	DownloadConcurrency TypeConcurrency    `json:"downloadConcurrency"`
	URLs                []TypeBlocklistURI `json:"urls"`
	UpdateEach          TypeDuration       `json:"updateEach"`
}

type Optional added in v2.1.3

type Optional struct {
	Enabled TypeBool `json:"enabled"`
}

type TypeBlocklistURI

type TypeBlocklistURI struct {
	Value string
}

func (TypeBlocklistURI) Get added in v2.1.0

func (t TypeBlocklistURI) Get(defaultValue string) string

func (TypeBlocklistURI) IsRemote

func (t TypeBlocklistURI) IsRemote() bool

func (TypeBlocklistURI) MarshalText

func (t TypeBlocklistURI) MarshalText() ([]byte, error)

func (*TypeBlocklistURI) Set added in v2.1.0

func (t *TypeBlocklistURI) Set(value string) error

func (TypeBlocklistURI) String

func (t TypeBlocklistURI) String() string

func (*TypeBlocklistURI) UnmarshalText

func (t *TypeBlocklistURI) UnmarshalText(data []byte) error

type TypeBool added in v2.1.0

type TypeBool struct {
	Value bool
}

func (TypeBool) Get added in v2.1.0

func (t TypeBool) Get(defaultValue bool) bool

func (TypeBool) MarshalJSON added in v2.1.0

func (t TypeBool) MarshalJSON() ([]byte, error)

func (*TypeBool) Set added in v2.1.0

func (t *TypeBool) Set(data string) error

func (TypeBool) String added in v2.1.0

func (t TypeBool) String() string

func (*TypeBool) UnmarshalJSON added in v2.1.0

func (t *TypeBool) UnmarshalJSON(data []byte) error

type TypeBytes

type TypeBytes struct {
	Value units.Base2Bytes
}

func (TypeBytes) Get added in v2.1.0

func (t TypeBytes) Get(defaultValue uint) uint

func (TypeBytes) MarshalText

func (t TypeBytes) MarshalText() ([]byte, error)

func (*TypeBytes) Set added in v2.1.0

func (t *TypeBytes) Set(value string) error

func (TypeBytes) String

func (t TypeBytes) String() string

func (*TypeBytes) UnmarshalText

func (t *TypeBytes) UnmarshalText(data []byte) error

type TypeConcurrency added in v2.1.0

type TypeConcurrency struct {
	Value uint
}

func (TypeConcurrency) Get added in v2.1.0

func (t TypeConcurrency) Get(defaultValue uint) uint

func (TypeConcurrency) MarshalJSON added in v2.1.0

func (t TypeConcurrency) MarshalJSON() ([]byte, error)

func (*TypeConcurrency) Set added in v2.1.0

func (t *TypeConcurrency) Set(value string) error

func (TypeConcurrency) String added in v2.1.0

func (t TypeConcurrency) String() string

func (*TypeConcurrency) UnmarshalJSON added in v2.1.0

func (t *TypeConcurrency) UnmarshalJSON(data []byte) error

type TypeDuration

type TypeDuration struct {
	Value time.Duration
}

func (TypeDuration) Get added in v2.1.0

func (t TypeDuration) Get(defaultValue time.Duration) time.Duration

func (TypeDuration) MarshalText

func (t TypeDuration) MarshalText() ([]byte, error)

func (*TypeDuration) Set added in v2.1.0

func (t *TypeDuration) Set(value string) error

func (TypeDuration) String

func (t TypeDuration) String() string

func (*TypeDuration) UnmarshalText

func (t *TypeDuration) UnmarshalText(data []byte) error

type TypeErrorRate

type TypeErrorRate struct {
	Value float64
}

func (TypeErrorRate) Get added in v2.1.0

func (t TypeErrorRate) Get(defaultValue float64) float64

func (TypeErrorRate) MarshalJSON added in v2.1.0

func (t TypeErrorRate) MarshalJSON() ([]byte, error)

func (*TypeErrorRate) Set added in v2.1.0

func (t *TypeErrorRate) Set(value string) error

func (TypeErrorRate) String

func (t TypeErrorRate) String() string

func (*TypeErrorRate) UnmarshalJSON

func (t *TypeErrorRate) UnmarshalJSON(data []byte) error

type TypeHTTPPath

type TypeHTTPPath struct {
	Value string
}

func (TypeHTTPPath) Get added in v2.1.0

func (t TypeHTTPPath) Get(defaultValue string) string

func (TypeHTTPPath) MarshalText

func (t TypeHTTPPath) MarshalText() ([]byte, error)

func (*TypeHTTPPath) Set added in v2.1.0

func (t *TypeHTTPPath) Set(value string) error

func (TypeHTTPPath) String

func (t TypeHTTPPath) String() string

func (*TypeHTTPPath) UnmarshalText

func (t *TypeHTTPPath) UnmarshalText(data []byte) error

type TypeHostPort

type TypeHostPort struct {
	Value string
	Host  string
	Port  uint
}

func (TypeHostPort) Get added in v2.1.0

func (t TypeHostPort) Get(defaultValue string) string

func (TypeHostPort) MarshalText

func (t TypeHostPort) MarshalText() ([]byte, error)

func (*TypeHostPort) Set added in v2.1.0

func (t *TypeHostPort) Set(value string) error

func (TypeHostPort) String

func (t TypeHostPort) String() string

func (*TypeHostPort) UnmarshalText

func (t *TypeHostPort) UnmarshalText(data []byte) error

type TypeIP

type TypeIP struct {
	Value net.IP
}

func (*TypeIP) Get added in v2.1.0

func (t *TypeIP) Get(defaultValue net.IP) net.IP

func (TypeIP) MarshalText

func (t TypeIP) MarshalText() ([]byte, error)

func (*TypeIP) Set added in v2.1.0

func (t *TypeIP) Set(value string) error

func (TypeIP) String

func (t TypeIP) String() string

func (*TypeIP) UnmarshalText

func (t *TypeIP) UnmarshalText(data []byte) error

type TypeMetricPrefix

type TypeMetricPrefix struct {
	Value string
}

func (TypeMetricPrefix) Get added in v2.1.0

func (t TypeMetricPrefix) Get(defaultValue string) string

func (TypeMetricPrefix) MarshalText

func (t TypeMetricPrefix) MarshalText() ([]byte, error)

func (*TypeMetricPrefix) Set added in v2.1.0

func (t *TypeMetricPrefix) Set(value string) error

func (TypeMetricPrefix) String

func (t TypeMetricPrefix) String() string

func (*TypeMetricPrefix) UnmarshalText

func (t *TypeMetricPrefix) UnmarshalText(data []byte) error

type TypePort

type TypePort struct {
	Value uint
}

func (TypePort) Get added in v2.1.0

func (t TypePort) Get(defaultValue uint) uint

func (TypePort) MarshalJSON

func (t TypePort) MarshalJSON() ([]byte, error)

func (*TypePort) Set added in v2.1.0

func (t *TypePort) Set(value string) error

func (TypePort) String

func (t TypePort) String() string

func (*TypePort) UnmarshalJSON

func (t *TypePort) UnmarshalJSON(data []byte) error

type TypePreferIP

type TypePreferIP struct {
	Value string
}

func (*TypePreferIP) Get added in v2.1.0

func (t *TypePreferIP) Get(defaultValue string) string

func (TypePreferIP) MarshalText

func (t TypePreferIP) MarshalText() ([]byte, error)

func (*TypePreferIP) Set added in v2.1.0

func (t *TypePreferIP) Set(value string) error

func (TypePreferIP) String

func (t TypePreferIP) String() string

func (*TypePreferIP) UnmarshalText

func (t *TypePreferIP) UnmarshalText(data []byte) error

type TypeProxyURL added in v2.1.0

type TypeProxyURL struct {
	Value *url.URL
}

func (*TypeProxyURL) Get added in v2.1.0

func (t *TypeProxyURL) Get(defaultValue *url.URL) *url.URL

func (TypeProxyURL) MarshalText added in v2.1.0

func (t TypeProxyURL) MarshalText() ([]byte, error)

func (*TypeProxyURL) Set added in v2.1.0

func (t *TypeProxyURL) Set(value string) error

func (TypeProxyURL) String added in v2.1.0

func (t TypeProxyURL) String() string

func (*TypeProxyURL) UnmarshalText added in v2.1.0

func (t *TypeProxyURL) UnmarshalText(data []byte) error

type TypeStatsdTagFormat

type TypeStatsdTagFormat struct {
	Value string
}

func (TypeStatsdTagFormat) Get added in v2.1.0

func (t TypeStatsdTagFormat) Get(defaultValue string) string

func (*TypeStatsdTagFormat) MarshalText

func (t *TypeStatsdTagFormat) MarshalText() ([]byte, error)

func (*TypeStatsdTagFormat) Set added in v2.1.0

func (t *TypeStatsdTagFormat) Set(value string) error

func (*TypeStatsdTagFormat) String

func (t *TypeStatsdTagFormat) String() string

func (*TypeStatsdTagFormat) UnmarshalText

func (t *TypeStatsdTagFormat) UnmarshalText(data []byte) error

Jump to

Keyboard shortcuts

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