Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions advertisements_without_network.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// docker run --init -it --network none -v $(pwd):/tmp --rm node bash -c "node /tmp/advertisements_without_network.js"

const dnssd = require('./')

const interfaces = require('os').networkInterfaces()
Object.entries(interfaces).forEach(([name, addresses]) => {
console.log(name)
console.log(addresses)
if (addresses.filter(addressRecord => addressRecord.family === 'IPv4').length) {
const ad = new dnssd.Advertisement(dnssd.tcp('http'), 9999, {
interface: name
})
ad.on('error', err => {
console.log(err)
})
ad.start()
}
})

// setInterval(() => console.log('yay'), 1000)
4 changes: 3 additions & 1 deletion lib/NetworkInterface.js
Original file line number Diff line number Diff line change
Expand Up @@ -434,8 +434,10 @@ NetworkInterface.prototype.stop = function () {
NetworkInterface.prototype._onError = function (err) {
debug(this._id + ' had an error: ' + err + '\n' + err.stack);

if (this._usingMe > 0) {
this.emit('error', err);
}
this.stop();
this.emit('error', err);
};

module.exports = NetworkInterface;
6 changes: 4 additions & 2 deletions src/NetworkInterface.js
Original file line number Diff line number Diff line change
Expand Up @@ -425,11 +425,13 @@ NetworkInterface.prototype.stop = function() {
};


NetworkInterface.prototype._onError = function(err) {
NetworkInterface.prototype._onError = function (err) {
debug(`${this._id} had an error: ${err}\n${err.stack}`);

if (this._usingMe > 0) {
this.emit('error', err);
}
this.stop();
this.emit('error', err);
};


Expand Down