config

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2025 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package config provides structures and methods to parse /etc/hosts-like configuration files.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Alias

type Alias struct {
	IP        net.IP
	Hostnames []string
}

Alias represents an alias for an IP address.

type Checker added in v0.5.0

type Checker struct {
	FileName      string
	CheckInterval time.Duration
	Delay         time.Duration
	UpdateFn      func(Config)
}

Checker is a configuration checker.

func (*Checker) Run added in v0.5.0

func (d *Checker) Run(ctx context.Context) error

Run runs the configuration checker. Blocks until the context is canceled.

type Config

type Config struct {
	Sections []Section
}

Config represents the DNS server configuration.

func Parse

func Parse(file io.Reader) (result Config, err error)

Parse parses a configuration file.

func (Config) String added in v0.5.0

func (c Config) String() string

String returns the string representation of the configuration.

type Section

type Section struct {
	Aliases []Alias
	SectionConfig
}

Section represents a section of the configuration.

func (Section) CIDRContains added in v0.8.0

func (s Section) CIDRContains(ip net.IP) bool

CIDRContains checks if the section contains the given IP address.

type SectionConfig

type SectionConfig struct {
	From  *net.IPNet
	TSTag map[string]struct{}
}

SectionConfig represents the configuration of a section.

func (*SectionConfig) UnmarshalYAML

func (s *SectionConfig) UnmarshalYAML(v *yaml.Node) error

UnmarshalYAML unmarshals a YAML node into a SectionConfig.

Jump to

Keyboard shortcuts

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