Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

libp2p-mdns

Package Overview
Dependencies
Maintainers
2
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

libp2p-mdns

Node.js libp2p mDNS discovery implementation for peer discovery

  • 0.14.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1.3K
increased by45.01%
Maintainers
2
Weekly downloads
 
Created
Source

libp2p-mdns JavaScript implementation

Discourse posts Dependency Status js-standard-style

JavaScript libp2p MulticastDNS discovery implementation

Lead Maintainer

Jacob Heun

Usage

const MDNS = require('libp2p-mdns')

const mdns = new MDNS(options)

mdns.on('peer', (peerData) => {
  console.log('Found a peer in the local network', peerData.id.toB58String(), peerData.multiaddrs)
})

// Broadcast for 20 seconds
mdns.start()
setTimeout(() => mdns.stop(), 20 * 1000)
  • options
    • peerId - PeerId to announce
    • multiaddrs - multiaddrs to announce
    • broadcast - (true/false) announce our presence through mDNS, default false
    • interval - query interval, default 10 * 1000 (10 seconds)
    • serviceTag - name of the service announce , default 'ipfs.local`
    • compat - enable/disable compatibility with go-libp2p-mdns, default true

MDNS messages

A query is sent to discover the IPFS nodes on the local network

{ type: 'query',
  questions: [ { name: 'ipfs.local', type: 'PTR' } ]
}

When a query is detected, each IPFS node sends an answer about itself

[ { name: 'ipfs.local',
    type: 'PTR',
    class: 'IN',
    ttl: 120,
    data: 'QmNPubsDWATVngE3d5WDSNe7eVrFLuk38qb9t6vdLnu2aK.ipfs.local' },
  { name: 'QmNPubsDWATVngE3d5WDSNe7eVrFLuk38qb9t6vdLnu2aK.ipfs.local',
    type: 'SRV',
    class: 'IN',
    ttl: 120,
    data:
     { priority: 10,
       weight: 1,
       port: '20002',
       target: 'LAPTOP-G5LJ7VN9' } },
  { name: 'QmNPubsDWATVngE3d5WDSNe7eVrFLuk38qb9t6vdLnu2aK.ipfs.local',
    type: 'TXT',
    class: 'IN',
    ttl: 120,
    data: ['QmNPubsDWATVngE3d5WDSNe7eVrFLuk38qb9t6vdLnu2aK'] },
  { name: 'LAPTOP-G5LJ7VN9',
    type: 'A',
    class: 'IN',
    ttl: 120,
    data: '127.0.0.1' },
  { name: 'LAPTOP-G5LJ7VN9',
    type: 'AAAA',
    class: 'IN',
    ttl: 120,
    data: '::1' } ]

Keywords

FAQs

Package last updated on 02 Jul 2020

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc