Extracted from CommSystemFacadeImpl (2026-09-06) so the peer-render cluster, its RouterInfo/capacity caches, and its i18n state live apart from the facade core. The facade retains thin commSystem() delegators so the public API is unchanged; collaborators (country lookup, reverse-DNS) are injected rather than fetched through commSystem() round-trips.
Pure memory-independent decisions (bandwidth classification, visible-cap cleanup) are package-visible statics so they can be tested without a running router; see PeerHTMLRendererDecisionTest.
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final RouterContextRemoves the leading D/E/G bandwidth marker from a visible capacity string.private final CountryLookupThe lookup of the peer countries.private final ReverseDnsLookupThe reverse dns lookup of peer addresses.private static final StringBundle of the common translated strings.The cached capacity strings, by peer.private static final StringBundle of the translated country names.private final Map<Hash, RouterInfo> The cached router infos, by peer, to speed repeated lookups.Constructor Summary
ConstructorsConstructorDescriptionPeerHTMLRenderer(RouterContext ctx, CountryLookup countryLookup, ReverseDnsLookup rdns) Create a renderer.Method Summary
Modifier and TypeMethodDescriptionprivate final StringLooks up the console translation of a string in this renderer's bundle.(package private) static StringclassifyCapacity(String caps) Highest-priority bandwidth capability char present in the caps string, or "?" when none is advertised.private StringgetCapacityCached(Hash peer) Gets the capacity text from the cache.private RouterInfogetRouterInfoCached(Hash peer) Gets the router info from the cache.private StringlocalizedCountryName(String code) Localized country display name for a two-letter code.renderPeerCaps(Hash peer, boolean inline) Renders the peer's capability HTML block.renderPeerFlag(Hash peer) Render the HTML flag image for the given peer.renderPeerHTML(Hash peer, boolean extended) Renders HTML for a peer with optional extended info.private StringReverse-DNS label: resolvesipto its canonical host name when reverse lookups are enabled and the resolver offers a distinct, known name.
Field Details
BUNDLE_NAME
Bundle of the common translated strings.- See Also:
COUNTRY_BUNDLE_NAME
Bundle of the translated country names.- See Also:
_context
Removes the leading D/E/G bandwidth marker from a visible capacity string._countryLookup
The lookup of the peer countries._rdns
The reverse dns lookup of peer addresses.routerInfoCache
The cached router infos, by peer, to speed repeated lookups.capacityCache
Constructor Details
PeerHTMLRenderer
Create a renderer.- Parameters:
ctx- non-nullcountryLookup- non-nullrdns- non-null
Method Details
renderPeerHTML
Renders HTML for a peer with optional extended info. Uses cached RouterInfo, country info, and reverse lookup cache.- Parameters:
peer- the hash of the peer to renderextended- Whether to show extended capabilities- Returns:
- HTML snippet representing peer
renderPeerFlag
renderPeerCaps
Renders the peer's capability HTML block. Caches data and removes unnecessary repeated computation.- Parameters:
peer- the hash of the peer whose capabilities are being renderedinline- If true, render inline without table wrapper- Returns:
- HTML snippet of peer capabilities
getRouterInfoCached
Gets the router info from the cache.- Parameters:
peer- the hash of the peer- Returns:
- the router info, null if absent
getCapacityCached
localizedCountryName
Localized country display name for a two-letter code. Names needing no translation (single words, already localized) are returned verbatim.Shared by
renderPeerHTML(Hash, boolean)andrenderPeerFlag(Hash); extracting it removes the duplicated lookup-and-translate branch from both.- Parameters:
code- two-letter country code (never null at call sites)- Returns:
- country name, translated when multi-word
resolveHostForDisplay
Reverse-DNS label: resolvesipto its canonical host name when reverse lookups are enabled and the resolver offers a distinct, known name. Otherwise returns the raw IP. Non-blocking-the lookup is served from the rDNS cache and a background lookup is queued on a miss.Deduplicates the resolver branch formerly duplicated across
renderPeerHTML(Hash, boolean)andrenderPeerFlag(Hash); the flag renderer adds the raw-IP suffix itself when the name differs.- Parameters:
ip- literal IP string (never null)- Returns:
- canonical host name or the raw IP
classifyCapacity
Highest-priority bandwidth capability char present in the caps string, or "?" when none is advertised.Priority follows
RouterInfo.BW_CAPABILITY_CHARSorder, so a peer advertising both a high and a low class is classified at its high end. This is the decision the formergetCapacityCachedinline loop made; it is exposed so the offlinePeerHTMLRendererDecisionTestcan pin both the string and the null/empty handling without a router.- Parameters:
caps- capabilities string (never null in practice; null treated as none)- Returns:
- single bandwidth-class char or "?"
_t