netguard

package
v1.9.13 Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package netguard holds the shared private-address egress guard used by notification adapters and synthetic checks. Validation happens both at save time (friendly errors) and at dial time (DNS-rebinding safe).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GuardedDialContext

func GuardedDialContext(timeout time.Duration) func(ctx context.Context, network, addr string) (net.Conn, error)

GuardedDialContext returns a DialContext that re-checks the resolved address at connection time, so a hostname cannot pass save-time validation and then be re-pointed at a private address (DNS rebinding).

func IsPrivateIP

func IsPrivateIP(ip net.IP) bool

func ValidateHost

func ValidateHost(host string) error

ValidateHost resolves a hostname and rejects it when any address is private/loopback/link-local/CGNAT.

func ValidateURL

func ValidateURL(raw string, allowPrivate bool) error

ValidateURL rejects an http(s) destination that resolves to the server's own network. Callers decide whether the guard applies (allowPrivate=true short-circuits).

Types

This section is empty.

Jump to

Keyboard shortcuts

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