netguard

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2026 License: Apache-2.0 Imports: 10 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package netguard builds HTTP clients that refuse to reach private networks.

Index

Constants

This section is empty.

Variables

View Source
var ErrBlocked = errors.New("destination not allowed")

ErrBlocked is returned when a destination is refused by the policy.

Functions

func PublicAddr

func PublicAddr(addr netip.Addr) bool

PublicAddr reports whether addr is a globally routable unicast address.

Types

type Options

type Options struct {
	AllowPrivate bool              // allow loopback, private and link-local destinations
	AllowHTTP    bool              // allow plain http:// URLs (development only)
	InsecureTLS  bool              // skip TLS verification (development only)
	Resolve      map[string]string // "host:port" -> "ip:port" overrides (development only)
}

Options relaxes the guard. The zero value is the production policy.

func (Options) CheckURL

func (o Options) CheckURL(raw string) error

CheckURL validates the scheme of an outbound URL.

func (Options) Client

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

Client returns an HTTP client enforcing the policy on every connection and redirect.

Jump to

Keyboard shortcuts

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