kademlia-dhtl/README.md
2025-05-13 21:38:51 +02:00

30 lines
1.4 KiB
Markdown

# Kademlia DHT over HTTP for lists
## TL;DR
Simple HTTP server impl that can be used for DHTs that can store multiple values at once,
using the techniques described in the infamous [Kademlia paper](https://pdos.csail.mit.edu/~petar/papers/maymounkov-kademlia-lncs.pdf).
Such a design may be useful when wanting to connect multiple peers with each other.
Think of meetings in the browser where participants must be connected via WebRTC.
## Limitations
* `SHA1` keys => 20 byte keys
* Max value size of `2048` bytes
* No authentication, etc (just like Kademlia)
* Short TTL (currently `10` minutes)
## Spec
### HTTP Routes
|Path|Description|
|-|-|
|GET `/ping`|Check if the node is alive, node should respond with own id in hex and status HTTP `242`|
|GET `/get/:key?limit=<limit>`|Obtain the entries for the given `key` from node; `limit` may be omitted|
|POST `/put/:key`|Add an entry to the given `key`; value base64 encoded in body as `text/plain`|
|GET `/find`|Obtain all remote nodes from the node; JSON schema like `[[hex_id0, host0], [hex_id1, host1]]`; May not be implemented|
|GET `/find/:key?limit=<limit>`|Obtain the remote nodes from the node that are closest to the given `key`, ordered closest-first; `limit` may be omitted; same JSON schema as `/find`|
|POST `/notify`|Notify the node about a given host; host as `text/plain` in body; May not be implemented but useful for keeping the network intact|