config

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package config is responsible for parsing configuration file.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DNS

type DNS struct {
	// ListenAddr is the address where the DNS server will listen to incoming
	// requests. Must be specified.
	ListenAddr string `yaml:"listen-addr"`

	// RedirectAddrV4 is the IPv4 address where the DNS server will re-route
	// type=A queries for domains listed in DomainRules. Must be specified.
	RedirectAddrV4 string `yaml:"redirect-addr-v4"`

	// RedirectAddrV6 is the IPv4 address where the DNS server will re-route
	// type=AAAA queries for domains listed in DomainRules. If not specified,
	// the DNS server will respond with empty NOERROR to AAAA queries.
	RedirectAddrV6 string `yaml:"redirect-addr-v6"`

	// PlainPort is the port for plain DNS server. Optional, if not specified,
	// the plain DNS server will not be started.
	PlainPort int `yaml:"plain-port"`

	// TLSPort is the port for DNS-over-TLS server. Optional, if not specified,
	// the plain DNS-over-TLS server will not be started.
	TLSPort int `yaml:"tls-port"`

	// HTTPSPort is the port for DNS-over-HTTPS server. Optional, if not
	// specified, the plain DNS-over-HTTPS server will not be started.
	HTTPSPort int `yaml:"https-port"`

	// QUICPort is the port for DNS-over-QUIC server. Optional, if not
	// specified, the plain DNS-over-QUIC server will not be started.
	QUICPort int `yaml:"quic-port"`

	// UpstreamAddr is the address of the upstream DNS server. This server will
	// be used for queries that shouldn't be re-routed. Must be specified.
	UpstreamAddr string `yaml:"upstream-addr"`

	// RateLimit is the maximum number of requests per second for a plain DNS
	// server. If 0 or not specified, there will be no rate limit.
	RateLimit int `yaml:"rate-limit"`

	// RateLimitAllowlist is a list of IP addresses excluded from rate limiting.
	RateLimitAllowlist []string `yaml:"rate-limit-allowlist"`

	// TLSCertPath is the path to the TLS certificate. It is only required if
	// one of the following properties are specified: TLSPort, HTTPSPort,
	// QUICPort.
	TLSCertPath string `yaml:"tls-cert-path"`

	// TLSKeyPath is the path to the TLS private key. It is only required if
	// one of the following properties are specified: TLSPort, HTTPSPort,
	// QUICPort.
	TLSKeyPath string `yaml:"tls-key-path"`
}

DNS represents the DNS server section of the configuration file.

type File

type File struct {
	// DNS is the DNS server section of the configuration file. If not
	// specified, the DNS server will not be started.
	DNS *DNS `yaml:"dns"`

	// Relay is the SNI relay server section of the configuration file. Must be
	// specified.
	Relay *Relay `yaml:"relay"`

	// Prometheus
	Prometheus *Prometheus `yaml:"prometheus"`

	// DomainRules is the map that controls what the snirelay does with the
	// domains. The key of this map is a wildcard and the value is the action.
	// Must be specified.
	//
	// If the domain is not specified in DomainRules, DNS queries for it will
	// be simply proxied to the upstream DNS server and no re-routing occurs.
	// Connections to the relay server for domains that are not listed will not
	// be accepted.
	//
	// If the action is "relay" then the DNS server will respond to A/AAAA
	// queries and re-route traffic to the relay server. HTTPS queries will be
	// suppressed in this case.
	DomainRules map[string]string `yaml:"domain-rules"`
}

File represents a configuration file.

func Load

func Load(path string) (cfg *File, err error)

Load loads and validates configuration from the specified file.

func (*File) ToDNSConfig

func (f *File) ToDNSConfig() (dnsCfg *dnssrv.Config, err error)

ToDNSConfig transforms the configuration to the internal dnssrv.Config. Note that this method can return nil if DNS section was not specified in the configuration.

func (*File) ToRelayConfig

func (f *File) ToRelayConfig() (relayCfg *relay.Config, err error)

ToRelayConfig transforms the configuration to the internal relay.Config.

type Prometheus

type Prometheus struct {
	// Addr is the address where prometheus metrics are exposed.
	Addr string `yaml:"addr"`

	// Port is the port where prometheus metrics will be exposed.
	Port uint16 `yaml:"port"`
}

Prometheus represents the prometheus configuration.

type Relay

type Relay struct {
	// ListenAddr is the address where the Relay server will listen to incoming
	// connections.
	ListenAddr string `yaml:"listen-addr"`

	// HTTPPort is the port where relay will expect to receive plain HTTP
	// connections.
	HTTPPort uint16 `yaml:"http-port"`

	// HTTPSPort is the port where relay will expect to receive HTTPS
	// connections.
	HTTPSPort uint16 `yaml:"https-port"`

	// ProxyURL is the optional port for upstream connections by the relay.
	// Format of the URL: [protocol://username:password@]host[:port]
	ProxyURL string `yaml:"proxy-url"`
}

Relay represents the SNI relay server section of the configuration file.

Jump to

Keyboard shortcuts

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