java.lang.Object
org.klomp.snark.web.I2PSnarkConfigure

class I2PSnarkConfigureextends Object
Renders the three forms of the /configure page - main settings, torrent creation filters, and tracker management - and applies submitted settings back to SnarkManager. Extracted wholesale from I2PSnarkServlet; bodies are verbatim moves qualified for servlet access via srv.
  • Field Details

    • srv

      private final I2PSnarkServlet srv
      The servlet whose settings are being edited.
    • times

      private static final int[] times
      Refresh intervals offered on the page, in seconds.
    • HOP

      private static final String HOP
      Copied from ConfigTunnelsHelper.
      See Also:
    • TUNNEL

      private static final String TUNNEL
      Form value naming the tunnel settings section.
      See Also:
    • DUMMY0

      private static final String DUMMY0
      Dummies for translation; prevents the ngettext line below from getting tagged.
      See Also:
    • DUMMY1

      private static final String DUMMY1
      Placeholder option so a select is never empty.
      See Also:
    • iopts

      private static final String[] iopts
      Tunnel parameters shown on the config page.
  • Constructor Details

    • I2PSnarkConfigure

      I2PSnarkConfigure(I2PSnarkServlet srv)
      Bind to the servlet whose protected helpers and settings this renderer calls.
      Parameters:
      srv - the owning servlet, reached for its manager, context path and translation
  • Method Details

    • writeConfigForm

      void writeConfigForm(PrintWriter out, HttpServletRequest req) throws IOException
      Writes the HTML configuration form with all I2PSnark settings.
      Parameters:
      out - the PrintWriter to write the HTML output
      req - the HTTP request containing query parameters
      Throws:
      IOException - if an I/O error occurs during writing
    • appendUIConfig

      private void appendUIConfig(StringBuilder buf, HttpServletRequest req)
      User Interface panel: theme, refresh interval, page size, language, collapsible panels, filter bar, lightbox, Add/Create persistence.
      Parameters:
      buf - the HTML of the panel is appended to
      req - the request whose user agent decides whether the panels may collapse
    • appendCommentsRatingsConfig

      private void appendCommentsRatingsConfig(StringBuilder buf)
      Comments & Ratings panel: global toggles and the author name.
      Parameters:
      buf - the HTML of the panel is appended to
    • appendTorrentOptionsConfig

      private void appendTorrentOptionsConfig(StringBuilder buf)
      Torrent Options panel: bandwidth, uploaders, open trackers, DHT, auto-start.
      Parameters:
      buf - the HTML of the panel is appended to
    • appendDataStorageConfig

      private void appendDataStorageConfig(StringBuilder buf)
      Data Storage panel: directories, permissions, preallocation, file cap.
      Parameters:
      buf - the HTML of the panel is appended to
    • appendTunnelConfig

      private void appendTunnelConfig(StringBuilder buf)
      Tunnel Configuration panel: destination, hop settings, multi-dest, I2CP.
      Parameters:
      buf - the HTML of the panel is appended to
    • appendBrowserIntegrationConfig

      private void appendBrowserIntegrationConfig(StringBuilder buf, HttpServletRequest req)
      Browser Integration panel: nonce-free adds, allowed hosts, API key.
      Parameters:
      buf - the HTML of the panel is appended to
      req - unused, kept for symmetry with the other panel methods
    • appendSaveConfigRow

      private void appendSaveConfigRow(StringBuilder buf, HttpServletRequest req)
      Browser-handler install/update control plus the Save row.
      Parameters:
      buf - the HTML of the row is appended to
      req - the request whose User-Agent decides whether the browser-handler row is shown
    • browserApiTarget

      private String browserApiTarget()
      The API key target for the Browser API panel, defaulting to the context name.
      Returns:
      the configured target, or the servlet's context name when none is set
    • writeTorrentCreateFilterForm

      void writeTorrentCreateFilterForm(PrintWriter out, HttpServletRequest req) throws IOException
      Writes the HTML form for managing torrent creation file filters.
      Parameters:
      out - the PrintWriter to which the HTML output will be written
      req - the HttpServletRequest containing the current request parameters
      Throws:
      IOException - if an I/O error occurs while writing to the output stream
    • writeTrackerForm

      void writeTrackerForm(PrintWriter out, HttpServletRequest req) throws IOException
      Writes the HTML form for managing trackers with optimized string building. Minimizes append() calls by batching HTML fragments, and caches collections for efficient lookups.
      Parameters:
      out - the PrintWriter to which the HTML output will be written
      req - the HttpServletRequest containing the current request parameters
      Throws:
      IOException - if an I/O error occurs while writing to the output stream
    • renderOptions

      private String renderOptions(int min, int max, int dflt, String strNow, String selName, String name)
      Generates HTML for a dropdown selection menu.
      Parameters:
      min - the minimum value for the dropdown options
      max - the maximum value for the dropdown options
      dflt - the default value for the dropdown
      strNow - the string representation of the current selected option
      selName - the name attribute for the select element
      name - the base name of the option to be displayed in the dropdown
      Returns:
      a string representing the HTML for the dropdown selection menu
    • applySettings

      public void applySettings(HttpServletRequest req)
      Parses the configuration form POST parameters and applies them via SnarkManager.
      Parameters:
      req - the configure-page POST request
    • buildI2CPOpts

      private static String buildI2CPOpts(HttpServletRequest req)
      Builds the I2CP options string from the individual tunnel quantity and length form parameters, appended to the free-form "i2cpOpts" value.
      Parameters:
      req - the HTTP request containing tunnel configuration parameters
      Returns:
      the combined I2CP options string