config

package
v0.0.0-...-b4268f6 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func OnUpdate

func OnUpdate(f func(c *Config) error) error

func Set

func Set(c *Config)

Types

type AuthConfig

type AuthConfig struct {
	Username string `json:"username"`
	Password string `yaml:",omitempty" json:"password,omitempty"`
}

type AutherConfig

type AutherConfig struct {
	Name   string        `json:"name"`
	Auths  []*AuthConfig `yaml:",omitempty" json:"auths,omitempty"`
	Reload time.Duration `yaml:",omitempty" json:"reload,omitempty"`
	File   *FileLoader   `yaml:",omitempty" json:"file,omitempty"`
	Redis  *RedisLoader  `yaml:",omitempty" json:"redis,omitempty"`
	HTTP   *HTTPLoader   `yaml:"http,omitempty" json:"http,omitempty"`
	Plugin *PluginConfig `yaml:",omitempty" json:"plugin,omitempty"`
}

type ChainConfig

type ChainConfig struct {
	Name string `json:"name"`
	// REMOVED since beta.6
	// Selector *SelectorConfig `yaml:",omitempty" json:"selector,omitempty"`
	Hops     []*HopConfig   `json:"hops"`
	Metadata map[string]any `yaml:",omitempty" json:"metadata,omitempty"`
}

type ChainGroupConfig

type ChainGroupConfig struct {
	Chains   []string        `yaml:",omitempty" json:"chains,omitempty"`
	Selector *SelectorConfig `yaml:",omitempty" json:"selector,omitempty"`
}

type Config

type Config struct {
	Services  []*ServiceConfig  `json:"services"`
	Chains    []*ChainConfig    `yaml:",omitempty" json:"chains,omitempty"`
	Hops      []*HopConfig      `yaml:",omitempty" json:"hops,omitempty"`
	Authers   []*AutherConfig   `yaml:",omitempty" json:"authers,omitempty"`
	Resolvers []*ResolverConfig `yaml:",omitempty" json:"resolvers,omitempty"`
	Hosts     []*HostsConfig    `yaml:",omitempty" json:"hosts,omitempty"`
	Recorders []*RecorderConfig `yaml:",omitempty" json:"recorders,omitempty"`
	TLS       *TLSConfig        `yaml:",omitempty" json:"tls,omitempty"`
	Log       *LogConfig        `yaml:",omitempty" json:"log,omitempty"`
	Profiling *ProfilingConfig  `yaml:",omitempty" json:"profiling,omitempty"`
}

func Global

func Global() *Config

func (*Config) Load

func (c *Config) Load() error

func (*Config) Read

func (c *Config) Read(r io.Reader) error

func (*Config) ReadFile

func (c *Config) ReadFile(file string) error

func (*Config) Write

func (c *Config) Write(w io.Writer, format string) error

type ConnectorConfig

type ConnectorConfig struct {
	Type     string         `json:"type"`
	Auth     *AuthConfig    `yaml:",omitempty" json:"auth,omitempty"`
	TLS      *TLSConfig     `yaml:",omitempty" json:"tls,omitempty"`
	Metadata map[string]any `yaml:",omitempty" json:"metadata,omitempty"`
}

type DialerConfig

type DialerConfig struct {
	Type     string         `json:"type"`
	Auth     *AuthConfig    `yaml:",omitempty" json:"auth,omitempty"`
	TLS      *TLSConfig     `yaml:",omitempty" json:"tls,omitempty"`
	Metadata map[string]any `yaml:",omitempty" json:"metadata,omitempty"`
}

type FileLoader

type FileLoader struct {
	Path string `json:"path"`
}

type FileRecorder

type FileRecorder struct {
	Path string `json:"path"`
	Sep  string `yaml:",omitempty" json:"sep,omitempty"`
}

type ForwardNodeConfig

type ForwardNodeConfig struct {
	Name     string          `yaml:",omitempty" json:"name,omitempty"`
	Addr     string          `yaml:",omitempty" json:"addr,omitempty"`
	Host     string          `yaml:",omitempty" json:"host,omitempty"`
	Protocol string          `yaml:",omitempty" json:"protocol,omitempty"`
	HTTP     *HTTPNodeConfig `yaml:",omitempty" json:"http,omitempty"`
	TLS      *TLSNodeConfig  `yaml:",omitempty" json:"tls,omitempty"`
	Auth     *AuthConfig     `yaml:",omitempty" json:"auth,omitempty"`
}

type ForwarderConfig

type ForwarderConfig struct {
	Name     string               `yaml:",omitempty" json:"name,omitempty"`
	Selector *SelectorConfig      `yaml:",omitempty" json:"selector,omitempty"`
	Nodes    []*ForwardNodeConfig `json:"nodes"`
	// DEPRECATED by nodes since beta.4
	Targets []string `yaml:",omitempty" json:"targets,omitempty"`
}

type HTTPLoader

type HTTPLoader struct {
	URL     string        `yaml:"url" json:"url"`
	Timeout time.Duration `yaml:",omitempty" json:"timeout,omitempty"`
}

type HTTPNodeConfig

type HTTPNodeConfig struct {
	Host   string            `yaml:",omitempty" json:"host,omitempty"`
	Header map[string]string `yaml:",omitempty" json:"header,omitempty"`
}

type HTTPRecorder

type HTTPRecorder struct {
	URL     string        `json:"url" yaml:"url"`
	Timeout time.Duration `json:"timeout"`
}

type HandlerConfig

type HandlerConfig struct {
	Type       string            `json:"type"`
	Retries    int               `yaml:",omitempty" json:"retries,omitempty"`
	Chain      string            `yaml:",omitempty" json:"chain,omitempty"`
	ChainGroup *ChainGroupConfig `yaml:"chainGroup,omitempty" json:"chainGroup,omitempty"`
	Auther     string            `yaml:",omitempty" json:"auther,omitempty"`
	Authers    []string          `yaml:",omitempty" json:"authers,omitempty"`
	Auth       *AuthConfig       `yaml:",omitempty" json:"auth,omitempty"`
	TLS        *TLSConfig        `yaml:",omitempty" json:"tls,omitempty"`
	Metadata   map[string]any    `yaml:",omitempty" json:"metadata,omitempty"`
}

type HopConfig

type HopConfig struct {
	Name      string          `json:"name"`
	Interface string          `yaml:",omitempty" json:"interface,omitempty"`
	SockOpts  *SockOptsConfig `yaml:"sockopts,omitempty" json:"sockopts,omitempty"`
	Selector  *SelectorConfig `yaml:",omitempty" json:"selector,omitempty"`
	Resolver  string          `yaml:",omitempty" json:"resolver,omitempty"`
	Hosts     string          `yaml:",omitempty" json:"hosts,omitempty"`
	Nodes     []*NodeConfig   `yaml:",omitempty" json:"nodes,omitempty"`
}

type HostMappingConfig

type HostMappingConfig struct {
	IP       string   `json:"ip"`
	Hostname string   `json:"hostname"`
	Aliases  []string `yaml:",omitempty" json:"aliases,omitempty"`
}

type HostsConfig

type HostsConfig struct {
	Name     string               `json:"name"`
	Mappings []*HostMappingConfig `yaml:",omitempty" json:"mappings,omitempty"`
	Reload   time.Duration        `yaml:",omitempty" json:"reload,omitempty"`
	File     *FileLoader          `yaml:",omitempty" json:"file,omitempty"`
	Redis    *RedisLoader         `yaml:",omitempty" json:"redis,omitempty"`
	HTTP     *HTTPLoader          `yaml:"http,omitempty" json:"http,omitempty"`
	Plugin   *PluginConfig        `yaml:",omitempty" json:"plugin,omitempty"`
}

type ListenerConfig

type ListenerConfig struct {
	Type       string            `json:"type"`
	Chain      string            `yaml:",omitempty" json:"chain,omitempty"`
	ChainGroup *ChainGroupConfig `yaml:"chainGroup,omitempty" json:"chainGroup,omitempty"`
	Auther     string            `yaml:",omitempty" json:"auther,omitempty"`
	Authers    []string          `yaml:",omitempty" json:"authers,omitempty"`
	Auth       *AuthConfig       `yaml:",omitempty" json:"auth,omitempty"`
	TLS        *TLSConfig        `yaml:",omitempty" json:"tls,omitempty"`
	Metadata   map[string]any    `yaml:",omitempty" json:"metadata,omitempty"`
}

