Documentation ¶
Index ¶
- Constants
- type AddressLocations
- type HostFileLine
- type HostFileLines
- type HostLocations
- type Hosts
- func (h *Hosts) AddHost(addressRaw string, hostRaw string)
- func (h *Hosts) AddHosts(address string, hosts []string)
- func (h *Hosts) GetHostFileLines() *HostFileLines
- func (h *Hosts) HostAddressLookup(host string, ipFamily IPFamily) (bool, string, int)
- func (h *Hosts) ListAddressesByHost(hostname string, exact bool) [][]string
- func (h *Hosts) ListHostsByCIDR(cidr string) [][]string
- func (h *Hosts) ListHostsByIP(address string) []string
- func (h *Hosts) Reload() error
- func (h *Hosts) RemoveAddress(address string)
- func (h *Hosts) RemoveAddresses(addresses []string)
- func (h *Hosts) RemoveCIDRs(cidrs []string) error
- func (h *Hosts) RemoveFirstAddress(address string) bool
- func (h *Hosts) RemoveFirstHost(host string) bool
- func (h *Hosts) RemoveHost(host string)
- func (h *Hosts) RemoveHosts(hosts []string)
- func (h *Hosts) RenderHostsFile() string
- func (h *Hosts) Save() error
- func (h *Hosts) SaveAs(fileName string) error
- type HostsConfig
- type IPFamily
Constants ¶
const ADDRESS = 30
const COMMENT = 20
const EMPTY = 10
const UNKNOWN = 0
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AddressLocations ¶
AddressLocations the location of an address in the HFL
type HostFileLine ¶
type HostFileLine struct { OriginalLineNum int LineType int Address string Parts []string Hostnames []string Raw string Trimmed string Comment string }
func ParseHosts ¶
func ParseHosts(path string) ([]HostFileLine, error)
func ParseHostsFromString ¶ added in v1.5.3
func ParseHostsFromString(input string) ([]HostFileLine, error)
type HostFileLines ¶
type HostFileLines []HostFileLine
type HostLocations ¶
HostLocations maps a hostname to an original line number
type Hosts ¶
type Hosts struct { sync.Mutex *HostsConfig // contains filtered or unexported fields }
func NewHostsDefault ¶
NewHostsDefault returns a hosts object with default configuration
func (*Hosts) AddHost ¶
AddHost adds a host to an address and removes the host from any existing address is may be associated with
func (*Hosts) AddHosts ¶
AddHosts adds an array of hosts to the first matching address it finds or creates the address and adds the hosts
func (*Hosts) GetHostFileLines ¶
func (h *Hosts) GetHostFileLines() *HostFileLines
func (*Hosts) HostAddressLookup ¶
HostAddressLookup returns true if the host is found, a string containing the address and the index of the hfl
func (*Hosts) ListAddressesByHost ¶ added in v1.5.2
ListAddressesByHost returns a list of IPs associated with a given hostname
func (*Hosts) ListHostsByCIDR ¶ added in v1.5.2
ListHostsByCIDR returns a list of IPs and hostnames associated with a given CIDR
func (*Hosts) ListHostsByIP ¶ added in v1.5.2
ListHostsByIP returns a list of hostnames associated with a given IP address
func (*Hosts) RemoveAddress ¶
RemoveAddress removes all entries (lines) with the provided address.
func (*Hosts) RemoveAddresses ¶
RemoveAddresses removes all entries (lines) with the provided address.
func (*Hosts) RemoveCIDRs ¶ added in v1.5.4
RemoveCIDRs Remove CIDR Range (Classless inter-domain routing) examples:
127.1.0.0/16 = 127.1.0.0 -> 127.1.255.255 127.1.27.0/24 = 127.1.27.0 -> 127.1.27.255
func (*Hosts) RemoveFirstAddress ¶
RemoveFirstAddress removes the first entry (line) found with the provided address.
func (*Hosts) RemoveFirstHost ¶
RemoveFirstHost the first hostname entry found and returns true if successful
func (*Hosts) RemoveHost ¶
RemoveHost removes all hostname entries of provided host
func (*Hosts) RemoveHosts ¶
RemoveHosts removes all hostname entries of the provided host slice