@matterbridge/dgram 3.7.5 → 3.7.6-dev-20260427-575abf6

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/coap.js CHANGED
@@ -123,7 +123,7 @@ export class Coap extends Multicast {
123
123
  if (tokenLength > 0) {
124
124
  parts.push(token);
125
125
  }
126
- const sortedOptions = msg.options.slice().sort((a, b) => a.number - b.number);
126
+ const sortedOptions = msg.options.toSorted((a, b) => a.number - b.number);
127
127
  let previousOptionNumber = 0;
128
128
  for (const option of sortedOptions) {
129
129
  const optionDelta = option.number - previousOptionNumber;
package/dist/mdns.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import dgram from 'node:dgram';
2
2
  import { AnsiLogger } from 'node-ansi-logger';
3
3
  import { Multicast } from './multicast.js';
4
- export declare const enum DnsRecordType {
4
+ export declare enum DnsRecordType {
5
5
  A = 1,
6
6
  NS = 2,
7
7
  MD = 3,
@@ -93,13 +93,13 @@ export declare const enum DnsRecordType {
93
93
  TA = 32768,
94
94
  DLV = 32769
95
95
  }
96
- export declare const enum DnsClass {
96
+ export declare enum DnsClass {
97
97
  IN = 1,
98
98
  CH = 3,
99
99
  HS = 4,
100
100
  ANY = 255
101
101
  }
102
- export declare const enum DnsClassFlag {
102
+ export declare enum DnsClassFlag {
103
103
  FLUSH = 32768,
104
104
  QU = 32768
105
105
  }
package/dist/mdns.js CHANGED
@@ -159,14 +159,14 @@ export class Mdns extends Multicast {
159
159
  this.onQuery(rinfo, result);
160
160
  }
161
161
  else {
162
- const ptr = result.answers?.find((record) => record.name === '_shelly._tcp.local' && record.type === 12) ||
163
- result.answers?.find((record) => record.name === '_http._tcp.local' && record.type === 12) ||
164
- result.answers?.find((record) => record.type === 12) ||
165
- result.answers?.find((record) => record.type === 16) ||
162
+ const ptr = result.answers?.find((record) => record.name === '_shelly._tcp.local' && record.type === DnsRecordType.PTR) ||
163
+ result.answers?.find((record) => record.name === '_http._tcp.local' && record.type === DnsRecordType.PTR) ||
164
+ result.answers?.find((record) => record.type === DnsRecordType.PTR) ||
165
+ result.answers?.find((record) => record.type === DnsRecordType.TXT) ||
166
166
  result.answers
167
167
  ? result.answers[0]
168
168
  : undefined;
169
- this.deviceResponses.set(rinfo.address, { rinfo, response: result, dataPTR: ptr?.type === 12 ? ptr?.data : ptr?.name });
169
+ this.deviceResponses.set(rinfo.address, { rinfo, response: result, dataPTR: ptr?.type === DnsRecordType.PTR ? ptr?.data : ptr?.name });
170
170
  this.onResponse(rinfo, result);
171
171
  }
172
172
  if (this.filters.length > 0) {
@@ -367,12 +367,12 @@ export class Mdns extends Multicast {
367
367
  const rdlength = msg.readUInt16BE(offset);
368
368
  offset += 2;
369
369
  let data;
370
- if (type === 12) {
370
+ if (type === DnsRecordType.PTR) {
371
371
  const ptrResult = this.decodeDnsName(msg, offset);
372
372
  data = ptrResult.name;
373
373
  offset += rdlength;
374
374
  }
375
- else if (type === 16) {
375
+ else if (type === DnsRecordType.TXT) {
376
376
  const txtStrings = [];
377
377
  const end = offset + rdlength;
378
378
  while (offset < end) {
@@ -384,7 +384,7 @@ export class Mdns extends Multicast {
384
384
  }
385
385
  data = txtStrings.join(', ');
386
386
  }
387
- else if (type === 33) {
387
+ else if (type === DnsRecordType.SRV) {
388
388
  const priority = msg.readUInt16BE(offset);
389
389
  const weight = msg.readUInt16BE(offset + 2);
390
390
  const port = msg.readUInt16BE(offset + 4);
@@ -398,12 +398,12 @@ export class Mdns extends Multicast {
398
398
  });
399
399
  offset = srvTargetResult.newOffset;
400
400
  }
401
- else if (type === 1) {
401
+ else if (type === DnsRecordType.A) {
402
402
  const ipBytes = msg.slice(offset, offset + 4);
403
403
  data = Array.from(ipBytes).join('.');
404
404
  offset += 4;
405
405
  }
406
- else if (type === 28) {
406
+ else if (type === DnsRecordType.AAAA) {
407
407
  const ipBytes = msg.slice(offset, offset + 16);
408
408
  const ipv6Parts = [];
409
409
  for (let i = 0; i < 16; i += 2) {
@@ -412,7 +412,7 @@ export class Mdns extends Multicast {
412
412
  data = ipv6Parts.join(':');
413
413
  offset += 16;
414
414
  }
415
- else if (type === 47) {
415
+ else if (type === DnsRecordType.NSEC) {
416
416
  const { name: nextDomain, newOffset } = this.decodeDnsName(msg, offset);
417
417
  const nextDomainLength = newOffset - offset;
418
418
  offset = newOffset;
@@ -462,7 +462,7 @@ export class Mdns extends Multicast {
462
462
  const qname = this.encodeDnsName(name);
463
463
  const qfields = Buffer.alloc(4);
464
464
  qfields.writeUInt16BE(qtype, 0);
465
- qfields.writeUInt16BE(unicastResponse ? qclass | 32768 : qclass, 2);
465
+ qfields.writeUInt16BE(unicastResponse ? qclass | DnsClassFlag.QU : qclass, 2);
466
466
  return Buffer.concat([qname, qfields]);
467
467
  });
468
468
  const query = Buffer.concat([header, ...questionBuffers]);
@@ -521,114 +521,114 @@ export class Mdns extends Multicast {
521
521
  }
522
522
  dnsTypeToString(type) {
523
523
  const typeMap = {
524
- [1]: 'A',
525
- [2]: 'NS',
526
- [3]: 'MD',
527
- [4]: 'MF',
528
- [5]: 'CNAME',
529
- [6]: 'SOA',
530
- [7]: 'MB',
531
- [8]: 'MG',
532
- [9]: 'MR',
533
- [10]: 'NULL',
534
- [11]: 'WKS',
535
- [12]: 'PTR',
536
- [13]: 'HINFO',
537
- [14]: 'MINFO',
538
- [15]: 'MX',
539
- [16]: 'TXT',
540
- [17]: 'RP',
541
- [18]: 'AFSDB',
542
- [19]: 'X25',
543
- [20]: 'ISDN',
544
- [21]: 'RT',
545
- [22]: 'NSAP',
546
- [23]: 'NSAP_PTR',
547
- [24]: 'SIG',
548
- [25]: 'KEY',
549
- [26]: 'PX',
550
- [27]: 'GPOS',
551
- [28]: 'AAAA',
552
- [29]: 'LOC',
553
- [30]: 'NXT',
554
- [31]: 'EID',
555
- [32]: 'NIMLOC',
556
- [33]: 'SRV',
557
- [34]: 'ATMA',
558
- [35]: 'NAPTR',
559
- [36]: 'KX',
560
- [37]: 'CERT',
561
- [38]: 'A6',
562
- [39]: 'DNAME',
563
- [40]: 'SINK',
564
- [41]: 'OPT',
565
- [42]: 'APL',
566
- [43]: 'DS',
567
- [44]: 'SSHFP',
568
- [45]: 'IPSECKEY',
569
- [46]: 'RRSIG',
570
- [47]: 'NSEC',
571
- [48]: 'DNSKEY',
572
- [49]: 'DHCID',
573
- [50]: 'NSEC3',
574
- [51]: 'NSEC3PARAM',
575
- [52]: 'TLSA',
576
- [53]: 'SMIMEA',
577
- [55]: 'HIP',
578
- [56]: 'NINFO',
579
- [57]: 'RKEY',
580
- [58]: 'TALINK',
581
- [59]: 'CDS',
582
- [60]: 'CDNSKEY',
583
- [61]: 'OPENPGPKEY',
584
- [62]: 'CSYNC',
585
- [63]: 'ZONEMD',
586
- [64]: 'SVCB',
587
- [65]: 'HTTPS',
588
- [99]: 'SPF',
589
- [100]: 'UINFO',
590
- [101]: 'UID',
591
- [102]: 'GID',
592
- [103]: 'UNSPEC',
593
- [104]: 'NID',
594
- [105]: 'L32',
595
- [106]: 'L64',
596
- [107]: 'LP',
597
- [108]: 'EUI48',
598
- [109]: 'EUI64',
599
- [249]: 'TKEY',
600
- [250]: 'TSIG',
601
- [251]: 'IXFR',
602
- [252]: 'AXFR',
603
- [253]: 'MAILB',
604
- [254]: 'MAILA',
605
- [255]: 'ANY',
606
- [256]: 'URI',
607
- [257]: 'CAA',
608
- [258]: 'AVC',
609
- [259]: 'DOA',
610
- [260]: 'AMTRELAY',
611
- [261]: 'ZONEVERSION',
612
- [32768]: 'TA',
613
- [32769]: 'DLV',
524
+ [DnsRecordType.A]: 'A',
525
+ [DnsRecordType.NS]: 'NS',
526
+ [DnsRecordType.MD]: 'MD',
527
+ [DnsRecordType.MF]: 'MF',
528
+ [DnsRecordType.CNAME]: 'CNAME',
529
+ [DnsRecordType.SOA]: 'SOA',
530
+ [DnsRecordType.MB]: 'MB',
531
+ [DnsRecordType.MG]: 'MG',
532
+ [DnsRecordType.MR]: 'MR',
533
+ [DnsRecordType.NULL]: 'NULL',
534
+ [DnsRecordType.WKS]: 'WKS',
535
+ [DnsRecordType.PTR]: 'PTR',
536
+ [DnsRecordType.HINFO]: 'HINFO',
537
+ [DnsRecordType.MINFO]: 'MINFO',
538
+ [DnsRecordType.MX]: 'MX',
539
+ [DnsRecordType.TXT]: 'TXT',
540
+ [DnsRecordType.RP]: 'RP',
541
+ [DnsRecordType.AFSDB]: 'AFSDB',
542
+ [DnsRecordType.X25]: 'X25',
543
+ [DnsRecordType.ISDN]: 'ISDN',
544
+ [DnsRecordType.RT]: 'RT',
545
+ [DnsRecordType.NSAP]: 'NSAP',
546
+ [DnsRecordType.NSAP_PTR]: 'NSAP_PTR',
547
+ [DnsRecordType.SIG]: 'SIG',
548
+ [DnsRecordType.KEY]: 'KEY',
549
+ [DnsRecordType.PX]: 'PX',
550
+ [DnsRecordType.GPOS]: 'GPOS',
551
+ [DnsRecordType.AAAA]: 'AAAA',
552
+ [DnsRecordType.LOC]: 'LOC',
553
+ [DnsRecordType.NXT]: 'NXT',
554
+ [DnsRecordType.EID]: 'EID',
555
+ [DnsRecordType.NIMLOC]: 'NIMLOC',
556
+ [DnsRecordType.SRV]: 'SRV',
557
+ [DnsRecordType.ATMA]: 'ATMA',
558
+ [DnsRecordType.NAPTR]: 'NAPTR',
559
+ [DnsRecordType.KX]: 'KX',
560
+ [DnsRecordType.CERT]: 'CERT',
561
+ [DnsRecordType.A6]: 'A6',
562
+ [DnsRecordType.DNAME]: 'DNAME',
563
+ [DnsRecordType.SINK]: 'SINK',
564
+ [DnsRecordType.OPT]: 'OPT',
565
+ [DnsRecordType.APL]: 'APL',
566
+ [DnsRecordType.DS]: 'DS',
567
+ [DnsRecordType.SSHFP]: 'SSHFP',
568
+ [DnsRecordType.IPSECKEY]: 'IPSECKEY',
569
+ [DnsRecordType.RRSIG]: 'RRSIG',
570
+ [DnsRecordType.NSEC]: 'NSEC',
571
+ [DnsRecordType.DNSKEY]: 'DNSKEY',
572
+ [DnsRecordType.DHCID]: 'DHCID',
573
+ [DnsRecordType.NSEC3]: 'NSEC3',
574
+ [DnsRecordType.NSEC3PARAM]: 'NSEC3PARAM',
575
+ [DnsRecordType.TLSA]: 'TLSA',
576
+ [DnsRecordType.SMIMEA]: 'SMIMEA',
577
+ [DnsRecordType.HIP]: 'HIP',
578
+ [DnsRecordType.NINFO]: 'NINFO',
579
+ [DnsRecordType.RKEY]: 'RKEY',
580
+ [DnsRecordType.TALINK]: 'TALINK',
581
+ [DnsRecordType.CDS]: 'CDS',
582
+ [DnsRecordType.CDNSKEY]: 'CDNSKEY',
583
+ [DnsRecordType.OPENPGPKEY]: 'OPENPGPKEY',
584
+ [DnsRecordType.CSYNC]: 'CSYNC',
585
+ [DnsRecordType.ZONEMD]: 'ZONEMD',
586
+ [DnsRecordType.SVCB]: 'SVCB',
587
+ [DnsRecordType.HTTPS]: 'HTTPS',
588
+ [DnsRecordType.SPF]: 'SPF',
589
+ [DnsRecordType.UINFO]: 'UINFO',
590
+ [DnsRecordType.UID]: 'UID',
591
+ [DnsRecordType.GID]: 'GID',
592
+ [DnsRecordType.UNSPEC]: 'UNSPEC',
593
+ [DnsRecordType.NID]: 'NID',
594
+ [DnsRecordType.L32]: 'L32',
595
+ [DnsRecordType.L64]: 'L64',
596
+ [DnsRecordType.LP]: 'LP',
597
+ [DnsRecordType.EUI48]: 'EUI48',
598
+ [DnsRecordType.EUI64]: 'EUI64',
599
+ [DnsRecordType.TKEY]: 'TKEY',
600
+ [DnsRecordType.TSIG]: 'TSIG',
601
+ [DnsRecordType.IXFR]: 'IXFR',
602
+ [DnsRecordType.AXFR]: 'AXFR',
603
+ [DnsRecordType.MAILB]: 'MAILB',
604
+ [DnsRecordType.MAILA]: 'MAILA',
605
+ [DnsRecordType.ANY]: 'ANY',
606
+ [DnsRecordType.URI]: 'URI',
607
+ [DnsRecordType.CAA]: 'CAA',
608
+ [DnsRecordType.AVC]: 'AVC',
609
+ [DnsRecordType.DOA]: 'DOA',
610
+ [DnsRecordType.AMTRELAY]: 'AMTRELAY',
611
+ [DnsRecordType.ZONEVERSION]: 'ZONEVERSION',
612
+ [DnsRecordType.TA]: 'TA',
613
+ [DnsRecordType.DLV]: 'DLV',
614
614
  };
615
615
  return typeMap[type] ?? `TYPE${type}`;
616
616
  }
617
617
  dnsResponseClassToString(cls) {
618
- const isFlush = !!(cls & 32768);
618
+ const isFlush = !!(cls & DnsClassFlag.FLUSH);
619
619
  const baseClass = cls & 0x7fff;
620
620
  let classStr;
621
621
  switch (baseClass) {
622
- case 1:
622
+ case DnsClass.IN:
623
623
  classStr = 'IN';
624
624
  break;
625
- case 3:
625
+ case DnsClass.CH:
626
626
  classStr = 'CH';
627
627
  break;
628
- case 4:
628
+ case DnsClass.HS:
629
629
  classStr = 'HS';
630
630
  break;
631
- case 255:
631
+ case DnsClass.ANY:
632
632
  classStr = 'ANY';
633
633
  break;
634
634
  default:
@@ -637,20 +637,20 @@ export class Mdns extends Multicast {
637
637
  return isFlush ? `${classStr}|FLUSH` : classStr;
638
638
  }
639
639
  dnsQuestionClassToString(cls) {
640
- const isQU = !!(cls & 32768);
640
+ const isQU = !!(cls & DnsClassFlag.QU);
641
641
  const baseClass = cls & 0x7fff;
642
642
  let classStr;
643
643
  switch (baseClass) {
644
- case 1:
644
+ case DnsClass.IN:
645
645
  classStr = 'IN';
646
646
  break;
647
- case 3:
647
+ case DnsClass.CH:
648
648
  classStr = 'CH';
649
649
  break;
650
- case 4:
650
+ case DnsClass.HS:
651
651
  classStr = 'HS';
652
652
  break;
653
- case 255:
653
+ case DnsClass.ANY:
654
654
  classStr = 'ANY';
655
655
  break;
656
656
  default:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@matterbridge/dgram",
3
- "version": "3.7.5",
3
+ "version": "3.7.6-dev-20260427-575abf6",
4
4
  "description": "Matterbridge dgram library",
5
5
  "author": "https://github.com/Luligu",
6
6
  "homepage": "https://matterbridge.io/",
@@ -61,8 +61,8 @@
61
61
  "CHANGELOG.md"
62
62
  ],
63
63
  "dependencies": {
64
- "@matterbridge/jest-utils": "3.7.5",
65
- "@matterbridge/utils": "3.7.5",
64
+ "@matterbridge/jest-utils": "3.7.6-dev-20260427-575abf6",
65
+ "@matterbridge/utils": "3.7.6-dev-20260427-575abf6",
66
66
  "node-ansi-logger": "3.2.1"
67
67
  }
68
68
  }