public class SnarkManager extends Object implements CompleteListener, ClientApp, I2PSocketManager.DisconnectListener
This class is the core controller that manages:
As a ClientApp, it integrates with the I2P router application framework and can be started, stopped, and monitored through the standard I2P interfaces.
| Modifier and Type | Field and Description |
|---|---|
static String | CONFIG_DIR_SUFFIX |
static String | CONFIG_FILE |
static String | DEFAULT_BACKUP_TRACKERURL. |
static int | DEFAULT_BAN_DISCARD_PERIOD |
static String | DEFAULT_BAN_DISCARD_RATIO |
static String | DEFAULT_ENABLE_ADDCREATE |
static String | DEFAULT_ENABLE_LIGHTBOX |
static int | DEFAULT_MAX_FILES_PER_TORRENT |
static int | DEFAULT_MAX_UP_BW |
static int | DEFAULT_MULTI_DEST_MAXDefault cap on destinations so many torrents share destinations instead of exhausting memory |
static String | DEFAULT_PREALLOCATE_FILES |
static int | DEFAULT_REFRESH_DELAY_SECS |
static String | DEFAULT_SHOULD_PAD_FILES |
static String | DEFAULT_SHOW_STATUSFILTER |
static int | DEFAULT_STARTUP_DELAY_MAX |
static int | DEFAULT_STARTUP_DELAY_MIN |
static String | DEFAULT_THEME |
static Set<String> | DEFAULT_TRACKER_ANNOUNCESDefault set of tracker announce URLs to use when no torrent trackers are configured. |
static int | DEFAULT_TUNNEL_QUANTITY |
(package private) static Set<String> | KNOWN_OPENTRACKERSHost names for config form. |
static int | MAX_MULTI_DESTAbsolute maximum for the destination cap |
static int | MIN_DOWN_BW |
static int | MIN_UP_BW |
static String | PROP_AUTO_START |
static String | PROP_BAN_DISCARD_PERIODDuration of the ban applied to peers with an excessive discard ratio, in minutes. |
static String | PROP_BAN_DISCARD_RATIODisconnect peers that cancel most of what they request. |
static String | PROP_BROWSER_APIWhether the nonce-free browser API (magnet/torrent add) is enabled. |
static String | PROP_BROWSER_API_HOSTSComma-separated hosts (IPs or hostnames) allowed to use the browser API
without a nonce, in addition to loopback. |
static String | PROP_CLIENT_IDClient identity spoofing: empty (default) to identify as I2PSnark,
"random" to pick a random known client profile per destination per run,
or the name of a known client (e.g. |
static String | PROP_CLIENT_IDSOptional comma-separated subset of client names (see
ClientID.profiles()) to choose from when
PROP_CLIENT_ID is "random"; unknown names are ignored. |
static String | PROP_COLLAPSE_PANELS |
static String | PROP_DEST_CYCLEWhether running torrents are periodically stopped and restarted so their
destinations rotate to fresh identities, breaking long-lived linkage
between the router's IP and the torrents' destinations at trackers and in
the DHT. |
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_MAX_PARTSIZECap on a single piece request from a peer. |
static String | PROP_MAX_PIPELINEMaximum request pipeline depth for outbound requests. |
static String | PROP_MIN_PIPELINEMinimum request pipeline depth for outbound requests. |
static String | PROP_MULTI_DESTWhether each torrent runs on its own destination. |
static String | PROP_MULTI_DEST_MAXMaximum number of destinations in multi-dest mode, 0 for one per torrent. |
static String | PROP_OLD_AUTO_START |
static String | PROP_OPENTRACKERS |
static String | PROP_PAGE_SIZE |
static String | PROP_PARTSIZEChunk size for outbound piece requests. |
static String | PROP_PREALLOCATE_FILES |
static String | PROP_PRIVATETRACKERS |
static String | PROP_RANDOMIZE_STARTUPStagger batched starts with a random delay, so torrents that start together
cannot be correlated by trackers or DHT peers, and tunnel builds are spread
out. |
static String | PROP_REFRESH_DELAY |
static String | PROP_SHOULD_PAD_FILESAdd BEP 47 padding files to new torrents. |
static String | PROP_SHOW_STATUSFILTER |
static String | PROP_STARTUP_DELAY_MAX |
static String | PROP_STARTUP_DELAY_MIN |
static String | PROP_TEMP_DIRConfiguration key for the staging directory where incomplete files are
written until a file's pieces are all downloaded, at which point the
file is copied into the data directory. |
static String | PROP_THEME |
static String | PROP_TORRENT_CREATE_FILTERSComma delimited list of name=filterPattern for torrent create filters. |
static String | PROP_TORRENT_FILTERS_CONFIGFilename for serialized torrent filters config. |
static String | PROP_TRACKERSComma 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 and Description |
|---|
SnarkManager(I2PAppContext ctx)For embedded. |
SnarkManager(I2PAppContext ctx,
String ctxPath,
String ctxName)For webapp. |
| 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 | addMessageAndPrint(String message)Queue a message and, when running standalone, print it to stdout. |
void | addMessageAndPrint(String message,
String print)Queue a message and, when running standalone, print possibly different text to stdout. |
void | addMessageNoEscape(String message)Use if it includes a link. |
void | addMessageNoEscapeAndPrint(String message)Queue a message and, when running standalone, print it to stdout. |
void | addMessageNoEscapeAndPrint(String message,
String print)Queue a message and, when running standalone, print possibly different text to stdout. |
boolean | addTorrent(MetaInfo metainfo,
BitField bitfield,
String filename,
File baseFile,
boolean dontAutoStart)Add a torrent from a MetaInfo. |
boolean | areFilesPublic()Whether the files in the data directory are world-readable. |
boolean | browserApiEnabled()Whether the nonce-free browser API for adding torrents is enabled. |
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. |
(package private) static int | countRealFiles(List<List<String>> files)Count the files in a metainfo file list for the max files per torrent
check, excluding BEP 47 padding files (.pad) and parse-renamed padding
(_pad); a padded torrent must not be rejected because of its synthetic
zero files. |
void | deleteMagnet(Snark snark)Stop and delete a torrent running in magnet mode |
static String | escapeMessage(String message)Escape a message for HTML display, preserving intentional ' ' spacers. |
void | fatal(Snark snark,
String error)A Snark.CompleteListener method. |
BandwidthListener | getBandwidthListener()The bandwidth listener for this manager. |
String | getBrowserApiHosts()The raw comma-separated browser API allowed hosts config, for the config form. |
File | getConfigDir()For RPC |
int | getCreateFilterCount()Returns the current number of configured file filters |
File | getDataDir()The configured torrent data directory. |
String | getDiskUsage()The cached disk usage string for display. |
String | getDisplayName()ClientApp method. |
int | getMaxFilesPerTorrent()Maximum number of files a torrent may contain. |
int | getMaxLogMessages()Maximum number of messages kept for display on the web page. |
List<UIMessages.Message> | getMessages()The list of recent UI messages for display on the web page. |
String | getName()ClientApp method. |
int | getPageSize()For GUI |
List<String> | getPrivateTrackers()The configured private tracker list. |
boolean | getRandomizeStartupDelay()Whether batched torrent starts are staggered with a random delay, so torrents
starting together cannot be correlated, and tunnel builds are spread out. |
int | getRefreshDelaySeconds()How often the web page refreshes itself. |
long[] | getSavedAddedAndCompleted(Snark snark)Setting for a torrent from the config file. |
CommentSet | getSavedComments(Snark snark)The comments for a torrent |
boolean | getSavedCommentsEnabled(Snark snark)Setting for comments enabled from the config file. |
boolean | getSavedPreserveNamesSetting(Snark snark)Setting for a torrent from the config file. |
BitField | getSavedTorrentBitField(Snark snark)Saved bitfield for a torrent from the config file. |
long | getSavedTorrentTime(Snark snark)Timestamp for a torrent from the config file. |
long | getSavedUploaded(Snark snark)Setting for a torrent from the config file. |
List<TorrentCreateFilter> | getSortedTorrentCreateFilterStrings()Sorted copy |
List<Tracker> | getSortedTrackers()Sorted copy |
ClientAppState | getState()ClientApp method. |
String | getTheme()The current theme for this web interface. |
String[] | getThemes()All themes available for this web interface. |
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()Whether themes are applied across all applications. |
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 | isBrowserApiHost(String host)Whether the given remote address may use the browser API without a nonce. |
boolean | isCollapsePanelsEnabled()Whether the web interface collapses panels by default. |
boolean | isEnableLightbox()Whether the lightbox is used to display large images in the web interface. |
static boolean | isLoopbackHost(String host)IPv4 loopback (127/8), IPv6 loopback, and "localhost". |
boolean | isShowStatusFilter()Whether the status filter bar is shown in the web interface. |
boolean | isSmartSortEnabled()Whether smart sort is enabled in the web interface. |
boolean | isStopping()Whether the manager is in the process of stopping. |
boolean | isVaryInboundHops()Whether hops are randomly varied for inbound torrent tunnels. |
boolean | isVaryOutboundHops()Whether hops are randomly varied for outbound torrent tunnels. |
Set<String> | listTorrentFiles()Canonical .torrent filenames that we are dealing with. |
void | loadConfig(String filename)Load the config from the given file. |
void | loadSavedFilePriorities(Snark snark)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. |
(package private) static boolean | parseShouldPadFiles(Properties props)Parses the PROP_SHOULD_PAD_FILES value from the given
properties, applying the default when absent or unparsable. |
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. |
static Set<InetAddress> | resolveBrowserApiHosts(String hosts)Parse a comma-separated host list into resolved addresses. |
void | saveConfig() |
void | saveMagnetStatus(byte[] ih,
String dir,
String trackerURL,
String dn)Just remember we have it. |
void | saveOpenTrackers(List<String> ot)Save the given open tracker list. |
void | savePrivateTrackers(List<String> pt)Save the given private tracker list. |
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 | setAPI(String target,
String key)Set and persist the API key for remote access, mirroring the apiKey/apiTarget
handling in updateConfig. |
void | setBrowserApi(boolean enable,
String hosts)Set and persist the browser API enable flag and allowed hosts list. |
void | setDefaultTorrentCreateFilterMap() |
void | setDefaultTrackerMap() |
void | setSavedCommentsEnabled(Snark snark,
boolean yes)Setting for comments enabled in the config file. |
boolean | shouldAutoStart()Whether newly added torrents should be started automatically. |
boolean | shouldDestCycle()Whether running torrents are periodically restarted with fresh
destinations. |
boolean | shouldPreallocateFiles()Whether new torrents preallocate their storage files. |
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 |
(package private) static long | startDelay(Random rnd)Random delay between auto-started torrents in multi-dest mode, 30-90 seconds. |
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()Called by the webapp at Jetty shutdown. |
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 startDelayMin,
String startDelayMax,
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,
boolean multiDest,
String multiDestMax,
boolean randomizeStartup,
String apiTarget,
String apiKey,
String maxFiles,
boolean preallocateFiles,
String tempDir)All params may be null or need trimming. |
void | updateStatus(Snark snark)A Snark.CompleteListener method. |
I2PSnarkUtil | util()The I2PSnarkUtil instance for this manager. |
public static final String CONFIG_DIR_SUFFIX
public static final String CONFIG_FILE
public static final String DEFAULT_BACKUP_TRACKER
public static final int DEFAULT_BAN_DISCARD_PERIOD
public static final String DEFAULT_BAN_DISCARD_RATIO
public static final String DEFAULT_ENABLE_ADDCREATE
public static final String DEFAULT_ENABLE_LIGHTBOX
public static final int DEFAULT_MAX_FILES_PER_TORRENT
public static final int DEFAULT_MAX_UP_BW
public static final int DEFAULT_MULTI_DEST_MAX
public static final String DEFAULT_PREALLOCATE_FILES
public static final int DEFAULT_REFRESH_DELAY_SECS
public static final String DEFAULT_SHOULD_PAD_FILES
public static final String DEFAULT_SHOW_STATUSFILTER
public static final int DEFAULT_STARTUP_DELAY_MAX
public static final int DEFAULT_STARTUP_DELAY_MIN
public static final String DEFAULT_THEME
public static final Set<String> DEFAULT_TRACKER_ANNOUNCES
public static final int DEFAULT_TUNNEL_QUANTITY
public static final int MAX_MULTI_DEST
public static final int MIN_DOWN_BW
public static final int MIN_UP_BW
public static final String PROP_AUTO_START
public static final String PROP_BAN_DISCARD_PERIOD
public static final String PROP_BAN_DISCARD_RATIO
public static final String PROP_BROWSER_API
public static final String PROP_BROWSER_API_HOSTS
public static final String PROP_CLIENT_ID
public static final String PROP_CLIENT_IDS
ClientID.profiles()) to choose from when
PROP_CLIENT_ID is "random"; unknown names are ignored.public static final String PROP_COLLAPSE_PANELS
public static final String PROP_DEST_CYCLE
public static final String PROP_DIR
public static final String PROP_DOWNBW_MAX
public static final String PROP_ENABLE_ADDCREATE
public static final String PROP_ENABLE_LIGHTBOX
public static final String PROP_FILES_PUBLIC
public static final String PROP_I2CP_HOST
public static final String PROP_I2CP_OPTS
public static final String PROP_I2CP_PORT
public static final String PROP_MAX_FILES_PER_TORRENT
public static final String PROP_MAX_MESSAGES
public static final String PROP_MAX_PARTSIZE
public static final String PROP_MAX_PIPELINE
public static final String PROP_MIN_PIPELINE
public static final String PROP_MULTI_DEST
public static final String PROP_MULTI_DEST_MAX
public static final String PROP_OLD_AUTO_START
public static final String PROP_OPENTRACKERS
public static final String PROP_PAGE_SIZE
public static final String PROP_PARTSIZE
public static final String PROP_PREALLOCATE_FILES
public static final String PROP_PRIVATETRACKERS
public static final String PROP_RANDOMIZE_STARTUP
public static final String PROP_REFRESH_DELAY
public static final String PROP_SHOULD_PAD_FILES
public static final String PROP_SHOW_STATUSFILTER
public static final String PROP_STARTUP_DELAY_MAX
public static final String PROP_STARTUP_DELAY_MIN
public static final String PROP_TEMP_DIR
public static final String PROP_THEME
public static final String PROP_TORRENT_CREATE_FILTERS
public static final String PROP_TORRENT_FILTERS_CONFIG
public static final String PROP_TRACKERS
public static final String PROP_UPBW_MAX
public static final String PROP_UPLOADERS_TOTAL
public static final String PROP_VARY_INBOUND_HOPS
public static final String PROP_VARY_OUTBOUND_HOPS
public static final String RC_PROP_THEME
public static final String RC_PROP_UNIVERSAL_THEMING
public SnarkManager(I2PAppContext ctx)
public SnarkManager(I2PAppContext ctx, String ctxPath, String ctxName)
ctxPath - generally "/i2psnark"ctxName - generally "i2psnark"public void addDownloader(Snark torrent)
torrent - must be instanceof FetchAndAddRuntimeException - via Snark.fatal()?public void addMagnet(String name, byte[] ih, String trackerURL, boolean updateStatus)
name - hex or b32 name from the magnet linkih - 20 byte info hashtrackerURL - may be nullupdateStatus - should we add this magnet to the config file, to save it across restarts,
in case we don't get the metadata before shutdown?RuntimeException - via Snark.fatal()public Snark addMagnet(String name, byte[] ih, String trackerURL, boolean updateStatus, boolean autoStart, File dataDir, CompleteListener listener)
name - hex or b32 name from the magnet linkih - 20 byte info hashtrackerURL - may be nullupdateStatus - 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 directorylistener - to intercept callbacks, should pass through to thisRuntimeException - via Snark.fatal()public void addMagnet(String name, byte[] ih, String trackerURL, boolean updateStatus, File dataDir)
name - hex or b32 name from the magnet linkih - 20 byte info hashtrackerURL - may be nullupdateStatus - 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 directoryRuntimeException - via Snark.fatal()public void addMessage(Snark snark, String message)
addMessage in interface CompleteListenerpublic void addMessage(String message)
public void addMessageAndPrint(String message)
message - the message to queuepublic void addMessageAndPrint(String message, String print)
message - the message to queueprint - the text to print, or null for no outputpublic void addMessageNoEscape(String message)
public void addMessageNoEscapeAndPrint(String message)
message - the message to queuepublic void addMessageNoEscapeAndPrint(String message, String print)
message - the message to queueprint - the text to print, or null for no outputpublic boolean addTorrent(MetaInfo metainfo, BitField bitfield, String filename, File baseFile, boolean dontAutoStart) throws IOException
Called from servlet. This is only for the 'create torrent' form.
metainfo - the metainfo for the torrentbitfield - the current completion status of the torrent, or nullfilename - 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 rootDataDirRuntimeException - via Snark.fatal()IOExceptionpublic boolean areFilesPublic()
public boolean browserApiEnabled()
public void clearMessages()
public void clearMessages(int id)
public boolean copyAndAddTorrent(File fromfile, String filename, File dataDir) throws IOException
fromfile - where the file is now, presumably in a temp directory somewherefilename - 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 directoryRuntimeException - via Snark.fatal()IOExceptionstatic int countRealFiles(List<List<String>> files)
files - from MetaInfo.getFiles(), may be nullpublic void deleteMagnet(Snark snark)
snark - a torrent with a fake file name ("Magnet xxxx")public static String escapeMessage(String message)
message - the raw message text, not nullpublic void fatal(Snark snark, String error)
fatal in interface CompleteListenerpublic BandwidthListener getBandwidthListener()
getBandwidthListener in interface CompleteListenerpublic String getBrowserApiHosts()
public File getConfigDir()
public int getCreateFilterCount()
public File getDataDir()
public String getDiskUsage()
public String getDisplayName()
getDisplayName in interface ClientApppublic int getMaxFilesPerTorrent()
public int getMaxLogMessages()
public List<UIMessages.Message> getMessages()
public String getName()
public int getPageSize()
public List<String> getPrivateTrackers()
public boolean getRandomizeStartupDelay()
public int getRefreshDelaySeconds()
public long[] getSavedAddedAndCompleted(Snark snark)
public CommentSet getSavedComments(Snark snark)
getSavedComments in interface CompleteListenerpublic boolean getSavedCommentsEnabled(Snark snark)
public boolean getSavedPreserveNamesSetting(Snark snark)
getSavedPreserveNamesSetting in interface CompleteListenerpublic BitField getSavedTorrentBitField(Snark snark)
getSavedTorrentBitField in interface CompleteListenersnark - the Snark instancepublic long getSavedTorrentTime(Snark snark)
getSavedTorrentTime in interface CompleteListenersnark - the Snark instancepublic long getSavedUploaded(Snark snark)
getSavedUploaded in interface CompleteListenerpublic List<TorrentCreateFilter> getSortedTorrentCreateFilterStrings()
public ClientAppState getState()
public String getTheme()
public String[] getThemes()
public String getTime()
public Snark getTorrent(String filename)
public Snark getTorrentByBaseName(String filename)
filename - must be the filtered name, which may be different than the metainfo's namepublic Snark getTorrentByInfoHash(byte[] infohash)
public Map<String,TorrentCreateFilter> getTorrentCreateFilterMap()
public Collection<TorrentCreateFilter> getTorrentCreateFilterStrings()
public Collection<Snark> getTorrents()
public Map<String,Tracker> getTrackerMap()
public Collection<Tracker> getTrackers()
public boolean getUniversalTheming()
public String gotMetaInfo(Snark snark)
gotMetaInfo in interface CompleteListenerpublic void gotPiece(Snark snark)
gotPiece in interface CompleteListenerpublic boolean hasModifiedTrackers()
public boolean isBrowserApiHost(String host)
host - remote address string from the requestpublic boolean isCollapsePanelsEnabled()
public boolean isEnableLightbox()
public static boolean isLoopbackHost(String host)
public boolean isShowStatusFilter()
public boolean isSmartSortEnabled()
public boolean isStopping()
public boolean isVaryInboundHops()
public boolean isVaryOutboundHops()
public Set<String> listTorrentFiles()
public void loadConfig(String filename)
filename - null to set initial defaultspublic void loadSavedFilePriorities(Snark snark)
public void locked_saveComments(Snark snark, CommentSet comments)
locked_saveComments in interface CompleteListenercomments - non-nullstatic boolean parseShouldPadFiles(Properties props)
PROP_SHOULD_PAD_FILES value from the given
properties, applying the default when absent or unparsable.props - the config propertiespublic void recheckTorrent(Snark snark)
public void removeMagnetStatus(byte[] ih)
public void removeTorrent(String filename)
public static Set<InetAddress> resolveBrowserApiHosts(String hosts)
hosts - comma-separated hostnames or IPs, may be nullpublic void saveConfig()
public void saveMagnetStatus(byte[] ih,
String dir,
String trackerURL,
String dn)dir - may be nulltrackerURL - may be nulldn - may be nullpublic void saveOpenTrackers(List<String> ot)
ot - null to restore defaultpublic void savePrivateTrackers(List<String> pt)
pt - null ok, default is nonepublic void saveTorrentCreateFilterMap()
public void saveTorrentStatus(Snark snark)
public void saveTrackerMap()
public void sessionDisconnected()
sessionDisconnected in interface I2PSocketManager.DisconnectListenerpublic void setAPI(String target, String key)
target - the API target base pathkey - the API keypublic void setBrowserApi(boolean enable,
String hosts)enable - whether the browser API is enabled at allhosts - comma-separated hostnames or IPs, may be null/emptypublic void setDefaultTorrentCreateFilterMap()
public void setDefaultTrackerMap()
public void setSavedCommentsEnabled(Snark snark, boolean yes)
public boolean shouldAutoStart()
shouldAutoStart in interface CompleteListenerpublic boolean shouldDestCycle()
public boolean shouldPreallocateFiles()
public void shutdown(String[] args)
public void start()
public void startAllTorrents()
static long startDelay(Random rnd)
rnd - source of randomnesspublic void startTorrent(byte[] infoHash)
RuntimeException - via Snark.fatal()public void startTorrent(Snark snark)
RuntimeException - via Snark.fatal()public void startup()
public void stop()
public void stopAllTorrents(boolean finalShutdown)
finalShutdown - if true, sleep at the end if any torrents were runningpublic void stopTorrent(Snark torrent)
public void stopTorrent(Snark torrent, boolean shouldRemove)
public Snark stopTorrent(String filename, boolean shouldRemove)
public void torrentComplete(Snark snark)
torrentComplete in interface CompleteListenersnark - the Snark instance that completedpublic void updateConfig(String dataDir, boolean filesPublic, boolean autoStart, String refreshDelay, String startDelayMin, String startDelayMax, 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, boolean multiDest, String multiDestMax, boolean randomizeStartup, String apiTarget, String apiKey, String maxFiles, boolean preallocateFiles, String tempDir)
public void updateStatus(Snark snark)
updateStatus in interface CompleteListenersnark - the Snark instance to update status forpublic I2PSnarkUtil util()