utils

package
v2.4.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2018 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// An IPv4 regular expression
	IPv4RE = "((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)[.]){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)"
	// This regular expression + the base domain will match on all names and subdomains
	SUBRE = "(([_a-zA-Z0-9]{1}|[a-zA-Z0-9]{1}[a-zA-Z0-9-]{0,61}[a-zA-Z0-9]{1})[.]{1})+"
)
View Source
const (
	USER_AGENT  = "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36"
	ACCEPT      = "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8"
	ACCEPT_LANG = "en-US,en;q=0.8"
)

Variables

This section is empty.

Functions

func AnySubdomainRegex

func AnySubdomainRegex() *regexp.Regexp

func CIDRSubset

func CIDRSubset(cidr *net.IPNet, addr string, num int) []net.IP

getCIDRSubset - Returns a subset of the hosts slice with num elements around the addr element

func GetWebPage

func GetWebPage(url string, hvals map[string]string) (string, error)

func HexString

func HexString(b []byte) string

func IPv6NibbleFormat

func IPv6NibbleFormat(ip string) string

func NetHosts

func NetHosts(cidr *net.IPNet) []net.IP

Obtained/modified the next two functions from the following: https://gist.github.com/kotakanbe/d3059af990252ba89a82

func NewUniqueElements

func NewUniqueElements(orig []string, add ...string) []string

NewUniqueElements - Removes elements that have duplicates in the original or new elements

func RangeHosts

func RangeHosts(start, end net.IP) []net.IP

func ReverseIP

func ReverseIP(ip string) string

func SetDialContext

func SetDialContext(dc DialCtx)

func SubdomainRegex

func SubdomainRegex(domain string) *regexp.Regexp

func UniqueAppend

func UniqueAppend(orig []string, add ...string) []string

UniqueAppend - Behaves like the Go append, but does not add duplicate elements

Types

type DialCtx

type DialCtx func(ctx context.Context, network, addr string) (net.Conn, error)
var (
	DialContext DialCtx
)

Jump to

Keyboard shortcuts

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