inputlist

package
v0.0.0-...-72c2bb7 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2020 License: MIT Imports: 9 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrMissingDot If a line contains no period (and not an ipv6 address)
	ErrMissingDot = errors.New("missing period")
	// ErrTooManyCIDRAddresses If too many addresses in a CIDR block are encountered
	ErrTooManyCIDRAddresses = errors.New("too many addresses in CIDR block")
	// ErrTooManyAddresses if we exceeded our total address count
	ErrTooManyAddresses = errors.New("too many addresses in input list")
	// ErrInvalidIP if the ip address is malformed (starts/ends with number but does not parse)
	ErrInvalidIP = errors.New("parsing IP address failure")
	// ErrHostMatchesETLD if the host is a public suffix
	ErrHostMatchesETLD = errors.New("host provided matches a top level domain")
	// ErrInvalidURLHostname url parses, but hostname is invalid
	ErrInvalidURLHostname = errors.New("hostname in url is invalid")
)

Functions

func IsCIDR

func IsCIDR(line string) bool

func IsIP

func IsIP(line string) bool

func IsURL

func IsURL(line string) bool

func ParseHost

func ParseHost(host string) (string, error)

ParseHost removes trailing/leading .

Types

type ParseError

type ParseError struct {
	LineNumber int    `json:"line_number"`
	Line       string `json:"line"`
	Err        string `json:"error"`
}

ParseError contains the line number, line and parse error

func ParseList

func ParseList(in io.Reader, maxAddresses int) (map[string]struct{}, []*ParseError)

ParseList parses a list of hostnames, domains, urls, ip addresses, and cidr ranges and returns a de-duplicated list of strings and any errors with line numbers returns nil if number of addresses exceeds maxAddress

Jump to

Keyboard shortcuts

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