class UDPTrackerClient extends Object implements I2PSessionMuxedListener
The main difference from BEP 15 is that the announce response contains a 32-byte hash instead of a 4-byte IP and a 2-byte port.
We send both repliable and raw datagrams, but we only receive raw datagrams, as follows:
client tracker type
----------+----------------+--------------------
conn req | --> | repliable Datagram2
| <-- conn resp | raw
announce | --> | repliable Datagram3
| <-- ann resp | raw
| <-- error | raw
----------+-----------------+-------------------
| Modifier and Type | Class and Description |
|---|---|
static class |
UDPTrackerClient.TrackerResponse
Represents a response from a UDP tracker.
This class encapsulates the tracker's response including peer lists, interval information, and any error messages. |
| Modifier and Type | Field and Description |
|---|---|
static int |
EVENT_COMPLETED |
static int |
EVENT_NONE |
static int |
EVENT_STARTED |
static int |
EVENT_STOPPED |
| Constructor and Description |
|---|
UDPTrackerClient(I2PAppContext ctx,
I2PSession session,
I2PSnarkUtil util) |
| Modifier and Type | Method and Description |
|---|---|
UDPTrackerClient.TrackerResponse |
announce(byte[] ih,
byte[] peerID,
int max,
long maxWait,
String toHost,
int toPort,
long downloaded,
long left,
long uploaded,
int event,
boolean fast)
Announce and get peers for a torrent.
|
void |
disconnected(I2PSession session)
Notify the client that the session has been terminated.
|
void |
errorOccurred(I2PSession session,
String message,
Throwable error)
Notify the client that some error occurred.
|
void |
messageAvailable(I2PSession session,
int msgId,
long size)
for non-muxed
|
void |
messageAvailable(I2PSession session,
int msgId,
long size,
int proto,
int fromPort,
int toPort)
Instruct the client that the given session has received a message
|
void |
reportAbuse(I2PSession session,
int severity)
Instruct the client that the session specified seems to be under attack
and that the client may wish to move its destination to another router.
|
void |
start()
Can't be restarted after stopping?
|
void |
stop()
Stop everything.
|
public static final int EVENT_COMPLETED
public static final int EVENT_NONE
public static final int EVENT_STARTED
public static final int EVENT_STOPPED
public UDPTrackerClient(I2PAppContext ctx, I2PSession session, I2PSnarkUtil util)
public UDPTrackerClient.TrackerResponse announce(byte[] ih, byte[] peerID, int max, long maxWait, String toHost, int toPort, long downloaded, long left, long uploaded, int event, boolean fast)
ih - the Info Hash (torrent)max - maximum number of peers to returnmaxWait - the maximum time to wait (ms) must be > 0fast - if true, don't wait for dest, no retx, ...public void disconnected(I2PSession session)
I2PSessionMuxedListenerdisconnected in interface I2PSessionListenerdisconnected in interface I2PSessionMuxedListenerpublic void errorOccurred(I2PSession session, String message, Throwable error)
I2PSessionMuxedListenererrorOccurred in interface I2PSessionListenererrorOccurred in interface I2PSessionMuxedListenererror - can be null? or not?public void messageAvailable(I2PSession session, int msgId, long size)
messageAvailable in interface I2PSessionListenermessageAvailable in interface I2PSessionMuxedListenersession - session to notifymsgId - message number availablesize - size of the message - why it's a long and not an int is a mysterypublic void messageAvailable(I2PSession session, int msgId, long size, int proto, int fromPort, int toPort)
Will be called only if you register via addMuxedSessionListener(). Will be called only for the proto(s) and toPort(s) you register for.
messageAvailable in interface I2PSessionMuxedListenersession - session to notifymsgId - message number availablesize - size of the message - why it's a long and not an int is a mysteryproto - 1-254 or 0 for unspecifiedfromPort - 1-65535 or 0 for unspecifiedtoPort - 1-65535 or 0 for unspecifiedpublic void reportAbuse(I2PSession session, int severity)
I2PSessionMuxedListenerreportAbuse in interface I2PSessionListenerreportAbuse in interface I2PSessionMuxedListenersession - session to report abuse toseverity - how bad the abuse ispublic void start()
public void stop()