Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
_announce(sock, onComplete, flush, repeat, unicast) {
let message = require.weak("mdns/message");
if (unicast)
flush = false; // RFC6762 10.2
if (this.service)
var msg = [
{name: this.host, type: DNS_RRTYPE_A, addr: sock.addr, ttl: this.ttl, flush: flush},
{name: this.name, type: DNS_RRTYPE_SRV, target: this.host, port: this.port, ttl: this.ttl, flush: flush},
{name: this.service + "." + server.domain, type: DNS_RRTYPE_PTR, domain: this.name, ttl: this.ttl}, // !!! 'flush' MUST NOT ever be set !!!
];
else
var msg = [
{name: this.name, type: DNS_RRTYPE_A, addr: sock.addr, ttl: this.ttl, flush: flush},
{name: sock.addr + ".in-addr.arpa", type: DNS_RRTYPE_PTR, domain: this.name, ttl: this.ttl, flush: flush},
];
if (this.txt)
msg.push({name: this.name, type: DNS_RRTYPE_TXT, txt: this.txt, ttl: this.ttl, flush: flush});
var an = message.announce(msg);
return new MSocket(sock, {repeat: repeat, interval: [1000], data: an, unicast: unicast, onComplete: onComplete});
};
deannounce(socks, onComplete) {
match(name) {
if (name.startsWith("*."))
name = name.substr(2);
if (name.endsWith("."))
name = name.slice(0, -1);
if (name == this.name)
return true;
if (name.endsWith("." + server.domain))
name = name.slice(0, -(server.domain.length + 1));
if (this.service)
return this.service == name;
else
return this.servname == name;
};