@matterbridge/dgram 3.11.1 → 3.11.2-dev-20261030-d621b1f

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/mdns.d.ts CHANGED
@@ -140,11 +140,13 @@ interface DnsQuestion {
140
140
  name: string;
141
141
  type: DnsRecordType;
142
142
  class: DnsClass;
143
+ unicastResponse: boolean;
143
144
  }
144
145
  interface MdnsRecord {
145
146
  name: string;
146
147
  type: DnsRecordType;
147
148
  class: DnsClass;
149
+ cacheFlush: boolean;
148
150
  ttl: number;
149
151
  data: string;
150
152
  }
@@ -240,8 +242,8 @@ export declare class Mdns extends Multicast {
240
242
  rdata: Buffer;
241
243
  }[]): Buffer<ArrayBuffer>;
242
244
  dnsTypeToString(type: number): string;
243
- dnsResponseClassToString(cls: number): string;
244
- dnsQuestionClassToString(cls: number): string;
245
+ dnsResponseClassToString(cls: number, cacheFlush?: boolean): string;
246
+ dnsQuestionClassToString(cls: number, unicastResponse?: boolean): string;
245
247
  logMdnsMessage(msg: MdnsMessage, log?: AnsiLogger, text?: string): void;
246
248
  logDevices(): void;
247
249
  }
package/dist/mdns.js CHANGED
@@ -123,6 +123,12 @@ export var DnsHeaderFlag;
123
123
  DnsHeaderFlag[DnsHeaderFlag["CD"] = 16] = "CD";
124
124
  DnsHeaderFlag[DnsHeaderFlag["RCODE"] = 15] = "RCODE";
125
125
  })(DnsHeaderFlag || (DnsHeaderFlag = {}));
126
+ function wireToDnsRecordType(value) {
127
+ return value;
128
+ }
129
+ function wireToDnsClass(value) {
130
+ return value;
131
+ }
126
132
  export function isMdns(message) {
127
133
  if (!message || message.length < 12)
128
134
  return false;
@@ -265,7 +271,7 @@ export class Mdns extends Multicast {
265
271
  offset += 2;
266
272
  const qclass = msg.readUInt16BE(offset);
267
273
  offset += 2;
268
- mdnsMessage.questions?.push({ name: qname, type: qtype, class: qclass });
274
+ mdnsMessage.questions?.push({ name: qname, type: wireToDnsRecordType(qtype), class: wireToDnsClass(qclass & 0x7fff), unicastResponse: (qclass & DnsClassFlag.QU) !== 0 });
269
275
  }
270
276
  for (let i = 0; i < anCount; i++) {
271
277
  const rrResult = this.decodeResourceRecord(msg, offset);
@@ -510,7 +516,7 @@ export class Mdns extends Multicast {
510
516
  offset += rdlength;
511
517
  }
512
518
  return {
513
- record: { name, type, class: rrclass, ttl, data },
519
+ record: { name, type: wireToDnsRecordType(type), class: wireToDnsClass(rrclass & 0x7fff), cacheFlush: (rrclass & DnsClassFlag.FLUSH) !== 0, ttl, data },
514
520
  newOffset: offset,
515
521
  };
516
522
  }
@@ -684,9 +690,9 @@ export class Mdns extends Multicast {
684
690
  };
685
691
  return typeMap[type] ?? `TYPE${type}`;
686
692
  }
