org.klomp.snark

## Class SnarkManager

- java.lang.Object
- - org.klomp.snark.SnarkManager

- All Implemented Interfaces:
    ClientApp, I2PSocketManager.DisconnectListener, CompleteListener

      public class SnarkManager
      extends Object
      implements CompleteListener, ClientApp, I2PSocketManager.DisconnectListener

  Central manager for multiple torrent downloads and the I2PSnark application.

  This class is the core controller that manages:

  - Multiple torrent instances (Snarks) and their lifecycle
  - Configuration management and persistence
  - Peer coordination and bandwidth management
  - Tracker communication and DHT integration
  - Web interface and user interaction
  - Torrent file monitoring and auto-loading
  - Magnet link handling
  - Comments and metadata management

  As a ClientApp, it integrates with the I2P router application framework and can be started, stopped, and monitored through the standard I2P interfaces.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static String` | `CONFIG_DIR_SUFFIX`
    `static String` | `CONFIG_FILE`
    `static String` | `DEFAULT_BACKUP_TRACKER` URL.
    `static String` | `DEFAULT_ENABLE_ADDCREATE`
    `static String` | `DEFAULT_ENABLE_LIGHTBOX`
    `static int` | `DEFAULT_MAX_FILES_PER_TORRENT`
    `static int` | `DEFAULT_MAX_UP_BW`
    `static String` | `DEFAULT_PREALLOCATE_FILES`
    `static int` | `DEFAULT_REFRESH_DELAY_SECS`
    `static String` | `DEFAULT_SHOW_STATUSFILTER`
    `static int` | `DEFAULT_STARTUP_DELAY`
    `static String` | `DEFAULT_THEME`
    `static Set<String>` | `DEFAULT_TRACKER_ANNOUNCES`
    `static int` | `DEFAULT_TUNNEL_QUANTITY`
    `(package private) static Set<String>` | `KNOWN_OPENTRACKERS` host names for config form
    `static int` | `MIN_DOWN_BW`
    `static int` | `MIN_UP_BW`
    `static String` | `PROP_AUTO_START`
    `static String` | `PROP_COLLAPSE_PANELS`
    `static String` | `PROP_DIR`
    `static String` | `PROP_DOWNBW_MAX`
    `static String` | `PROP_ENABLE_ADDCREATE`
    `static String` | `PROP_ENABLE_LIGHTBOX`
    `static String` | `PROP_FILES_PUBLIC`
    `static String` | `PROP_I2CP_HOST`
    `static String` | `PROP_I2CP_OPTS`
    `static String` | `PROP_I2CP_PORT`
    `static String` | `PROP_MAX_FILES_PER_TORRENT`
    `static String` | `PROP_MAX_MESSAGES`
    `static String` | `PROP_OLD_AUTO_START`
    `static String` | `PROP_OPENTRACKERS`
    `static String` | `PROP_PAGE_SIZE`
    `static String` | `PROP_PREALLOCATE_FILES`
    `static String` | `PROP_PRIVATETRACKERS`
    `static String` | `PROP_REFRESH_DELAY`
    `static String` | `PROP_SHOW_STATUSFILTER`
    `static String` | `PROP_STARTUP_DELAY`
    `static String` | `PROP_THEME`
    `static String` | `PROP_TORRENT_CREATE_FILTERS` comma delimited list of name=filterPattern for torrent create filters.
    `static String` | `PROP_TORRENT_FILTERS_CONFIG` filename for serialized torrent filters config
    `static String` | `PROP_TRACKERS` comma delimited list of name=announceURL=baseURL for the trackers to be displayed
    `static String` | `PROP_UPBW_MAX`
    `static String` | `PROP_UPLOADERS_TOTAL`
    `static String` | `PROP_VARY_INBOUND_HOPS`
    `static String` | `PROP_VARY_OUTBOUND_HOPS`
    `static String` | `RC_PROP_THEME`
    `static String` | `RC_PROP_UNIVERSAL_THEMING`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `SnarkManager(I2PAppContext ctx)` For embedded.
    `SnarkManager(I2PAppContext ctx, String ctxPath, String ctxName)` For webapp.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addDownloader(Snark torrent)` Add and start a FetchAndAdd task.
    `void` | `addMagnet(String name, byte[] ih, String trackerURL, boolean updateStatus)` Add a torrent with the info hash alone (magnet / maggot)
    `Snark` | `addMagnet(String name, byte[] ih, String trackerURL, boolean updateStatus, boolean autoStart, File dataDir, CompleteListener listener)` Add a torrent with the info hash alone (magnet / maggot) External use is for UpdateRunner.
    `void` | `addMagnet(String name, byte[] ih, String trackerURL, boolean updateStatus, File dataDir)` Add a torrent with the info hash alone (magnet / maggot)
    `void` | `addMessage(Snark snark, String message)` A Snark.CompleteListener method.
    `void` | `addMessage(String message)` Use if it does not include a link.
    `void` | `addMessageNoEscape(String message)` Use if it includes a link.
    `boolean` | `addTorrent(MetaInfo metainfo, BitField bitfield, String filename, File baseFile, boolean dontAutoStart)` Add a torrent from a MetaInfo.
    `boolean` | `areFilesPublic()`
    `void` | `clearMessages()`
    `void` | `clearMessages(int id)` Clear through this id
    `boolean` | `copyAndAddTorrent(File fromfile, String filename, File dataDir)` Add a torrent from a file not in the torrent directory.
    `void` | `deleteMagnet(Snark snark)` Stop and delete a torrent running in magnet mode
    `void` | `fatal(Snark snark, String error)` A Snark.CompleteListener method.
    `BandwidthListener` | `getBandwidthListener()` The BandwidthManager.
    `File` | `getConfigDir()` For RPC
    `int` | `getCreateFilterCount()` Returns the current number of configured file filters
    `File` | `getDataDir()`
    `String` | `getDiskUsage()`
    `String` | `getDisplayName()` ClientApp method.
    `int` | `getMaxFilesPerTorrent()`
    `int` | `getMaxLogMessages()`
    `List<UIMessages.Message>` | `getMessages()` newest last
    `String` | `getName()` ClientApp method.
    `int` | `getPageSize()` For GUI
    `List<String>` | `getPrivateTrackers()`
    `int` | `getRefreshDelaySeconds()`
    `long[]` | `getSavedAddedAndCompleted(Snark snark)` Get setting for a torrent from the config file.
    `CommentSet` | `getSavedComments(Snark snark)` The comments for a torrent
    `boolean` | `getSavedCommentsEnabled(Snark snark)` Get setting for comments enabled from the config file.
    `boolean` | `getSavedPreserveNamesSetting(Snark snark)` Get setting for a torrent from the config file.
    `BitField` | `getSavedTorrentBitField(Snark snark)` Get the saved bitfield for a torrent from the config file.
    `long` | `getSavedTorrentTime(Snark snark)` Get the timestamp for a torrent from the config file.
    `long` | `getSavedUploaded(Snark snark)` Get setting for a torrent from the config file.
    `List<TorrentCreateFilter>` | `getSortedTorrentCreateFilterStrings()` Sorted copy
    `List<Tracker>` | `getSortedTrackers()` Sorted copy
    `ClientAppState` | `getState()` ClientApp method.
    `String` | `getTheme()` Get current theme.
    `String[]` | `getThemes()` Get all themes
    `String` | `getTime()`
    `Snark` | `getTorrent(String filename)` Grab the torrent given the (canonical) filename of the .torrent file
    `Snark` | `getTorrentByBaseName(String filename)` Grab the torrent given the base name of the storage
    `Snark` | `getTorrentByInfoHash(byte[] infohash)` Grab the torrent given the info hash
    `Map<String,TorrentCreateFilter>` | `getTorrentCreateFilterMap()` Unsorted map of name to TorrentCreateFilter object Modifiable, not a copy
    `Collection<TorrentCreateFilter>` | `getTorrentCreateFilterStrings()` Unsorted, do not modify
    `Collection<Snark>` | `getTorrents()` Unmodifiable
    `Map<String,Tracker>` | `getTrackerMap()` Unsorted map of name to Tracker object Modifiable, not a copy
    `Collection<Tracker>` | `getTrackers()` Unsorted, do not modify
    `boolean` | `getUniversalTheming()`
    `String` | `gotMetaInfo(Snark snark)` We transitioned from magnet mode, we have now initialized our metainfo and storage.
    `void` | `gotPiece(Snark snark)` A Snark.CompleteListener method.
    `boolean` | `hasModifiedTrackers()` Has the default tracker list been modified?
    `boolean` | `isCollapsePanelsEnabled()`
    `boolean` | `isEnableLightbox()`
    `boolean` | `isShowStatusFilter()`
    `boolean` | `isSmartSortEnabled()`
    `boolean` | `isStopping()`
    `boolean` | `isVaryInboundHops()`
    `boolean` | `isVaryOutboundHops()`
    `Set<String>` | `listTorrentFiles()` Set of canonical .torrent filenames that we are dealing with.
    `void` | `loadConfig(String filename)`
    `void` | `loadSavedFilePriorities(Snark snark)` Get the saved priorities for a torrent from the config file.
    `void` | `locked_saveComments(Snark snark, CommentSet comments)` Save the comments for a torrent Caller must synchronize on comments.
    `void` | `recheckTorrent(Snark snark)` Threaded.
    `void` | `removeMagnetStatus(byte[] ih)` Remove the magnet marker from the config file.
    `void` | `removeTorrent(String filename)` Stop the torrent and delete the torrent file itself, but leaving the data behind.
    `void` | `saveConfig()`
    `void` | `saveMagnetStatus(byte[] ih, String dir, String trackerURL, String dn)` Just remember we have it.
    `void` | `saveOpenTrackers(List<String> ot)`
    `void` | `savePrivateTrackers(List<String> pt)`
    `void` | `saveTorrentCreateFilterMap()`
    `void` | `saveTorrentStatus(Snark snark)` Save the completion status of a torrent and other data in the config file for that torrent.
    `void` | `saveTrackerMap()`
    `void` | `sessionDisconnected()` DisconnectListener interface
    `void` | `setDefaultTorrentCreateFilterMap()`
    `void` | `setDefaultTrackerMap()`
    `void` | `setSavedCommentsEnabled(Snark snark, boolean yes)` Set setting for comments enabled in the config file.
    `boolean` | `shouldAutoStart()`
    `boolean` | `shouldPreallocateFiles()`
    `void` | `shutdown(String[] args)` ClientApp method.
    `void` | `start()` Caller _must_ call loadConfig(file) before this if setting new values for i2cp host/port or i2psnark.dir
    `void` | `startAllTorrents()` Always thread it
    `void` | `startTorrent(byte[] infoHash)` If not connected, thread it, otherwise inline
    `void` | `startTorrent(Snark snark)` If not connected, thread it, otherwise inline
    `void` | `startup()` ClientApp method.
    `void` | `stop()`
    `void` | `stopAllTorrents(boolean finalShutdown)` Stop all running torrents, and close the tunnel after a delay to allow for announces.
    `void` | `stopTorrent(Snark torrent)` Stop the torrent only, leaving it on the list of torrents.
    `void` | `stopTorrent(Snark torrent, boolean shouldRemove)` Stop the torrent, leaving it on the list of torrents unless told to remove it.
    `Snark` | `stopTorrent(String filename, boolean shouldRemove)` Stop the torrent, leaving it on the list of torrents unless told to remove it.
    `void` | `torrentComplete(Snark snark)` A Snark.CompleteListener method.
    `void` | `updateConfig(String dataDir, boolean filesPublic, boolean autoStart, String refreshDelay, String startDelay, String pageSize, String seedPct, String eepHost, String eepPort, String i2cpHost, String i2cpPort, String i2cpOpts, String upLimit, String upBW, String downBW, boolean useOpenTrackers, boolean useDHT, String theme, String lang, boolean enableRatings, boolean enableComments, String commentName, boolean collapsePanels, boolean showStatusFilter, boolean enableLightbox, boolean enableAddCreate, boolean enableVaryInboundHops, boolean enableVaryOutboundHops, String apiTarget, String apiKey)` all params may be null or need trimming
    `void` | `updateStatus(Snark snark)` A Snark.CompleteListener method.
    `I2PSnarkUtil` | `util()` hook to I2PSnarkUtil for the servlet

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

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

