java.lang.Object
net.i2p.router.web.helpers.NetDbRenderer
Renders the network database (netdb) information for the router console. Handles router and leaseset listings, search, and statistics. Optimized for performance with parallel rendering and optional reverse DNS lookups.
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static classMemoized "{0} ago" translations.private static classInternal class to hold reverse DNS cache entries with expiration time.private classJob used to wait for a router lookup.private static classSummary tallies for the /netdb overview, all read-only once built.Field Summary
Modifier and TypeFieldDescriptionExpensive translator behindagoMemo(String), bound once so the memo never sees a fresh lambda.private final NetDbRenderer.AgoMemoMemo for the "{0} ago" renders ofrenderRouterInfo(StringBuilder, RouterInfo, boolean), one per renderer.private static NetDbRenderer.RouterTalliesCached tallies, valid only for_cachedTalliesSource.private static List<RouterInfo> Tally source list the cached tallies were computed from.private static longExpiry for_cachedTallies.private StringMemoized capability tooltip for this render pass, null until first use.private final RouterContextThe router context.private final LogLogger for the netdb page.private longMemoized result ofmemoryUsedMB(), -1 until first use.private booleanWhether_memoryUsedMBholds a value for this render pass.private final ProfileOrganizerSource of the peer profiles.Pending IPs for background reverse DNS resolution.Dedup set — prevents the same IP from being queued multiple times.private static final AtomicBooleanGuards against multiple concurrent background workers.LeaseSet keys already rendered for this request, so a LeaseSet stored in more than one facade is shown only once.private final NetDbRouterCacheCache of router infos for the display.private final intRouter lookups run per batch.private static final char[]Symbols marking the bandwidth tiers.private static final String[]Descriptions of the bandwidth tiers.private static final String[]Labels for the bandwidth tiers.private static final PatternSplits a comma or space separated list.private static final intFilter bit for IPv6 routers.private booleanTrue once the summary was rendered.intNumber of local lease sets, set during lease set rendering.private static final longInterval between background reverse DNS lookups.static final intHow long to wait for a router lookup before giving up.private static final intPause after this many lookups to let the system breathe.static final intHow long to wait for a remote lease set lookup.private longThe current time for the age calculations.private static final intFilter bit for NTCP routers.private static final longPause between lookup batches, in ms.private static final longBound on a single parallel render task so a stalled common pool cannot hang the netdb page.private final LHMCache<String, NetDbRenderer.CacheEntry> Reverse DNS cache with TTL (24 hours).private static final intFilter bit for SSU routers.private static final intFilter bit for SSU introducers.private static final longHow long cached overview tallies stay valid.private static final String[]Display names of the transport filter bits.private static final longCache lifetime of 24 hours, in ms.private static final DecimalFormatFormatter for numbers with two decimals.Constructor Summary
ConstructorsMethod Summary
Modifier and TypeMethodDescriptionprivate StringTranslate a string via the router console messages bundle.private StringTranslate a string with a parameter via the router console messages bundle.private static final StringMark a string for translation extraction, a no-op at runtime.private StringTranslate and memoize "{0} ago" for one rendered row.private voidappendUrlParam(StringBuilder sb, String key, String value) Appends a URL parameter to the given StringBuilder if the value is not null.private NetDbRenderer.RouterTalliescachedTallies(List<RouterInfo> routers) Overview tallies for the sorted router list, memoized for a few seconds.private StringThe capability link tooltip, resolved once per render pass.private static intclassifyTransports(RouterInfo info) Classifies router transports into bit flags.private voidcountFullRouterStats(List<RouterInfo> routers, ObjectCounterUnsafe<String> versions, ObjectCounterUnsafe<String> countries, int[] transportCount, Map<String, int[]> countryTiers) Counts the summary statistics for the /netdb overview in a single pass: versions, countries, transports, and per-country X-tier / floodfill totals.private voidenqueueRdnsLookups(List<String> ips) Queue uncached IPs for background staggered reverse DNS lookup.private static Stringfmt(double val) Formats a number with two decimals.private StringCached reverse DNS hostname for the IP, or null if absent or expired.private StringLocal client nickname for a destination hash.getPeerProfileTier(Hash peer, boolean fullname) Peer profile tier name or CSS class.private StringgetTranslatedCountry(String code) Translated country name for the given country code.booleanWhether the router is a floodfill.private booleanChecks whether the router is marked unreachable.private RouterInfolookupRouterInfoWithWait(NetworkDatabaseFacade networkDatabase, Hash hash, long timeout) Looks up a RouterInfo by its hash with a timeout.private booleanmatchesCapabilities(RouterInfo ri, String capabilities) Whether the router matches all capability characters in the filter.private longResident memory in whole megabytes, for the local row's "Memory usage" cell.private voidpaginate(StringBuilder buf, StringBuilder ubuf, int page, int pageSize, boolean morePages, int sz) Renders pagination controls.precacheReverseDNSLookups(Collection<RouterInfo> routers) Pre-resolves reverse DNS for the given routers, returning the cached results and queuing the rest for background staggered lookups.private voidputCachedReverseDNS(String ip, String hostname) Caches a reverse DNS result for 24 hours.private voidRenders the bandwidth tiers table, one row per tier that has peers.private voidRenders the congestion capabilities table, or nothing at all when no router in the NetDb advertises one of the three congestion capabilities.private voidrenderCountryTable(StringBuilder buf, ObjectCounterUnsafe<String> countries, Map<String, int[]> countryTiers) Renders the country list table with the X-tier, floodfill and total counts for each country; countries whose total drops to zero are left out.voidrenderLeaseSet(Writer out, String hostname, boolean debug) Renders a single leaseset by hostname or b32.private voidrenderLeaseSet(StringBuilder buf, LeaseSet ls, boolean debug, long now, boolean linkSusi, String distance) Renders a single LeaseSet as HTML.voidrenderLeaseSetHTML(Writer out, boolean debug, Hash client) Renders all leasesets.voidrenderLeaseSetListFragment(Writer out, boolean debug) Renders the leaseset listing and keyspace estimate for the contentonly fragment mode of the netdb page, reusing the full lease list render.voidRenders the local (per-client) leaseset listing, wrapping the lease tables in the #lsWrapper div so the netdb page refreshes them with the same contentonly fragment path as the remote listing.voidrenderLocalSummary(Writer out) Renders the local leaseset summary header (hidden until JS shows it).private voidrenderRouterInfo(StringBuilder buf, RouterInfo routerInfo, boolean isLocalRouter) Renders a single RouterInfo as HTML.private voidrenderRouterInfo(StringBuilder buf, RouterInfo routerInfo, boolean isLocalRouter, Map<String, String> rdnsLookups) Renders a single RouterInfo as HTML with optional pre-resolved reverse DNS lookups.voidrenderRouterInfoHTML(Writer out, int pageSize, int page, String routerPrefix, String version, String country, String family, String capabilities, String ipAddress, String sybil, int port, int highPort, SigType signatureType, EncType encryptionType, String mtu, String ipv6Address, String ssuCapabilities, String transport, int cost, int introducerCount) Renders router information matching search criteria to the given writer.private voidrenderRouterInfoSafe(StringBuilder sb, RouterInfo ri, boolean isLocalRouter, Map<String, String> rdnsLookups) Renders a single RouterInfo, isolating any failure to this one entry.renderRouterInfosInParallel(Collection<RouterInfo> routerInfos, boolean isLocalRouter) Renders multiple RouterInfo objects in parallel, in ordered chunks of BATCH_SIZE.voidrenderRoutersToWriter(Collection<RouterInfo> routers, Writer out, boolean isLocal, int page, int pageSize) Renders a list of RouterInfo objects to the given Writer.voidrenderRoutersToWriter(Collection<RouterInfo> routers, Writer out, boolean isLocal, int page, int pageSize, boolean applyPagination) Renders a list of RouterInfo objects to the given Writer.voidrenderStatusHTML(Writer out, int pageSize, int page, int mode) Renders the network database status page.private voidrenderSummaryTables(StringBuilder buf, ObjectCounterUnsafe<String> versions, ObjectCounterUnsafe<String> countries, int[] transportCount, Map<String, int[]> countryTiers) Renders the summary tables (versions, bandwidth, transports, countries).private voidrenderTransportsTable(StringBuilder buf, int[] transportCount) Renders the transports table, one row per transport combination that at least one router uses.private voidrenderVersionsTable(StringBuilder buf, ObjectCounterUnsafe<String> versions) Renders the router versions table, highest version first, with one row per version present in the router list.private voidStaggered reverse-DNS worker: drains the RDNS queue one lookup perLOOKUP_INTERVAL_MS, pausing after everyLOOKUPS_BEFORE_PAUSE.private voidStart the background staggered rdns worker if not already running.private static booleanstartsWith(byte[] haystack, byte[] needle) True if the needle is a prefix of the haystack.private voidwriteNoResults(StringBuilder buf, String routerPrefix, String version, String country, String family, String capabilities, String ipAddress, int port, int highPort, String mtu, String ipv6Address, String ssuCapabilities, int cost, SigType signatureType, EncType encryptionType, String transport) Writes a message indicating no routers matched the search criteria.
Field Details
_context
The router context._routerCache
Cache of router infos for the display._log
Logger for the netdb page.TWO_DECIMALS
Formatter for numbers with two decimals.COMMA_SPACE_SPLIT
Splits a comma or space separated list.LOOKUP_WAIT
public static final int LOOKUP_WAITHow long to wait for a router lookup before giving up.- See Also:
LS_LOOKUP_WAIT
public static final int LS_LOOKUP_WAITHow long to wait for a remote lease set lookup.- See Also:
localLSCount
public int localLSCountNumber of local lease sets, set during lease set rendering._renderedLeaseSetKeys
_organizer
Source of the peer profiles.BATCH_SIZE
private final int BATCH_SIZERouter lookups run per batch.RENDER_TASK_TIMEOUT
private static final long RENDER_TASK_TIMEOUTBound on a single parallel render task so a stalled common pool cannot hang the netdb page.- See Also:
_agoMemo
Memo for the "{0} ago" renders ofrenderRouterInfo(StringBuilder, RouterInfo, boolean), one per renderer._agoFormat
Expensive translator behindagoMemo(String), bound once so the memo never sees a fresh lambda._memoryUsedMB
private volatile long _memoryUsedMBMemoized result ofmemoryUsedMB(), -1 until first use._memoryUsedValid
private volatile boolean _memoryUsedValidWhether_memoryUsedMBholds a value for this render pass._capTooltip
Memoized capability tooltip for this render pass, null until first use.now
private long nowThe current time for the age calculations.LOOKUP_INTERVAL_MS
private static final long LOOKUP_INTERVAL_MSInterval between background reverse DNS lookups. 100ms = 10 lookups/second. Gentle on the system, no burst.- See Also:
LOOKUPS_BEFORE_PAUSE
private static final int LOOKUPS_BEFORE_PAUSEPause after this many lookups to let the system breathe. 500 lookups at 10/sec = 50 seconds, then 1 second pause.- See Also:
PAUSE_AFTER_BATCH_MS
private static final long PAUSE_AFTER_BATCH_MSPause between lookup batches, in ms.- See Also:
_rdnsQueue
_rdnsQueued
_rdnsWorkerRunning
Guards against multiple concurrent background workers.isRendered
private boolean isRenderedTrue once the summary was rendered.BW_CAPS
private static final char[] BW_CAPSSymbols marking the bandwidth tiers.BW_LABELS
Labels for the bandwidth tiers.BW_DESCRIPTIONS
Descriptions of the bandwidth tiers.TALLIES_CACHE_MS
private static final long TALLIES_CACHE_MSHow long cached overview tallies stay valid. Well under the ten second /netdb auto-refresh, so it only bounds how long a hash whose country resolves late stays uncounted.- See Also:
_cachedTalliesSource
Tally source list the cached tallies were computed from._cachedTallies
Cached tallies, valid only for_cachedTalliesSource._cachedTalliesUntil
private static volatile long _cachedTalliesUntilExpiry for_cachedTallies.reverseLookupCache
Reverse DNS cache with TTL (24 hours). Small cache since we rely on file-backed rdnsCache inCommSystemFacadeImpl.TTL_24_HOURS
private static final long TTL_24_HOURSCache lifetime of 24 hours, in ms.- See Also:
SSU
SSUI
NTCP
IPV6
TNAMES
Display names of the transport filter bits.
Constructor Details
NetDbRenderer
Create a renderer bound to the given context.- Parameters:
ctx- the router context
Method Details
fmt
Formats a number with two decimals.- Parameters:
val- the number to format- Returns:
- the formatted text
isFloodfill
public boolean isFloodfill()Whether the router is a floodfill.- Returns:
- true if this router is a floodfill
matchesCapabilities
Whether the router matches all capability characters in the filter.- Parameters:
ri- the router to checkcapabilities- capability characters that must all be present (e.g. "fK")- Returns:
- whether the router's capability string contains every character
renderRouterInfoHTML
public void renderRouterInfoHTML(Writer out, int pageSize, int page, String routerPrefix, String version, String country, String family, String capabilities, String ipAddress, String sybil, int port, int highPort, SigType signatureType, EncType encryptionType, String mtu, String ipv6Address, String ssuCapabilities, String transport, int cost, int introducerCount) throws IOException Renders router information matching search criteria to the given writer. Supports filtering by version, country, family, capabilities, IP, port, etc. Streams results to reduce memory pressure on low-memory systems. Performs reverse DNS lookups in parallel if enabled.- Parameters:
out- Writer to output HTMLpageSize- number of results per pagepage- zero-based page indexrouterPrefix- optional base64 hash prefix to filter routers (null for all)version- optional version string to filter routerscountry- optional country code(s) (comma/space separated) to filter routersfamily- optional router family name to filter routerscapabilities- optional capability characters (e.g. "fK") to match allipAddress- optional IPv4 address or prefix to filter routerssybil- optional; if non-null, collects hashes for Sybil analysisport- optional port or start of range (used with highPort)highPort- optional end of port rangesignatureType- optional signature type to filter routersencryptionType- optional encryption type to filter routersmtu- optional MTU value to filter routersipv6Address- optional IPv6 address or prefix to filter routersssuCapabilities- optional SSU capability characters to matchtransport- optional transport style (e.g., "NTCP", "SSU")cost- optional cost value to filter router addressesintroducerCount- ignored, retained for signature compatibility- Throws:
IOException- if writing fails
appendUrlParam
Appends a URL parameter to the given StringBuilder if the value is not null.- Parameters:
sb- StringBuilder to append tokey- URL parameter namevalue- parameter value, may be null
writeNoResults
private void writeNoResults(StringBuilder buf, String routerPrefix, String version, String country, String family, String capabilities, String ipAddress, int port, int highPort, String mtu, String ipv6Address, String ssuCapabilities, int cost, SigType signatureType, EncType encryptionType, String transport) Writes a message indicating no routers matched the search criteria.- Parameters:
buf- buffer the "no routers matched" HTML is appended torouterPrefix- optional router hash prefixversion- optional version stringcountry- optional country codefamily- optional family namecapabilities- optional capability stringipAddress- optional IPv4 addressport- optional port or start of rangehighPort- optional end of port rangemtu- optional MTU valueipv6Address- optional IPv6 addressssuCapabilities- optional SSU capabilitiescost- optional address costsignatureType- optional signature typeencryptionType- optional encryption typetransport- optional transport style
paginate
private void paginate(StringBuilder buf, StringBuilder ubuf, int page, int pageSize, boolean morePages, int sz) Renders pagination controls.- Parameters:
buf- buffer the pagination HTML is appended toubuf- URL parameters for linkspage- current page (0-based)pageSize- results per pagemorePages- true if there are more pages after this onesz- total number of results
isUnreachable
Checks whether the router is marked unreachable.- Parameters:
ri- the router info to check- Returns:
- true if unreachable
lookupRouterInfoWithWait
private RouterInfo lookupRouterInfoWithWait(NetworkDatabaseFacade networkDatabase, Hash hash, long timeout) Looks up a RouterInfo by its hash with a timeout. Tries local lookup first, then remote, then local again.- Parameters:
networkDatabase- the network database facadehash- the router hashtimeout- max time to wait in milliseconds- Returns:
- the RouterInfo or null if not found
precacheReverseDNSLookups
Pre-resolves reverse DNS for the given routers, returning the cached results and queuing the rest for background staggered lookups.- Parameters:
routers- routers whose primary IPs to resolve- Returns:
- map of IP to hostname for already-cached lookups
enqueueRdnsLookups
Queue uncached IPs for background staggered reverse DNS lookup. The background worker processes one lookup everyLOOKUP_INTERVAL_MS, with a pause after everyLOOKUPS_BEFORE_PAUSElookups. Results accumulate in rdnsCache for future page loads.- Parameters:
ips- numeric addresses to resolve, as formatted for display; addresses already queued are ignored
startRdnsWorker
private void startRdnsWorker()Start the background staggered rdns worker if not already running. Uses the async getCanonicalHostName() to avoid blocking on DNS/WHOIS.runRdnsWorker
private void runRdnsWorker()Staggered reverse-DNS worker: drains the RDNS queue one lookup perLOOKUP_INTERVAL_MS, pausing after everyLOOKUPS_BEFORE_PAUSE. Runs on a daemon thread.renderLeaseSetHTML
Renders all leasesets.- Parameters:
out- Writer to output HTMLdebug- if true, sort by distance and show debug infoclient- if non-null, render only leasesets for that client- Throws:
IOException- if an I/O error occurs
renderLeaseSetListFragment
Renders the leaseset listing and keyspace estimate for the contentonly fragment mode of the netdb page, reusing the full lease list render.- Parameters:
out- the writer that receives the leaseset listing HTMLdebug- if true, show debug info- Throws:
IOException- if an I/O error occurs
renderLocalLeaseSetList
Renders the local (per-client) leaseset listing, wrapping the lease tables in the #lsWrapper div so the netdb page refreshes them with the same contentonly fragment path as the remote listing. The summary table is emitted before the div, mirroring the remote layout. Used by both the full local netdb page and the fragment mode.- Parameters:
out- the writer that receives the local leaseset listing HTML- Throws:
IOException- if an I/O error occurs
renderLocalSummary
Renders the local leaseset summary header (hidden until JS shows it).- Parameters:
out- where the HTML is written- Throws:
IOException- if the writer fails
renderLeaseSet
Renders a single leaseset by hostname or b32.- Parameters:
out- Writer to output HTMLhostname- the destination b32, full hash, or hostnamedebug- if true, show debug info- Throws:
IOException- if an I/O error occurs
renderLeaseSet
private void renderLeaseSet(StringBuilder buf, LeaseSet ls, boolean debug, long now, boolean linkSusi, String distance) Renders a single LeaseSet as HTML.- Parameters:
buf- buffer the LeaseSet HTML is appended tols- the LeaseSet to renderdebug- if true, include debug info like distancenow- current time for expiry calculationlinkSusi- if true, link to susidns (unused)distance- hash distance from local router (for debug)
getLocalClientNickname
renderStatusHTML
Renders the network database status page.- Parameters:
out- Writer to output HTMLpageSize- number of routers per pagepage- zero-based page indexmode- selects which view to render: 0 = summary charts, 1 = full router infos, 2 = compact router infos, 3 = summary charts sorted by country count- Throws:
IOException- if an I/O error occurs
renderRoutersToWriter
public void renderRoutersToWriter(Collection<RouterInfo> routers, Writer out, boolean isLocal, int page, int pageSize) throws IOException Renders a list of RouterInfo objects to the given Writer. Uses parallel rendering for sets up to 100 routers, streams for larger sets.- Parameters:
routers- the routers to renderout- where the HTML is writtenisLocal- true to mark the routers as localpage- zero-based page indexpageSize- number of routers per page- Throws:
IOException- if the writer fails
renderRoutersToWriter
public void renderRoutersToWriter(Collection<RouterInfo> routers, Writer out, boolean isLocal, int page, int pageSize, boolean applyPagination) throws IOException Renders a list of RouterInfo objects to the given Writer. Uses parallel rendering for sets up to 100 routers, streams for larger sets.- Parameters:
routers- the routers to renderout- where the HTML is writtenisLocal- true to mark the routers as localpage- zero-based page indexpageSize- number of routers per pageapplyPagination- whether to apply pagination internally (false if list is already paginated)- Throws:
IOException- if the writer fails
renderSummaryTables
private void renderSummaryTables(StringBuilder buf, ObjectCounterUnsafe<String> versions, ObjectCounterUnsafe<String> countries, int[] transportCount, Map<String, int[]> countryTiers) Renders the summary tables (versions, bandwidth, transports, countries).- Parameters:
buf- buffer the table HTML is appended toversions- router counts keyed by the router.version option stringcountries- router counts keyed by two-letter country codetransportCount- router counts indexed by the classifyTransports valuecountryTiers- per-country [X-tier, floodfill] counts
renderVersionsTable
Renders the router versions table, highest version first, with one row per version present in the router list.- Parameters:
buf- buffer the table HTML is appended toversions- router counts keyed by the router.version option string
renderBandwidthTiers
Renders the bandwidth tiers table, one row per tier that has peers.- Parameters:
buf- buffer the table HTML is appended to
renderCongestionCaps
Renders the congestion capabilities table, or nothing at all when no router in the NetDb advertises one of the three congestion capabilities.- Parameters:
buf- buffer the table HTML is appended to
renderTransportsTable
Renders the transports table, one row per transport combination that at least one router uses.- Parameters:
buf- buffer the table HTML is appended totransportCount- router counts indexed by the classifyTransports value, so the array is as long as the transport name table
renderCountryTable
private void renderCountryTable(StringBuilder buf, ObjectCounterUnsafe<String> countries, Map<String, int[]> countryTiers) Renders the country list table with the X-tier, floodfill and total counts for each country; countries whose total drops to zero are left out.- Parameters:
buf- buffer the table HTML is appended tocountries- router counts keyed by two-letter country code, the local router included; the row total subtracts that onecountryTiers- per-country [X-tier, floodfill] counts; a country absent from the map counts as zero for both columns
cachedTallies
Overview tallies for the sorted router list, memoized for a few seconds.Counting costs a country lookup, an option read and a transport classification per known router, and the sorted list is only replaced on its own expiry. So the list's identity is the stamp the tallies belong to, and the TTL bounds a country that resolves later.
- Parameters:
routers- the sorted list fromNetDbRouterCache- Returns:
- tallies for that list, never null
countFullRouterStats
private void countFullRouterStats(List<RouterInfo> routers, ObjectCounterUnsafe<String> versions, ObjectCounterUnsafe<String> countries, int[] transportCount, Map<String, int[]> countryTiers) Counts the summary statistics for the /netdb overview in a single pass: versions, countries, transports, and per-country X-tier / floodfill totals.- Parameters:
routers- routers to tally, the local router includedversions- version string to count, filled in herecountries- country code to count, the local router includedtransportCount- transport class index to count, sized for TNAMEScountryTiers- country code to [X-tier count, floodfill count]
getTranslatedCountry
getCachedReverseDNS
putCachedReverseDNS
Caches a reverse DNS result for 24 hours. A result that repeats the IP or is the literal "unknown" is not worth caching and is dropped.- Parameters:
ip- the address the hostname was resolved forhostname- the hostname to store, ignored when null, equal to ip, or "unknown"
renderRouterInfo
Renders a single RouterInfo as HTML.- Parameters:
buf- buffer the router HTML is appended torouterInfo- the router to renderisLocalRouter- true if this is the local router
renderRouterInfo
private void renderRouterInfo(StringBuilder buf, RouterInfo routerInfo, boolean isLocalRouter, Map<String, String> rdnsLookups) Renders a single RouterInfo as HTML with optional pre-resolved reverse DNS lookups.- Parameters:
buf- buffer the router HTML is appended torouterInfo- the router to renderisLocalRouter- true if this is the local routerrdnsLookups- map of IP to hostname for reverse DNS, may be null
renderRouterInfoSafe
private void renderRouterInfoSafe(StringBuilder sb, RouterInfo ri, boolean isLocalRouter, Map<String, String> rdnsLookups) Renders a single RouterInfo, isolating any failure to this one entry.The netdb listing streams progressively, so an exception escaping a single render would truncate the rest of the page with no way to re-render.
- Parameters:
sb- buffer the router HTML is appended tori- the router to renderisLocalRouter- true if this is the local routerrdnsLookups- map of IP to hostname for reverse DNS, may be null
renderRouterInfosInParallel
public String renderRouterInfosInParallel(Collection<RouterInfo> routerInfos, boolean isLocalRouter) Renders multiple RouterInfo objects in parallel, in ordered chunks of BATCH_SIZE. Falls back to synchronous rendering when the set is larger than one batch, to bound peak memory.- Parameters:
routerInfos- collection of routers to renderisLocalRouter- true if rendering the local router- Returns:
- the rendered HTML for every router, in input order
startsWith
private static boolean startsWith(byte[] haystack, byte[] needle) True if the needle is a prefix of the haystack.- Parameters:
haystack- the data to check, never nullneedle- non-empty prefix to find- Returns:
- whether haystack starts with needle
classifyTransports
Classifies router transports into bit flags.- Parameters:
info- the router whose transport addresses and their options are read- Returns:
- an index into the transport name table for the router's addresses, or 0 when no transport was recognised
getPeerProfileTier
_t
_x
_t
agoMemo
Translate and memoize "{0} ago" for one rendered row.- Parameters:
duration- the age, already run throughDataHelper.formatDuration2(long)- Returns:
- the localized "<duration> ago"
- See Also:
memoryUsedMB
private long memoryUsedMB()Resident memory in whole megabytes, for the local row's "Memory usage" cell.Memoized because
renderRoutersToWriterhands every row in a list the same isLocal flag, so this would otherwise run once per row rather than once per page. The rate itself averages over a minute, longer than any render.- Returns:
- megabytes of memory in use, 0 if the stat is not registered yet
capTooltip
The capability link tooltip, resolved once per render pass. The value depends only on the UI language and a renderer is created per request, so the memo cannot go stale within a pass.- Returns:
- the tooltip suffix inserted before each capability link's span