host

package
v0.2.2 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 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

IsHostLine checks if a line is a host line or a comment line.

func ListProfiles

func ListProfiles(src string, opts *ListOptions) error

ListProfiles shows a table with profile names status and routing information

func NotEmptyProfile added in v0.2.0

func NotEmptyProfile(p string) error

NotEmptyProfile controls the profile name.

func Read

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

Read returns hosts file content grouped by profiles. If you pass strict=true it would remove all comments.

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 ValidProfile added in v0.2.0

func ValidProfile(p string) error

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

func WriteToFile

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

WriteToFile write hosts content to file

Types

type ListOptions

type ListOptions struct {
	Profile string
}

ListOptions contains available options for listing.

Jump to

Keyboard shortcuts

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