hosts

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2020 License: MIT Imports: 6 Imported by: 2

Documentation

Index

Constants

View Source
const (
	MinReloadTick = time.Second
)

Variables

This section is empty.

Functions

This section is empty.

Types

type FileReader

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

func NewFileReader

func NewFileReader(filename string, reloadTick time.Duration) (r *FileReader, err error)

解析目标文件内容中的Hosts

func (*FileReader) IP

func (r *FileReader) IP(hostname string, ipv6 bool) string

获取hostname对应的ip地址,如不存在则返回空串

func (*FileReader) Record

func (r *FileReader) Record(hostname string, ipv6 bool) string

生成hostname对应的dns记录,格式为"hostname ttl IN A ip",如不存在则返回空串

type Reader

type Reader interface {
	IP(hostname string, ipv6 bool) string
	Record(hostname string, ipv6 bool) string
}

type TextReader

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

func NewTextReader

func NewTextReader(text string) (r *TextReader)

解析文本内容中的Hosts

func (*TextReader) IP

func (r *TextReader) IP(hostname string, ipv6 bool) (val string)

获取hostname对应的ip地址,如不存在则返回空串

func (*TextReader) Record

func (r *TextReader) Record(hostname string, ipv6 bool) (record string)

生成hostname对应的dns记录,格式为"hostname ttl IN A ip",如不存在则返回空串

Jump to

Keyboard shortcuts

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