ipfilter

package
v0.81.0-rc.3 Latest Latest
Warning

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

Go to latest
Published: Jun 19, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package ipfilter provides IP-based allow/deny filtering for network listeners.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Denial

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

Denial describes the outcome of an IP filter check. A zero-value Denial means the address was allowed.

func (Denial) Allowed

func (d Denial) Allowed() bool

Allowed returns true when the address passed the filter.

func (Denial) Reason

func (d Denial) Reason() string

Reason returns a human-readable explanation when the address was denied. Empty when allowed.

type DenialInfo

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

DenialInfo tracks per-reason denial counts for display in agent status. It implements the InfoProvider interface from pkg/logs/status/utils.

func NewDenialInfo

func NewDenialInfo() *DenialInfo

NewDenialInfo creates a new DenialInfo instance.

func (*DenialInfo) Info

func (d *DenialInfo) Info() []string

Info returns denial statistics as a sorted list of strings.

func (*DenialInfo) InfoKey

func (d *DenialInfo) InfoKey() string

InfoKey returns the label used in agent status output.

func (*DenialInfo) Record

func (d *DenialInfo) Record(reason string)

Record increments the counter for the given denial reason.

type Filter

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

Filter evaluates incoming connection addresses against allow and deny lists.

Evaluation order (standard firewall semantics):

  1. If the IP matches any denied prefix, reject.
  2. If the allow list is non-empty and the IP matches no allowed prefix, reject.
  3. Otherwise, accept.

func New

func New(allowed, denied []string) (*Filter, error)

New parses the allow and deny string slices into a Filter. Each entry may be a bare IP address (e.g. "10.0.0.1") or CIDR notation (e.g. "10.0.0.0/24").

func (*Filter) Allow

func (f *Filter) Allow(addr net.Addr) bool

Allow returns true if the address should be permitted.

func (*Filter) Check

func (f *Filter) Check(addr net.Addr) Denial

Check evaluates the address and returns a Denial describing the outcome. When the address is denied, Denial.Reason() identifies which rule matched.

Jump to

Keyboard shortcuts

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