687
- dnsResponseClassToString(cls) {
688
- const isFlush = !!(cls & DnsClassFlag.FLUSH);
689
- const baseClass = cls & 0x7fff;
693
+ dnsResponseClassToString(cls, cacheFlush = false) {
694
+ const isFlush = cacheFlush || !!(cls & DnsClassFlag.FLUSH);
695
+ const baseClass = wireToDnsClass(cls & 0x7fff);
690
696
  let classStr;
691
697
  switch (baseClass) {
692
698
  case DnsClass.IN:
@@ -706,9 +712,9 @@ export class Mdns extends Multicast {
706
712
  }
707
713
  return isFlush ? `${classStr}|FLUSH` : classStr;
708
714
  }
709
- dnsQuestionClassToString(cls) {
710
- const isQU = !!(cls & DnsClassFlag.QU);
711
- const baseClass = cls & 0x7fff;
715
+ dnsQuestionClassToString(cls, unicastResponse = false) {
716
+ const isQU = unicastResponse || !!(cls & DnsClassFlag.QU);
717
+ const baseClass = wireToDnsClass(cls & 0x7fff);
712
718
  let classStr;
713
719
  switch (baseClass) {
714
720
  case DnsClass.IN:
@@ -731,16 +737,16 @@ export class Mdns extends Multicast {
731
737
  logMdnsMessage(msg, log = this.log, text = 'Decoded mDNS message') {
732
738
  log.info(`${text}: ID ${MAGENTA}${msg.id}${nf}, QR ${GREEN}${msg.qr === 0 ? 'Query' : 'Response'}${nf}, OPCODE ${MAGENTA}${msg.opcode}${nf}, AA ${MAGENTA}${msg.aa}${nf}, TC ${MAGENTA}${msg.tc}${nf}, RD ${MAGENTA}${msg.rd}${nf}, RA ${MAGENTA}${msg.ra}${nf}, Z ${MAGENTA}${msg.z}${nf}, RCODE ${MAGENTA}${msg.rcode}${nf}, QDCount ${MAGENTA}${msg.qdCount}${nf}, ANCount ${MAGENTA}${msg.anCount}${nf}, NSCount ${MAGENTA}${msg.nsCount}${nf}, ARCount ${MAGENTA}${msg.arCount}${nf}`);
733
739
  msg.questions?.forEach((question) => {
734
- log.info(`Question: ${CYAN}${question.name}${nf} type ${idn}${this.dnsTypeToString(question.type)}${rs}${nf} class ${CYAN}${this.dnsQuestionClassToString(question.class)}${nf}`);
740
+ log.info(`Question: ${CYAN}${question.name}${nf} type ${idn}${this.dnsTypeToString(question.type)}${rs}${nf} class ${CYAN}${this.dnsQuestionClassToString(question.class, question.unicastResponse)}${nf}`);
735
741
  });
736
742
  msg.answers?.forEach((answer) => {
737
- log.info(`Answer: ${CYAN}${answer.name}${nf} type ${idn}${this.dnsTypeToString(answer.type)}${rs}${nf} class ${CYAN}${this.dnsResponseClassToString(answer.class)}${nf} ttl ${CYAN}${answer.ttl}${nf} data ${CYAN}${answer.data}${nf}`);
743
+ log.info(`Answer: ${CYAN}${answer.name}${nf} type ${idn}${this.dnsTypeToString(answer.type)}${rs}${nf} class ${CYAN}${this.dnsResponseClassToString(answer.class, answer.cacheFlush)}${nf} ttl ${CYAN}${answer.ttl}${nf} data ${CYAN}${answer.data}${nf}`);
738
744
  });
739
745
  msg.authorities?.forEach((authority) => {
740
- log.info(`Authority: ${CYAN}${authority.name}${nf} type ${idn}${this.dnsTypeToString(authority.type)}${rs}${nf} class ${CYAN}${this.dnsResponseClassToString(authority.class)}${nf} ttl ${CYAN}${authority.ttl}${nf} data ${CYAN}${authority.data}${nf}`);
746
+ log.info(`Authority: ${CYAN}${authority.name}${nf} type ${idn}${this.dnsTypeToString(authority.type)}${rs}${nf} class ${CYAN}${this.dnsResponseClassToString(authority.class, authority.cacheFlush)}${nf} ttl ${CYAN}${authority.ttl}${nf} data ${CYAN}${authority.data}${nf}`);
741
747
  });
742
748
  msg.additionals?.forEach((additional) => {
743
- log.info(`Additional: ${CYAN}${additional.name}${nf} type ${idn}${this.dnsTypeToString(additional.type)}${rs}${nf} class ${CYAN}${this.dnsResponseClassToString(additional.class)}${nf} ttl ${CYAN}${additional.ttl}${nf} data ${CYAN}${additional.data}${nf}`);
749
+ log.info(`Additional: ${CYAN}${additional.name}${nf} type ${idn}${this.dnsTypeToString(additional.type)}${rs}${nf} class ${CYAN}${this.dnsResponseClassToString(additional.class, additional.cacheFlush)}${nf} ttl ${CYAN}${additional.ttl}${nf} data ${CYAN}${additional.data}${nf}`);
744
750
  });
745
751
  log.info(`---\n`);
746
752
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@matterbridge/dgram",
3
- "version": "3.11.1",
3
+ "version": "3.11.2-dev-20261030-d621b1f",
4
4
  "description": "Matterbridge dgram library",
5
5
  "author": "https://github.com/Luligu",
6
6
  "homepage": "https://matterbridge.io/",
@@ -67,7 +67,7 @@
67
67
  "skipTsconfig": true
68
68
  },
69
69
  "dependencies": {
70
- "@matterbridge/utils": "3.11.1",
70
+ "@matterbridge/utils": "3.11.2-dev-20261030-d621b1f",
71
71
  "node-ansi-logger": "3.3.1"
72
72
  }
73
73
  }