General notes:
- Libtorrent’s DHT security extension is enforced, requiring the Node ID to be restricted by the external IP.
- Default’s libtorrent’s parameters are used: search_branching (alpha) = 5, bucket_size (k) = 8 and agressive_lookup = true.
- Stored resources meant for persistence in DHT network (like profile, avatar etc) are refreshed every hour. Previous studies have shown (Paper: Profiling a million user dht) that, under some assumptions and configurations, long-term data persistence may be achieved by refreshing every couple of hours.
- Persisted resources are also saved to disk and restored when twister daemon restarts.
-
DHT command: ping
ping query = {“t”:”aa”, “z”:”q”, “q”:”ping”, “x”:{“id”:”abcdefghij0123456789″}}
Response = {“t”:”aa”, “z”:”r”, “r”: {“id”:”mnopqrstuvwxyz123456″}}
-
DHT command: findNode
findNode Query = {“t”:”aa”, “z”:”q”, “q”:”findNode”, “x”: {“id”:”abcdefghij0123456789″, “target”:”mnopqrstuvwxyz123456″}}
Response = {“t”:”aa”, “z”:”r”, “r”: {“id”:”0123456789abcdefghij”, “nodes”: “def456…”}}
-
DHT command: announcePeer
Note: this command may be removed in future.
announcePeer Query = {“t”:”aa”, “z”:”q”, “q”:”announce_peer”, “x”: {“id”:”abcdefghij0123456789″, “implied_port”: 1, “info_hash”:”mnopqrstuvwxyz123456″, “port”: 6881, “token”: “aoeusnth”}}
Response = {“t”:”aa”, “z”:”r”, “r”: {“id”:”mnopqrstuvwxyz123456″}}
-
DHT command: getPeers
Unlike BitTorrent DHT, getPeers command doesn’t exist. Use command getData with “target”={“username”,”tracker”,”m”} instead.
-
DHT command: putData
putData Query = {“t”:”aa”, “z”:”q”, “q”:”putData”, “x”: {
“id”:”abcdefghij0123456789″, “sig_p”:”34fdd3wdw”, “sig_user”:”nobody”, “token”: “aoeusnth”, “p”: {
“v” : “arbitrary-value”, “seq” : “10″, “time” : “13131321321″, height : “1000″, “target”: {
“n”:”name”, “r”:”resource”, “t”:”m” }}}}Response = {“t”:”aa”, “z”:”r”, “r”: {“id”:”mnopqrstuvwxyz123456″}}
Note: target_id is the hash of bencoded “target” field.
-
DHT command: getData
getData Query = {“t”:”aa”, “z”:”q”, “q”:”getData”, “x”: {
“id”:”abcdefghij0123456789″, “justtoken”:”0″, “target”: {
“n”:”name”, “r”:”resource”, “t”:”m” }}}}Response = {“t”:”aa”, “z”:”r”, “r”: {“id”:”mnopqrstuvwxyz123456″, “token”: “aoeusnth”, “data”: [
{"p":"data1", "sig_p":"34fdd3wdw", "sig_user":"nobody",
{"p":"data2", "sig_p":"fg40958ejfdg", "sig_user":"twister" ] }}Note: target_id is the hash of bencoded “target” field.
It would be nice if you’d use http://jsonlint.com/ to get a more beautified json structure