net.i2p.router.web.helpers

## Class NetDbRenderer

- java.lang.Object
- - net.i2p.router.web.helpers.NetDbRenderer

-     class NetDbRenderer
      extends Object

  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 Classes
    Modifier and Type | Class and Description
    --- | ---
    `(package private) static class` | `NetDbRenderer.RAComparator` Comparator for router addresses by transport then host.

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `int` | `localLSCount`
    `static int` | `LOOKUP_WAIT`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `NetDbRenderer(RouterContext ctx)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `enableReverseLookups()`
    `String` | `getPeerProfileTier(Hash peer, boolean fullname)` Gets the peer profile tier name.
    `boolean` | `isFloodfill()`
    `void` | `precacheIntroducerInfos()` Precaches RouterInfo for all known introducers by querying the network database.
    `Map<String,String>` | `precacheReverseDNSLookups(Collection<RouterInfo> routers)` Precache reverse DNS lookups for a collection of RouterInfo entries.
    `void` | `renderLeaseSet(Writer out, String hostname, boolean debug)` Renders a single leaseset by hostname or b32.
    `void` | `renderLeaseSetHTML(Writer out, boolean debug, Hash client)` Renders all leasesets.
    `void` | `renderLocalSummary(Writer out)` Renders the local leaseset summary header (hidden until JS shows it).
    `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)` Renders router information matching search criteria to the given writer.
    `String` | `renderRouterInfosInParallel(Collection<RouterInfo> routerInfos, boolean isLocalRouter)` Renders multiple RouterInfo objects in parallel.
    `void` | `renderRoutersToWriter(Collection<RouterInfo> routers, Writer out, boolean isLocal, int page, int pageSize)` Renders a list of RouterInfo objects to given Writer.
    `void` | `renderRoutersToWriter(Collection<RouterInfo> routers, Writer out, boolean isLocal, int page, int pageSize, boolean applyPagination)` Renders a list of RouterInfo objects to given Writer.
    `void` | `renderStatusHTML(Writer out, int pageSize, int page, int mode)` Renders the network database status page.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### localLSCount

          public int localLSCount

    - #### LOOKUP_WAIT

          public static final int LOOKUP_WAIT

      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### NetDbRenderer

          public NetDbRenderer(RouterContext ctx)

  - ### Method Detail

    - #### enableReverseLookups

          public boolean enableReverseLookups()

    - #### getPeerProfileTier

          public String getPeerProfileTier(Hash peer,
                                           boolean fullname)

      Gets the peer profile tier name.
      Parameters:
        `peer` - the peer hash
        `fullname` - if true, return full name; else CSS class
      Returns:
        the tier name or class

    - #### isFloodfill

          public boolean isFloodfill()

    - #### precacheIntroducerInfos

          public void precacheIntroducerInfos()

      Precaches RouterInfo for all known introducers by querying the network database. This helps ensure we have up-to-date info for routers we might need to contact.

    - #### precacheReverseDNSLookups

          public Map<String,String> precacheReverseDNSLookups(Collection<RouterInfo> routers)

      Precache reverse DNS lookups for a collection of RouterInfo entries.
      Parameters:
        `routers` - Collection of RouterInfo objects to resolve
      Returns:
        Map of IP address to canonical hostname (may be empty)

    - #### renderLeaseSet

          public void renderLeaseSet(Writer out,
                                     String hostname,
                                     boolean debug)
                              throws IOException

      Renders a single leaseset by hostname or b32.
      Parameters:
        `out` - Writer to output HTML
        `hostname` - the destination b32, full hash, or hostname
        `debug` - if true, show debug info
      Throws:
        `IOException`

    - #### renderLeaseSetHTML

          public void renderLeaseSetHTML(Writer out,
                                         boolean debug,
                                         Hash client)
                                  throws IOException

      Renders all leasesets.
      Parameters:
        `out` - Writer to output HTML
        `debug` - if true, sort by distance and show debug info
        `client` - if non-null, render only leasesets for that client
      Throws:
        `IOException`

    - #### renderLocalSummary

          public void renderLocalSummary(Writer out)
                                  throws IOException

      Renders the local leaseset summary header (hidden until JS shows it).
      Throws:
        `IOException`

    - #### 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 HTML
        `pageSize` - number of results per page
        `page` - zero-based page index
        `routerPrefix` - optional base64 hash prefix to filter routers (null for all)
        `version` - optional version string to filter routers
        `country` - optional country code(s) (comma/space separated) to filter routers
        `family` - optional router family name to filter routers
        `capabilities` - optional capability characters (e.g. "fK") to match all
        `ipAddress` - optional IPv4 address or prefix to filter routers
        `sybil` - optional; if non-null, collects hashes for Sybil analysis
        `port` - optional port or start of range (used with highPort)
        `highPort` - optional end of port range
        `signatureType` - optional signature type to filter routers
        `encryptionType` - optional encryption type to filter routers
        `mtu` - optional MTU value to filter routers
        `ipv6Address` - optional IPv6 address or prefix to filter routers
        `ssuCapabilities` - optional SSU capability characters to match
        `transport` - optional transport style (e.g., "NTCP", "SSU")
        `cost` - optional cost value to filter router addresses
        `introducerCount` - unused
      Throws:
        `IOException` - if writing fails

    - #### renderRouterInfosInParallel

          public String renderRouterInfosInParallel(Collection<RouterInfo> routerInfos,
                                                    boolean isLocalRouter)

      Renders multiple RouterInfo objects in parallel.
      Parameters:
        `routerInfos` - collection of routers to render
        `isLocalRouter` - true if rendering the local router
      Returns:
        concatenated HTML

    - #### renderRoutersToWriter

          public void renderRoutersToWriter(Collection<RouterInfo> routers,
                                            Writer out,
                                            boolean isLocal,
                                            int page,
                                            int pageSize)
                                     throws IOException

      Renders a list of RouterInfo objects to given Writer. Uses parallel rendering for small sets (< 300), streams for large sets.
      Throws:
        `IOException`

    - #### 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 given Writer. Uses parallel rendering for small sets (< 300), streams for large sets.
      Parameters:
        `applyPagination` - whether to apply pagination internally (false if list is already paginated)
      Throws:
        `IOException`

    - #### renderStatusHTML

          public void renderStatusHTML(Writer out,
                                       int pageSize,
                                       int page,
                                       int mode)
                                throws IOException

      Renders the network database status page.
      Parameters:
        `out` - Writer to output HTML
        `pageSize` - number of routers per page
        `page` - zero-based page index
        `mode` - rendering mode: 0 = summary charts, 1 = full router infos, 2 = compact router infos, 3 = summary charts sorted by country count
      Throws:
        `IOException`