hosts

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Hosts

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

Hosts is the representation of IP-to-Host and Host-to-IP mappings.

func New

func New() Hosts

New creates empty `Hosts` instance.

func (*Hosts) Add

func (h *Hosts) Add(ip netip.Addr, alias ...string)

Add adds IP:[]Host mapping skipping invalid IPs and hosts aliases.

func (*Hosts) DelByAlias

func (h *Hosts) DelByAlias(alias string)

DelByAlias removes all IP addresses (and their aliases) associated with specified alias.

func (*Hosts) DelByIP

func (h *Hosts) DelByIP(ip netip.Addr)

DelByIP removes all aliases associated with specified IP address.

func (*Hosts) GetAlias

func (h *Hosts) GetAlias(ip netip.Addr) []string

GetAlias returns all aliases associated with specified IP address.

func (*Hosts) GetIP

func (h *Hosts) GetIP(alias string) []netip.Addr

GetIP returns all IP addresses associated with specified alias.

func (*Hosts) Len

func (h *Hosts) Len() int

Len returns amount of mapped IP addresses.

func (*Hosts) Read

func (h *Hosts) Read(reader io.Reader) error

Read appends hosts read from file using provided `io.Reader`.

func (*Hosts) String

func (h *Hosts) String() string

func (*Hosts) Write

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

Write writes all mappings from `Hosts` instance to hosts file using provided `io.Writer`.

Jump to

Keyboard shortcuts

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