@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 +1 -1
- package/dist/mdns.d.ts +3 -3
- package/dist/mdns.js +112 -112
- package/package.json +3 -3
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.
|
|
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
|
|
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
|
|
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
|
|
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 ===
|
|
163
|
-
result.answers?.find((record) => record.name === '_http._tcp.local' && record.type ===
|
|
164
|
-
result.answers?.find((record) => record.type ===
|
|
165
|
-
result.answers?.find((record) => record.type ===
|
|
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 ===
|
|
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 ===
|
|
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 ===
|
|
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 ===
|
|
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 ===
|
|
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 ===
|
|
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 ===
|
|
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 |
|
|
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
|
-
[
|
|
525
|
-
[
|
|
526
|
-
[
|
|
527
|
-
[
|
|
528
|
-
[
|
|
529
|
-
[
|
|
530
|
-
[
|
|
531
|
-
[
|
|
532
|
-
[
|
|
533
|
-
[
|
|
534
|
-
[
|
|
535
|
-
[
|
|
536
|
-
[
|
|
537
|
-
[
|
|
538
|
-
[
|
|
539
|
-
[
|
|
540
|
-
[
|
|
541
|
-
[
|
|
542
|
-
[
|
|
543
|
-
[
|
|
544
|
-
[
|
|
545
|
-
[
|
|
546
|
-
[
|
|
547
|
-
[
|
|
548
|
-
[
|
|
549
|
-
[
|
|
550
|
-
[
|
|
551
|
-
[
|
|
552
|
-
[
|
|
553
|
-
[
|
|
554
|
-
[
|
|
555
|
-
[
|
|
556
|
-
[
|
|
557
|
-
[
|
|
558
|
-
[
|
|
559
|
-
[
|
|
560
|
-
[
|
|
561
|
-
[
|
|
562
|
-
[
|
|
563
|
-
[
|
|
564
|
-
[
|
|
565
|
-
[
|
|
566
|
-
[
|
|
567
|
-
[
|
|
568
|
-
[
|
|
569
|
-
[
|
|
570
|
-
[
|
|
571
|
-
[
|
|
572
|
-
[
|
|
573
|
-
[
|
|
574
|
-
[
|
|
575
|
-
[
|
|
576
|
-
[
|
|
577
|
-
[
|
|
578
|
-
[
|
|
579
|
-
[
|
|
580
|
-
[
|
|
581
|
-
[
|
|
582
|
-
[
|
|
583
|
-
[
|
|
584
|
-
[
|
|
585
|
-
[
|
|
586
|
-
[
|
|
587
|
-
[
|
|
588
|
-
[
|
|
589
|
-
[
|
|
590
|
-
[
|
|
591
|
-
[
|
|
592
|
-
[
|
|
593
|
-
[
|
|
594
|
-
[
|
|
595
|
-
[
|
|
596
|
-
[
|
|
597
|
-
[
|
|
598
|
-
[
|
|
599
|
-
[
|
|
600
|
-
[
|
|
601
|
-
[
|
|
602
|
-
[
|
|
603
|
-
[
|
|
604
|
-
[
|
|
605
|
-
[
|
|
606
|
-
[
|
|
607
|
-
[
|
|
608
|
-
[
|
|
609
|
-
[
|
|
610
|
-
[
|
|
611
|
-
[
|
|
612
|
-
[
|
|
613
|
-
[
|
|
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 &
|
|
618
|
+
const isFlush = !!(cls & DnsClassFlag.FLUSH);
|
|
619
619
|
const baseClass = cls & 0x7fff;
|
|
620
620
|
let classStr;
|
|
621
621
|
switch (baseClass) {
|
|
622
|
-
case
|
|
622
|
+
case DnsClass.IN:
|
|
623
623
|
classStr = 'IN';
|
|
624
624
|
break;
|
|
625
|
-
case
|
|
625
|
+
case DnsClass.CH:
|
|
626
626
|
classStr = 'CH';
|
|
627
627
|
break;
|
|
628
|
-
case
|
|
628
|
+
case DnsClass.HS:
|
|
629
629
|
classStr = 'HS';
|
|
630
630
|
break;
|
|
631
|
-
case
|
|
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 &
|
|
640
|
+
const isQU = !!(cls & DnsClassFlag.QU);
|
|
641
641
|
const baseClass = cls & 0x7fff;
|
|
642
642
|
let classStr;
|
|
643
643
|
switch (baseClass) {
|
|
644
|
-
case
|
|
644
|
+
case DnsClass.IN:
|
|
645
645
|
classStr = 'IN';
|
|
646
646
|
break;
|
|
647
|
-
case
|
|
647
|
+
case DnsClass.CH:
|
|
648
648
|
classStr = 'CH';
|
|
649
649
|
break;
|
|
650
|
-
case
|
|
650
|
+
case DnsClass.HS:
|
|
651
651
|
classStr = 'HS';
|
|
652
652
|
break;
|
|
653
|
-
case
|
|
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.
|
|
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.
|
|
65
|
-
"@matterbridge/utils": "3.7.
|
|
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
|
}
|