Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function Service (opts) {
if (!opts.name) throw new Error('Required name not given')
if (!opts.type) throw new Error('Required type not given')
if (!opts.port) throw new Error('Required port not given')
this.name = opts.name
this.protocol = opts.protocol || 'tcp'
this.type = serviceName.stringify(opts.type, this.protocol)
this.host = opts.host || os.hostname()
this.port = opts.port
this.fqdn = this.name + '.' + this.type + TLD
this.subtypes = opts.subtypes || null
this.txt = opts.txt || null
this.published = false
this._activated = false // indicates intent - true: starting/started, false: stopping/stopped
}
function Service (opts) {
if (!opts.name) throw new Error('Required name not given')
if (!opts.type) throw new Error('Required type not given')
if (!opts.port) throw new Error('Required port not given')
this.name = opts.name
this.protocol = opts.protocol || 'tcp'
this.type = serviceName.stringify(opts.type, this.protocol)
this.host = opts.host || os.hostname()
this.port = opts.port
this.fqdn = this.name + '.' + this.type + TLD
this.subtypes = opts.subtypes || null
this.txt = opts.txt || null
this.published = false
this._activated = false // indicates intent - true: starting/started, false: stopping/stopped
}
function Service (opts) {
if (!opts.name) throw new Error('Required name not given')
if (!opts.type) throw new Error('Required type not given')
if (!opts.port) throw new Error('Required port not given')
this.name = opts.name
this.protocol = opts.protocol || 'tcp'
this.type = serviceName.stringify(opts.type, this.protocol)
this.host = opts.host || os.hostname()
this.port = opts.port
this.fqdn = this.name + '.' + this.type + TLD
this.subtypes = opts.subtypes || null
this.txt = opts.txt || null
this.published = false
this._activated = false // indicates intent - true: starting/started, false: stopping/stopped
}
function Browser (mdns, opts, onup) {
if (typeof opts === 'function') return new Browser(mdns, null, opts)
EventEmitter.call(this)
this._mdns = mdns
this._onresponse = null
this._serviceMap = {}
this._txt = dnsTxt(opts.txt)
if (!opts || !opts.type) {
this._name = WILDCARD
this._wildcard = true
} else {
this._name = serviceName.stringify(opts.type, opts.protocol || 'tcp') + TLD
if (opts.name) this._name = opts.name + '.' + this._name
this._wildcard = false
}
this.services = []
if (onup) this.on('up', onup)
this.start()
}
var Browser = module.exports = function (protocol, type, onup) {
if (!(this instanceof Browser)) return new Browser(protocol, type, onup)
if (!type) throw new Error('Required type not given')
EventEmitter.call(this)
if (onup) this.on('up', onup)
this._name = serviceName.stringify(type, protocol) + TLD
this.services = []
mdns.on('response', this._onresponse)
mdns.query(this._name, 'PTR')
}