Help us shape the future of Go! Take the 2026 Go Developer Survey

hostmatcher

package
v3.1.61 Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2026 License: MIT, MIT Imports: 9 Imported by: 0

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

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

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

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

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

func (hl *HostMatchList) AppendBuiltin(builtin string)

AppendBuiltin appends more builtins to match

func (*HostMatchList) AppendPattern

func (hl *HostMatchList) AppendPattern(pattern string)

AppendPattern appends more pattern to match

func (*HostMatchList) IsEmpty

func (hl *HostMatchList) IsEmpty() bool

IsEmpty checks if the checklist is empty

func (*HostMatchList) MatchHostName

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

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

func (*HostMatchList) MatchHostOrIP

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

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`

Source Files

  • hostmatcher.go
  • http.go

Jump to

Keyboard shortcuts

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