etchosts

package
v0.0.0-...-cfe5e5d Latest Latest
Warning

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

Go to latest
Published: Jul 1, 2019 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrBadHWAddrFormat  error = errors.New("Malformed hardware address address")
	ErrBadIPFormat      error = errors.New("Malformed IP address")
	ErrBadEntryFormat   error = errors.New("Malformed entry")
	ErrMissingHostname  error = errors.New("Missing hostname")
	ErrDuplicate        error = errors.New("Duplicated entry")
	ErrNotFoundHostname error = errors.New("Hostname not found in the hostsfile")
	ErrNotFoundAddress  error = errors.New("Address not found in the hostsfile")
)

Functions

This section is empty.

Types

type Conf

type Conf struct {
	// contains filtered or unexported fields
}

Conf represents the configured Bindings

func NewConf

func NewConf() *Conf

func Parse

func Parse(r io.Reader) (*Conf, error)

Parse creates a Conf from a reader, which must return content in etchosts (man 5 hosts) format

func (*Conf) Add

func (m *Conf) Add(name, addr string, aliases []string) (Host, error, bool)

func (*Conf) GetByAddress

func (m *Conf) GetByAddress(addr string) (Host, error)

func (*Conf) GetByAlias

func (m *Conf) GetByAlias(alias string) (Host, error)

func (*Conf) GetByHostname

func (m *Conf) GetByHostname(name string) (Host, error)

func (*Conf) Len

func (m *Conf) Len() int

Len returns the number of configured Bindings

func (*Conf) Remove

func (m *Conf) Remove(name string) (Host, bool)

func (*Conf) String

func (m *Conf) String() string

String converts all the registered hosts in the Conf in content in etchosts (man 8 dnsmasq) representation

type Host

type Host struct {
	Address           net.IP
	CanonicalHostname string
	Aliases           []string
}

Host represents a single entry in the /etc/hosts file

func ParseHost

func ParseHost(addr, name string, aliases []string) (Host, error)

func ParseHostString

func ParseHostString(s string) (Host, error)

func (Host) Duplicate

func (h Host) Duplicate(x Host) bool

func (Host) Equal

func (h Host) Equal(x Host) bool

func (Host) String

func (h Host) String() string

Jump to

Keyboard shortcuts

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