config

package
v0.0.0-...-799489d Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2022 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SetGlobal

func SetGlobal(c *Config)

Types

type APIConfig

type APIConfig struct {
	Addr       string      `json:"addr"`
	PathPrefix string      `yaml:"pathPrefix,omitempty" json:"pathPrefix,omitempty"`
	AccessLog  bool        `yaml:"accesslog,omitempty" json:"accesslog,omitempty"`
	Auth       *AuthConfig `yaml:",omitempty" json:"auth,omitempty"`
	Auther     string      `yaml:",omitempty" json:"auther,omitempty"`
}

type AdmissionConfig

type AdmissionConfig struct {
	Name     string        `json:"name"`
	Reverse  bool          `yaml:",omitempty" json:"reverse,omitempty"`
	Matchers []string      `json:"matchers"`
	Reload   time.Duration `yaml:",omitempty" json:"reload,omitempty"`
	File     *FileLoader   `yaml:",omitempty" json:"file,omitempty"`
	Redis    *RedisLoader  `yaml:",omitempty" json:"redis,omitempty"`
}

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"`
	Reload time.Duration `yaml:",omitempty" json:"reload,omitempty"`
	File   *FileLoader   `yaml:",omitempty" json:"file,omitempty"`
	Redis  *RedisLoader  `yaml:",omitempty" json:"redis,omitempty"`
}

type BypassConfig

type BypassConfig struct {
	Name     string        `json:"name"`
	Reverse  bool          `yaml:",omitempty" json:"reverse,omitempty"`
	Matchers []string      `json:"matchers"`
	Reload   time.Duration `yaml:",omitempty" json:"reload,omitempty"`
	File     *FileLoader   `yaml:",omitempty" json:"file,omitempty"`
	Redis    *RedisLoader  `yaml:",omitempty" json:"redis,omitempty"`
}

type ChainConfig

type ChainConfig struct {
	Name     string          `json:"name"`
	Selector *SelectorConfig `yaml:",omitempty" json:"selector,omitempty"`
	Hops     []*HopConfig    `json:"hops"`
}

type Config

type Config struct {
	Services   []*ServiceConfig   `json:"services"`
	Chains     []*ChainConfig     `yaml:",omitempty" json:"chains,omitempty"`
	Authers    []*AutherConfig    `yaml:",omitempty" json:"authers,omitempty"`
	Admissions []*AdmissionConfig `yaml:",omitempty" json:"admissions,omitempty"`
	Bypasses   []*BypassConfig    `yaml:",omitempty" json:"bypasses,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"`
	API        *APIConfig         `yaml:",omitempty" json:"api,omitempty"`
	Metrics    *MetricsConfig     `yaml:",omitempty" json:"metrics,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

func (*Config) WriteServices

func (c *Config) WriteServices(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 ForwarderConfig

type ForwarderConfig struct {
	Targets  []string        `json:"targets"`
	Selector *SelectorConfig `yaml:",omitempty" json:"selector,omitempty"`
}

type HandlerConfig

type HandlerConfig struct {
	Type     string         `json:"type"`
	Retries  int            `yaml:",omitempty" json:"retries,omitempty"`
	Chain    string         `yaml:",omitempty" json:"chain,omitempty"`
	Auther   string         `yaml:",omitempty" json:"auther,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"`
	Bypass    string          `yaml:",omitempty" json:"bypass,omitempty"`
	Resolver  string          `yaml:",omitempty" json:"resolver,omitempty"`
	Hosts     string          `yaml:",omitempty" json:"hosts,omitempty"`
	Nodes     []*NodeConfig   `json:"nodes"`
}

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 `json:"mappings"`
}

type ListenerConfig

type ListenerConfig struct {
	Type     string         `json:"type"`
	Chain    string         `yaml:",omitempty" json:"chain,omitempty"`
	Auther   string         `yaml:",omitempty" json:"auther,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"`
}

type MetricsConfig

type MetricsConfig struct {
	Addr string `json:"addr"`
	Path string `yaml:",omitempty" json:"path,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"`
	Interface string           `yaml:",omitempty" json:"interface,omitempty"`
	SockOpts  *SockOptsConfig  `yaml:"sockopts,omitempty" json:"sockopts,omitempty"`
	Bypass    string           `yaml:",omitempty" json:"bypass,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"`
}

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"`
	Redis *RedisRecorder `yaml:",omitempty" json:"redis,omitempty"`
}

type RecorderObject

type RecorderObject struct {
	Name   string `json:"name"`
	Record string `json:"record"`
}

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 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 `json:"nameservers"`
}

type Result

type Result struct {
	Data    any  `json:"data"`
	Success bool `json:"success"`
	Total   int  `json:"total"`
}

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"`
	Interface string            `yaml:",omitempty" json:"interface,omitempty"`
	SockOpts  *SockOptsConfig   `yaml:"sockopts,omitempty" json:"sockopts,omitempty"`
	Admission string            `yaml:",omitempty" json:"admission,omitempty"`
	Bypass    string            `yaml:",omitempty" json:"bypass,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"`
}

type SockOptsConfig

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

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"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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