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

resin-discoverable-services

v2.0.5

Published

Balena local service discovery utilities

Downloads

182

Readme

resin-discoverable-services

Discover all resin registered services from the local network.

npm version [dependencies Build Status ![Gitter](https://badges.gitter.im/Join Chat.svg)

Role

The intention of this module is to provide a way to discover zeroconf services advertised by Resin.io components and devices on a local network.

Installation

Install resin-discoverable-services by running:

$ npm install --save resin-discoverable-services

API

This module exports three methods:

setRegistryPath(path)

This informs the module where to search for valid services to register with itself. By default this is the services directory within it. Service definitions are defined as a set of nested directories, and take the form:

`[<subtype>/]<type>/<protocol>`

A tags.json file may exist in the lowest level directory in a service definition and consists of an array of strings, each of which is a 'shortened name' for the service defined, eg.:

`[ 'serviceShortName', 'reallyShort' ]`

enumerateServices([callback(error, services)])

Returns the list of currently registered service definitions. Service definitions are returned in the standard service form:

`{ service: `[_<subtype>._sub]._<type>._protocol`, tags: [ [tagNames] ] }`

Notice Should a callback not be provided, then the method will return a resolvable Promise.

Only registered services returned by the enumerateServices() method may be used to find services on the local network.

Should a callback not be provided, then the method will return a resolvable Promise.

findServices(services, [[timeout], [callback(error, services)])

Searches for any occurrences of the specified services on the local network. Services are passed in the standard service form, or as a tag associated with that service.

Notice Should a callback not be provided, then the method will return a resolvable Promise.

The timeout value is the length of time in milliseconds that the module will search for before returning any results. If no value is passed, it defaults to 2000ms.

The method returns an array of services that conform to those registered. Each service information object consists of:

  • Array[String] addresses: An array denoting either an IPv4 or IPv6 addresses where the service is located.
  • String name: The name of the service, eg. My Service.
  • String fqdn: The fully qualified domain name of the service, eg. My Service._ssh._tcp.local.
  • String host: The machine node name where the service is located, eg. myMachine.local.
  • Number port: 222,
  • String type: The type of the service, eg. ssh.
  • String protocol: The protocol the service uses, eg. tcp.
  • Array[String] subtypes: An array of subtypes pertaining to this service, these will only be filled in should the specific subtype have been used in the method call.
  • Object txt: Any text records that go along with the service, eg. 'username'.
  • Object referer: An object containing:
    • String address: Address of the referer.
    • String family: IP family that the referer used (IPv4 or IPv6).
    • Number port: The port on which the referer runs.

publishServices(services, [options, [callback(error, services)]])

Publishes any valid service to the network. If a call to this method is made then a corresponding call to unpublishServices() must be made before process exit to ensure any existing network sockets are finalised.

Notice Should a callback not be provided, then the method will return a resolvable Promise.

services is an array of objects, each of which contains:

  • String identifier: The standard service form of the service to publish, or a tag associated with that service.
  • String name: The name under which to publish the service, (eg. Resin SSH).
  • Number port: The port number to advertise the service as running on.
  • String host: An optional host name to publish the service as running on. This is useful for proxying.

options is an object allowing publishing options to be passed:

  • String mdnsInterface: An IPv4 or IPv6 address of a current valid interface with which to bind the MDNS service to (if unset, first available interface).

unpublishServices([callback])

Unpublishes all services currently published to the network. This method must be called prior to process exit should any calls to publishServices() have been made.

Notice Should a callback not be provided, then the method will return a resolvable Promise.

Support

If you're having any problem, please raise an issue on GitHub and the Resin.io team will be happy to help.

Tests

Run the test suite by doing:

$ gulp test

Contribute

Before submitting a PR, please make sure that you include tests, and that coffeelint runs without any warning:

$ gulp lint

License

The project is licensed under the Apache 2.0 license.