GithubHelp home page GithubHelp logo

jinroh / kadoh Goto Github PK

View Code? Open in Web Editor NEW
242.0 27.0 31.0 9.99 MB

The Kademlia DHT in Javascript for Node.js and Browsers

Home Page: http://jinroh.github.com/kadoh

License: Other

JavaScript 84.51% CSS 15.22% Ruby 0.27%

kadoh's Introduction

KadOH - Javascript P2P framework

KadOH is a framework to build P2P applications for browsers and node.js. By implementing the basis of the Kademlia DHT, KadOH lets you build distributed web applications for mobile and desktop devices. With its flexible and extensible design, you can easily adapt KadOH to fit your needs. KadOH is available under the MIT License.

KadOH abstract many different transport protocols to provide P2P connections. In the browser we support XMPP over Bosh and Socket.io shipped with a node.js router, and you can go for UDP and native XMPP in a node.js application. We plan to support WebRTC soon !

See the wiki for more informations ! Also take look at our report and be aware that this document may be outdated.


Acknowledgments — We would like to thank Dr. Tudor Dumitraş, who gave us the honor to work with him during our project and always made available his support.

Alexandre Lachèze and Pierre Guilleminot

See it in action

Live demo based on XMPP transport running on Amazon EC2.

Run it yourself

First you can start a little DHT based on UDP transport using this command :

bin/dht udp.default

Then in an other terminal, start the web-based debug UI using the following Jake command and go to localhost:8080 :

jake run:udp

See the wiki for more informations on how to launch your own DHT from scratch and on different environments.

Installation

Install KadOH

The only required dependency is node.js (version >= 0.6, but you clould try below..). Take a look at the official manual to install node on your system.

Then run :

npm install kadoh
# or: git clone https://github.com/jinroh/kadoh.git
cd kadoh
npm install

You may also want to install the Jake module globally :

npm install -g jake

For Linux users, if the installation of KadOH's dependencies fails, you may need to install the libexpat-dev package. For Ubuntu/Debian users, run the following command :

sudo apt-get install libexpat-dev

Build and go

Browser

To build the source inside the dist folder run one of the following Jake command :

jake build

This will build two versions of KadOH supporting different transports :

  • SimUDP using Socket.io
  • XMPP using Strophe.js for XMPP over Bosh

Node.js

If you need to use KadOH in a node.js application, just add kadoh in your package dependencies and use :

var kadoh = require('kadoh');

Thanks

KadOH is built on top of many open-source libraries and projects:

Tests

Build Status

For the moment, tests are not running anymore.. But we hope that will be fixed as soon as we migrate to Mocha.

jake test:node
jake test:browser

kadoh's People

Contributors

alacheze avatar alexstrat avatar garyhodgson avatar jinroh avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

kadoh's Issues

The XMPP protocol

Let's list here all the technologies we have seen that could help us to implement our system over XMPP

License

Chosing a LICENSE for our project :

  • MIT
  • BSD
  • GPL (v2 || v3)
  • Apache
  • ...

Adaptive time-out

Based on RTTs and stats of received response to an already completed query.

Organize as Classes

Organize client side code as Classes with appropriate namespaces..

Find the appropriate framework that works both on client side and Node (for testing and benchmarking).

avoidusingcomplexdesignpatternsinwhichweneverknowwhatisThis

Have an XMPP over BOSH bot

It's closer to reality for benchmarking.

Related to #41 since node-xmpp wil have an XMPP bosh for node.js and browser.

Fusion /router and /dht

Separate server-side than client-side code

In /lib create 2 folders : client and server

Handle with the namespace

Migrate SimUDP client Code into client/transport/SimUDP.js

Handle with the dependencies of Socket.io.client

Unify the build code

Migrate the readme into docs

Migrate example into example/SmUDP

Test Fail in Peer sometimes

Il m'est arrivé 1 ou 2 fois seulement en lançant les tests dans node d'avoir le fail suivant :

