collect

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 1, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Collect

func Collect(ctx context.Context, name domain.Name, registryBaseURL string, whoisIANAServer string, opts Options) []model.SourceRecord

Collect fans out to registry RDAP (and, unless NoFollow, the registrar RDAP hop via the registry's "related" link) and the WHOIS chain concurrently — the two branches share no state (separate rdap.Client and whois.Client instances) and neither depends on the other's result, so they run in parallel goroutines rather than one after the other; only the registrar RDAP hop within the RDAP branch, and the registry -> registrar chasing within the WHOIS branch, are genuinely sequential (each depends on its predecessor's response to find the next hop). Collect returns one model.SourceRecord per source actually attempted AND allowed by opts.Sources, always in a fixed registry-rdap, registrar-rdap, registry-whois, registrar-whois order regardless of which goroutine finished first, so callers (e.g. the CLI's -v output) see a stable order across runs. registryBaseURL is the already-resolved RDAP service base for the domain's TLD (empty string means no RDAP coverage — Collect degrades to WHOIS-only). whoisIANAServer overrides the WHOIS client's IANA server (empty string uses whois.Client's own "whois.iana.org" default) — this parameter exists so tests can point the WHOIS chain at a local fake IANA server, the same way internal/whois's own tests do.

After both branches finish, if the WHOIS chain didn't discover a registrar-whois server itself (the registry hop gave no "Registrar WHOIS Server:" referral — e.g. because the registry doesn't run WHOIS for this TLD at all, as several of Identity Digital's newer gTLDs don't) but the registrar-RDAP hop's response carries RFC 9083's optional port43 field, Collect makes one direct fallback WHOIS query to that server. This is a genuinely sequential extra step (it needs both branches' results to decide whether it's even needed), not part of the concurrent fan-out above, and only fires when registrar-whois is actually a wanted source.

A single source failing is normal, not fatal — Collect never returns an error; callers pass the (possibly partial) result straight to merge.Merge.

func FromRDAP

func FromRDAP(src model.SourceID, result *rdap.Result, latency time.Duration, fetchErr error) model.SourceRecord

FromRDAP adapts an RDAP client result into a model.SourceRecord tagged as src (SourceRegistryRDAP or SourceRegistrarRDAP — the caller decides which, since the same DomainResponse shape serves both hops).

Registrar identity is populated only from the shallow jCard fields (RegistrarEntity's "fn", AbuseEntity's "email"/"tel") — IANA ID and URL are not extracted from RDAP in M3 (that would require parsing the entity's publicIds array, out of scope for this milestone's "shallow" jCard reading); those fields are populated from WHOIS only, if at all.

func FromWHOIS

func FromWHOIS(result *whois.Result) []model.SourceRecord

FromWHOIS adapts a WHOIS lookup's hop chain into per-hop model.SourceRecords. It skips Hops[0] (the IANA referral hop — never a data source, per whois.Client.Lookup's documented hop order) and maps the registry hop (Hops[1], if present) to SourceRegistryWHOIS and the registrar hop (Hops[2], if present) to SourceRegistrarWHOIS.

If the IANA hop itself failed (network error), that's surfaced as its own failed SourceRegistryWHOIS record rather than returning zero records — otherwise a genuine network failure is indistinguishable from a TLD that simply has no WHOIS coverage (both would otherwise hit the len(Hops) < 2 case below), unlike the RDAP branch, which always surfaces a fetch error as its own SourceRecord (see FromRDAP).

Types

type Options

type Options struct {
	// NoFollow skips the registrar RDAP related-link hop even if the
	// registry response advertises one.
	NoFollow bool
	// Timeout bounds each individual fetch (registry RDAP, registrar
	// RDAP, and the whole WHOIS chain).
	Timeout time.Duration
	// Sources restricts which of the four possible sources Collect
	// includes in its output. nil (the zero value) means all four are
	// allowed. This does not always suppress the underlying network
	// call: registrar RDAP can only be discovered via the registry
	// RDAP response's related link, and the WHOIS registrar hop can
	// only be reached by completing the same referral chain that
	// visits the registry hop — in both cases the upstream fetch still
	// happens when needed to reach an allowed downstream source, but
	// its own SourceRecord is only emitted if it is itself allowed.
	Sources []model.SourceID
}

Options controls Collect's behavior.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL