editor

package module
v0.7.1 Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

README

etc-hosts-editor

Utility for managing the OS /etc/hosts file.

INSTALLATION

> go install github.com/go-curses/coreutils-etc-hosts-editor/cmd/eheditor@latest

DOCUMENTATION

> eheditor --help
NAME:
   eheditor - etc hosts editor

USAGE:
   eheditor [options] [/etc/hosts]

VERSION:
   v0.1.1 (trunk)

DESCRIPTION:
   command line utility for managing the OS /etc/hosts file

GLOBAL OPTIONS:
   --help, -h, --usage  display command-line usage information (default: false)
   --read-only, -r      do not write any changes to the etc hosts file (default: false)
   --version, -v        display the version (default: false)

LICENSE

Copyright 2023  The Go-Curses Authors

Licensed under the Apache License, Version 2.0 (the "License");
you may not use file except in compliance with the License.
You may obtain a copy of the license at

 http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	HostValidations = map[string]string{
		"localhost":      "IPv4 (localhost)",
		"ip6-localhost":  "IPv6 (localhost)",
		"ip6-loopback":   "IPv6 (loopback)",
		"ip6-allnodes":   "IPv6 (all nodes)",
		"ip6-allrouters": "IPv6 (all routers)",
	}
)

Functions

This section is empty.

Types

type Host

type Host struct {
	HostInfo

	sync.RWMutex
	// contains filtered or unexported fields
}

func NewComment

func NewComment(comment string) (host *Host)

func NewHostFromInfo

func NewHostFromInfo(info HostInfo) (host *Host)

func (*Host) Active

func (h *Host) Active() bool

func (*Host) AddDomain

func (h *Host) AddDomain(domain string)

func (*Host) Address

func (h *Host) Address() string

func (*Host) AppendComment

func (h *Host) AppendComment(text string)

func (*Host) Block

func (h *Host) Block() string

func (*Host) Changed

func (h *Host) Changed() bool

func (*Host) Comment

func (h *Host) Comment() string

func (*Host) Domains

func (h *Host) Domains() []string

func (*Host) Empty

func (h *Host) Empty() bool

func (*Host) Equals

func (h *Host) Equals(host *Host) bool

func (*Host) GetActualInfo

func (h *Host) GetActualInfo() (label, tooltip string)

func (*Host) HasDomain

func (h *Host) HasDomain(needle string) (found bool)

func (*Host) Importance

func (h *Host) Importance() HostImportance

func (*Host) IsComment

func (h *Host) IsComment() bool

func (*Host) IsOnlyComment

func (h *Host) IsOnlyComment() (onlyComment bool)

func (*Host) Line

func (h *Host) Line() string

func (*Host) Lookup

func (h *Host) Lookup() string

func (*Host) Name

func (h *Host) Name() (ipOrName string)

func (*Host) PerformLookup

func (h *Host) PerformLookup() (found []net.IP, err error)

func (*Host) RemoveDomain

func (h *Host) RemoveDomain(domain string)

func (*Host) SetActive

func (h *Host) SetActive(active bool)

func (*Host) SetAddress

func (h *Host) SetAddress(value string)

func (*Host) SetComment

func (h *Host) SetComment(text string)

func (*Host) SetDomains

func (h *Host) SetDomains(text string)

func (*Host) SetLookup

func (h *Host) SetLookup(value string)

func (*Host) String

func (h *Host) String() string

type HostImportance

type HostImportance string
const (
	HostNotImportant    HostImportance = "none"
	HostIsLocalhostIPv4 HostImportance = "ipv4"
	HostIsLocalhostIPv6 HostImportance = "ipv6"
)

type HostInfo

type HostInfo struct {
	// contains filtered or unexported fields
}

func (HostInfo) SameHostInfo

func (h HostInfo) SameHostInfo(other HostInfo) (same bool)

type Hostfile

type Hostfile struct {
	Path string

	Comment string

	sync.RWMutex
	// contains filtered or unexported fields
}

func ParseFile

func ParseFile(path string) (eh *Hostfile, err error)

func (*Hostfile) Hosts

func (eh *Hostfile) Hosts() []*Host

func (*Hostfile) IndexOf

func (eh *Hostfile) IndexOf(host *Host) int

func (*Hostfile) InsertHost

func (eh *Hostfile) InsertHost(host *Host, idx int)

func (*Hostfile) Len

func (eh *Hostfile) Len() int

func (*Hostfile) MoveHost

func (eh *Hostfile) MoveHost(from, to int)

func (*Hostfile) RemoveHost

func (eh *Hostfile) RemoveHost(idx int)

func (*Hostfile) Save

func (eh *Hostfile) Save() (err error)

func (*Hostfile) Validate

func (eh *Hostfile) Validate() (errs []error)

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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