org.klomp.snark.web

## Class I2PSnarkServlet

- java.lang.Object
- - javax.servlet.GenericServlet
  - - javax.servlet.http.HttpServlet
    - - org.klomp.snark.web.BasicServlet
      - - org.klomp.snark.web.I2PSnarkServlet

- All Implemented Interfaces:
    Serializable, Servlet, ServletConfig

      public class I2PSnarkServlet
      extends BasicServlet

  Web interface servlet for I2PSnark torrent management.

  This servlet provides the complete web-based user interface for I2PSnark, allowing users to manage their torrents through a browser. It handles:

  - Torrent listing and status display
  - Adding torrents from files, URLs, or magnet links
  - Torrent creation from local files
  - Peer management and connection monitoring
  - Bandwidth configuration and statistics
  - DHT and tracker status
  - Comments and ratings system
  - File browsing and downloading
  - Configuration management
  - Theme and localization support

  The servlet has been refactored to eliminate Jetty-specific dependencies and works with standard servlet containers.

  Security features include:

  - CSRF protection via nonces
  - Content Security Policy headers
  - Input validation and sanitization
  - Secure file handling
  See Also:
    Serialized Form

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from class org.klomp.snark.web.BasicServlet

      `BasicServlet.HttpContent`

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `(package private) String` | `cspNonce`
    `(package private) static char` | `HELLIP`
    `(package private) static int` | `MAX_DISPLAYED_FILENAME_LENGTH`
    `static String` | `PROP_CONFIG_FILE`
    `static String` | `WARBASE`

    - ### Fields inherited from class org.klomp.snark.web.BasicServlet

      `_context, _log, _resourceBase`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `I2PSnarkServlet()`

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `destroy()`
    `void` | `doGet(HttpServletRequest request, HttpServletResponse response)` Handle what we can here, calling super.doGet() for the rest.
    `void` | `doPost(HttpServletRequest request, HttpServletResponse response)` Handle what we can here, calling super.doPost() for the rest.
    `File` | `getResource(String pathInContext)` We override this to set the file relative to the storage directory for the torrent.
    `void` | `init(ServletConfig cfg)`
    `boolean` | `isAdvanced()`
    `(package private) String` | `toIcon(String path)` Returns the icon name representing the file type or mime type of the given file path.
    `(package private) static String` | `urlify(String s)` This is for a full URL.
    `boolean` | `useSoraFont()`

    - ### Methods inherited from class org.klomp.snark.web.BasicServlet

      `addMimeMapping, addPaths, decodePath, doDelete, doOptions, doTrace, encodePath, getContent, getMimeType, loadMimeMap, passConditionalHeaders, sendData, setResourceBase, setWarBase, writeHeaders`

    - ### Methods inherited from class javax.servlet.http.HttpServlet

      `doHead, doPut, getLastModified, service, service`

    - ### Methods inherited from class javax.servlet.GenericServlet

      `getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, log, log`

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

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

- - ### Field Detail

    - #### cspNonce

          String cspNonce

    - #### HELLIP

          static final char HELLIP

      See Also:
        Constant Field Values

    - #### MAX_DISPLAYED_FILENAME_LENGTH

          static final int MAX_DISPLAYED_FILENAME_LENGTH

      See Also:
        Constant Field Values

    - #### PROP_CONFIG_FILE

          public static final String PROP_CONFIG_FILE

      See Also:
        Constant Field Values

    - #### WARBASE

          public static final String WARBASE

      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### I2PSnarkServlet

          public I2PSnarkServlet()

  - ### Method Detail

    - #### destroy

          public void destroy()

      Specified by:
        `destroy` in interface `Servlet`
      Overrides:
        `destroy` in class `GenericServlet`

    - #### doGet

          public void doGet(HttpServletRequest request,
                            HttpServletResponse response)
                     throws ServletException,
                            IOException

      Handle what we can here, calling super.doGet() for the rest.
      Overrides:
        `doGet` in class `BasicServlet`
      Throws:
        `ServletException`
        `IOException`

    - #### doPost

          public void doPost(HttpServletRequest request,
                             HttpServletResponse response)
                      throws ServletException,
                             IOException

      Handle what we can here, calling super.doPost() for the rest.
      Overrides:
        `doPost` in class `BasicServlet`
      Throws:
        `ServletException`
        `IOException`

    - #### getResource

          public File getResource(String pathInContext)

      We override this to set the file relative to the storage directory for the torrent.
      Overrides:
        `getResource` in class `BasicServlet`
      Parameters:
        `pathInContext` - should always start with /
      Returns:
        The resource to serve or null if not existing

    - #### init

          public void init(ServletConfig cfg)
                    throws ServletException

      Specified by:
        `init` in interface `Servlet`
      Overrides:
        `init` in class `BasicServlet`
      Throws:
        `ServletException`

    - #### isAdvanced

          public boolean isAdvanced()

    - #### toIcon

          String toIcon(String path)

      Returns the icon name representing the file type or mime type of the given file path. Determines custom icons for certain special cases like i2p install executables.
      Parameters:
        `path` - the file path or file name to analyze
      Returns:
        a string representing the icon name matching the file type

    - #### urlify

          static String urlify(String s)

      This is for a full URL. For a path only, use encodePath().

    - #### useSoraFont

          public boolean useSoraFont()