Package org.klomp.snark
Class UDPTrackerClient
java.lang.Object
org.klomp.snark.UDPTrackerClient
- All Implemented Interfaces:
I2PSessionListener,I2PSessionMuxedListener
One of these for all trackers and info hashes.
Ref: BEP 15, proposal 160
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.
This implements only "fast mode".
We send only repliable datagrams, and
receive only raw datagrams, as follows:
client tracker type
------ ------- ----
announce --> repliable
<-- ann resp raw
- Since:
- 0.9.53, enabled in 0.9.54
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intstatic final intstatic final intstatic final int -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionannounce(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.voiddisconnected(I2PSession session) Notify the client that the session has been terminated.voiderrorOccurred(I2PSession session, String message, Throwable error) Notify the client that some error occurred.voidmessageAvailable(I2PSession session, int msgId, long size) for non-muxedvoidmessageAvailable(I2PSession session, int msgId, long size, int proto, int fromPort, int toPort) Instruct the client that the given session has received a message Will be called only if you register via addMuxedSessionListener().voidreportAbuse(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.voidstart()Can't be restarted after stopping?voidstop()Stop everything.
-
Field Details
-
EVENT_NONE
public static final int EVENT_NONE- See Also:
-
EVENT_COMPLETED
public static final int EVENT_COMPLETED- See Also:
-
EVENT_STARTED
public static final int EVENT_STARTED- See Also:
-
EVENT_STOPPED
public static final int EVENT_STOPPED- See Also:
-
-
Constructor Details
-
UDPTrackerClient
-
-
Method Details
-
start
public void start()Can't be restarted after stopping? -
stop
public void stop()Stop everything. -
announce
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) Announce and get peers for a torrent. Blocking! Caller should run in a thread.- Parameters:
ih- the Info Hash (torrent)max- maximum number of peers to returnmaxWait- the maximum time to wait (ms) must be greater than 0fast- if true, don't wait for dest, no retx, ...- Returns:
- null on fail or if fast is true
-
messageAvailable
public 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 Will be called only if you register via addMuxedSessionListener(). Will be called only for the proto(s) and toPort(s) you register for.- Specified by:
messageAvailablein interfaceI2PSessionMuxedListener- Parameters:
session- 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 unspecified
-
messageAvailable
for non-muxed- Specified by:
messageAvailablein interfaceI2PSessionListener- Specified by:
messageAvailablein interfaceI2PSessionMuxedListener- Parameters:
session- session to notifymsgId- message number availablesize- size of the message - why it's a long and not an int is a mystery
-
reportAbuse
Description copied from interface:I2PSessionMuxedListenerInstruct the client that the session specified seems to be under attack and that the client may wish to move its destination to another router. All registered listeners will be called. Unused. Not fully implemented.- Specified by:
reportAbusein interfaceI2PSessionListener- Specified by:
reportAbusein interfaceI2PSessionMuxedListener- Parameters:
session- session to report abuse toseverity- how bad the abuse is
-
disconnected
Description copied from interface:I2PSessionMuxedListenerNotify the client that the session has been terminated. All registered listeners will be called.- Specified by:
disconnectedin interfaceI2PSessionListener- Specified by:
disconnectedin interfaceI2PSessionMuxedListener
-
errorOccurred
Description copied from interface:I2PSessionMuxedListenerNotify the client that some error occurred. All registered listeners will be called.- Specified by:
errorOccurredin interfaceI2PSessionListener- Specified by:
errorOccurredin interfaceI2PSessionMuxedListener- Parameters:
error- can be null? or not?
-