This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
# Build the project
cargo build
# Build release version (optimized, stripped binary)
cargo build --release
# Run tests
cargo test
# Run only library tests
cargo test --lib
# Run a specific test
cargo test test_detect_type
# Run the CLI directly
cargo run -- example.com
# Check without building
cargo check
# Run an example
cargo run --example basic_queryThis is an RDAP (Registration Data Access Protocol) client written in Rust, implementing RFCs 7480-7484. It provides both a CLI tool and a library.
src/main.rs- CLI entry point using clap for argument parsing, includesrdap updatesubcommandsrc/lib.rs- Library entry point, re-exports public APIsrc/client.rs-RdapClient- main client that orchestrates queries, handles HTTP requests, parses responses, and follows registrar referrals for multi-layer RDAP queriessrc/request.rs-RdapRequestandQueryType- request building and query type detectionsrc/bootstrap.rs-BootstrapClient- IANA bootstrap service discovery to find authoritative RDAP servers, with TLD override supportsrc/config.rs- Configuration management with priority loading (local > user > system > builtin)src/display.rs-RdapDisplayandRdapDisplayWithQuerytraits - colored terminal output formatting, abuse contact displaysrc/cache.rs- Bootstrap file caching in~/.cache/rdap/src/ip.rs- IP address utilities: normalization (shorthand → standard), CIDR detection/parsingsrc/models/- RDAP data models (Domain, Entity, Autnum, IpNetwork, Nameserver, etc.)
Priority (highest to lowest):
1. ~/.config/rdap/*.local.json - User local overrides (never updated)
2. ~/.config/rdap/*.json - Downloaded configs
3. /etc/rdap/*.json - System configs
4. Built-in defaults - Embedded in binary via include_str!
Files:
- config.json - Bootstrap URLs for IANA RDAP
- tlds.json - TLD overrides for ccTLDs not in IANA bootstrap
- *.local.json - User overrides (merged, not replaced)
Config files in config/ directory are embedded into the binary at compile time.
- User provides query string (domain, TLD, IP, CIDR, AS number)
RdapRequest::detect_type_with_tld_check()auto-detects query type:- Pure numbers →
QueryType::Autnum(AS number) - Checks if single word matches IANA TLD list (from
tlds.txt) →QueryType::Tld - IP-like patterns →
QueryType::Ip - Otherwise →
QueryType::Domain
- Pure numbers →
- For IP queries:
ip::normalize_ip()normalizes shorthand IPs (1.1 → 1.0.0.1) - For domains: Check TLD overrides from
tlds.jsonfirst, then IANA bootstrap BootstrapClientfetches IANA bootstrap registry to find authoritative RDAP serverRdapClientsends HTTP request withAccept: application/rdap+json- Response is parsed into appropriate
RdapObjectvariant based onobjectClassName - For domain queries: Follow registrar referral link for multi-layer RDAP data
- Result is displayed via
RdapDisplaytrait (with abuse contact for IP/ASN) or serialized to JSON
RdapObject- enum of all possible RDAP response types (Domain, Entity, IpNetwork, Autnum, etc.)QueryType- enum for query types (Domain, Tld, Ip, Autnum, Entity, Nameserver, searches)RdapQueryResult- Result with registry and optional registrar data, plus server URLsVCard- jCard/vCard parsing for contact information in entitiesConfig- Configuration with bootstrap URLs and cache settingsTldOverrides- HashMap of TLD -> RDAP server URLTldList- IANA TLD list for detecting TLD queries (e.g.,rdap google→ query .google TLD)
rdap <query>- Main query commandrdap --update/rdap -u- Update config files from GitHub
tokio+reqwest- async HTTP clientserde+serde_json- JSON serializationclap- CLI parsing with subcommandscolored+comfy-table- terminal output formattingipnet- IP network/CIDR parsing and matching