Documentation
¶
Index ¶
- Variables
- func AddFromArgs(opts *AddFromArgsOptions) error
- func AddFromFile(opts *AddFromFileOptions) error
- func BackupFile(src, dstPath string) (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 ReadFromArgs(domains []string, ip string) *hostFile
- func ReadHostFile(file string) (*hostFile, error)
- func ReadHostFileStrict(file string) (*hostFile, error)
- func RemoveDomains(dst, profile string, domains []string) error
- func RemoveProfile(dst, profile string) error
- func RestoreFile(src, dst string) error
- func WriteToFile(f *os.File, h *hostFile) error
- type AddFromArgsOptions
- type AddFromFileOptions
- type ListOptions
Constants ¶
This section is empty.
Variables ¶
var DefaultProfileError = errors.New("'default' profile should not be handled by hostctl")
DefaultProfileError when trying to edit default content
var MissingDestError = errors.New("missing destination file")
MissingSourceError when trying to write to a file
var MissingDomainsError = errors.New("no domains provided")
MissingDomainsError when trying to set/add domains and none were given
var MissingProfileError = errors.New("missing profile name")
MissingProfileError when the profile is mandatory
var MissingSourceError = errors.New("missing source file")
MissingSourceError when trying to read from a file
Functions ¶
func AddFromArgs ¶ added in v0.4.0
func AddFromArgs(opts *AddFromArgsOptions) error
func AddFromFile ¶
func AddFromFile(opts *AddFromFileOptions) 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 ¶
BackupFile creates a copy of your hosts file to a new location with the date as extension
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 ¶
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 Read ¶
Read returns hosts file content grouped by profiles. If you pass strict=true it would remove all comments.
func ReadFromArgs ¶ added in v0.4.0
ReadFromArgs read arguments into a hostFile struct
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 RemoveDomains ¶ added in v0.5.2
RemoveDomains removes domains from a hosts file.
func RemoveProfile ¶ added in v0.5.2
RemoveProfile removes a profile from a hosts file.
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 AddFromArgsOptions ¶ added in v0.4.0
AddFromArgsOptions contains available options for adding from arguments.
type AddFromFileOptions ¶ added in v0.4.0
AddFromFileOptions contains available options for adding from file.
type ListOptions ¶
type ListOptions struct {
Profile string
}
ListOptions contains available options for listing.