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 |
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() |
static boolean |
isValidAnnounce(String ann) |
void |
reinitialize()
Call after editing torrent
|
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.
|
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 run()
public void start()
public boolean started()
public static String urlencode(byte[] bs)
RFC1738: 0-9a-zA-Z$-_.+!*'(), Us: 0-9a-zA-Z