java.lang.Object
org.klomp.snark.web.I2PSnarkConfigure
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 Summary
FieldsModifier and TypeFieldDescriptionprivate static final StringDummies for translation; prevents the ngettext line below from getting tagged.private static final StringPlaceholder option so a select is never empty.private static final StringCopied from ConfigTunnelsHelper.private static final String[]Tunnel parameters shown on the config page.private final I2PSnarkServletThe servlet whose settings are being edited.private static final int[]Refresh intervals offered on the page, in seconds.private static final StringForm value naming the tunnel settings section.Constructor Summary
ConstructorsConstructorDescriptionBind to the servlet whose protected helpers and settings this renderer calls.Method Summary
Modifier and TypeMethodDescriptionprivate voidBrowser Integration panel: nonce-free adds, allowed hosts, API key.private voidComments & Ratings panel: global toggles and the author name.private voidData Storage panel: directories, permissions, preallocation, file cap.private voidBrowser-handler install/update control plus the Save row.private voidTorrent Options panel: bandwidth, uploaders, open trackers, DHT, auto-start.private voidTunnel Configuration panel: destination, hop settings, multi-dest, I2CP.private voidappendUIConfig(StringBuilder buf, HttpServletRequest req) User Interface panel: theme, refresh interval, page size, language, collapsible panels, filter bar, lightbox, Add/Create persistence.voidParses the configuration form POST parameters and applies them via SnarkManager.private StringThe API key target for the Browser API panel, defaulting to the context name.private static StringBuilds the I2CP options string from the individual tunnel quantity and length form parameters, appended to the free-form "i2cpOpts" value.private StringrenderOptions(int min, int max, int dflt, String strNow, String selName, String name) Generates HTML for a dropdown selection menu.(package private) voidwriteConfigForm(PrintWriter out, HttpServletRequest req) Writes the HTML configuration form with all I2PSnark settings.(package private) voidWrites the HTML form for managing torrent creation file filters.(package private) voidwriteTrackerForm(PrintWriter out, HttpServletRequest req) Writes the HTML form for managing trackers with optimized string building.
Field Details
srv
The servlet whose settings are being edited.times
private static final int[] timesRefresh intervals offered on the page, in seconds.HOP
TUNNEL
Form value naming the tunnel settings section.- See Also:
DUMMY0
Dummies for translation; prevents the ngettext line below from getting tagged.- See Also:
DUMMY1
Placeholder option so a select is never empty.- See Also:
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
Writes the HTML configuration form with all I2PSnark settings.- Parameters:
out- the PrintWriter to write the HTML outputreq- the HTTP request containing query parameters- Throws:
IOException- if an I/O error occurs during writing
appendUIConfig
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 toreq- the request whose user agent decides whether the panels may collapse
appendCommentsRatingsConfig
Comments & Ratings panel: global toggles and the author name.- Parameters:
buf- the HTML of the panel is appended to
appendTorrentOptionsConfig
Torrent Options panel: bandwidth, uploaders, open trackers, DHT, auto-start.- Parameters:
buf- the HTML of the panel is appended to
appendDataStorageConfig
Data Storage panel: directories, permissions, preallocation, file cap.- Parameters:
buf- the HTML of the panel is appended to
appendTunnelConfig
Tunnel Configuration panel: destination, hop settings, multi-dest, I2CP.- Parameters:
buf- the HTML of the panel is appended to
appendBrowserIntegrationConfig
Browser Integration panel: nonce-free adds, allowed hosts, API key.- Parameters:
buf- the HTML of the panel is appended toreq- unused, kept for symmetry with the other panel methods
appendSaveConfigRow
Browser-handler install/update control plus the Save row.- Parameters:
buf- the HTML of the row is appended toreq- the request whose User-Agent decides whether the browser-handler row is shown
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
Writes the HTML form for managing torrent creation file filters.- Parameters:
out- the PrintWriter to which the HTML output will be writtenreq- the HttpServletRequest containing the current request parameters- Throws:
IOException- if an I/O error occurs while writing to the output stream
writeTrackerForm
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 writtenreq- 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 optionsmax- the maximum value for the dropdown optionsdflt- the default value for the dropdownstrNow- the string representation of the current selected optionselName- the name attribute for the select elementname- the base name of the option to be displayed in the dropdown- Returns:
- a string representing the HTML for the dropdown selection menu
applySettings
Parses the configuration form POST parameters and applies them via SnarkManager.- Parameters:
req- the configure-page POST request
buildI2CPOpts
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