0.0.20 • Published 6 years ago

hypernode v0.0.20

Weekly downloads
4
License
MIT
Repository
github
Last release
6 years ago

Build Status Downloads MIT license

HyperNode logo

THIS IS AN UNFINISHED PROJECT

HyperNode is an open-source Node.js framework for building both large to small scale peer-to-peer (P2P) networks. The aim is to create a framework which allows developers to easily create peer-to-peer applications using any transport they please. All the complicated stuff like NAT traversal, managing peer health, etc. are being taken care of by Hypernode. Currently only transport via UDP is supported but we aim to support TCP and WebRTC in the near future.

Todo's

  • Implement more transports (TCP, WebRTC, WebSockets).
  • Implement more mechanisms for NAT traversal (currently only UDP holepunching is supported).
  • Implement E2EE mechanisms.
  • Efficiently distribute data across the network using a DHT.

Installation

npm install --save hypernode

Getting started

A Hypernode network requires at least one bootnode to function properly.

const Hypernode = require('hypernode')

// Create a bootnode.
const keypair = {
  public: '-----BEGIN PUBLIC KEY----- ... -----END PUBLIC KEY-----',
  private: '-----BEGIN RSA PRIVATE KEY----- ... -----END RSA PRIVATE KEY-----'
}
const bootnode = new Hypernode({ port: 3000, keypair: keypair })

// Create a default node (Hypernode distinguishes between bootnodes and default nodes using the initialPeers prop)
const node = new Hypernode({ port: 3000, initialPeers: initialPeers, keypair: keypair })

By omitting the keypair property Hypernode will generate a new keypair for you. By omitting te initialPeers property Hypernode will assume you're setting up a bootnode, and thus will not start gossiping.

Events

Each node is also an event listener which means you can do stuff like:

const node = new Hypernode({ port: 3001 })

node.on('message', (data, peer) => {
  // Emitted whenever a message from the network is received. `peer` contains info about the message sender.
});

node.on('peer:connected', peer => {
  // Emitted whenever a new peer joins the network.
})

node.on('peer:disconnected', peer => {
  // Emitted whenever a peer disconnects from the network.
})

Documentation

In development

Contributing

In development

License

Code released under the MIT license.

0.0.20

6 years ago

0.0.19

6 years ago

0.0.18

6 years ago

0.0.17

6 years ago

0.0.16

6 years ago

0.0.15

6 years ago

0.0.14

6 years ago

0.0.13

6 years ago

0.0.12

6 years ago

0.0.11

6 years ago

0.0.10

6 years ago

0.0.9

6 years ago

0.0.8

6 years ago

0.0.7

6 years ago

0.0.6

6 years ago

0.0.5

6 years ago

0.0.4

6 years ago

0.0.3

6 years ago

0.0.2

6 years ago

0.0.1

6 years ago