GeoIP and ASN Plugin
The bundled geoip plugin registers configuration-compiled generic DecisionFactProvider components. Each entry in the required decision_bindings list selects exact Policy targets and one admitted IP input, so the same local lookup serves authentication, DKIM2 current-peer checks, reputation observations, or any other namespace. No binding is implicit. The plugin requires a local primary GeoIP database and can add ASN organization, routing-prefix, registry allocation, and network-privacy evidence from optional sources.
The authentication example binds the component environment for authn/authenticate and authn/lookup_identity, which Policy uses as authn/plugin.geoip.environment. Scalar bindings qualify their outputs under plugin.geoip.*; record bindings emit one correlated record collection. The plugin does not register an authentication-shaped EnvironmentSource.
The container artifact is:
/usr/local/lib/nauthilus/plugins/geoip.so
Public contract
| Item | Value |
|---|---|
| Metadata name | geoip |
| Product version | 0.1.0 |
| Interfaces | Plugin, RuntimePlugin, ReloadablePlugin |
| Registered lifecycle component | InitTask named database |
| Registered request components | One DecisionFactProvider per decision_bindings entry, named by its component |
| Canonical Policy provider | <namespace>/plugin.geoip.<component>, for example authn/plugin.geoip.environment |
| Source timeout | descriptor timeout MaximumDecisionFactProviderTimeout (10m); each lookup sequence is bounded by lookup_timeout, default 50ms |
| Abort policy | none |
| Sensitive capabilities | none |
| Local debug modules | none; use the automatic plugin.<module> selector |
The configured module name participates in Policy binding. The reviewed example configures the module as geoip; a differently named module must use a matching provider declaration and exact descriptor ownership.
Strict configuration schema
Configuration is decoded strictly. Unknown keys, wrong types, relative database paths, unsupported format strings, invalid URLs, and invalid durations reject registration or reload.
Database and lookup fields
| Field | Type | Default | Validation and meaning |
|---|---|---|---|
database_path | string | required | Cleaned absolute path to the required primary JSON or MaxMind database. File opening happens during the init task. |
database_format | string | auto | Exactly auto, json, or mmdb. auto selects mmdb for a .mmdb suffix and json otherwise. Values are case-sensitive. |
asn_database_path | string | empty | Optional cleaned absolute path to a secondary JSON or MaxMind ASN database. |
asn_database_format | string | inferred | Exactly auto, json, or mmdb. Setting it without asn_database_path is invalid. |
refresh_interval | duration string | disabled (0) | Non-negative interval for periodically reopening the local primary and optional ASN databases. Empty or 0s disables this worker. |
lookup_timeout | duration string | 50ms | Must be positive. Bounds each request-time primary and ASN lookup sequence. |
decision_bindings
decision_bindings is required and holds 1-32 immutable bindings. Each binding registers one fact provider.
| Field | Validation and meaning |
|---|---|
component | Provider name, unique within the module. Policy refers to it as <namespace>/plugin.geoip.<component>. |
targets | 1-32 exact namespace/action selectors sharing one namespace. A target can belong to only one binding. |
input.fact | Admitted fact that carries the IP address (scalar) or the record list (record binding). |
input.category | Category of that fact, for example environment or resource. |
output_schema | geoip.facts.v1 for a scalar binding, geoip.records.v1 for a record binding. |
output_fact | Record bindings only: the single output name, qualified as plugin.geoip.<output_fact>. Must be empty for scalar bindings. |
input.records.ip_field | Record bindings only: string field that contains the IP. |
input.records.match | Optional exact string predicates (at most 8) that select rows, for example {kind: ip}. |
input.records.correlation_fields | Optional string fields (at most 8) copied into each output record. They cannot collide with GeoIP output names. |
Examples:
decision_bindings:
# Authentication: scalar facts under plugin.geoip.*
- component: environment
targets: [authn/authenticate, authn/lookup_identity]
input: {fact: nauthilus.request.client.ip, category: environment}
output_schema: geoip.facts.v1
# Reputation observations: one record per admitted IP subject
- component: observation
targets: [reputation/observe]
input:
fact: resource.reputation.subjects
category: resource
records:
ip_field: value
match: {kind: ip}
correlation_fields: [role]
output_schema: geoip.records.v1
output_fact: observations
Changing decision_bindings requires a restart; a reload that changes them is rejected and keeps the previous state. At activation, the host checks that every required input field is visible to the exact provider and has a compatible type.
freshness
| Field | Type | Default | Validation and meaning |
|---|---|---|---|
freshness.max_age | duration string | 1080h (45 days) | Source age after which a match becomes stale. |
freshness.max_stale_age | duration string | 2160h (90 days) | Absolute maximum usable age. At least max_age and at most one year. |
Source age comes from the data, not from the reload time. JSON databases use the file's modification time. MaxMind databases use the earlier of the modification time and the embedded build time. Routing and registry snapshots use their own load times, and the oldest contributing source governs the result. Reloading unchanged data does not reset its age.
asn_lookup
This optional worker downloads routing prefix-to-AS snapshots and builds an in-memory IPv4/IPv6 longest-prefix trie.
| Field | Type | Default | Validation and meaning |
|---|---|---|---|
asn_lookup.enabled | boolean | false | Enables immediate and periodic routing snapshot fetches, with bounded retries after failures. |
asn_lookup.refresh_interval | duration string | 720h | Non-negative. Empty and explicit 0s both select 720h; disable with enabled: false. |
asn_lookup.timeout | duration string | 30s | Must be positive; applied independently to each configured source fetch. |
asn_lookup.source_urls | list of strings | CAIDA IPv4 and IPv6 creation logs when enabled | Every entry must be a nonempty HTTP(S) URL, even when the worker is disabled. |
Default routing sources:
https://publicdata.caida.org/datasets/routing/routeviews-prefix2as/pfx2as-creation.log
https://publicdata.caida.org/datasets/routing/routeviews6-prefix2as/pfx2as-creation.log
The parser accepts direct text or gzip-compressed prefix data and CAIDA creation logs. For a creation log it fetches the last valid listed snapshot path. Plain CIDR rows, CAIDA address/prefix-length rows, AS prefixes, AS sets, and MOAS tokens are accepted; for a set or MOAS value, the first numeric ASN is used.
asn_registry
This optional worker downloads delegated RIR statistics and maps active ASN ranges to registry metadata.
| Field | Type | Default | Validation and meaning |
|---|---|---|---|
asn_registry.enabled | boolean | false | Enables immediate and periodic registry feed fetches. |
asn_registry.refresh_interval | duration string | 720h | Non-negative. Empty and explicit 0s both select 720h; disable with enabled: false. |
asn_registry.timeout | duration string | 30s | Must be positive; applied independently to each feed. |
asn_registry.source_urls | list of strings | five worldwide RIR feeds when enabled | Every entry must be a nonempty HTTP(S) URL. |
Default feeds cover AfriNIC, APNIC, ARIN, LACNIC, and RIPE NCC. Only asn rows whose status is allocated or assigned are retained.
privacy_intelligence
This optional subsystem classifies addresses from immutable in-memory snapshots. It performs no file or network I/O on the request path and never makes the authentication decision itself.
| Field | Type | Default | Validation and meaning |
|---|---|---|---|
privacy_intelligence.enabled | boolean | false | Requires at least one source or enabled hosting rules when set. |
privacy_intelligence.lookup_timeout | duration string | 10ms | Must be positive and no greater than the parent lookup_timeout. |
privacy_intelligence.max_snapshot_entries | integer | 1000000 | Positive per-source input and expanded-entry bound. |
privacy_intelligence.max_download_bytes | integer | 33554432 | Positive bound for one remote response, local source, or persistent-cache read. |
privacy_intelligence.refresh.cache_dir | string | empty | Optional absolute directory for derived remote cache paths. |
privacy_intelligence.refresh.max_concurrent_downloads | integer | 2 | Shared download limit; must be from 1 through 8. |
privacy_intelligence.refresh.startup_jitter | duration string | 30s | Non-negative delay available before a background refresh when a cache or optional source permits deferral. |
privacy_intelligence.refresh.default_refresh_interval | duration string | 6h | Positive default for non-Tor sources. |
privacy_intelligence.refresh.default_min_refresh_interval | duration string | 1h | Positive lower bound for non-Tor source refresh. |
privacy_intelligence.refresh.default_max_refresh_backoff | duration string | 24h | Positive failure-backoff ceiling. |
The former environment-only privacy_intelligence.public_log_fields key is rejected; request logging is host-owned.
Each sources entry has this common contract:
| Field | Required | Meaning |
|---|---|---|
id | yes | Unique 1-63 character identifier containing lowercase letters, digits, and non-leading underscores. |
kind | yes | tor_exit_list, normalized_json, cidr_list, or cidr_csv. |
authority | yes | official, operator, community, or derived; Tor requires official. |
path / url | exactly one | An absolute local path or credential-free HTTPS URL. Privacy URLs are stricter than the HTTP(S) URLs accepted by the ASN workers. |
required | no | Makes initialization/reload fail when no valid initial snapshot can be obtained. After startup, a missing or expired required snapshot produces stale state. |
refresh_interval | no | Positive interval, default 6h; Tor defaults to 1h. It must not be below min_refresh_interval. |
min_refresh_interval | no | Positive lower bound, default 1h; Tor has a hard minimum and default of 30m. |
max_refresh_backoff | no | Positive ceiling, default 24h, and at least refresh_interval. |
refresh_jitter | no | Non-negative and smaller than refresh_interval; defaults to the smaller of 10% of the interval or 10 minutes. |
max_age | no | Positive freshness window, default 24h. |
cache_path | no | Absolute path available only to remote sources; otherwise derived from refresh.cache_dir. |
confidence | no | Evidence confidence. Community values are capped at 80 and derived values at 60; official and operator values default to 100. This is evidence confidence, not authentication risk. |
license, license_url | community | Both are mandatory for community sources; normalized community JSON must also carry license metadata. |
cidr_list and cidr_csv additionally require a bounded provider identifier and a nonempty classes list. CSV uses zero-based cidr_column in the range 0-63 and optional has_header; those CSV fields are rejected for line lists. Both formats accept only public unicast prefixes, reject the entire candidate on malformed input, deduplicate coverage, and losslessly collapse adjacent or contained prefixes before expanding classes. Supported classes are:
tor_exitknown_vpn_exitcommunity_vpn_exitpublic_proxyprivacy_relayshared_egresshosting
shared_egress is for operator-reviewed public NAT egress prefixes. The plugin intentionally does not infer it from an entire carrier ASN or organization name. hosting remains separate from VPN evidence and by itself does not set privacy_detected.
Source formats
tor_exit_listaccepts complete bare-address lists, TorDNSEL or CollecTor 1.0 exit records, and bounded Onionoo details JSON. Onionoo entries must describe running relays with theExitflag. The plugin never sends the current client address to Tor.normalized_jsonis a strict versioned schema withschema_version: 1, source identity, authority, generation and optional validity timestamps, and per-prefix classes/provider/confidence. Unknown JSON fields, invalid metadata, invalid or non-public prefixes, and entries beyond the configured bounds reject the candidate atomically.cidr_listaccepts one public prefix per line with blank lines and#comments.cidr_csvaccepts RFC 4180 records and extracts the configured prefix column.
No third-party list is bundled. Operators remain responsible for feed licenses, attribution, automation terms, redistribution limits, and egress allowlists. The implementation does not require MaxMind Anonymous IP or another commercial privacy database.