Package org.klomp.snark
Class TrackerClient
java.lang.Object
org.klomp.snark.TrackerClient
- All Implemented Interfaces:
Runnable
Informs metainfo tracker of events and gets new peers for peer
coordinator.
start() creates a thread and starts it.
At the end of each run, a TimedEvent is queued on the SimpleTimer2 queue.
The TimedEvent creates a new thread and starts it, so it does not
clog SimpleTimer2.
The thread runs one pass through the trackers, the PEX, and the DHT,
then queues a new TimedEvent and exits.
Thus there are only threads that are actively announcing, not one thread per torrent forever.
start() may be called again after halt().
- Author:
- Mark Wielaard (mark@klomp.org)
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionTrackerClient(I2PSnarkUtil util, MetaInfo meta, String additionalTrackerURL, PeerCoordinator coordinator, Snark snark) Call start() to start it. -
Method Summary
Modifier and TypeMethodDescriptionvoidhalt(boolean fast) Interrupts this Thread to stop it.booleanhalted()static booleanisValidAnnounce(String ann) voidrun()Setup the first time only, then one pass (usually) through the trackers, PEX, and DHT.voidstart()booleanstarted()static Stringurlencode(byte[] bs) Very lazy byte[] to URL encoder.
-
Field Details
-
PORT
public static final int PORT- See Also:
-
-
Constructor Details
-
TrackerClient
public TrackerClient(I2PSnarkUtil util, MetaInfo meta, String additionalTrackerURL, PeerCoordinator coordinator, Snark snark) Call start() to start it.- Parameters:
meta- null if in magnet modeadditionalTrackerURL- may be null, from the ?tr= param in magnet mode, otherwise ignored
-
-
Method Details
-
start
public void start() -
halted
public boolean halted() -
started
public boolean started() -
halt
public void halt(boolean fast) Interrupts this Thread to stop it.- Parameters:
fast- if true, limit the life of the unannounce threads
-
run
public void run()Setup the first time only, then one pass (usually) through the trackers, PEX, and DHT. This will take several seconds to several minutes. -
urlencode
Very lazy byte[] to URL encoder. Just encodes almost everything, even some "normal" chars. By not encoding about 1/4 of the chars, we make random data like hashes about 16% smaller. RFC1738: 0-9a-zA-Z$-_.+!*'(), Us: 0-9a-zA-Z -
isValidAnnounce
- Parameters:
ann- an announce URL, may be null, returns false if null- Returns:
- true for i2p hosts only
- Since:
- 0.7.12
-