type LogConfig

type LogConfig struct {
	Output   string             `yaml:",omitempty" json:"output,omitempty"`
	Level    string             `yaml:",omitempty" json:"level,omitempty"`
	Format   string             `yaml:",omitempty" json:"format,omitempty"`
	Rotation *LogRotationConfig `yaml:",omitempty" json:"rotation,omitempty"`
}

type LogRotationConfig

type LogRotationConfig struct {
	// MaxSize is the maximum size in megabytes of the log file before it gets
	// rotated. It defaults to 100 megabytes.
	MaxSize int `yaml:"maxSize,omitempty" json:"maxSize,omitempty"`
	// MaxAge is the maximum number of days to retain old log files based on the
	// timestamp encoded in their filename.  Note that a day is defined as 24
	// hours and may not exactly correspond to calendar days due to daylight
	// savings, leap seconds, etc. The default is not to remove old log files
	// based on age.
	MaxAge int `yaml:"maxAge,omitempty" json:"maxAge,omitempty"`
	// MaxBackups is the maximum number of old log files to retain.  The default
	// is to retain all old log files (though MaxAge may still cause them to get
	// deleted.)
	MaxBackups int `yaml:"maxBackups,omitempty" json:"maxBackups,omitempty"`
	// LocalTime determines if the time used for formatting the timestamps in
	// backup files is the computer's local time. The default is to use UTC
	// time.
	LocalTime bool `yaml:"localTime,omitempty" json:"localTime,omitempty"`
	// Compress determines if the rotated log files should be compressed
	// using gzip. The default is not to perform compression.
	Compress bool `yaml:"compress,omitempty" json:"compress,omitempty"`
}

type NameserverConfig

type NameserverConfig struct {
	Addr     string        `json:"addr"`
	Chain    string        `yaml:",omitempty" json:"chain,omitempty"`
	Prefer   string        `yaml:",omitempty" json:"prefer,omitempty"`
	ClientIP string        `yaml:"clientIP,omitempty" json:"clientIP,omitempty"`
	Hostname string        `yaml:",omitempty" json:"hostname,omitempty"`
	TTL      time.Duration `yaml:",omitempty" json:"ttl,omitempty"`
	Timeout  time.Duration `yaml:",omitempty" json:"timeout,omitempty"`
}

type NodeConfig

type NodeConfig struct {
	Name      string           `json:"name"`
	Addr      string           `yaml:",omitempty" json:"addr,omitempty"`
	Host      string           `yaml:",omitempty" json:"host,omitempty"`
	Protocol  string           `yaml:",omitempty" json:"protocol,omitempty"`
	Interface string           `yaml:",omitempty" json:"interface,omitempty"`
	SockOpts  *SockOptsConfig  `yaml:"sockopts,omitempty" json:"sockopts,omitempty"`
	Resolver  string           `yaml:",omitempty" json:"resolver,omitempty"`
	Hosts     string           `yaml:",omitempty" json:"hosts,omitempty"`
	Connector *ConnectorConfig `yaml:",omitempty" json:"connector,omitempty"`
	Dialer    *DialerConfig    `yaml:",omitempty" json:"dialer,omitempty"`
	Metadata  map[string]any   `yaml:",omitempty" json:"metadata,omitempty"`
	HTTP      *HTTPNodeConfig  `yaml:",omitempty" json:"http,omitempty"`
	TLS       *TLSNodeConfig   `yaml:",omitempty" json:"tls,omitempty"`
	Auth      *AuthConfig      `yaml:",omitempty" json:"auth,omitempty"`
}

type PluginConfig

type PluginConfig struct {
	Type    string        `json:"type"`
	Addr    string        `json:"addr"`
	TLS     *TLSConfig    `yaml:",omitempty" json:"tls,omitempty"`
	Timeout time.Duration `yaml:",omitempty" json:"timeout,omitempty"`
	Token   string        `yaml:",omitempty" json:"token,omitempty"`
}

type ProfilingConfig

type ProfilingConfig struct {
	Addr string `json:"addr"`
}

type RecorderConfig

