Package org.klomp.snark
Class TrackerClient
- java.lang.Object
-
- org.klomp.snark.TrackerClient
-
- All Implemented Interfaces:
Runnable
public class TrackerClient extends Object implements 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 Modifier and Type Field Description static int
PORT
-
Constructor Summary
Constructors Constructor Description TrackerClient(I2PSnarkUtil util, MetaInfo meta, String additionalTrackerURL, PeerCoordinator coordinator, Snark snark)
Call start() to start it.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
halt(boolean fast)
Interrupts this Thread to stop it.boolean
halted()
static boolean
isValidAnnounce(String ann)
void
run()
Setup the first time only, then one pass (usually) through the trackers, PEX, and DHT.void
start()
boolean
started()
static String
urlencode(byte[] bs)
Very lazy byte[] to URL encoder.
-
-
-
Field Detail
-
PORT
public static final int PORT
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
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 Detail
-
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
public static String urlencode(byte[] bs)
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
public static boolean isValidAnnounce(String ann)
- Parameters:
ann
- an announce URL, may be null, returns false if null- Returns:
- true for i2p hosts only
- Since:
- 0.7.12
-
-