tubemail-mdns

2.0.0 • Public • Published

Tube Mail: Discovery mDNS

This is just a helper module for Tube Mail. This module can be used to enable mDNS-based discovery.

Example

// npm install tubemail tubemail-mds
const fs = require('fs');
const tubemail = require('tubemail');
 
const toBuffer = (obj) => Buffer.from(obj.toString());
 
tubemail.join({
    key: fs.readFileSync('./hood.peer1.key'),
    cert: fs.readFileSync('./hood.peer1.crt'),
    ca: fs.readFileSync('./hood.crt'),
    discovery: require('tubemail-mdns');
}).then((hood) => {
    // Send the current time every second
    setInterval(() => hood.send(toBuffer(new Date())), 1000);
 
    // Say hello to new neighs
    hood.on('foundNeigh', (n) => n.send(toBuffer(`Hello ${n.info.subject.commonName}!`)));
});

/tubemail-mdns/

    Package Sidebar

    Install

    npm i tubemail-mdns

    Weekly Downloads

    3

    Version

    2.0.0

    License

    MIT

    Unpacked Size

    3.02 kB

    Total Files

    4

    Last publish

    Collaborators

    • jue89