netguard

package
v1.10.21 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2026 License: AGPL-3.0 Imports: 7 Imported by: 0

Documentation

Overview

Package netguard provides SSRF-resistant HTTP clients for outbound requests to user-supplied URLs. It validates the *resolved* IP at dial time, so DNS rebinding cannot smuggle a request to an internal address. Loopback and link-local are always blocked; private ranges by default.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Client

func Client(timeout time.Duration) *http.Client

Client returns an HTTP client whose dialer enforces the SSRF policy. Redirects are followed but each hop is re-validated by the dialer.

func Configure

func Configure(allow bool)

Configure sets whether private-range targets are allowed. Call once at startup. Default (unconfigured) blocks private ranges.

func ValidateURL

func ValidateURL(raw string) error

ValidateURL performs an up-front check: the scheme must be http(s), a host must be present, and any IP-literal host must be allowed. Hostnames are re-checked against their resolved IPs at dial time.

Types

type ErrBlocked

type ErrBlocked struct {
	IP   string
	Host string
}

ErrBlocked is returned when a destination IP is disallowed.

func (*ErrBlocked) Error

func (e *ErrBlocked) Error() string

Jump to

Keyboard shortcuts

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