Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if (isAny || networkName === LOOPBACK_NAME) {
this._loopbackAllowed = true;
}
// Special case, where loopback interface is used
if (networkName === LOOPBACK_NAME) {
// There is a linux-avahi exception when dealling with a loopback interface
if (mdns.isAvahi) {
return callback(
new Error('loopback address is not supported on linux-avahi platform')
);
}
// Use specical key
network = mdns.loopbackInterface();
} else if (isAny) {
network = undefined;
}
this._discover = mdns.createBrowser(this._key, {
networkInterface: network
});
this._discover.on('error', this._relayError);
this._discover.start();
this._announce = mdns.createAdvertisement(
this._key, this._address.port, {
// workaround for some wird bug
// ref: https://github.com/agnat/node_mdns/issues/51
}
function MCHammer(options:any) {
options = options || {};
return function MCHammer(service:HammerTimeService, next:()=>void) {
console.log('STOP!');
setTimeout(function() {
console.log('hammertime...');
service.hammerTime = new Date();
next();
}, options.delay || 1000);
}
}
var browser = mdns.createBrowser( mdns.tcp('http')
, { networkInterface: mdns.loopbackInterface()});
var ad:MDNS.Advertisement;
function createAdvertisement() {
try {
ad = mdns.createAdvertisement(mdns.tcp('http'), 1337);
ad.on('error', handleError);
ad.start();
} catch (ex) {
handleError(ex);
}
}
function handleError(error:MDNS.DnsSdError) {
switch (error.errorCode) {
case mdns.kDNSServiceErr_Unknown: