2.0.3 • Published 4 years ago

find-peers v2.0.3

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

find-peers

A module to find nodes on a network, establish secure communication channels, execute code and much much more.

Features

  • Communication channels after node discovery

  • Node monitoring via a local web server

  • Complete control over node & remote access terminals
  • Scale and execute code on connected peers (Javascript through Node.js VM or binary executables through Child Process)
  • File transfers & file synchronisation
  • Sync with a node list on a server
  • Automatically refresh node status every N seconds
  • Interact through emitted events, RXJS or promises
  • Communication through TCP, HTTP, TLS, HTTPS or socket.io
  • Definable master-slave sub networks / nodes
  • 6 Authentication levels:
  • No authentication (0)
  • Hashed key exchange (1)
  • Encrypted key (2)
  • Generated key exchange (RSA, ec, x448) etc. (3)
  • End to end encryption (4)
  • Middle man server communication (5)

Installation

npm i find-peers --save

Installation notes

Socket.io

To use find-peers in Socket.io mode install it first.

npm i socket.io-client
npm i socket.io

node-forge

To automatically generate self signed SSL certificates at runtime node-forge must be installed.

npm i node-forge

Quick usage

Import it

const { FindPeers } = require('find-peers');

Basic config

const options = { autoGenId: true };

Create instance

const find = new FindPeers(options);

Listen for events

  find.on('found-nodes', (data) => {
      // new discovered nodes
  });
  find.on('server_up', () => {
      console.log('server is up!');
  });
  find.on('server_err', (err) => {
      console.log(err);
  });
  find.on('multicast_err', (err) => {
      console.log(err);
  });
  find.on('echo', (data) => {
      console.log(data.message, 'from', data.from.id);
  });

Config options

PropertyDescriptionDefault value
autoGenIdAutomatically generate a 32 word random idfalse
identitySet node details: id, bind to ip etc.undefined
securityLevelSecurity mode of the library to be used4
verifyTriesNumber of times to attempt to verify a node during initial pairing3
tryTimeTimeout limit10000
hashOptionsOptions passed to argon 2 as per argon2.Options from node-argon2 ( 1 ){ hashLength: 32, memoryCost: 2**16, parallelism: 1, type: argon2.argon2i }
modLengthLength of generated RSA key ( 3 )2048
keyGenGroupAlgorithm for key generation ( 3 )rsa
aesVersionType of aes-256 to be used ( 2 - 4 )aes-256-cbc
oaepHashHash to use alongside pbkdf2sha-256
groupNameMod group to use in Diffie - Hellman exchangemodp15
autoStartSearchAutomatically start searching for nodes as soon as object is createdtrue
serverTypeServer type to be used for communication after node discoverytcp
serverPortServer port19235
multicastPortMulticast port18235
broadCastIntervalInterval at which to send out multicast500
multiCastTimeoutDuration of node search60000
multiCastReSearchAutomatically re - search for nodes300000
shouldReSearchEnable re - searchfalse
searchForeverDisable multiCastTimeout and re - searchfalse
shouldPingPing nodes to veriy if still activefalse
pingIntervalInterval to ping nodes at1000
pingCountNumber of failed ping attempts before marked as disconnect20
temporaryDisconnectNumber of failed ping attempts before marked as temporary disconnect10
pingMIANumber of seconds between ping reponses to be marked as temporary disconnect25000
pingLimitNumber of failed ping attempts before reconnection attempts are stopped100
whiteListArray of nodes (by ip or id) to be whitelisted from pingundefined
blackListArray of nodes (by ip or id) to be blacklisted from connectionsundefined
privateServerKeyPrivate key for https, tls server or Socket.io https serverundefined
certificateCertificate / public key for https, tls server or Socket.io https serverundefined
genKeypairAutomatically generate an SSL key pair (private key, certificate) for use with https, tls or Socket.io https server using node-forgefalse
attrsAttributes passed for SSL key pair generation (country name, address, organization name, etc...) { name : 'commonName' , value : 'example.org' } , { name : 'countryName' , value : 'US' } , { shortName : 'ST' , value : 'Virginia' } , { name : 'localityName' , value : 'Blacksburg' } , { name : 'organizationName' , value : 'Test' } , { shortName : 'OU' , value : 'Test' }
socketIOOptionsOptions to be used with Socket.io server { path:'/', mode:'http' }

Functions

FunctionDescriptionArguments
getClientsGet entire list of verified nodesvoid
echoSend a message to all nodesmessage: string, omit ?: string[]
messageClientSend message to a specific nodeid: string, message: string
getIdentityGet identity object of current nodevoid
2.0.3

4 years ago

2.0.2

4 years ago

2.0.1

4 years ago

2.0.0

4 years ago

1.0.1004

4 years ago

1.0.1003

4 years ago

1.0.1002

4 years ago

1.0.1001

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago