|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.klomp.snark.dht.KRPC
public class KRPC
Standard BEP 5 Mods for I2P:
- The UDP port need not be pinged after receiving a PORT message. - The UDP (datagram) port listed in the compact node info is used to receive repliable (signed) datagrams. This is used for queries, except for announces. We call this the "query port". In addition to that UDP port, we use a second datagram port equal to the signed port + 1. This is used to receive unsigned (raw) datagrams for replies, errors, and announce queries.. We call this the "response port". - Compact peer info is 32 bytes (32 byte SHA256 Hash) instead of 4 byte IP + 2 byte port. There is no peer port. - Compact node info is 54 bytes (20 byte SHA1 Hash + 32 byte SHA256 Hash + 2 byte port) instead of 20 byte SHA1 Hash + 4 byte IP + 2 byte port. Port is the query port, the response port is always the query port + 1. - The trackerless torrent dictionary "nodes" key is a list of 32 byte binary strings (SHA256 Hashes) instead of a list of lists containing a host string and a port integer.Questions: - nodes (in the find_node and get_peers response) is one concatenated string, not a list of strings, right? - Node ID enforcement, keyspace rotation?
| Field Summary | |
|---|---|
static NID |
FAKE_NID
all-zero NID used for pings |
static boolean |
SECURE_NID
|
| Constructor Summary | |
|---|---|
KRPC(I2PAppContext ctx,
I2PSession session)
|
|
| Method Summary | |
|---|---|
void |
announce(byte[] ih)
Announce to ourselves. |
void |
announce(byte[] ih,
byte[] peerHash)
Announce somebody else we know about. |
int |
announce(byte[] ih,
int max,
long maxWait)
Announce to the closest peers in the local DHT. |
void |
clear()
Clears the tracker and DHT data. |
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. |
List<NodeInfo> |
findClosest(byte[] ih,
int max)
Local lookup only |
Collection<Hash> |
getPeers(byte[] ih,
int max,
long maxWait)
Get peers for a torrent. |
int |
getPort()
|
int |
getRPort()
|
(package private) NodeInfo |
heardAbout(NodeInfo nInfo)
Called for bootstrap or for all nodes in a receiveNodes reply. |
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 Will be called only if you register via addMuxedSessionListener(). |
void |
ping(Destination dest,
int port)
Ping. |
String |
renderStatusHTML()
Debug info, HTML formatted |
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. |
int |
size()
Known nodes, not estimated total network size. |
void |
start()
Loads the DHT from file. |
void |
stop()
Stop everything. |
void |
unannounce(byte[] ih)
Remove reference to ourselves in the local tracker. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final NID FAKE_NID
public static final boolean SECURE_NID
| Constructor Detail |
|---|
public KRPC(I2PAppContext ctx,
I2PSession session)
| Method Detail |
|---|
public int size()
size in interface DHTpublic int getPort()
getPort in interface DHTpublic int getRPort()
getRPort in interface DHT
public void ping(Destination dest,
int port)
ping in interface DHT
public List<NodeInfo> findClosest(byte[] ih,
int max)
ih - a 20-byte info hashmax - max to return
public Collection<Hash> getPeers(byte[] ih,
int max,
long maxWait)
getPeers in interface DHTih - the Info Hash (torrent)max - maximum number of peers to returnmaxWait - the maximum time to wait (ms) must be > 0
public void announce(byte[] ih)
announce in interface DHTih - the Info Hash (torrent)
public void announce(byte[] ih,
byte[] peerHash)
announce in interface DHTih - the Info Hash (torrent)peerHash - the peer's Hashpublic void unannounce(byte[] ih)
unannounce in interface DHTih - the Info Hash (torrent)
public int announce(byte[] ih,
int max,
long maxWait)
announce in interface DHTih - the Info Hash (torrent)max - maximum number of peers to announce tomaxWait - the maximum total time to wait (ms) or 0 to do all in parallel and return immediately.
public void start()
public void stop()
stop in interface DHTpublic void clear()
public String renderStatusHTML()
renderStatusHTML in interface DHTNodeInfo heardAbout(NodeInfo nInfo)
public void messageAvailable(I2PSession session,
int msgId,
long size,
int proto,
int fromPort,
int toPort)
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 unspecified
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 mystery
public void reportAbuse(I2PSession session,
int severity)
I2PSessionMuxedListener
reportAbuse in interface I2PSessionListenerreportAbuse in interface I2PSessionMuxedListenersession - session to report abuse toseverity - how bad the abuse ispublic void disconnected(I2PSession session)
I2PSessionMuxedListener
disconnected in interface I2PSessionListenerdisconnected in interface I2PSessionMuxedListener
public void errorOccurred(I2PSession session,
String message,
Throwable error)
I2PSessionMuxedListener
errorOccurred in interface I2PSessionListenererrorOccurred in interface I2PSessionMuxedListenererror - can be null? or not?
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||