Peer
  it should be possible to instanciate a peer using a triple
  Error: Expected '90f6505db61ecc6021beb7fec7ee16793d83c33a' to equal '3164dfe811bf14f8b185b62c8da4d7a8164fc082'.
    at [object Object].<anonymous> (/Users/alex/Taf/3A Eurecom/SemesterProject/kadoh/spec/peer.spec.js:40:26)

Chelou ! Grave ?

Logic Routing Table : ping oldest..

Lorsqu'on veut ajouter un nouveau peer et que son KBucket est full et non splittable, on prend le plus vieux peer du KBucket, on le PING et s'il répond on laisse tomber le nouveau.

Ne penses tu pas qu'on devrait les pinger un par un dans l'ordre décroissant de vieillesse jusqu'à ce qu'il y en ait un qui ne réponde pas ?

C'est déjà vu quelque part ?

Re-write connection/disconnection flow

Ideas :

  • create an other state of the reactor : kind of pause state where RPCs are not sent for any reasons (transport disconnected).
  • automatic re-connection after disconnection.. Related to #42

Using WebWorkers ?

Maybe we could use webworkers to run our node object since we don't need any DOM access and we would take advantage of multithreading.

stackoverflow

  • John Resig (of jQuery fame) has a bunch of interesting examples of using web workers here - games, graphics, crypto.
  • Another use is Web I/O - in other words, polling URLs in background. That way you don't block the UI waiting for polling results.
  • Another practical use: in Bespin, they’re using Web Workers to do the syntax highlighting, which you wouldn’t want to block your code editing whilst you’re using the app.
  • From Mozilla: One way workers are useful is to allow your code to perform processor-intensive calculations without blocking the user interface thread.
    As a practical example, think of an app which has a large table of #s (this is real world, BTW - taken from an app I programmed ~2 years ago). You can change one # in a table via inpput field and a bunch of other numbers in different columns get re-computed in a fairly intensive process.
    The old workflow was: Change the #. Go get coffee while JavaScript crunches through changes to other numbers and the web page is unresponsive for 3 minutes - after I optimized it to hell and back. Get Back with coffee. Change a second #. Repeat many times. Click SAVE button.
    The new workflow with the workers could be: Change the #. Get a status message that something is being recomputed but you can change other #s. Change more #s. When done changing, wait till status changes to "all calculations complete, you can now review the final #s and save".

Centralyzed logging server/DB

Create a REST server that receives the logging data of runnings instances (bots and non-bots) and store them in a SQL DB. There are then possibilities to gather interesting stistics information.

TODO

  • what logging data do we need ?
  • schema ?

Wish List..

  • tests : migration from Jasmine to Mocha
  • eventually migrate to Browserify
  • do a complete BitTorrent Client
  • have a nice documentation generator. Hope is here : doctor
  • .. a report maybe ?

EventEmitter to report activity

Bon alors comme on en avait discuter, je pense qu'il sera plus simple de faire un gros "EventManager" pour tout KadOH plutôt que chaque objet (RoutingTable , les KBuckets...) soient chacun un EventEmitter auquel il faudra s'abonner individuellement..

Avantages :

  • on s'occupe d'ajouter des listeners qu'à un seul endroit, c'est à dire à l'endroit où on en a vraiment besoin : juste avant un console-log, à l'update d'une UI ou avant de l'envoyer dans socket.io pour un report à distance.
  • pas d'extension de classe qui peut-être badante.

Petits inconvénients

  • faudrait faire gaffe à faire un namespace des events "intelligent" et à donner des arguments "utiles" aux listeners, avec une bonne doc.

Petits plus

Y'a moyen de faire un systeme de namespace comme dans celui de EventEmitter2 qui permet de s'abonner à des events qui matchent un pattern (eg foo:bar)... Mais je trouve l'intêret finalement limité.

Démystification

Un systeme d'EventEmitter n'est en fait qu'un tableau de callback quoi qu'il arrive. Jette un coup au module event de Node.js, c'est déconcertant de simplicité.

Du coup..

Je vasi essayer de mettre en place ce truc rapidement, comme ça on rajoute des emitions d'event un peu partout rapidement..

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.