hosts

package
v0.0.0-...-4b51ba2 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultPath = "/etc/hosts"

DefaultPath is the default path to the hosts file.

Functions

func WriteEtcHosts

func WriteEtcHosts(outputDir string, hosts *Hosts) (string, error)

WriteEtcHosts writes the Hosts to a file in outputDir and returns the path to the file. The intent is that this is written to a containerd snapshot directory to be mounted into a container.

Types

type HostEntry

type HostEntry struct {
	Addr  netip.Addr
	Hosts []string
}

HostEntry associates IP addresses with host names.

type Hosts

type Hosts struct {
	Entries []HostEntry
}

Hosts is a parsed /etc/hosts file.

func Default

func Default() *Hosts

Default returns a Hosts with the default localhost entries.

func Local

func Local() (*Hosts, error)

Local parses and returns the local /etc/hosts file.

func Parse

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

Parse parses a hosts file from r.

func ParseFile

func ParseFile(name string) (*Hosts, error)

ParseFile parses the named hosts file path.

func (*Hosts) Write

func (h *Hosts) Write(w io.Writer) error

Write writes hosts to w.

Jump to

Keyboard shortcuts

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