hostsfile

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

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

Go to latest
Published: Oct 12, 2020 License: BSD-3-Clause Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RemoveEntry

func RemoveEntry(hostname string) error

RemoveEntry - Remove an entry from /etc/hosts or equivalent

Types

type Hosts

type Hosts struct {
	Path  string
	Lines []HostsLine
}

Hosts - Represents a hosts file.

func NewHosts

func NewHosts() (Hosts, error)

NewHosts - Return a new instance of “Hosts“.

func (*Hosts) Add

func (h *Hosts) Add(ip string, hosts ...string) error

Add an entry to the hosts file.

func (Hosts) Flush

func (h Hosts) Flush() error

Flush any changes made to hosts file.

func (Hosts) Has

func (h Hosts) Has(ip string, host string) bool

Has - Return a bool if ip/host combo in hosts file.

func (*Hosts) IsWritable

func (h *Hosts) IsWritable() bool

IsWritable - Return ```true``` if hosts file is writable.

func (*Hosts) Load

func (h *Hosts) Load() error

Load the hosts file into ```l.Lines```. ```Load()``` is called by ```NewHosts()``` and ```Hosts.Flush()``` so you generally you won't need to call this yourself.

func (*Hosts) Remove

func (h *Hosts) Remove(ip string, hosts ...string) error

Remove an entry from the hosts file.

func (*Hosts) WriteElevated

func (h *Hosts) WriteElevated() error

WriteElevated - Request a password then write the new hostsfile

type HostsLine

type HostsLine struct {
	IP    string
	Hosts []string
	Raw   string
	Err   error
}

HostsLine - Represents a single line in the hosts file.

func NewHostsLine

func NewHostsLine(raw string) HostsLine

NewHostsLine - Return a new instance of ```HostsLine```.

func (HostsLine) IsComment

func (l HostsLine) IsComment() bool

IsComment - Return ```true``` if the line is a comment.

Jump to

Keyboard shortcuts

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