type RecorderConfig struct {
	Name   string         `json:"name"`
	File   *FileRecorder  `yaml:",omitempty" json:"file,omitempty"`
	TCP    *TCPRecorder   `yaml:"tcp,omitempty" json:"tcp,omitempty"`
	HTTP   *HTTPRecorder  `yaml:"http,omitempty" json:"http,omitempty"`
	Redis  *RedisRecorder `yaml:",omitempty" json:"redis,omitempty"`
	Plugin *PluginConfig  `yaml:",omitempty" json:"plugin,omitempty"`
}

type RecorderObject

type RecorderObject struct {
	Name     string `json:"name"`
	Record   string `json:"record"`
	Metadata map[string]any
}

type RedisLoader

type RedisLoader struct {
	Addr     string `json:"addr"`
	DB       int    `yaml:",omitempty" json:"db,omitempty"`
	Password string `yaml:",omitempty" json:"password,omitempty"`
	Key      string `yaml:",omitempty" json:"key,omitempty"`
	Type     string `yaml:",omitempty" json:"type,omitempty"`
}

type RedisRecorder

type RedisRecorder struct {
	Addr     string `json:"addr"`
	DB       int    `yaml:",omitempty" json:"db,omitempty"`
	Password string `yaml:",omitempty" json:"password,omitempty"`
	Key      string `yaml:",omitempty" json:"key,omitempty"`
	Type     string `yaml:",omitempty" json:"type,omitempty"`
}

type ResolverConfig

type ResolverConfig struct {
	Name        string              `json:"name"`
	Nameservers []*NameserverConfig `yaml:",omitempty" json:"nameservers,omitempty"`
	Plugin      *PluginConfig       `yaml:",omitempty" json:"plugin,omitempty"`
}

type SelectorConfig

type SelectorConfig struct {
	Strategy    string        `json:"strategy"`
	MaxFails    int           `yaml:"maxFails" json:"maxFails"`
	FailTimeout time.Duration `yaml:"failTimeout" json:"failTimeout"`
}

type ServiceConfig

type ServiceConfig struct {
	Name string `json:"name"`
	Addr string `yaml:",omitempty" json:"addr,omitempty"`
	// DEPRECATED by metadata.interface since beta.5
	Interface string `yaml:",omitempty" json:"interface,omitempty"`
	// DEPRECATED by metadata.so_mark since beta.5
	SockOpts  *SockOptsConfig   `yaml:"sockopts,omitempty" json:"sockopts,omitempty"`
	Resolver  string            `yaml:",omitempty" json:"resolver,omitempty"`
	Hosts     string            `yaml:",omitempty" json:"hosts,omitempty"`
	Recorders []*RecorderObject `yaml:",omitempty" json:"recorders,omitempty"`
	Handler   *HandlerConfig    `yaml:",omitempty" json:"handler,omitempty"`
	Listener  *ListenerConfig   `yaml:",omitempty" json:"listener,omitempty"`
	Forwarder *ForwarderConfig  `yaml:",omitempty" json:"forwarder,omitempty"`
	Metadata  map[string]any    `yaml:",omitempty" json:"metadata,omitempty"`
}

type SockOptsConfig

type SockOptsConfig struct {
	Mark int `yaml:",omitempty" json:"mark,omitempty"`
}

type TCPRecorder

type TCPRecorder struct {
	Addr    string        `json:"addr"`
	Timeout time.Duration `json:"timeout"`
}

type TLSConfig

type TLSConfig struct {
	CertFile   string `yaml:"certFile,omitempty" json:"certFile,omitempty"`
	KeyFile    string `yaml:"keyFile,omitempty" json:"keyFile,omitempty"`
	CAFile     string `yaml:"caFile,omitempty" json:"caFile,omitempty"`
	Secure     bool   `yaml:",omitempty" json:"secure,omitempty"`
	ServerName string `yaml:"serverName,omitempty" json:"serverName,omitempty"`

	// for auto-generated default certificate.
	Validity     time.Duration `yaml:",omitempty" json:"validity,omitempty"`
	CommonName   string        `yaml:"commonName,omitempty" json:"commonName,omitempty"`
	Organization string        `yaml:",omitempty" json:"organization,omitempty"`
}

type TLSNodeConfig

type TLSNodeConfig struct {
	ServerName string `yaml:"serverName,omitempty" json:"serverName,omitempty"`
	Secure     bool   `yaml:",omitempty" json:"secure,omitempty"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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