Documentation
¶
Index ¶
- func AddFromFile(from, dst, profile string, reset bool) error
- func BackupFile(src, dstPath string) error
- func CheckProfile(p string) error
- func Disable(dst, profile string) error
- func Enable(dst, profile string) error
- func EnableLine(line string) string
- func IsDisabled(line string) bool
- func IsHostLine(line string) bool
- func ListProfiles(src string, opts *ListOptions) error
- func Read(r io.Reader, strict bool) (*hostFile, error)
- func ReadHostFile(file string) (*hostFile, error)
- func ReadHostFileStrict(file string) (*hostFile, error)
- func Remove(dst, profile string) error
- func RestoreFile(src, dst string) error
- func WriteToFile(f *os.File, h *hostFile) error
- type ListOptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddFromFile ¶
AddFromFile reads content from a file and adds it as a profile into your hosts file. If you pass reset=true it will delete all previous content of the profile.
func BackupFile ¶
BackupFile creates a copy of your hosts file to a new location with the date as extension
func CheckProfile ¶
CheckProfile controls that you don't ask to handle 'default' profile.
func Disable ¶
Disable marks a profile as disable by commenting all hosts lines. The content remains on the file and can be enabled later.
func Enable ¶
Enable marks a profile as enable by uncommenting all hosts lines making the routing work again.
func EnableLine ¶
EnableLine removes the # comment marker of the line.
func IsDisabled ¶
IsDisabled check if a line starts with a # comment marker.
func IsHostLine ¶
func ListProfiles ¶
func ListProfiles(src string, opts *ListOptions) error
ListProfiles shows a table with profile names status and routing information
func ReadHostFile ¶
ReadHostFile open a file an read content into a hostFile struct
func ReadHostFileStrict ¶
ReadHostFileStrict open a file an read content into a hostFile struct. removes all comments.
func RestoreFile ¶
RestoreFile overwrite content of a hosts file with the content of a backup.
func WriteToFile ¶
WriteToFile write hosts content to file
Types ¶
type ListOptions ¶
type ListOptions struct {
Profile string
}