config

package
v2.0.1 Latest Latest
Warning

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

Go to latest
Published: May 17, 2021 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TypePreferIPPreferIPv4 = "prefer-ipv4"
	TypePreferIPPreferIPv6 = "prefer-ipv6"
	TypePreferOnlyIPv4     = "only-ipv4"
	TypePreferOnlyIPv6     = "only-ipv6"
)
View Source
const (
	TypeStatsdTagFormatInfluxdb = "influxdb"
	TypeStatsdTagFormatDatadog  = "datadog"
	TypeStatsdTagFormatGraphite = "graphite"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Debug                bool          `json:"debug"`
	Secret               mtglib.Secret `json:"secret"`
	BindTo               TypeHostPort  `json:"bind-to"`
	TCPBuffer            TypeBytes     `json:"tcp-buffer"`
	PreferIP             TypePreferIP  `json:"prefer-ip"`
	DomainFrontingPort   TypePort      `json:"domain-fronting-port"`
	TolerateTimeSkewness TypeDuration  `json:"tolerate-time-skewness"`
	Concurrency          uint          `json:"concurrency"`
	Defense              struct {
		AntiReplay struct {
			Enabled   bool          `json:"enabled"`
			MaxSize   TypeBytes     `json:"max-size"`
			ErrorRate TypeErrorRate `json:"error-rate"`
		} `json:"anti-replay"`
		Blocklist struct {
			Enabled             bool               `json:"enabled"`
			DownloadConcurrency uint               `json:"download-concurrency"`
			URLs                []TypeBlocklistURI `json:"urls"`
			UpdateEach          TypeDuration       `json:"update-each"`
		} `json:"blocklist"`
	} `json:"defense"`
	Network struct {
		Timeout struct {
			TCP  TypeDuration `json:"tcp"`
			HTTP TypeDuration `json:"http"`
			Idle TypeDuration `json:"idle"`
		} `json:"timeout"`
		DOHIP   TypeIP    `json:"doh-ip"`
		Proxies []TypeURL `json:"proxies"`
	} `json:"network"`
	Stats struct {
		StatsD struct {
			Enabled      bool                `json:"enabled"`
			Address      TypeHostPort        `json:"address"`
			MetricPrefix TypeMetricPrefix    `json:"metric-prefix"`
			TagFormat    TypeStatsdTagFormat `json:"tag-format"`
		} `json:"statsd"`
		Prometheus struct {
			Enabled      bool             `json:"enabled"`
			BindTo       TypeHostPort     `json:"bind-to"`
			HTTPPath     TypeHTTPPath     `json:"http-path"`
			MetricPrefix TypeMetricPrefix `json:"metric-prefix"`
		} `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 TypeBlocklistURI

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

func (TypeBlocklistURI) IsRemote

func (c TypeBlocklistURI) IsRemote() bool

func (TypeBlocklistURI) MarshalText

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

func (TypeBlocklistURI) String

func (c TypeBlocklistURI) String() string

func (*TypeBlocklistURI) UnmarshalText

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

func (TypeBlocklistURI) Value

func (c TypeBlocklistURI) Value(defaultValue string) string

type TypeBytes

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

func (TypeBytes) MarshalText

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

func (TypeBytes) String

func (c TypeBytes) String() string

func (*TypeBytes) UnmarshalText

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

func (TypeBytes) Value

func (c TypeBytes) Value(defaultValue uint) uint

type TypeDuration

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

func (TypeDuration) MarshalText

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

func (TypeDuration) String

func (c TypeDuration) String() string

func (*TypeDuration) UnmarshalText

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

func (TypeDuration) Value

func (c TypeDuration) Value(defaultValue time.Duration) time.Duration

type TypeErrorRate

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

func (*TypeErrorRate) MarshalText

func (c *TypeErrorRate) MarshalText() ([]byte, error)

func (TypeErrorRate) String

func (c TypeErrorRate) String() string

func (*TypeErrorRate) UnmarshalJSON

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

func (TypeErrorRate) Value

func (c TypeErrorRate) Value(defaultValue float64) float64

type TypeHTTPPath

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

func (TypeHTTPPath) MarshalText

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

func (TypeHTTPPath) String

func (c TypeHTTPPath) String() string

func (*TypeHTTPPath) UnmarshalText

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

func (TypeHTTPPath) Value

func (c TypeHTTPPath) Value(defaultValue string) string

type TypeHostPort

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

func (TypeHostPort) HostValue

func (c TypeHostPort) HostValue(defaultValue net.IP) net.IP

func (TypeHostPort) MarshalText

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

func (TypeHostPort) PortValue

func (c TypeHostPort) PortValue(defaultValue uint) uint

func (TypeHostPort) String

func (c TypeHostPort) String() string

func (*TypeHostPort) UnmarshalText

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

func (TypeHostPort) Value

func (c TypeHostPort) Value(defaultHostValue net.IP, defaultPortValue uint) string

type TypeIP

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

func (*TypeIP) MarshalText

func (c *TypeIP) MarshalText() ([]byte, error)

func (TypeIP) String

func (c TypeIP) String() string

func (*TypeIP) UnmarshalText

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

func (TypeIP) Value

func (c TypeIP) Value(defaultValue net.IP) net.IP

type TypeMetricPrefix

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

func (TypeMetricPrefix) MarshalText

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

func (TypeMetricPrefix) String

func (c TypeMetricPrefix) String() string

func (*TypeMetricPrefix) UnmarshalText

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

func (TypeMetricPrefix) Value

func (c TypeMetricPrefix) Value(defaultValue string) string

type TypePort

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

func (*TypePort) MarshalJSON

func (c *TypePort) MarshalJSON() ([]byte, error)

func (TypePort) String

func (c TypePort) String() string

func (*TypePort) UnmarshalJSON

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

func (TypePort) Value

func (c TypePort) Value(defaultValue uint) uint

type TypePreferIP

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

func (TypePreferIP) MarshalText

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

func (*TypePreferIP) String

func (c *TypePreferIP) String() string

func (*TypePreferIP) UnmarshalText

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

func (*TypePreferIP) Value

func (c *TypePreferIP) Value(defaultValue string) string

type TypeStatsdTagFormat

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

func (TypeStatsdTagFormat) MarshalText

func (c TypeStatsdTagFormat) MarshalText() ([]byte, error)

func (*TypeStatsdTagFormat) String

func (c *TypeStatsdTagFormat) String() string

func (*TypeStatsdTagFormat) UnmarshalText

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

func (*TypeStatsdTagFormat) Value

func (c *TypeStatsdTagFormat) Value(defaultValue string) string

type TypeURL

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

func (*TypeURL) MarshalText

func (c *TypeURL) MarshalText() ([]byte, error)

func (TypeURL) String

func (c TypeURL) String() string

func (*TypeURL) UnmarshalText

func (c *TypeURL) UnmarshalText(data []byte) error

func (TypeURL) Value

func (c TypeURL) Value(defaultValue *url.URL) *url.URL

Jump to

Keyboard shortcuts

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