Pierre Krieger 68299c40a5
Implement Kademlia peer discovery (#120)
* Impl Clone for SwarmController and remove 'static

* Implement Kademlia

* Implement ConnectionReuse correctly

* Implement ConnectionReuse correctly

* Add some tests and fixes

* Remove useless boolean in active_connections

* Correctly run tests

* Optimize the processing

* Rustfmt on libp2p-kad

* Improve Kademlia example

* Next incoming is now in two steps

* Some work

* Remove log

* Fix dialing a node even if we already have a connection

* Add a proper PeerId to Peerstore

* Turn identify into a transport layer

* Expose the dialed multiaddress

* Add identified nodes to the peerstore

* Allow configuring the TTL of the addresses

* Split identify in two modules

* Some comments and tweaks

* Run rustfmt

* More work

* Add test and bugfix

* Fix everything

* Start transition to new identify system

* More work

* Minor style

* Start implementation of Kademlia server upgrade

* Continue implementing the Kademlia server

* Start reimplementing high-level kademlia code

* Continue reimplementing high-level code

* More work

* More work

* More work

* Fix wrong address reported when dialing

* Make it work

* Remove cluster_level field everywhere

* Fix bug in varint-rs when encoding

* More work

* More work

* More work

* More work

* More work

* Bugfix

* More work

* Implement ping

* Style in kademlia_handler

* More work

* Better error handling in query.rs

* More work

* More work

* More work

* Debug impls

* Some cleanup in swarm

* More work

* Clean up changes in swarm

* Unpublish the kbucket module

* Fix examples and some warnings

* Fix websocket browser code

* Rustfmt on libp2p-kad

* Kad initialization process

* Add logging to the example

* Fix concerns

* Fix style
2018-03-15 15:18:21 +01:00
..

Examples

Running one of the examples:

cargo run --example <name-of-the-example>

The follow examples exist:

  • echo-dialer will attempt to connect to /ip4/127.0.0.1/tcp/10333, negotiate the /echo/1.0.0 protocol, then send the "hello world" message. Compatible with the echo-server example.
  • echo-server will listen on /ip4/0.0.0.0/tcp/10333, negotiate the /echo/1.0.0 protocol with each incoming connection, then send back any entering message. Compatible with the echo-dialer example.
  • ping-client will try to connect to /ip4/127.0.0.1/tcp/4001, which is the default address of your local IPFS node if you're running one. It will then open a substream and ping the node.

How the keys were generated

The keys used in the examples were generated like this:

openssl genrsa -out private.pem 2048
openssl rsa -in private.pem -outform DER -pubout -out public.der
openssl pkcs8 -in private.pem -topk8 -nocrypt -out private.pk8
rm private.pem      # optional