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

@astronautlabs/mdns

v1.0.10

Published

Fully featured mDNS and DNS-SD implementation in Typescript

Downloads

101

Readme

@/mdns

npm CircleCI

📜 IETF RFC 6762
Multicast DNS

📜 IETF RFC 6763
DNS-Based Service Discovery

📺 Part of the Astronaut Labs Broadcast Suite

Production Quality
This library is ready for use today (v1.x.x) but will be receiving substantial API upgrades and retooling to use more of the @astronautlabs/* frameworks in v2.x, so expect fairly large compatibility changes when those versions are released.

Fully featured mDNS and DNS-SD implementation in Typescript. No native dependencies, works alongside OS-level implementations as long as multiple UDP socket listeners are supported on your platform (supported in modern macOS, Windows, Linux). Extensive tests with continuous integration. Intended for use by Astronaut Labs' NMOS IS-04 implementation, but usable for any general purpose mDNS/DNS-SD use cases.

npm install @astronautlabs/mdns

Usage

Advertise an HTTP server on port 4321:

import { Advertisement } from '@astronautlabs/mdns';

const ad = new Advertisement('_http._tcp', 4321)
  .start();

Find all Google Cast compatible devices:

import { Browser } from '@astronautlabs/mdns';

new Browser('_googlecast._tcp')
  .on('serviceUp', service => console.log("Device up: ", service))
  .on('serviceDown', service => console.log("Device down: ", service))
  .start();

You can also use this library to query multicast DNS as you would unicast DNS using the MulticastDNS class.

import { MulticastDNS } from '@astronautlabs/mdns';
let ipAddress: string = await MulticastDNS.A('myService._http._tcp');

You can also use MulticastDNS.query() to retrieve the records themselves.

import { MulticastDNS, SRVRecord } from '@astronautlabs/mdns';

let { answer, related } = await MulticastDNS.query<SRVRecord>('myService._http._tcp', 'SRV');
// answer: SRVRecord, related: ResourceRecord[]

Validation

Service type names and TXT records have some specific restrictions.

Service names:

  • must start with an underscore _
  • less than 16 chars including the leading _
  • must start with a letter or digit
  • only letters / digits / hyphens (but not consecutively: --)

TXT records:

  • Keys <= 9 chars
  • Keys must be ascii and can't use '='
  • Values must be a string, buffer, number, or boolean
  • Each key/value pair must be < 255 bytes
  • Total TXT object is < 1300 bytes

Credits

This package is based on Gravity Software's dnssd.js package, which itself is based on David Siegel's mdns package.