ipallowlist

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2026 License: MIT Imports: 1 Imported by: 0

README

ip-allowlist

Deny every request whose client IP is not on an allowlist that ships inside the bundle. The list lives in data/allowlist.txt, a read-only data file embedded at build time. Because data files are hashed into the bundle's identity, the allowlist is versioned, validated, and rolled back exactly like the rule code: changing an entry produces a new immutable bundle that must pass its embedded tests before it can activate.

The rule reads the file through sdk.DataSet, which parses the newline-delimited list into a membership set once and caches it for the life of the instance, so the per-request cost is a single map lookup.

Behavior

Request client IP Result
present in allowlist.txt next, reason allowlisted
absent (or empty) deny 403, reason not-allowlisted

The rule matches whole IP strings. The client IP is adapter-resolved: under Caddy it honors trusted_proxies, so put the allowlist rule behind correct proxy configuration if you terminate TLS upstream.

Data files

data/allowlist.txt is picked up automatically from the data/ directory next to the rule. Point elsewhere with switchboard build --data ./path, and cap the embedded size with --max-data-bytes (default 4mb). See the data files guide.

Build, test, deploy

switchboard build ./examples/ip-allowlist --out ./dist-example
switchboard test ./dist-example

The build embeds both tests.yaml and data/allowlist.txt; the test suite runs against the exact bundled data, so "tests passed" means "passed with this allowlist."

Documentation

Overview

Package ipallowlist denies any request whose client IP is not in an allowlist bundled with the rule. The allowlist lives in data/allowlist.txt, a read-only data file baked into the bundle and hashed into its identity, so changing the list is a normal build-and-deploy with the same validation and rollback as a code change. The set is parsed once and cached for the life of the instance.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Handle

func Handle(req sdk.Request) sdk.Action

Types

This section is empty.

Jump to

Keyboard shortcuts

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