org.klomp.snark
public class Snark extends Object implements StorageListener, CoordinatorListener, ShutdownListener
Modifier and Type | Class and Description |
---|---|
static interface |
Snark.CompleteListener |
Modifier and Type | Field and Description |
---|---|
(package private) String |
activity |
static int |
ALL |
static int |
DEBUG |
static int |
ERROR |
static int |
INFO |
(package private) static int |
MAX_TOTAL_UPLOADERS |
(package private) static int |
MIN_TOTAL_UPLOADERS
Maintain a configurable total uploader cap
coordinatorListener
|
static int |
NOTICE |
static String |
PROP_MAX_CONNECTIONS
No, not maintaining a command-line client
public static void main(String[] args)
{
System.out.println(copyright);
System.out.println();
if ( (args.length > 0) && ("--config".equals(args[0])) ) {
I2PThread.addOOMEventListener(new OOMListener());
SnarkManager sm = SnarkManager.instance();
if (args.length > 1)
sm.loadConfig(args[1]);
System.out.println("Running in multitorrent mode");
while (true) {
try {
synchronized (sm) {
sm.wait();
}
} catch (InterruptedException ie) {}
}
}
// Parse debug, share/ip and torrent file options.
|
static int |
WARNING |
Constructor and Description |
---|
Snark(I2PAppContext ctx,
Properties opts,
String torrent,
StorageListener slistener,
boolean start,
String rootDir)
single torrent - via router
|
Snark(I2PSnarkUtil util,
String torrent,
byte[] ih,
String trackerURL,
Snark.CompleteListener complistener,
PeerCoordinatorSet peerCoordinatorSet,
ConnectionAcceptor connectionAcceptor,
boolean start,
String rootDir)
multitorrent, magnet
|
Snark(I2PSnarkUtil util,
String torrent,
String ip,
int user_port,
StorageListener slistener,
CoordinatorListener clistener)
from main() via parseArguments() single torrent
|
Snark(I2PSnarkUtil util,
String torrent,
String ip,
int user_port,
StorageListener slistener,
CoordinatorListener clistener,
Snark.CompleteListener complistener,
PeerCoordinatorSet peerCoordinatorSet,
ConnectionAcceptor connectionAcceptor,
boolean start,
String rootDir)
multitorrent
|
Modifier and Type | Method and Description |
---|---|
String |
getBaseName() |
long |
getDownloaded() |
long |
getDownloadRate() |
byte[] |
getID() |
byte[] |
getInfoHash() |
MetaInfo |
getMetaInfo() |
String |
getName() |
long |
getNeeded() |
int |
getPeerCount() |
List<Peer> |
getPeerList() |
int |
getPieceLength(int p) |
int |
getPieces() |
Storage |
getStorage() |
long |
getTotalLength() |
String |
getTrackerProblems() |
int |
getTrackerSeenPeers() |
String |
getTrackerURL() |
long |
getUploaded() |
long |
getUploadRate() |
void |
gotMetaInfo(PeerCoordinator coordinator,
MetaInfo metainfo)
Called when the PeerCoordinator got the MetaInfo via magnet.
|
boolean |
isStopped() |
boolean |
overUpBWLimit() |
boolean |
overUpBWLimit(long total) |
boolean |
overUploadLimit(int uploaders) |
void |
peerChange(PeerCoordinator coordinator,
Peer peer)
CoordinatorListener - this does nothing
|
boolean |
restartAcceptor() |
void |
setTrackerProblems(String p) |
void |
setTrackerSeenPeers(int p) |
void |
setWantedPieces(Storage storage)
Reset the peer's wanted pieces table
Call after the storage double-check fails
|
void |
shutdown()
SnarkSnutdown callback unused
|
void |
startTorrent()
Start up contacting peers and querying the tracker
|
void |
stopTorrent()
Stop contacting the tracker and talking with peers
|
void |
storageAllChecked(Storage storage)
Called when all pieces in the storage have been checked.
|
void |
storageAllocated(Storage storage,
long length)
Called to indicate that length bytes have been allocated.
|
void |
storageChecked(Storage storage,
int num,
boolean checked)
Called when storage is being checked and the num piece of that
total pieces has been checked.
|
void |
storageCompleted(Storage storage)
Called the one time when the data is completely received and checked.
|
void |
storageCreateFile(Storage storage,
String name,
long length)
Called when the storage creates a new file of a given length.
|
void |
updatePiecePriorities() |
public static final int ERROR
public static final int WARNING
public static final int NOTICE
public static final int INFO
public static final int DEBUG
public static final int ALL
String activity
public static final String PROP_MAX_CONNECTIONS
static final int MIN_TOTAL_UPLOADERS
static final int MAX_TOTAL_UPLOADERS
Snark(I2PSnarkUtil util, String torrent, String ip, int user_port, StorageListener slistener, CoordinatorListener clistener)
public Snark(I2PAppContext ctx, Properties opts, String torrent, StorageListener slistener, boolean start, String rootDir)
public Snark(I2PSnarkUtil util, String torrent, String ip, int user_port, StorageListener slistener, CoordinatorListener clistener, Snark.CompleteListener complistener, PeerCoordinatorSet peerCoordinatorSet, ConnectionAcceptor connectionAcceptor, boolean start, String rootDir)
public Snark(I2PSnarkUtil util, String torrent, byte[] ih, String trackerURL, Snark.CompleteListener complistener, PeerCoordinatorSet peerCoordinatorSet, ConnectionAcceptor connectionAcceptor, boolean start, String rootDir)
torrent
- a fake name for now (not a file name)ih
- 20-byte info hashtrackerURL
- may be nullpublic void startTorrent()
public void stopTorrent()
public String getName()
public String getBaseName()
public byte[] getID()
public byte[] getInfoHash()
public MetaInfo getMetaInfo()
public Storage getStorage()
public boolean isStopped()
public long getDownloadRate()
public long getUploadRate()
public long getDownloaded()
public long getUploaded()
public int getPeerCount()
public String getTrackerProblems()
public void setTrackerProblems(String p)
p
- tracker error string or nullpublic int getTrackerSeenPeers()
public void setTrackerSeenPeers(int p)
public void updatePiecePriorities()
public long getTotalLength()
public long getNeeded()
public int getPieceLength(int p)
p
- the piece numberpublic int getPieces()
public boolean restartAcceptor()
public String getTrackerURL()
public void peerChange(PeerCoordinator coordinator, Peer peer)
peerChange
in interface CoordinatorListener
public void gotMetaInfo(PeerCoordinator coordinator, MetaInfo metainfo)
gotMetaInfo
in interface CoordinatorListener
RuntimeException
- via fatal()public void storageCreateFile(Storage storage, String name, long length)
StorageListener
storageCreateFile
in interface StorageListener
public void storageAllocated(Storage storage, long length)
StorageListener
storageAllocated
in interface StorageListener
public void storageChecked(Storage storage, int num, boolean checked)
StorageListener
storageChecked
in interface StorageListener
public void storageAllChecked(Storage storage)
StorageListener
storageAllChecked
in interface StorageListener
public void storageCompleted(Storage storage)
StorageListener
storageCompleted
in interface StorageListener
public void setWantedPieces(Storage storage)
StorageListener
setWantedPieces
in interface StorageListener
public void shutdown()
shutdown
in interface ShutdownListener
public boolean overUploadLimit(int uploaders)
overUploadLimit
in interface CoordinatorListener
public boolean overUpBWLimit()
overUpBWLimit
in interface CoordinatorListener
public boolean overUpBWLimit(long total)
overUpBWLimit
in interface CoordinatorListener