@monochromatic-dev/module-wg-allowedips #
Generate minimized WireGuard AllowedIPs values from allowed and disallowed text.
Inputs may contain IPv4 or IPv6 addresses,
CIDRs,
domains,
and autonomous system numbers in AS<number> form.
import { generateAllowedIps } from '@monochromatic-dev/module-wg-allowedips';
const value = await generateAllowedIps({
allowedText: '0.0.0.0/0\n::/0',
disallowedText: '127.0.0.0/8\n::1/128',
});
The result is the minimized exact set difference, formatted as comma-separated CIDRs with one trailing newline. Complete subtraction returns an empty string.
Resolution and cache ownership #
Domains resolve through the operating system.
ASN records come from IPinfo Lite and use per-ASN cache files.
The default cache directory is
$WG_ALLOWEDIPS_CACHE_DIRECTORY,
then $XDG_CACHE_HOME/wg-allowedips/asn,
then ~/.cache/wg-allowedips/asn.
Set IPINFO_TOKEN when a missing or expired cache may need a refresh.
Callers with another data owner can construct an ASN adapter with
createAsnLookup({ cacheDirectory, token }).
The low-level lookupAsnNetworks({ asn, cacheDirectory, token }) API never infers a workspace path.
Source imports #
Workspace consumers use @monochromatic-dev/module-wg-allowedips/ts.
Submodules are available through @monochromatic-dev/module-wg-allowedips/ts/*.
No runtime package resolution is required.
Development #
Run package tasks through mise:
mise run //package/module/wg-allowedips:buildAndTest
mise run //package/module/wg-allowedips:lint
mise run //package/module/wg-allowedips:lint:types