feat: add RTR protocol support for RPKI ROA fetching#106
Merged
Conversation
Add support for fetching ROAs via RTR (RPKI-to-Router) protocol as an alternative to the default Cloudflare JSON API. ASPAs are always fetched from Cloudflare since RTR v1 (RFC 8210) doesn't support ASPA. Features: - New RtrClient for RTR v1/v0 protocol with version negotiation - Configuration via environment variables or --rtr-endpoint flag - Automatic fallback to Cloudflare on RTR failure (configurable) - Track ROA/ASPA sources separately in database metadata - Support for IPv6 RTR endpoints using bracket notation Configuration options: - MONOCLE_RPKI_RTR_HOST: RTR server hostname - MONOCLE_RPKI_RTR_PORT: RTR port (default: 8282) - MONOCLE_RPKI_RTR_TIMEOUT_SECS: Connection timeout (default: 10) - MONOCLE_RPKI_RTR_NO_FALLBACK: Disable Cloudflare fallback Resolves #94
There was a problem hiding this comment.
Pull request overview
This PR adds support for fetching RPKI ROAs via the RTR (RPKI-to-Router) protocol, wires it into configuration and CLI flows, and tracks ROA/ASPA data sources in the database so downstream tooling can display where data came from.
Changes:
- Introduces an
RtrClientimplementing RTR v1 with v0 downgrade and converts RTR prefix PDUs intoRpkiRoaRecords. - Extends the RPKI lens, configuration, CLI, and database schema to support RTR-based refreshes, configurable timeouts, and per-type data source metadata for ROAs and ASPAs.
- Updates CLI outputs and changelog to surface the new configuration knobs and to display human-readable RPKI data sources.
Reviewed changes
Copilot reviewed 6 out of 8 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
src/lens/rpki/rtr.rs |
New RTR client that speaks RFC 8210 (v1 with v0 fallback), connects over TCP with timeouts, and converts Prefix PDUs into ROA records; includes basic unit and ignored integration tests. |
src/lens/rpki/mod.rs |
Exposes RtrClient, adds RpkiRefreshResult, refactors ROA/ASPA extraction into helpers, adds refresh_with_rtr with configurable fallback behavior, and uses the new store signature with ROA/ASPA sources. |
src/database/monocle/rpki.rs |
Extends RpkiCacheMetadata with roa_source/aspa_source, adds format_source, updates the rpki_meta schema and store to persist sources, and introduces a lightweight migration plus tests updating all store call sites. |
src/database/monocle/mod.rs |
Adjusts the RPKI repository test helper to call the new store(&roas, &aspas, roa_source, aspa_source) signature. |
src/config.rs |
Adds RTR-related config fields (host, port, timeout, no-fallback), parses them from TOML/env, surfaces them in summary(), and updates tests and the default config template. |
src/bin/commands/rpki.rs |
Switches to using RpkiLens (no direct load_current_rpki), reuses ensure_rpki_cache, and updates validate/roas_from_cache/aspas_from_cache to print a dynamic data source string via meta.format_source(). |
src/bin/commands/config.rs |
Replaces direct RPKI loading with RpkiLens::refresh_with_rtr, adds --rtr-endpoint override, wires effective RTR endpoint/timeout/no-fallback logic, and propagates warnings on RTR failure plus updated summary messages. |
CHANGELOG.md |
Documents RTR support, including config/env/CLI options, fallback semantics, timeouts, and version negotiation behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Fix doc comment for refresh_with_rtr to describe RpkiRefreshResult return type - Run migration in get_metadata() to handle older databases without source columns - Update core schema definition to include roa_source and aspa_source columns
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add support for fetching ROAs via RTR (RPKI-to-Router) protocol as an alternative to the default Cloudflare JSON API.
ROAs can come from RTR or Cloudflare RPKI portal, but ASPAs always come from Cloudflare RPKI portal (because RTR v1 per RFC 8210 doesn't support ASPA).
Resolves #94
Features
[::1]:8282)Usage Examples
Using CLI flag
Using environment variables
Fallback behavior
When RTR fails and fallback is enabled (default):
When RTR fails and fallback is disabled:
Configuration Options
MONOCLE_RPKI_RTR_HOST--rtr-endpointMONOCLE_RPKI_RTR_PORTMONOCLE_RPKI_RTR_TIMEOUT_SECSMONOCLE_RPKI_RTR_NO_FALLBACKChanges
RtrClientinsrc/lens/rpki/rtr.rsfor RTR protocol communicationMonocleConfigroa_sourceandaspa_sourcefields toRpkiCacheMetadata