goodhosts

package
v4.1.3 Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2024 License: MIT Imports: 7 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsComment

func IsComment(line string) bool

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

Types

type Hosts

type Hosts struct {
	Path         string
	Section      string
	FileLines    []HostsLine
	SectionLines []HostsLine
}

Hosts Represents a hosts file.

func NewHosts

func NewHosts(sectionName string) (Hosts, error)

NewHosts Return a new instance of “Hosts“.

func (*Hosts) Add

func (h *Hosts) Add(ip, comment 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, host string, forceFile bool) 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) RemoveSection

func (h *Hosts) RemoveSection() error

RemoveSection removes an entire section from the hostsfile

type HostsLine

type HostsLine struct {
	IP      string
	Hosts   []string
	Comment 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```.

Jump to

Keyboard shortcuts

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