hostmatcher

package
v1.21.11 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2024 License: MIT Imports: 8 Imported by: 2

Documentation

Index

Constants

View Source
const MatchBuiltinExternal = "external"

MatchBuiltinExternal A valid non-private unicast IP, all hosts on public internet are matched

View Source
const MatchBuiltinLoopback = "loopback"

MatchBuiltinLoopback 127.0.0.0/8 for IPv4 and ::1/128 for IPv6, localhost is included.

View Source
const MatchBuiltinPrivate = "private"

MatchBuiltinPrivate RFC 1918 (10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16) and RFC 4193 (FC00::/7). Also called LAN/Intranet.

Variables

This section is empty.

Functions

func NewDialContext added in v1.16.0

func NewDialContext(usage string, allowList, blockList *HostMatchList) func(ctx context.Context, network, addr string) (net.Conn, error)

NewDialContext returns a DialContext for Transport, the DialContext will do allow/block list check

func NewDialContextWithProxy added in v1.20.6

func NewDialContextWithProxy(usage string, allowList, blockList *HostMatchList, proxy *url.URL) func(ctx context.Context, network, addr string) (net.Conn, error)

Types

type HostMatchList

type HostMatchList struct {
	SettingKeyHint string
	SettingValue   string
	// contains filtered or unexported fields
}

HostMatchList is used to check if a host or IP is in a list.

func ParseHostMatchList

func ParseHostMatchList(settingKeyHint, hostList string) *HostMatchList

ParseHostMatchList parses the host list HostMatchList

func ParseSimpleMatchList added in v1.16.0

func ParseSimpleMatchList(settingKeyHint, matchList string) *HostMatchList

ParseSimpleMatchList parse a simple matchlist (no built-in networks, no CIDR support, only wildcard pattern match)

func (*HostMatchList) AppendBuiltin added in v1.16.0

func (hl *HostMatchList) AppendBuiltin(builtin string)

AppendBuiltin appends more builtins to match

func (*HostMatchList) AppendPattern added in v1.17.1

func (hl *HostMatchList) AppendPattern(pattern string)

AppendPattern appends more pattern to match

func (*HostMatchList) IsEmpty added in v1.16.0

func (hl *HostMatchList) IsEmpty() bool

IsEmpty checks if the checklist is empty

func (*HostMatchList) MatchHostName added in v1.16.0

func (hl *HostMatchList) MatchHostName(host string) bool

MatchHostName checks if the host matches an allow/deny(block) list

func (*HostMatchList) MatchHostOrIP added in v1.16.0

func (hl *HostMatchList) MatchHostOrIP(host string, ip net.IP) bool

MatchHostOrIP checks if the host or IP matches an allow/deny(block) list

func (*HostMatchList) MatchIPAddr added in v1.16.0

func (hl *HostMatchList) MatchIPAddr(ip net.IP) bool

MatchIPAddr checks if the IP matches an allow/deny(block) list, it's safe to pass `nil` to `ip`

Jump to

Keyboard shortcuts

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