|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.klomp.snark.SnarkManager
public class SnarkManager
Manage multiple snarks
Nested Class Summary | |
---|---|
class |
SnarkManager.SnarkManagerShutdown
|
Field Summary | |
---|---|
static String |
DEFAULT_AUTO_START
|
static String |
DEFAULT_LINK_PREFIX
|
static int |
DEFAULT_MAX_UP_BW
|
static int |
DEFAULT_STARTUP_DELAY
|
static String |
DEFAULT_THEME
|
static int |
MIN_UP_BW
|
static String |
PROP_AUTO_START
|
static String |
PROP_DIR
|
static String |
PROP_I2CP_HOST
|
static String |
PROP_I2CP_OPTS
|
static String |
PROP_I2CP_PORT
|
static String |
PROP_LINK_PREFIX
|
static String |
PROP_META_BITFIELD_SUFFIX
|
static String |
PROP_META_MAGNET_PREFIX
|
static String |
PROP_META_PREFIX
|
static String |
PROP_META_PRIORITY_SUFFIX
|
static String |
PROP_STARTUP_DELAY
|
static String |
PROP_THEME
|
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
|
Method Summary | |
---|---|
void |
addMagnet(String name,
byte[] ih,
String trackerURL,
boolean updateStatus)
Add a torrent with the info hash alone (magnet / maggot) |
void |
addMessage(String message)
|
void |
addTorrent(MetaInfo metainfo,
BitField bitfield,
String filename,
boolean dontAutoStart)
Add a torrent from a MetaInfo. |
void |
copyAndAddTorrent(File fromfile,
String filename)
Add a torrent from a file not in the torrent directory. |
void |
deleteMagnet(Snark snark)
Stop and delete a torrent running in magnet mode |
Properties |
getConfig()
|
File |
getDataDir()
|
List |
getMessages()
newest last |
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. |
String |
getTheme()
Get current theme. |
String[] |
getThemes()
Get all themes |
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,String> |
getTrackers()
sorted map of name to announceURL=baseURL |
String |
gotMetaInfo(Snark snark)
We transitioned from magnet mode, we have now initialized our metainfo and storage. |
static SnarkManager |
instance()
|
String |
linkPrefix()
|
Set<String> |
listTorrentFiles()
Set of canonical .torrent filenames that we are dealing with. |
void |
loadConfig(String filename)
null to set initial defaults |
void |
loadSavedFilePriorities(Snark snark)
Get the saved priorities for a torrent from the config file. |
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 |
removeTorrentStatus(MetaInfo metainfo)
Remove the status of a torrent from the config file. |
void |
saveConfig()
|
void |
saveMagnetStatus(byte[] ih)
Just remember we have it |
void |
saveTorrentStatus(MetaInfo metainfo,
BitField bitfield,
int[] priorities)
Save the completion status of a torrent and the current time in the config file in the form "i2psnark.zmeta.$base64infohash=$time,$base64bitfield". |
boolean |
shouldAutoStart()
|
void |
start()
Caller _must_ call loadConfig(file) before this if setting new values for i2cp host/port or i2psnark.dir |
void |
stop()
|
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 autoStart,
String startDelay,
String seedPct,
String eepHost,
String eepPort,
String i2cpHost,
String i2cpPort,
String i2cpOpts,
String upLimit,
String upBW,
boolean useOpenTrackers,
String openTrackers,
String theme)
|
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 |
---|
public static final String PROP_I2CP_HOST
public static final String PROP_I2CP_PORT
public static final String PROP_I2CP_OPTS
public static final String PROP_UPLOADERS_TOTAL
public static final String PROP_UPBW_MAX
public static final String PROP_DIR
public static final String PROP_META_PREFIX
public static final String PROP_META_BITFIELD_SUFFIX
public static final String PROP_META_PRIORITY_SUFFIX
public static final String PROP_META_MAGNET_PREFIX
public static final String PROP_AUTO_START
public static final String DEFAULT_AUTO_START
public static final String PROP_LINK_PREFIX
public static final String DEFAULT_LINK_PREFIX
public static final String PROP_STARTUP_DELAY
public static final String PROP_THEME
public static final String DEFAULT_THEME
public static final int MIN_UP_BW
public static final int DEFAULT_MAX_UP_BW
public static final int DEFAULT_STARTUP_DELAY
public static final String PROP_TRACKERS
Method Detail |
---|
public static SnarkManager instance()
public void start()
public void stop()
public I2PSnarkUtil util()
public void addMessage(String message)
public List getMessages()
public boolean shouldAutoStart()
public String linkPrefix()
public File getDataDir()
public void loadConfig(String filename)
public String getTheme()
public String[] getThemes()
public void updateConfig(String dataDir, boolean autoStart, String startDelay, String seedPct, String eepHost, String eepPort, String i2cpHost, String i2cpPort, String i2cpOpts, String upLimit, String upBW, boolean useOpenTrackers, String openTrackers, String theme)
public void saveConfig()
public Properties getConfig()
public Set<String> listTorrentFiles()
public Snark getTorrent(String filename)
public Snark getTorrentByBaseName(String filename)
public Snark getTorrentByInfoHash(byte[] infohash)
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 void deleteMagnet(Snark snark)
snark
- a torrent with a fake file name ("Magnet xxxx")public void addTorrent(MetaInfo metainfo, BitField bitfield, String filename, boolean dontAutoStart) throws IOException
metainfo
- the metainfo for the torrentbitfield
- the current completion status of the torrentfilename
- 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.
RuntimeException
- via Snark.fatal()
IOException
public void copyAndAddTorrent(File fromfile, String filename) 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.
RuntimeException
- via Snark.fatal()
IOException
public long getSavedTorrentTime(Snark snark)
getSavedTorrentTime
in interface Snark.CompleteListener
public BitField getSavedTorrentBitField(Snark snark)
getSavedTorrentBitField
in interface Snark.CompleteListener
public void loadSavedFilePriorities(Snark snark)
public void saveTorrentStatus(MetaInfo metainfo, BitField bitfield, int[] priorities)
bitfield
- non-nullpriorities
- may be nullpublic void removeTorrentStatus(MetaInfo metainfo)
public void saveMagnetStatus(byte[] ih)
public void removeMagnetStatus(byte[] ih)
public Snark stopTorrent(String filename, boolean shouldRemove)
public void stopTorrent(Snark torrent, boolean shouldRemove)
public void removeTorrent(String filename)
public void torrentComplete(Snark snark)
torrentComplete
in interface Snark.CompleteListener
public void updateStatus(Snark snark)
updateStatus
in interface Snark.CompleteListener
public String gotMetaInfo(Snark snark)
gotMetaInfo
in interface Snark.CompleteListener
public Map<String,String> getTrackers()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |