hashycfg

package
v0.0.0-...-93d3e9d Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2025 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultServerAddress is the address used by a Server when the Address
	// field is unset.
	DefaultServerAddress = ":53"

	// DefaultServerAddress is the network used by a Server when the
	// Network field is unset.
	DefaultServerNetwork = "udp"
)

Variables

This section is empty.

Functions

func NewViper

func NewViper() (v *viper.Viper, err error)

NewViper sets up the viper environment for the hashy process.

func Provide

func Provide() fx.Option

Provide establishes the configuration, possibly unmarshaled externally, for a hashy process.

Types

type Config

type Config struct {
	// Servers configures the set of dns.Server instances that get started.
	// If this field is unset, (2) dns.Server instances get started:
	// (1) a udp server on the DefaultServerAddress, and (2) a tcp server
	// on the DefaultServerAddress.
	Servers Servers `json:"servers" yaml:"servers" mapstructure:"servers"`

	// Zone holds information about the DNS zone that hashy serves.
	Zone ZoneConfig `json:"zone" yaml:"zone" mapstructure:"zone"`
}

Config represents the configuration file or document that sets up a hashy process. This is the top-level configuration object that is unmarshaled.

func Unmarshal

func Unmarshal(v *viper.Viper) (cfg Config, err error)

Unmarshal extracts a hashy configuration from the viper environment. This function also applies certain defaults to the configuration.

type Server

type Server struct {
	Address string `json:"address" yaml:"address" mapstructure:"address"`
	Network string `json:"network" yaml:"network" mapstructure:"network"`

	ReadTimeout  time.Duration `json:"readTimeout" yaml:"readTimeout" mapstructure:"readTimeout"`
	WriteTimeout time.Duration `json:"writeTimeout" yaml:"writeTimeout" mapstructure:"writeTimeout"`
	IdleTimeout  time.Duration `json:"idleTimeout" yaml:"idleTimeout" mapstructure:"idleTimeout"`

	UDPSize       int  `json:"udpSize" yaml:"udpSize" mapstructure:"udpSize"`
	MaxTCPQueries int  `json:"maxTCPQueries" yaml:"maxTCPQueries" mapstructure:"maxTCPQueries"`
	ReusePort     bool `json:"reusePort" yaml:"reusePort" mapstructure:"reusePort"`
	ReuseAddress  bool `json:"reuseAddress" yaml:"reuseAddress" mapstructure:"reuseAddress"`
}

Server represents a single server's configuration within the hashy process.

func (Server) NewServer

func (s Server) NewServer() *dns.Server

NewServer creates a dns.Server from this configuration.

type Servers

type Servers []Server

Servers is an aggregate of multiple server configurations.

func (Servers) NewServers

func (ss Servers) NewServers() (servers []*dns.Server)

NewServers creates a slice of dns.Server instances corresponding to this configuration.

type ZoneConfig

type ZoneConfig struct {
	// Origin is the origin name for hashy.  This is used as the $ORIGIN
	// when parsing master files.
	Origin string `json:"origin" yaml:"origin" mapstructure:"origin"`

	// Files is a list of system paths that are RFC1035 master files.
	// These files can contain an SOA record for hashy's domain as well
	// as extra domain name information that hashy will use when responding
	// to DNS requests.
	Files []string `json:"files" yaml:"files" mapstructure:"files"`

	// Text is an embedded set of RR records.  This field allows a master
	// file to be embedded within hashy's configuration file.
	Text string `json:"text" yaml:"text" mapstructure:"text"`
}

ZoneConfig holds any static RR records that hashy should know about.

Jump to

Keyboard shortcuts

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