public class TrackerClient extends Object implements Runnable
This class manages tracker announcements and peer discovery by:
Threading Model: The start() method creates a thread that runs one complete announcement cycle through all trackers, PEX, and DHT, then queues a new timed event and exits. This approach prevents thread accumulation while ensuring regular announcements.
The client can be restarted after halt() and handles various tracker responses including registration failures and error conditions.
| Modifier and Type | Field and Description |
|---|---|
static int | PORTDefault BitTorrent tracker port. |
| Constructor and Description |
|---|
TrackerClient(I2PSnarkUtil util,
MetaInfo meta,
String additionalTrackerURL,
PeerCoordinator coordinator,
Snark snark)Call start() to start it. |
| Modifier and Type | Method and Description |
|---|---|
void | halt(boolean fast)Interrupts this Thread to stop it. |
boolean | halted()Check if this tracker client has been halted. |
static boolean | isValidAnnounce(String ann) |
void | reinitialize()Call after editing torrent |
void | run()run. |
void | start()Start the tracker client thread. |
boolean | started()Check if this tracker client has been started. |
static String | urlencode(byte[] bs)Very lazy byte[] to URL encoder. |
public static final int PORT
public TrackerClient(I2PSnarkUtil util, MetaInfo meta, String additionalTrackerURL, PeerCoordinator coordinator, Snark snark)
meta - null if in magnet modeadditionalTrackerURL - may be null, from the ?tr= param in magnet mode, otherwise
ignoredpublic void halt(boolean fast)
fast - if true, limit the life of the unannounce threadspublic boolean halted()
public static boolean isValidAnnounce(String ann)
ann - an announce URL, may be null, returns false if nullpublic void reinitialize()
public void start()
public boolean started()
public static String urlencode(byte[] bs)
RFC1738: 0-9a-zA-Z$-_.+!*'(), Us: 0-9a-zA-Z
bs - the bytes to encode