npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

host-discovery

v1.0.5

Published

A simple discovery service which sends and receives messages to/from a multicast address in JSON format.

Downloads

5

Readme

host-discovery

A simple service which sends messages to a multicast address in JSON format. It is designed to run on multiple hosts to maintain a list of subscribers to the multicast group. That can be useful for creating a distributed service. A filter, represented by the "service" field, can be used to filter messages if other hosts emit packets on the same multicast address. IPv4 and IPv6 are supported.

Installation

npm install host-discovery

How to

Import module

var hostDiscovery = require('host-discovery');

Create instance

var service = new hostDiscovery({
    service: 'test',    // Default to 'all'
    protocol: 'udp4',   // Default to udp4, can be udp6
    port: 60600         // Default to 2900
});

If default options are sufficient for you, you can create an instance like this :

var service = new hostDiscovery();

Or for one option :

var service = new hostDiscovery({
    protocol: 'udp6'    
});

Events

Two events are implemented :

  • join for new members of multicast group and service field
  • leave for members which has left multicast group
service.on('join', (ip) => { 
    console.log('A new member has joined the group : ' + ip); 
});

service.on('leave', (ip) => { 
    console.log('A member has left the group : ' + ip); 
});

The detection of a leaving host is between 10 and 15 seconds.

Methods

To start the service :

service.start();

To stop the service :

service.stop();

To get active hosts :

service.hosts();

// The result will be :
[ '192.168.0.11': { 
    address: '192.168.0.11',
    hostname: 'test01',
    timestamp: 1463782466523
  },
  '192.168.0.12': { 
    address: '192.168.0.12',
    hostname: 'test02',
    timestamp: 1463782466527
  },
  '192.168.0.13': { 
    address: '192.168.0.13',
    hostname: 'test03',
    timestamp: 1463782466537
  } 
]

Updates

  • v1.0.5 : Sometimes, we are doing stupid things. Timestamp field is back and host's desinscription magically works again.
  • v1.0.4 : Remove "timestamp" field
  • v1.0.3 : Add "address" field
  • v1.0.2 : Fix "ReferenceError: os is not defined"
  • v1.0.1 : Fix "ReferenceError: util is not defined"
  • v1.0.0 : Initial release

Licence

The MIT License (MIT) Copyright (c) 2016 Julien Blanc