this is a practice in UDP Multicasting, and DHT experimentation in a localhost. the idea is to run as many instances of this daemon as you want, and all instances will find eachother via udp multicast and build a dht network. each peer of the network generates an ed25519 keypair, and binds to a random port. the port is an http service that takes requests at these endpoints:
the /dht endpoint serves websocket rpc requests
the /api endpoint serves https curl requests. right now the only implemented rpc call is "ping"
its all a work-in-progress. more work to be added soon.
as each instance of this is executed on the network (or on the same computer), every 5 seconds the instance broadcasts a UDP packet containing a newly generated public key, a random service port, and consequentially its own ip address from the IP packet. each time an instance receives a UDP multicast packet, it checks the new peer's public key against a map, if its a newly found peer, it will log it to stdout, and add it to the map in memory. the bucket is printed every 5 seconds
git clone
this project, or download here: master.zip./build.sh
to build in docker, or just use go build
./demo.sh
to spawn ten instancescurl -kvs https://localhost:port/api/ping
^^^ this will tell the peer to perform an RPC ping to the top three closest peers in the bucket.
some things to note: