netguard

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2026 License: AGPL-3.0 Imports: 4 Imported by: 0

Documentation

Overview

Package netguard keeps the backend's own outgoing connections (to an administrator's sign-in providers and mail server) away from addresses that a typo or a hostile setting must not be able to reach: the cloud metadata services and the other addresses on a link, and, unless an administrator allows it, the private networks the server sits in. It takes nothing but the standard library, so both sides of the process boundary may use it.

The check runs when the connection is made, on the address the name resolved to, so a name that answers with a different address on each lookup (DNS rebinding) and a redirect to a private address get the same answer as a private address typed in.

Index

Constants

This section is empty.

Variables

View Source
var ErrBlocked = errors.New("refusing to connect to that address")

ErrBlocked is returned for an address the guard refuses. The text names no address: it may reach a person who must not learn what is behind a name.

Functions

func Check

func Check(ip netip.Addr, allowPrivate bool) error

Check says whether a connection to ip may be made. Loopback is allowed: the sign-in provider rule lets a development server on http://localhost through, and the mail client accepts an unencrypted server on this machine, so both are already deliberate.

func Control

func Control(allowPrivate func() bool) func(network, address string, c syscall.RawConn) error

Control is a net.Dialer's Control function. allowPrivate is asked at each connection, so a setting changed on the Admin page applies to the next one.

Types

This section is empty.

Jump to

Keyboard shortcuts

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