etchosts

package
v0.2.6 Latest Latest
Warning

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

Go to latest
Published: May 27, 2020 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultBanner = "# ! MANAGED AUTOMATICALLY !"

DefaultBanner is the default magic comment used to identify entries managed by etchosts

View Source
const DefaultPath = "/etc/hosts"

DefaultPath is the default path used to write hosts entries

Variables

This section is empty.

Functions

This section is empty.

Types

type EtcHosts

type EtcHosts struct {
	// Banner is the magic comment used to identify entries managed by etchosts; if not set, will use DefaultBanner.
	// It must start with "#" to mark it as a comment.
	Banner string
	// Path is the path to the /etc/hosts file; if not set, will use DefaultPath.
	Path string
	// Logger is an optional logrus.StdLogger interface, used for debugging.
	Logger log.StdLogger
}

EtcHosts contains the options used to write hosts entries. The zero value can be used to write to DefaultPath using DefaultBanner as a marker.

func (*EtcHosts) WriteEntries

func (eh *EtcHosts) WriteEntries(ipsToNames map[string][]string) error

WriteEntries is used to write the hosts entries to EtcHosts.Path Each IP address with their (potentially multiple) hostnames are written to a line marked with EtcHosts.Banner, to avoid overwriting preexisting entries.

Jump to

Keyboard shortcuts

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