Documentation ¶
Index ¶
- Constants
- func NewDialContext(usage string, allowList, blockList *HostMatchList) func(ctx context.Context, network, addr string) (net.Conn, error)
- func NewDialContextWithProxy(usage string, allowList, blockList *HostMatchList, proxy *url.URL) func(ctx context.Context, network, addr string) (net.Conn, error)
- type HostMatchList
- func (hl *HostMatchList) AppendBuiltin(builtin string)
- func (hl *HostMatchList) AppendPattern(pattern string)
- func (hl *HostMatchList) IsEmpty() bool
- func (hl *HostMatchList) MatchHostName(host string) bool
- func (hl *HostMatchList) MatchHostOrIP(host string, ip net.IP) bool
- func (hl *HostMatchList) MatchIPAddr(ip net.IP) bool
Constants ¶
const MatchBuiltinExternal = "external"
MatchBuiltinExternal A valid non-private unicast IP, all hosts on public internet are matched
const MatchBuiltinLoopback = "loopback"
MatchBuiltinLoopback 127.0.0.0/8 for IPv4 and ::1/128 for IPv6, localhost is included.
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
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`