acl

package
v1.3.2 Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2026 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package acl implements ordered IP/CIDR access-control lists. Each rule is either "allow <CIDR>" or "deny <CIDR>"; rules are evaluated in order and the first matching rule decides. When a list has any rules, the default policy is denied (an address matching no rule is rejected). An empty/nil list allows everything, preserving the previous open behaviour.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type List

type List struct {
	// contains filtered or unexported fields
}

List is a compiled, ordered access-control list. A nil *List allows all.

func Compile

func Compile(specs []string) (*List, error)

Compile parses a slice of "allow <CIDR>" / "deny <CIDR>" strings into a List. A nil or empty input yields a nil List (allow all). Invalid entries produce an error and the offending rule text.

func (*List) Allow

func (l *List) Allow(addr string) bool

Allow reports whether the given address string (an IP, optionally an "ip:port" or "[ip]:port") is permitted. A nil list allows everything.

func (*List) AllowAddr

func (l *List) AllowAddr(ip netip.Addr) bool

AllowAddr reports whether the given address is permitted. A nil list allows everything. IPv4-mapped IPv6 addresses are normalised to IPv4 so rules written for IPv4 also match mapped connections.

Jump to

Keyboard shortcuts

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