(WIP) feat(registry): add support for rdap/whois resolving#163
(WIP) feat(registry): add support for rdap/whois resolving#163ezrizhu wants to merge 2 commits intonatesales:mainfrom
Conversation
There was a problem hiding this comment.
4 issues found across 9 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="registry/registry.go">
<violation number="1" location="registry/registry.go:141">
P2: RIR routing keys are duplicated across RDAP and WHOIS switch tables, creating drift risk and inconsistent fallback behavior over time.</violation>
</file>
<file name="registry/rdap_pretty.go">
<violation number="1" location="registry/rdap_pretty.go:220">
P2: Parent entity `Public ID` lines are appended after recursive child rendering, so they can end up in a descendant’s section instead of the parent entity block.</violation>
</file>
<file name="registry/whois.go">
<violation number="1" location="registry/whois.go:135">
P2: WHOIS referral parsing is too narrow and misses `Whois Server:` style keys, which can prematurely stop referral-chain resolution.</violation>
</file>
<file name="registry/rdap.go">
<violation number="1" location="registry/rdap.go:67">
P2: RDAP formatter ignores `yaml` and returns pretty/JSON output despite CLI advertising YAML support.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
| @@ -0,0 +1,171 @@ | |||
| package registry | |||
There was a problem hiding this comment.
P2: RIR routing keys are duplicated across RDAP and WHOIS switch tables, creating drift risk and inconsistent fallback behavior over time.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At registry/registry.go, line 141:
<comment>RIR routing keys are duplicated across RDAP and WHOIS switch tables, creating drift risk and inconsistent fallback behavior over time.</comment>
<file context>
@@ -0,0 +1,171 @@
+ return ""
+}
+
+func rirRDAPBase(rir string) string {
+ switch strings.ToLower(rir) {
+ case "arin":
</file context>
| b.add("Registration", eventDate(e.Events, "registration")) | ||
| b.add("Last Changed", eventDate(e.Events, "last changed")) | ||
|
|
||
| for _, child := range e.Entities { |
There was a problem hiding this comment.
P2: Parent entity Public ID lines are appended after recursive child rendering, so they can end up in a descendant’s section instead of the parent entity block.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At registry/rdap_pretty.go, line 220:
<comment>Parent entity `Public ID` lines are appended after recursive child rendering, so they can end up in a descendant’s section instead of the parent entity block.</comment>
<file context>
@@ -0,0 +1,250 @@
+ b.add("Registration", eventDate(e.Events, "registration"))
+ b.add("Last Changed", eventDate(e.Events, "last changed"))
+
+ for _, child := range e.Entities {
+ appendEntity(b, &child)
+ }
</file context>
| continue | ||
| } | ||
| switch key { | ||
| case "refer", "whois": |
There was a problem hiding this comment.
P2: WHOIS referral parsing is too narrow and misses Whois Server: style keys, which can prematurely stop referral-chain resolution.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At registry/whois.go, line 135:
<comment>WHOIS referral parsing is too narrow and misses `Whois Server:` style keys, which can prematurely stop referral-chain resolution.</comment>
<file context>
@@ -0,0 +1,159 @@
+ continue
+ }
+ switch key {
+ case "refer", "whois":
+ return value
+ case "referralserver":
</file context>
|
|
||
| func formatRDAP(resp *rdap.Response, format string) (string, error) { | ||
| switch strings.ToLower(format) { | ||
| case "json", "raw": |
There was a problem hiding this comment.
P2: RDAP formatter ignores yaml and returns pretty/JSON output despite CLI advertising YAML support.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At registry/rdap.go, line 67:
<comment>RDAP formatter ignores `yaml` and returns pretty/JSON output despite CLI advertising YAML support.</comment>
<file context>
@@ -0,0 +1,84 @@
+
+func formatRDAP(resp *rdap.Response, format string) (string, error) {
+ switch strings.ToLower(format) {
+ case "json", "raw":
+ b, err := json.MarshalIndent(resp.Object, "", " ")
+ if err != nil {
</file context>
This PR adds cli option
-g/--registryto resolve internet numbers and domain names.By default it will use RDAP, and fail back to WHOIS in case the nic does not support it (e.g., nic.gg)
auto guesses RIR based off of suffix, e.g., EZRI-RIPE, matches whois(1) behavior
allow user to specify rir to use via --rir flag
allow user to force rdap or whois via --registry-{whois,rdap}
allow user to specify whois/rdap server
pretty output
nix shell
Summary by cubic
Add registry lookups to resolve domains, IPs, ASNs, and NIC handles via RDAP with a WHOIS fallback using
-g/--registry. Supports server/RIR overrides and pretty whois-style output.New Features
-g/--registry,--registry-rdap,--registry-whois,--rdap-server,--whois-server,--rir.--rir.jsonandraw.refer/ReferralServer) with a safe hop limit and can output hop chain injson.Dependencies
github.com/openrdap/rdap@v0.9.1and supporting indirect deps.shell.nixfor a Go dev environment.Written for commit 04eab65. Summary will update on new commits. Review in cubic