Socket
Book a DemoInstallSign in
Socket

lookup-multicast-dns

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lookup-multicast-dns

Lookup an ip for a hostname using multicast-dns if it is a .local domain or otherwise use the dns module

latest
Source
npmnpm
Version
1.0.3
Version published
Maintainers
1
Created
Source

lookup-multicast-dns

Lookup an ip for a hostname using multicast-dns if it is a .local domain or otherwise use the dns module

npm install lookup-multicast-dns

OSX supports resolving .local domains using mdns per default but unfortunately not all other platforms have as good support for it. On Ubuntu you currently have to install and run the avahi-daemon which is why I wrote this module that allows you to always resolve them from javascript without relying on os support.

Usage

var lookup = require('lookup-multicast-dns')

lookup('google.com', function (err, ip) {
  console.log(ip) // is resolved using normal dns (173.194.116.32 on my machine)
})

lookup('brunhilde.local', function (err, ip) {
  console.log(ip) // is resolved using multicast-dns (192.168.10.254 on my machine)
})

If you want the node core dns module to always support multicast-dns you can do the following

require('lookup-multicast-dns/global')

// core dns now always support resolving .local domains
var dns = require('dns')

dns.lookup('brunhilde.local', function (err, ip) {
  console.log(ip) // is resolved using multicast-dns (192.168.10.254 on my machine)
})

Command line tool

There is also a command line tool available if you install globally

npm install -g lookup-multicast-dns
lookup-multicast-dns brunhilde.local
> 192.168.10.254

Use register-multicast-dns to register a .local domain on another machine.

On one machine (let's pretend it has ip 192.168.10.456)

var register = require('register-multicast-dns')
register('hello-world.local')

On another

var lookup = require('lookup-multicast-dns')
lookup('hello-world.local', function (err, ip) {
  console.log(ip) // would print 192.168.10.456
})

License

MIT

FAQs

Package last updated on 10 Oct 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts