diff --git a/lib/Service.js b/lib/Service.js index c937ceb..ae92413 100644 --- a/lib/Service.js +++ b/lib/Service.js @@ -4,6 +4,7 @@ var os = require('os') var util = require('util') var EventEmitter = require('events').EventEmitter var serviceName = require('multicast-dns-service-types') +var net = require('net') var TLD = '.local' var REANNOUNCE_MAX_MS = 60 * 60 * 1000 @@ -24,6 +25,7 @@ var Service = function (opts) { this.subtypes = opts.subtypes || null this.txt = opts.txt || null this.published = false + this.ip = opts.ip || null this._activated = false // indicates intent - true: starting/started, false: stopping/stopped } @@ -104,6 +106,16 @@ var proto = { _records: function () { var records = [this._rrPtr(), this._rrSrv(), this._rrTxt()] + if (this.ip) { + if (net.isIP(this.ip) === 4) { + records.push(rrA(self, this.ip)) + return records + } else if (net.isIP(this.ip) === 6) { + records.push(rrAaaa(self, this.ip)) + return records + } + } + var interfaces = os.networkInterfaces() for (var ifaceID in interfaces) { var iface = interfaces[ifaceID]