host

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2020 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddFromFile

func AddFromFile(from, dst, profile string, reset bool) error

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

func BackupFile(src, dstPath string) error

BackupFile creates a copy of your hosts file to a new location with the date as extension

func CheckProfile

func CheckProfile(p string) error

CheckProfile controls that you don't ask to handle 'default' profile.

func Disable

func Disable(dst, profile string) error

Disable marks a profile as disable by commenting all hosts lines. The content remains on the file and can be enabled later.

func Enable

func Enable(dst, profile string) error

Enable marks a profile as enable by uncommenting all hosts lines making the routing work again.

func EnableLine

func EnableLine(line string) string

EnableLine removes the # comment marker of the line.

func IsDisabled

func IsDisabled(line string) bool

IsDisabled check if a line starts with a # comment marker.

func IsHostLine

func IsHostLine(line string) bool

func ListProfiles

func ListProfiles(src string, opts *ListOptions) error

ListProfiles shows a table with profile names status and routing information

func Read

func Read(r io.Reader, strict bool) (*hostFile, error)

func ReadHostFile

func ReadHostFile(file string) (*hostFile, error)

ReadHostFile open a file an read content into a hostFile struct

func ReadHostFileStrict

func ReadHostFileStrict(file string) (*hostFile, error)

ReadHostFileStrict open a file an read content into a hostFile struct. removes all comments.

func Remove

func Remove(dst, profile string) error

Remove removes a profile from a hosts file.

func RestoreFile

func RestoreFile(src, dst string) error

RestoreFile overwrite content of a hosts file with the content of a backup.

func WriteToFile

func WriteToFile(f *os.File, h *hostFile) error

WriteToFile write hosts content to file

Types

type ListOptions

type ListOptions struct {
	Profile string
}

Jump to

Keyboard shortcuts

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