- - ### Field Detail

    - #### CONFIG_DIR_SUFFIX

          public static final String CONFIG_DIR_SUFFIX

      See Also:
        Constant Field Values

    - #### CONFIG_FILE

          public static final String CONFIG_FILE

      See Also:
        Constant Field Values

    - #### DEFAULT_BACKUP_TRACKER

          public static final String DEFAULT_BACKUP_TRACKER

      URL. This is our equivalent to router.utorrent.com for bootstrap
      See Also:
        Constant Field Values

    - #### DEFAULT_ENABLE_ADDCREATE

          public static final String DEFAULT_ENABLE_ADDCREATE

      See Also:
        Constant Field Values

    - #### DEFAULT_ENABLE_LIGHTBOX

          public static final String DEFAULT_ENABLE_LIGHTBOX

      See Also:
        Constant Field Values

    - #### DEFAULT_MAX_FILES_PER_TORRENT

          public static final int DEFAULT_MAX_FILES_PER_TORRENT

      See Also:
        Constant Field Values

    - #### DEFAULT_MAX_UP_BW

          public static final int DEFAULT_MAX_UP_BW

      See Also:
        Constant Field Values

    - #### DEFAULT_PREALLOCATE_FILES

          public static final String DEFAULT_PREALLOCATE_FILES

      See Also:
        Constant Field Values

    - #### DEFAULT_REFRESH_DELAY_SECS

          public static final int DEFAULT_REFRESH_DELAY_SECS

      See Also:
        Constant Field Values

    - #### DEFAULT_SHOW_STATUSFILTER

          public static final String DEFAULT_SHOW_STATUSFILTER

      See Also:
        Constant Field Values

    - #### DEFAULT_STARTUP_DELAY

          public static final int DEFAULT_STARTUP_DELAY

      See Also:
        Constant Field Values

    - #### DEFAULT_THEME

          public static final String DEFAULT_THEME

      See Also:
        Constant Field Values

    - #### DEFAULT_TRACKER_ANNOUNCES

          public static final Set<String> DEFAULT_TRACKER_ANNOUNCES

    - #### DEFAULT_TUNNEL_QUANTITY

          public static final int DEFAULT_TUNNEL_QUANTITY

      See Also:
        Constant Field Values

    - #### KNOWN_OPENTRACKERS

          static final Set<String> KNOWN_OPENTRACKERS

      host names for config form

    - #### MIN_DOWN_BW

          public static final int MIN_DOWN_BW

      See Also:
        Constant Field Values

    - #### MIN_UP_BW

          public static final int MIN_UP_BW

      See Also:
        Constant Field Values

    - #### PROP_AUTO_START

          public static final String PROP_AUTO_START

      See Also:
        Constant Field Values

    - #### PROP_COLLAPSE_PANELS

          public static final String PROP_COLLAPSE_PANELS

      See Also:
        Constant Field Values

    - #### PROP_DIR

          public static final String PROP_DIR

      See Also:
        Constant Field Values

    - #### PROP_DOWNBW_MAX

          public static final String PROP_DOWNBW_MAX

      See Also:
        Constant Field Values

    - #### PROP_ENABLE_ADDCREATE

          public static final String PROP_ENABLE_ADDCREATE

      See Also:
        Constant Field Values

    - #### PROP_ENABLE_LIGHTBOX

          public static final String PROP_ENABLE_LIGHTBOX

      See Also:
        Constant Field Values

    - #### PROP_FILES_PUBLIC

          public static final String PROP_FILES_PUBLIC

      See Also:
        Constant Field Values

    - #### PROP_I2CP_HOST

          public static final String PROP_I2CP_HOST

      See Also:
        Constant Field Values

    - #### PROP_I2CP_OPTS

          public static final String PROP_I2CP_OPTS

      See Also:
        Constant Field Values

    - #### PROP_I2CP_PORT

          public static final String PROP_I2CP_PORT

      See Also:
        Constant Field Values

    - #### PROP_MAX_FILES_PER_TORRENT

          public static final String PROP_MAX_FILES_PER_TORRENT

      See Also:
        Constant Field Values

    - #### PROP_MAX_MESSAGES

          public static final String PROP_MAX_MESSAGES

      See Also:
        Constant Field Values

    - #### PROP_OLD_AUTO_START

          public static final String PROP_OLD_AUTO_START

      See Also:
        Constant Field Values

    - #### PROP_OPENTRACKERS

          public static final String PROP_OPENTRACKERS

      See Also:
        Constant Field Values

    - #### PROP_PAGE_SIZE

          public static final String PROP_PAGE_SIZE

      See Also:
        Constant Field Values

    - #### PROP_PREALLOCATE_FILES

          public static final String PROP_PREALLOCATE_FILES

      See Also:
        Constant Field Values

    - #### PROP_PRIVATETRACKERS

          public static final String PROP_PRIVATETRACKERS

      See Also:
        Constant Field Values

    - #### PROP_REFRESH_DELAY

          public static final String PROP_REFRESH_DELAY

      See Also:
        Constant Field Values

    - #### PROP_SHOW_STATUSFILTER

          public static final String PROP_SHOW_STATUSFILTER

      See Also:
        Constant Field Values

    - #### PROP_STARTUP_DELAY

          public static final String PROP_STARTUP_DELAY

      See Also:
        Constant Field Values

    - #### PROP_THEME

          public static final String PROP_THEME

      See Also:
        Constant Field Values

    - #### PROP_TORRENT_CREATE_FILTERS

          public static final String PROP_TORRENT_CREATE_FILTERS

      comma delimited list of name=filterPattern for torrent create filters. Deprecated. If detected, filters will be converted to new storage and then this config will be removed.
      See Also:
        Constant Field Values

    - #### PROP_TORRENT_FILTERS_CONFIG

          public static final String PROP_TORRENT_FILTERS_CONFIG

      filename for serialized torrent filters config
      See Also:
        Constant Field Values

    - #### PROP_TRACKERS

          public static final String PROP_TRACKERS

      comma delimited list of name=announceURL=baseURL for the trackers to be displayed
      See Also:
        Constant Field Values

    - #### PROP_UPBW_MAX

          public static final String PROP_UPBW_MAX

      See Also:
        Constant Field Values

    - #### PROP_UPLOADERS_TOTAL

          public static final String PROP_UPLOADERS_TOTAL

      See Also:
        Constant Field Values

    - #### PROP_VARY_INBOUND_HOPS

          public static final String PROP_VARY_INBOUND_HOPS

      See Also:
        Constant Field Values

    - #### PROP_VARY_OUTBOUND_HOPS

          public static final String PROP_VARY_OUTBOUND_HOPS

      See Also:
        Constant Field Values

    - #### RC_PROP_THEME

          public static final String RC_PROP_THEME

      See Also:
        Constant Field Values

    - #### RC_PROP_UNIVERSAL_THEMING

          public static final String RC_PROP_UNIVERSAL_THEMING

      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### SnarkManager

          public SnarkManager(I2PAppContext ctx)

      For embedded.

    - #### SnarkManager

          public SnarkManager(I2PAppContext ctx,
                              String ctxPath,
                              String ctxName)

      For webapp.
      Parameters:
        `ctxPath` - generally "/i2psnark"
        `ctxName` - generally "i2psnark"

  - ### Method Detail

    - #### addDownloader

          public void addDownloader(Snark torrent)

      Add and start a FetchAndAdd task. Remove it with deleteMagnet().
      Parameters:
        `torrent` - must be instanceof FetchAndAdd
      Throws:
        `RuntimeException` - via Snark.fatal()?

    - #### addMagnet

          public void addMagnet(String name,
                                byte[] ih,
                                String trackerURL,
                                boolean updateStatus)

      Add a torrent with the info hash alone (magnet / maggot)
      Parameters:
        `name` - hex or b32 name from the magnet link
        `ih` - 20 byte info hash
        `trackerURL` - may be null
        `updateStatus` - should we add this magnet to the config file, to save it across restarts, in case we don't get the metadata before shutdown?
      Throws:
        `RuntimeException` - via Snark.fatal()

    - #### addMagnet

          public Snark addMagnet(String name,
                                 byte[] ih,
                                 String trackerURL,
                                 boolean updateStatus,
                                 boolean autoStart,
                                 File dataDir,
                                 CompleteListener listener)

      Add a torrent with the info hash alone (magnet / maggot) External use is for UpdateRunner.
      Parameters:
        `name` - hex or b32 name from the magnet link
        `ih` - 20 byte info hash
        `trackerURL` - may be null
        `updateStatus` - should we add this magnet to the config file, to save it across restarts, in case we don't get the metadata before shutdown?
        `dataDir` - must exist, or null to default to snark data directory
        `listener` - to intercept callbacks, should pass through to this
      Returns:
        the new Snark or null on failure
      Throws:
        `RuntimeException` - via Snark.fatal()

    - #### addMagnet

          public void addMagnet(String name,
                                byte[] ih,
                                String trackerURL,
                                boolean updateStatus,
                                File dataDir)

      Add a torrent with the info hash alone (magnet / maggot)
      Parameters:
        `name` - hex or b32 name from the magnet link
        `ih` - 20 byte info hash
        `trackerURL` - may be null
        `updateStatus` - should we add this magnet to the config file, to save it across restarts, in case we don't get the metadata before shutdown?
        `dataDir` - must exist, or null to default to snark data directory
      Throws:
        `RuntimeException` - via Snark.fatal()

    - #### addMessage

          public void addMessage(Snark snark,
                                 String message)

      A Snark.CompleteListener method.
      Specified by:
        `addMessage` in interface `CompleteListener`

    - #### addMessage

          public void addMessage(String message)

      Use if it does not include a link. Escapes '<' and '>' before queueing

    - #### addMessageNoEscape

          public void addMessageNoEscape(String message)

      Use if it includes a link. Does not escape '<' and '>' before queueing

    - #### addTorrent

          public boolean addTorrent(MetaInfo metainfo,
                                    BitField bitfield,
                                    String filename,
                                    File baseFile,
                                    boolean dontAutoStart)
                             throws IOException

      Add a torrent from a MetaInfo. Save the MetaInfo data to filename. Holds the snarks lock to prevent interference from the DirMonitor. This verifies that a torrent with this infohash is not already added. This may take a LONG time to create or check the storage.

      Called from servlet. This is only for the 'create torrent' form.

      Parameters:
        `metainfo` - the metainfo for the torrent
        `bitfield` - the current completion status of the torrent, or null
        `filename` - the absolute path to save the metainfo to, generally ending in ".torrent", which is also the name of the torrent Must be a filesystem-safe name. If null, will generate a name from the metainfo.
        `baseFile` - may be null, if so look in rootDataDir
      Returns:
        success
      Throws:
        `RuntimeException` - via Snark.fatal()
        `IOException`

    - #### areFilesPublic

          public boolean areFilesPublic()

      Returns:
        default false

    - #### clearMessages

          public void clearMessages()

    - #### clearMessages

          public void clearMessages(int id)

      Clear through this id

    - #### copyAndAddTorrent

          public boolean copyAndAddTorrent(File fromfile,
                                           String filename,
                                           File dataDir)
                                    throws IOException

      Add a torrent from a file not in the torrent directory. Copy the file to filename. Holds the snarks lock to prevent interference from the DirMonitor. Caller must verify this torrent is not already added. This may take a LONG time to create or check the storage.
      Parameters:
        `fromfile` - where the file is now, presumably in a temp directory somewhere
        `filename` - the absolute path to save the metainfo to, generally ending in ".torrent", which is also the name of the torrent Must be a filesystem-safe name.
        `dataDir` - must exist, or null to default to snark data directory
      Returns:
        success
      Throws:
        `RuntimeException` - via Snark.fatal()
        `IOException`

    - #### deleteMagnet

          public void deleteMagnet(Snark snark)

      Stop and delete a torrent running in magnet mode
      Parameters:
        `snark` - a torrent with a fake file name ("Magnet xxxx")

    - #### fatal

          public void fatal(Snark snark,
                            String error)

      A Snark.CompleteListener method.
      Specified by:
        `fatal` in interface `CompleteListener`

    - #### getBandwidthListener

          public BandwidthListener getBandwidthListener()

      The BandwidthManager.
      Specified by:
        `getBandwidthListener` in interface `CompleteListener`

    - #### getConfigDir

          public File getConfigDir()

      For RPC

    - #### getCreateFilterCount

          public int getCreateFilterCount()

      Returns the current number of configured file filters

    - #### getDataDir

          public File getDataDir()

    - #### getDiskUsage

          public String getDiskUsage()

    - #### getDisplayName

          public String getDisplayName()

      ClientApp method.
      Specified by:
        `getDisplayName` in interface `ClientApp`
      Returns:
        non-null

    - #### getMaxFilesPerTorrent

          public int getMaxFilesPerTorrent()

    - #### getMaxLogMessages

          public int getMaxLogMessages()

    - #### getMessages

          public List<UIMessages.Message> getMessages()

      newest last

    - #### getName

          public String getName()

      ClientApp method.
      Specified by:
        `getName` in interface `ClientApp`
      Returns:
        non-null

    - #### getPageSize

          public int getPageSize()

      For GUI

    - #### getPrivateTrackers

          public List<String> getPrivateTrackers()

      Returns:
        non-null, fixed size, may be empty or unmodifiable

    - #### getRefreshDelaySeconds

          public int getRefreshDelaySeconds()

      Returns:
        -1 for never

    - #### getSavedAddedAndCompleted

          public long[] getSavedAddedAndCompleted(Snark snark)

      Get setting for a torrent from the config file.
      Returns:
        non-null, rv[0] is added time or 0; rv[1] is completed time or 0

    - #### getSavedComments

          public CommentSet getSavedComments(Snark snark)

      The comments for a torrent
      Specified by:
        `getSavedComments` in interface `CompleteListener`
      Returns:
        null if none

    - #### getSavedCommentsEnabled

          public boolean getSavedCommentsEnabled(Snark snark)

      Get setting for comments enabled from the config file. Caller must first check global I2PSnarkUtil.commentsEnabled() Default true.

    - #### getSavedPreserveNamesSetting

          public boolean getSavedPreserveNamesSetting(Snark snark)

      Get setting for a torrent from the config file.
      Specified by:
        `getSavedPreserveNamesSetting` in interface `CompleteListener`
      Returns:
        setting, false if not found

    - #### getSavedTorrentBitField

          public BitField getSavedTorrentBitField(Snark snark)

      Get the saved bitfield for a torrent from the config file. Convert "." to a full bitfield. A Snark.CompleteListener method.
      Specified by:
        `getSavedTorrentBitField` in interface `CompleteListener`

    - #### getSavedTorrentTime

          public long getSavedTorrentTime(Snark snark)

      Get the timestamp for a torrent from the config file. A Snark.CompleteListener method.
      Specified by:
        `getSavedTorrentTime` in interface `CompleteListener`

    - #### getSavedUploaded

          public long getSavedUploaded(Snark snark)

      Get setting for a torrent from the config file.
      Specified by:
        `getSavedUploaded` in interface `CompleteListener`
      Returns:
        setting, 0 if not found

    - #### getSortedTorrentCreateFilterStrings

          public List<TorrentCreateFilter> getSortedTorrentCreateFilterStrings()

      Sorted copy

    - #### getSortedTrackers

          public List<Tracker> getSortedTrackers()

      Sorted copy

    - #### getState

          public ClientAppState getState()

      ClientApp method. Doesn't matter, we are only registering.
      Specified by:
        `getState` in interface `ClientApp`
      Returns:
        INITIALIZED always.

    - #### getTheme

          public String getTheme()

      Get current theme.
      Returns:
        String -- the current theme

    - #### getThemes

          public String[] getThemes()

      Get all themes
      Returns:
        String[] -- Array of all the themes found, non-null, unsorted

    - #### getTime

          public String getTime()

    - #### getTorrent

          public Snark getTorrent(String filename)

      Grab the torrent given the (canonical) filename of the .torrent file
      Returns:
        Snark or null

    - #### getTorrentByBaseName

          public Snark getTorrentByBaseName(String filename)

      Grab the torrent given the base name of the storage
      Parameters:
        `filename` - must be the filtered name, which may be different than the metainfo's name
      Returns:
        Snark or null

    - #### getTorrentByInfoHash

          public Snark getTorrentByInfoHash(byte[] infohash)

      Grab the torrent given the info hash
      Returns:
        Snark or null

    - #### getTorrentCreateFilterMap

          public Map<String,TorrentCreateFilter> getTorrentCreateFilterMap()

      Unsorted map of name to TorrentCreateFilter object Modifiable, not a copy

    - #### getTorrentCreateFilterStrings

          public Collection<TorrentCreateFilter> getTorrentCreateFilterStrings()

      Unsorted, do not modify

    - #### getTorrents

          public Collection<Snark> getTorrents()

      Unmodifiable

    - #### getTrackerMap

          public Map<String,Tracker> getTrackerMap()

      Unsorted map of name to Tracker object Modifiable, not a copy

    - #### getTrackers

          public Collection<Tracker> getTrackers()

      Unsorted, do not modify

    - #### getUniversalTheming

          public boolean getUniversalTheming()

    - #### gotMetaInfo

          public String gotMetaInfo(Snark snark)

      We transitioned from magnet mode, we have now initialized our metainfo and storage. The listener should now call getMetaInfo() and save the data to disk. A Snark.CompleteListener method.
      Specified by:
        `gotMetaInfo` in interface `CompleteListener`
      Returns:
        the new name for the torrent or null on error

    - #### gotPiece

          public void gotPiece(Snark snark)

      A Snark.CompleteListener method.
      Specified by:
        `gotPiece` in interface `CompleteListener`

    - #### hasModifiedTrackers

          public boolean hasModifiedTrackers()

      Has the default tracker list been modified?

    - #### isCollapsePanelsEnabled

          public boolean isCollapsePanelsEnabled()

      Returns:
        default true

    - #### isEnableLightbox

          public boolean isEnableLightbox()

      Returns:
        default true

    - #### isShowStatusFilter

          public boolean isShowStatusFilter()

      Returns:
        default false

    - #### isSmartSortEnabled

          public boolean isSmartSortEnabled()

      Returns:
        default false

    - #### isStopping

          public boolean isStopping()

    - #### isVaryInboundHops

          public boolean isVaryInboundHops()

      Returns:
        default false

    - #### isVaryOutboundHops

          public boolean isVaryOutboundHops()

      Returns:
        default false

    - #### listTorrentFiles

          public Set<String> listTorrentFiles()

      Set of canonical .torrent filenames that we are dealing with. An unsynchronized copy.

    - #### loadConfig

          public void loadConfig(String filename)

      Parameters:
        `filename` - null to set initial defaults

    - #### loadSavedFilePriorities

          public void loadSavedFilePriorities(Snark snark)

      Get the saved priorities for a torrent from the config file.

    - #### locked_saveComments

          public void locked_saveComments(Snark snark,
                                          CommentSet comments)

      Save the comments for a torrent Caller must synchronize on comments.
      Specified by:
        `locked_saveComments` in interface `CompleteListener`
      Parameters:
        `comments` - non-null

    - #### recheckTorrent

          public void recheckTorrent(Snark snark)

      Threaded. Torrent must be stopped.

    - #### removeMagnetStatus

          public void removeMagnetStatus(byte[] ih)

      Remove the magnet marker from the config file.

    - #### removeTorrent

          public void removeTorrent(String filename)

      Stop the torrent and delete the torrent file itself, but leaving the data behind. Removes saved config file also. Holds the snarks lock to prevent interference from the DirMonitor.

    - #### saveConfig

          public void saveConfig()

    - #### saveMagnetStatus

          public void saveMagnetStatus(byte[] ih,
                                       String dir,
                                       String trackerURL,
                                       String dn)

      Just remember we have it. This used to simply store a line in the config file, but now we also save it in its own config file, just like other torrents, so we can remember the directory, tracker, etc.
      Parameters:
        `dir` - may be null
        `trackerURL` - may be null
        `dn` - may be null

    - #### saveOpenTrackers

          public void saveOpenTrackers(List<String> ot)

      Parameters:
        `ot` - null to restore default

    - #### savePrivateTrackers

          public void savePrivateTrackers(List<String> pt)

      Parameters:
        `pt` - null ok, default is none

    - #### saveTorrentCreateFilterMap

          public void saveTorrentCreateFilterMap()

    - #### saveTorrentStatus

          public void saveTorrentStatus(Snark snark)

      Save the completion status of a torrent and other data in the config file for that torrent. Does nothing for magnets.

    - #### saveTrackerMap

          public void saveTrackerMap()

    - #### sessionDisconnected

          public void sessionDisconnected()

      DisconnectListener interface
      Specified by:
        `sessionDisconnected` in interface `I2PSocketManager.DisconnectListener`

    - #### setDefaultTorrentCreateFilterMap

          public void setDefaultTorrentCreateFilterMap()

    - #### setDefaultTrackerMap

          public void setDefaultTrackerMap()

    - #### setSavedCommentsEnabled

          public void setSavedCommentsEnabled(Snark snark,
                                              boolean yes)

      Set setting for comments enabled in the config file.

    - #### shouldAutoStart

          public boolean shouldAutoStart()

      Specified by:
        `shouldAutoStart` in interface `CompleteListener`

    - #### shouldPreallocateFiles

          public boolean shouldPreallocateFiles()

      Returns:
        default true

    - #### shutdown

          public void shutdown(String[] args)

      ClientApp method. Does nothing. Doesn't matter, we are only registering.
      Specified by:
        `shutdown` in interface `ClientApp`
      Parameters:
        `args` - generally null but could be stopArgs from clients.config

    - #### start

          public void start()

      Caller _must_ call loadConfig(file) before this if setting new values for i2cp host/port or i2psnark.dir

    - #### startAllTorrents

          public void startAllTorrents()

      Always thread it

    - #### startTorrent

          public void startTorrent(byte[] infoHash)

      If not connected, thread it, otherwise inline
      Throws:
        `RuntimeException` - via Snark.fatal()

    - #### startTorrent

          public void startTorrent(Snark snark)

      If not connected, thread it, otherwise inline
      Throws:
        `RuntimeException` - via Snark.fatal()

    - #### startup

          public void startup()

      ClientApp method. Does nothing. Doesn't matter, we are only registering.
      Specified by:
        `startup` in interface `ClientApp`

    - #### stop

          public void stop()

    - #### stopAllTorrents

          public void stopAllTorrents(boolean finalShutdown)

      Stop all running torrents, and close the tunnel after a delay to allow for announces. If called at router shutdown via Jetty shutdown hook -> webapp destroy() -> stop(), the tunnel won't actually be closed as the SimpleTimer2 is already shutdown or will be soon, so we delay a few seconds inline.
      Parameters:
        `finalShutdown` - if true, sleep at the end if any torrents were running

    - #### stopTorrent

          public void stopTorrent(Snark torrent)

      Stop the torrent only, leaving it on the list of torrents.

    - #### stopTorrent

          public void stopTorrent(Snark torrent,
                                  boolean shouldRemove)

      Stop the torrent, leaving it on the list of torrents unless told to remove it. If shouldRemove is true, removes the config file also.

    - #### stopTorrent

          public Snark stopTorrent(String filename,
                                   boolean shouldRemove)

      Stop the torrent, leaving it on the list of torrents unless told to remove it. If shouldRemove is true, removes the config file also.

    - #### torrentComplete

          public void torrentComplete(Snark snark)

      A Snark.CompleteListener method.
      Specified by:
        `torrentComplete` in interface `CompleteListener`

    - #### updateConfig

          public void updateConfig(String dataDir,
                                   boolean filesPublic,
                                   boolean autoStart,
                                   String refreshDelay,
                                   String startDelay,
                                   String pageSize,
                                   String seedPct,
                                   String eepHost,
                                   String eepPort,
                                   String i2cpHost,
                                   String i2cpPort,
                                   String i2cpOpts,
                                   String upLimit,
                                   String upBW,
                                   String downBW,
                                   boolean useOpenTrackers,
                                   boolean useDHT,
                                   String theme,
                                   String lang,
                                   boolean enableRatings,
                                   boolean enableComments,
                                   String commentName,
                                   boolean collapsePanels,
                                   boolean showStatusFilter,
                                   boolean enableLightbox,
                                   boolean enableAddCreate,
                                   boolean enableVaryInboundHops,
                                   boolean enableVaryOutboundHops,
                                   String apiTarget,
                                   String apiKey)

      all params may be null or need trimming

    - #### updateStatus

          public void updateStatus(Snark snark)

      A Snark.CompleteListener method.
      Specified by:
        `updateStatus` in interface `CompleteListener`

    - #### util

          public I2PSnarkUtil util()

      hook to I2PSnarkUtil for the servlet