Documentation
¶
Overview ¶
Package hosts supports hosts formatted data (see also `man hosts`). Supported are conversions from a file or string to an internal representation and back to a string.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var Sys = "/etc/hosts" //TODO:LSB only
System hosts name
Functions ¶
This section is empty.
Types ¶
type Cfg ¶
type Cfg struct {
// contains filtered or unexported fields
}
Cfg represents a hosts.File with a change/modification guard/handler. Methods of Cfg are synchronized; multiple goroutines may invoke them concurrently.
func NewCfg ¶
NewCfg returns a newly created Cfg with hosts.File initialized from file fname or an Error of any. It binds the contained hosts.File to fname and on any changes to the fname file the Cfg hosts.File is reloaded on access via Cfg.File().
func (*Cfg) File ¶
File returns a hosts.File from Cfg and an indicator of its source file has been changed/modificated compared to the last invocation of this function or an Error if any.
func (*Cfg) SetChanged ¶
func (c *Cfg) SetChanged()
SetChanged forces next File() to handle modification of the wrapped hosts.File.
type File ¶
type File []*FileItem
A File holds items found in a hosts file, e.g. '/etc/hosts'. See also hosts(5)
func (*File) LoadString ¶
Load File from a hosts format string s. Return an Error, if any.
type FileItem ¶
type FileItem struct { IP net.IP // Well, it's an IP address CanonicalName string // Per specs canocalized hostname Aliases []string // Possibly empty hostname's aliases list }
An FileItem holds an item found in a hosts file, e.g. '/etc/hosts'. See also hosts(5)
type GoCfg ¶
type GoCfg struct {
// contains filtered or unexported fields
}
GoCfg is a Cfg wrapped in a goroutine allowing for concurrent access.
func NewGoCfg ¶
NewGoCfg returns a newly created GoCfg or an Error if any. It is assumed there will be only one/few GoCfg instance(s) in an application. The instance(s) and its associated goroutine(s) will never be released. This is by design in an atempt to avoid some possibly nasty races on finalization. The "impossible to release" doesn't apply when NewGoCfg returns an Error.