@netkitty/codec 1.2.0 → 2.0.0
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/CHANGELOG.md +170 -0
- package/README.md +58 -10
- package/README.zh-CN.md +52 -9
- package/dist/Codec.d.ts +3 -2
- package/dist/Codec.js +106 -10
- package/dist/abstracts/BaseHeader.d.ts +28 -2
- package/dist/abstracts/BaseHeader.js +132 -43
- package/dist/errors/CodecSchemaValidateError.d.ts +34 -1
- package/dist/errors/CodecSchemaValidateError.js +26 -3
- package/dist/headers/ADSAMS.js +2 -0
- package/dist/headers/AH.js +1 -0
- package/dist/headers/AMQP.js +2 -1
- package/dist/headers/ARP.js +16 -10
- package/dist/headers/BACnetIP.js +1 -0
- package/dist/headers/BGP.js +1 -0
- package/dist/headers/Babel.js +2 -1
- package/dist/headers/BitTorrent.d.ts +2 -0
- package/dist/headers/BitTorrent.js +4 -2
- package/dist/headers/C37118.js +1 -0
- package/dist/headers/CAPWAP.js +1 -0
- package/dist/headers/CDP.js +1 -1
- package/dist/headers/CMS.js +2 -2
- package/dist/headers/COTP.d.ts +2 -0
- package/dist/headers/COTP.js +6 -1
- package/dist/headers/CassandraCQL.js +1 -0
- package/dist/headers/Codesys.js +1 -0
- package/dist/headers/Collectd.js +1 -1
- package/dist/headers/DCCP.js +1 -0
- package/dist/headers/DHCPFailover.js +1 -0
- package/dist/headers/DNS.js +3 -3
- package/dist/headers/DTLS.js +1 -0
- package/dist/headers/Diameter.js +3 -2
- package/dist/headers/EAPOL.js +1 -1
- package/dist/headers/EIGRP.js +1 -1
- package/dist/headers/ENIP.js +1 -0
- package/dist/headers/Elasticsearch.js +1 -0
- package/dist/headers/EtherCAT.js +1 -0
- package/dist/headers/EthernetII.js +6 -0
- package/dist/headers/FTP.js +6 -6
- package/dist/headers/Finger.js +3 -3
- package/dist/headers/FoundationFieldbusHSE.js +1 -0
- package/dist/headers/GELF.js +7 -1
- package/dist/headers/GENEVE.js +1 -1
- package/dist/headers/GLBP.js +1 -1
- package/dist/headers/GTPU.js +1 -0
- package/dist/headers/GTPv2C.js +1 -0
- package/dist/headers/GitProtocol.js +2 -2
- package/dist/headers/Goose.d.ts +32 -2
- package/dist/headers/Goose.js +116 -89
- package/dist/headers/Gopher.js +6 -6
- package/dist/headers/HARTIP.js +1 -0
- package/dist/headers/HSR.js +2 -0
- package/dist/headers/HTTP.js +6 -6
- package/dist/headers/HTTP2.js +1 -0
- package/dist/headers/ICMP.js +1 -0
- package/dist/headers/ICMPv6.js +1 -0
- package/dist/headers/IEC104_I_Frame.js +26 -3
- package/dist/headers/IEC104_S_Frame.js +7 -2
- package/dist/headers/IEC104_U_Frame.js +14 -3
- package/dist/headers/IEC61850SampledValues.js +2 -1
- package/dist/headers/IGMP.js +1 -0
- package/dist/headers/IMAP.js +5 -5
- package/dist/headers/IPFIX.js +2 -1
- package/dist/headers/IPv4.js +18 -1
- package/dist/headers/IPv6.js +1 -0
- package/dist/headers/IPv6HopByHopOptions.js +12 -11
- package/dist/headers/IRC.js +4 -4
- package/dist/headers/ISAKMP.js +2 -1
- package/dist/headers/ISCSI.js +2 -0
- package/dist/headers/ISIS.js +2 -1
- package/dist/headers/ISOSession.d.ts +2 -0
- package/dist/headers/ISOSession.js +14 -10
- package/dist/headers/Ident.js +8 -8
- package/dist/headers/KNXnetIP.js +1 -0
- package/dist/headers/Kafka.js +1 -0
- package/dist/headers/Kerberos.js +1 -0
- package/dist/headers/L2TP.js +2 -2
- package/dist/headers/LACP.js +1 -1
- package/dist/headers/LDAP.js +2 -3
- package/dist/headers/LDP.js +1 -0
- package/dist/headers/LLC.d.ts +2 -0
- package/dist/headers/LLC.js +2 -0
- package/dist/headers/LPD.js +3 -3
- package/dist/headers/MGCP.js +7 -7
- package/dist/headers/MMS.d.ts +2 -0
- package/dist/headers/MMS.js +10 -6
- package/dist/headers/MQTT.js +1 -0
- package/dist/headers/MQTTSN.js +1 -0
- package/dist/headers/MarkerProtocol.js +1 -1
- package/dist/headers/Megaco.js +3 -3
- package/dist/headers/Memcached.js +3 -2
- package/dist/headers/ModbusTCP.js +1 -0
- package/dist/headers/ModbusUDP.js +1 -0
- package/dist/headers/MongoDB.js +1 -0
- package/dist/headers/MySQL.js +1 -0
- package/dist/headers/NATS.js +2 -2
- package/dist/headers/NBDS.js +1 -0
- package/dist/headers/NBSS.js +1 -0
- package/dist/headers/NFS.js +1 -0
- package/dist/headers/NHRP.js +1 -0
- package/dist/headers/NNTP.js +6 -6
- package/dist/headers/NetFlowV5.js +1 -0
- package/dist/headers/OLSR.js +2 -1
- package/dist/headers/OPCUA.js +1 -0
- package/dist/headers/OpenFlow.js +1 -0
- package/dist/headers/OpenVPN.js +1 -0
- package/dist/headers/PCWorx.js +1 -0
- package/dist/headers/POP3.js +5 -5
- package/dist/headers/PPPoEDiscovery.js +2 -1
- package/dist/headers/PPPoESession.js +1 -0
- package/dist/headers/PPTP.js +1 -0
- package/dist/headers/PTP.js +1 -0
- package/dist/headers/PostgreSQL.js +2 -0
- package/dist/headers/QUIC.js +2 -0
- package/dist/headers/RADIUS.js +1 -0
- package/dist/headers/RDP.d.ts +2 -0
- package/dist/headers/RDP.js +4 -1
- package/dist/headers/RFB.js +4 -4
- package/dist/headers/RGoose.js +6 -1
- package/dist/headers/RSVP.js +3 -2
- package/dist/headers/RTCP.js +1 -0
- package/dist/headers/RTP.js +2 -1
- package/dist/headers/RTPS.d.ts +2 -0
- package/dist/headers/RTPS.js +4 -1
- package/dist/headers/RTSP.js +7 -7
- package/dist/headers/RawData.js +1 -1
- package/dist/headers/Redis.js +4 -4
- package/dist/headers/Rlogin.js +5 -5
- package/dist/headers/Rsync.js +2 -2
- package/dist/headers/S7comm.d.ts +2 -0
- package/dist/headers/S7comm.js +5 -1
- package/dist/headers/SCTP.js +2 -2
- package/dist/headers/SFlow.js +2 -1
- package/dist/headers/SIP.js +6 -6
- package/dist/headers/SLMP.js +1 -0
- package/dist/headers/SLP.js +2 -0
- package/dist/headers/SLPv1.js +1 -0
- package/dist/headers/SMB1.js +1 -0
- package/dist/headers/SMB2.js +1 -0
- package/dist/headers/SMPP.js +1 -0
- package/dist/headers/SMTP.js +6 -6
- package/dist/headers/SNAP.js +18 -5
- package/dist/headers/SNMP.js +4 -4
- package/dist/headers/SOCKS4.js +11 -5
- package/dist/headers/SSDP.js +7 -7
- package/dist/headers/SSH.js +5 -4
- package/dist/headers/STOMP.js +5 -5
- package/dist/headers/STUN.js +2 -0
- package/dist/headers/Skinny.js +1 -0
- package/dist/headers/StatsD.js +4 -4
- package/dist/headers/SunRPC.js +1 -0
- package/dist/headers/Syslog.js +2 -2
- package/dist/headers/TCP.js +18 -6
- package/dist/headers/TLS_Alert.js +23 -11
- package/dist/headers/TLS_ApplicationData.js +9 -4
- package/dist/headers/TLS_ChangeCipherSpec.js +10 -5
- package/dist/headers/TLS_Handshake.js +41 -26
- package/dist/headers/TLS_Heartbeat.js +10 -1
- package/dist/headers/TPKT.js +3 -1
- package/dist/headers/TacacsPlus.js +1 -0
- package/dist/headers/Telnet.js +2 -1
- package/dist/headers/Teredo.js +2 -2
- package/dist/headers/UDP.js +8 -0
- package/dist/headers/VLAN_802dot1Q.js +7 -0
- package/dist/headers/WCCP.js +1 -0
- package/dist/headers/WHOIS.js +3 -3
- package/dist/headers/WSDiscovery.js +2 -2
- package/dist/headers/XMPP.js +3 -3
- package/dist/headers/Zabbix.js +1 -0
- package/dist/index.d.ts +3 -3
- package/dist/lib/SchemaValidator.d.ts +31 -0
- package/dist/lib/SchemaValidator.js +137 -0
- package/dist/schema/ProtocolFieldJSONSchema.d.ts +4 -1
- package/dist/schema/ProtocolJSONSchema.d.ts +1 -1
- package/dist/types/CodecErrorInfo.d.ts +11 -0
- package/dist/types/LayerGraph.d.ts +14 -1
- package/package.json +2 -2
- package/dist/lib/GetBERIntegerLengthFromBuffer.d.ts +0 -6
- package/dist/lib/GetBERIntegerLengthFromBuffer.js +0 -16
package/dist/headers/SCTP.js
CHANGED
|
@@ -84,9 +84,9 @@ class SCTP extends BaseHeader_1.BaseHeader {
|
|
|
84
84
|
properties: {
|
|
85
85
|
type: { type: 'integer', label: 'Chunk Type', minimum: 0, maximum: 255 },
|
|
86
86
|
flags: { type: 'integer', label: 'Chunk Flags', minimum: 0, maximum: 255 },
|
|
87
|
-
length: { type: 'integer', label: 'Chunk Length', minimum: 0, maximum: 65535 },
|
|
87
|
+
length: { type: 'integer', label: 'Chunk Length', autoCalculated: true, minimum: 0, maximum: 65535 },
|
|
88
88
|
value: { type: 'string', label: 'Value', contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.HEX },
|
|
89
|
-
padding: { type: 'string', label: 'Padding', contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.HEX }
|
|
89
|
+
padding: { type: 'string', label: 'Padding', autoCalculated: true, contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.HEX }
|
|
90
90
|
}
|
|
91
91
|
},
|
|
92
92
|
decode: function () {
|
package/dist/headers/SFlow.js
CHANGED
|
@@ -143,6 +143,7 @@ class SFlow extends BaseHeader_1.BaseHeader {
|
|
|
143
143
|
}, 'System Uptime'),
|
|
144
144
|
numSamples: {
|
|
145
145
|
type: 'integer',
|
|
146
|
+
autoCalculated: true,
|
|
146
147
|
label: 'Number of Samples',
|
|
147
148
|
minimum: 0,
|
|
148
149
|
maximum: 4294967295,
|
|
@@ -177,7 +178,7 @@ class SFlow extends BaseHeader_1.BaseHeader {
|
|
|
177
178
|
label: 'Sample',
|
|
178
179
|
properties: {
|
|
179
180
|
sampleType: { type: 'integer', label: 'Sample Type', minimum: 0, maximum: 4294967295 },
|
|
180
|
-
sampleLength: { type: 'integer', label: 'Sample Length', minimum: 0, maximum: 4294967295 },
|
|
181
|
+
sampleLength: { type: 'integer', label: 'Sample Length', autoCalculated: true, minimum: 0, maximum: 4294967295 },
|
|
181
182
|
sampleData: { type: 'string', label: 'Sample Data', contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.HEX }
|
|
182
183
|
}
|
|
183
184
|
},
|
package/dist/headers/SIP.js
CHANGED
|
@@ -113,12 +113,12 @@ class SIP extends BaseHeader_1.BaseHeader {
|
|
|
113
113
|
//Display-only metadata parsed from the start-line on decode (no encode — populated by the
|
|
114
114
|
//message field above, never read back). isRequest distinguishes a Request-Line from a
|
|
115
115
|
//Status-Line; method/requestUri are for requests, statusCode/reasonPhrase for responses.
|
|
116
|
-
isRequest: { type: 'boolean', label: 'Is Request' },
|
|
117
|
-
method: { type: 'string', label: 'Method' },
|
|
118
|
-
requestUri: { type: 'string', label: 'Request URI' },
|
|
119
|
-
version: { type: 'string', label: 'Version' },
|
|
120
|
-
statusCode: { type: 'integer', label: 'Status Code', minimum: 0, maximum: 999 },
|
|
121
|
-
reasonPhrase: { type: 'string', label: 'Reason Phrase' }
|
|
116
|
+
isRequest: { type: 'boolean', label: 'Is Request', readOnly: true },
|
|
117
|
+
method: { type: 'string', label: 'Method', readOnly: true },
|
|
118
|
+
requestUri: { type: 'string', label: 'Request URI', readOnly: true },
|
|
119
|
+
version: { type: 'string', label: 'Version', readOnly: true },
|
|
120
|
+
statusCode: { type: 'integer', label: 'Status Code', readOnly: true, minimum: 0, maximum: 999 },
|
|
121
|
+
reasonPhrase: { type: 'string', label: 'Reason Phrase', readOnly: true }
|
|
122
122
|
}
|
|
123
123
|
};
|
|
124
124
|
}
|
package/dist/headers/SLMP.js
CHANGED
package/dist/headers/SLP.js
CHANGED
|
@@ -92,6 +92,7 @@ class SLP extends BaseHeader_1.BaseHeader {
|
|
|
92
92
|
functionId: this.fieldUInt('functionId', 1, 1, 'Function-ID'),
|
|
93
93
|
length: {
|
|
94
94
|
type: 'integer',
|
|
95
|
+
autoCalculated: true,
|
|
95
96
|
label: 'Length',
|
|
96
97
|
minimum: 0,
|
|
97
98
|
maximum: 16777215,
|
|
@@ -124,6 +125,7 @@ class SLP extends BaseHeader_1.BaseHeader {
|
|
|
124
125
|
xid: this.fieldUInt('xid', 10, 2, 'XID'),
|
|
125
126
|
langTagLen: {
|
|
126
127
|
type: 'integer',
|
|
128
|
+
autoCalculated: true,
|
|
127
129
|
label: 'Language Tag Length',
|
|
128
130
|
minimum: 0,
|
|
129
131
|
maximum: 65535,
|
package/dist/headers/SLPv1.js
CHANGED
package/dist/headers/SMB1.js
CHANGED
package/dist/headers/SMB2.js
CHANGED
package/dist/headers/SMPP.js
CHANGED
|
@@ -48,6 +48,7 @@ class SMPP extends BaseHeader_1.BaseHeader {
|
|
|
48
48
|
properties: {
|
|
49
49
|
commandLength: {
|
|
50
50
|
type: 'integer',
|
|
51
|
+
autoCalculated: true,
|
|
51
52
|
label: 'Command Length',
|
|
52
53
|
//minimum 0 (not 16): a crafted/corrupt PDU may carry a command_length below the 16-byte
|
|
53
54
|
//header, and that value must round-trip (honored verbatim) rather than being rejected by
|
package/dist/headers/SMTP.js
CHANGED
|
@@ -125,12 +125,12 @@ class SMTP extends BaseHeader_1.BaseHeader {
|
|
|
125
125
|
//message field above, never read back). isReply distinguishes a server reply from a
|
|
126
126
|
//client command; replyCode/isMultiline/replyText describe a reply, command/argument a
|
|
127
127
|
//command.
|
|
128
|
-
isReply: { type: 'boolean', label: 'Is Reply' },
|
|
129
|
-
replyCode: { type: 'integer', label: 'Reply Code', minimum: 0, maximum: 999 },
|
|
130
|
-
isMultiline: { type: 'boolean', label: 'Is Multiline' },
|
|
131
|
-
replyText: { type: 'string', label: 'Reply Text' },
|
|
132
|
-
command: { type: 'string', label: 'Command' },
|
|
133
|
-
argument: { type: 'string', label: 'Argument' }
|
|
128
|
+
isReply: { type: 'boolean', label: 'Is Reply', readOnly: true },
|
|
129
|
+
replyCode: { type: 'integer', label: 'Reply Code', readOnly: true, minimum: 0, maximum: 999 },
|
|
130
|
+
isMultiline: { type: 'boolean', label: 'Is Multiline', readOnly: true },
|
|
131
|
+
replyText: { type: 'string', label: 'Reply Text', readOnly: true },
|
|
132
|
+
command: { type: 'string', label: 'Command', readOnly: true },
|
|
133
|
+
argument: { type: 'string', label: 'Argument', readOnly: true }
|
|
134
134
|
}
|
|
135
135
|
};
|
|
136
136
|
}
|
package/dist/headers/SNAP.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.SNAP = void 0;
|
|
4
4
|
const BaseHeader_1 = require("../abstracts/BaseHeader");
|
|
5
|
+
const HexToBuffer_1 = require("../helper/HexToBuffer");
|
|
5
6
|
/**
|
|
6
7
|
* SNAP — Sub-Network Access Protocol (IEEE 802.2), the 5-byte header that follows an LLC header whose
|
|
7
8
|
* DSAP/SSAP are 0xAA. It carries a 3-byte OUI (Organizationally Unique Identifier) and a 2-byte Protocol
|
|
@@ -34,14 +35,26 @@ class SNAP extends BaseHeader_1.BaseHeader {
|
|
|
34
35
|
type: 'object',
|
|
35
36
|
summary: 'SNAP oui=${oui} type=${etherType}',
|
|
36
37
|
properties: {
|
|
37
|
-
|
|
38
|
+
//When oui / etherType are left out they are taken from ouiProtocol — the field the editor
|
|
39
|
+
//graph sets to route a vendor child (snap→cdp is ouiProtocol '00000c2000').
|
|
40
|
+
oui: { ...this.fieldHex('oui', 0, 3, 'OUI'), encode: function () {
|
|
41
|
+
const ouiProtocol = this.instance.ouiProtocol.getValue('');
|
|
42
|
+
const oui = this.instance.oui.getValue(ouiProtocol.length === 10 ? ouiProtocol.substring(0, 6) : '000000');
|
|
43
|
+
this.instance.oui.setValue(oui);
|
|
44
|
+
this.writeBytes(0, (0, HexToBuffer_1.HexToBuffer)(oui));
|
|
45
|
+
} },
|
|
38
46
|
//Named `etherType` (not `pid`) so the existing ethertype demux + IPv4/ARP/IPv6 match() —
|
|
39
47
|
//which read the parent's `etherType` field literally — route through SNAP unchanged, exactly
|
|
40
48
|
//as they do through Ethernet II and 802.1Q.
|
|
41
|
-
etherType: this.fieldHex('etherType', 3, 2, 'Protocol Type'),
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
49
|
+
etherType: { ...this.fieldHex('etherType', 3, 2, 'Protocol Type'), encode: function () {
|
|
50
|
+
const ouiProtocol = this.instance.ouiProtocol.getValue('');
|
|
51
|
+
const etherType = this.instance.etherType.getValue(ouiProtocol.length === 10 ? ouiProtocol.substring(6, 10) : '0000');
|
|
52
|
+
this.instance.etherType.setValue(etherType);
|
|
53
|
+
this.writeBytes(3, (0, HexToBuffer_1.HexToBuffer)(etherType));
|
|
54
|
+
} },
|
|
55
|
+
//Demux key: OUI+PID concatenated, the `snapoui` key for vendor protocols (CDP/VTP under Cisco
|
|
56
|
+
//0x00000C). No encode closure — the bytes are written by oui + etherType — but it supplies
|
|
57
|
+
//them when they are left out (see oui), so the editor can route a child by setting it.
|
|
45
58
|
ouiProtocol: {
|
|
46
59
|
type: 'string',
|
|
47
60
|
label: 'OUI Protocol',
|
package/dist/headers/SNMP.js
CHANGED
|
@@ -164,8 +164,8 @@ class SNMP extends BaseHeader_1.BaseHeader {
|
|
|
164
164
|
version: {
|
|
165
165
|
type: 'integer',
|
|
166
166
|
label: 'Version',
|
|
167
|
-
|
|
168
|
-
|
|
167
|
+
//A BER INTEGER (0 v1, 1 v2c, 3 v3): any decoded value must re-encode, so the bounds
|
|
168
|
+
//are left open (a long INTEGER decodes to a large number), not the defined versions.
|
|
169
169
|
decode: function () {
|
|
170
170
|
const available = this.packet.length - this.startPos;
|
|
171
171
|
if (available <= 0)
|
|
@@ -277,8 +277,8 @@ class SNMP extends BaseHeader_1.BaseHeader {
|
|
|
277
277
|
//empty for the common request/response PDUs, which use the structured fields below.
|
|
278
278
|
pduRaw: { type: 'string', label: 'PDU Body', contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.HEX, hidden: true },
|
|
279
279
|
requestId: { type: 'integer', label: 'Request ID' },
|
|
280
|
-
errorStatus: { type: 'integer', label: 'Error Status'
|
|
281
|
-
errorIndex: { type: 'integer', label: 'Error Index'
|
|
280
|
+
errorStatus: { type: 'integer', label: 'Error Status' },
|
|
281
|
+
errorIndex: { type: 'integer', label: 'Error Index' },
|
|
282
282
|
variableBindings: {
|
|
283
283
|
type: 'array',
|
|
284
284
|
label: 'Variable Bindings',
|
package/dist/headers/SOCKS4.js
CHANGED
|
@@ -6,6 +6,7 @@ const BufferToNumber_1 = require("../helper/BufferToNumber");
|
|
|
6
6
|
const NumberToBuffer_1 = require("../helper/NumberToBuffer");
|
|
7
7
|
const BufferToIP_1 = require("../helper/BufferToIP");
|
|
8
8
|
const IPToBuffer_1 = require("../helper/IPToBuffer");
|
|
9
|
+
const StringContentEncodingEnum_1 = require("../lib/StringContentEncodingEnum");
|
|
9
10
|
/**
|
|
10
11
|
* SOCKS4 — the SOCKS Protocol Version 4 (and the SOCKS4a extension), carried over TCP well-known
|
|
11
12
|
* port 1080. Only two message shapes travel on the wire, discriminated by their leading octet:
|
|
@@ -62,6 +63,11 @@ class SOCKS4 extends BaseHeader_1.BaseHeader {
|
|
|
62
63
|
#isRequest() {
|
|
63
64
|
return this.instance.messageType.getValue('request') === 'request';
|
|
64
65
|
}
|
|
66
|
+
/** True for a SOCKS4a request: dstIp is 0.0.0.x with x != 0, so a domain follows the user-id. */
|
|
67
|
+
#isSocks4a() {
|
|
68
|
+
const octets = this.instance.dstIp.getValue('').split('.');
|
|
69
|
+
return octets.length === 4 && octets[0] === '0' && octets[1] === '0' && octets[2] === '0' && octets[3] !== '0';
|
|
70
|
+
}
|
|
65
71
|
/**
|
|
66
72
|
* Read a null-terminated latin1 string at `offset` (bounded by the captured length); returns its
|
|
67
73
|
* value plus the offset one past the terminator (or the end of buffer if never terminated).
|
|
@@ -133,7 +139,6 @@ class SOCKS4 extends BaseHeader_1.BaseHeader {
|
|
|
133
139
|
command: {
|
|
134
140
|
type: 'integer',
|
|
135
141
|
label: 'Command',
|
|
136
|
-
enum: [1, 2],
|
|
137
142
|
minimum: 0,
|
|
138
143
|
maximum: 255,
|
|
139
144
|
default: 1,
|
|
@@ -166,7 +171,6 @@ class SOCKS4 extends BaseHeader_1.BaseHeader {
|
|
|
166
171
|
status: {
|
|
167
172
|
type: 'integer',
|
|
168
173
|
label: 'Status',
|
|
169
|
-
enum: [0x5a, 0x5b, 0x5c, 0x5d],
|
|
170
174
|
minimum: 0,
|
|
171
175
|
maximum: 255,
|
|
172
176
|
default: 0x5a,
|
|
@@ -227,6 +231,7 @@ class SOCKS4 extends BaseHeader_1.BaseHeader {
|
|
|
227
231
|
type: 'string',
|
|
228
232
|
label: 'Destination IP',
|
|
229
233
|
default: '0.0.0.0',
|
|
234
|
+
contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.IPv4,
|
|
230
235
|
decode: function () {
|
|
231
236
|
this.instance.dstIp.setValue(this.#payloadLength() >= 8 ? (0, BufferToIP_1.BufferToIPv4)(this.readBytes(4, 4)) : '0.0.0.0');
|
|
232
237
|
},
|
|
@@ -256,14 +261,15 @@ class SOCKS4 extends BaseHeader_1.BaseHeader {
|
|
|
256
261
|
}
|
|
257
262
|
},
|
|
258
263
|
//REQUEST shape (SOCKS4a): the null-terminated destination domain that follows the
|
|
259
|
-
//user-id when the client could not resolve the host (dstIp 0.0.0.x).
|
|
260
|
-
//
|
|
264
|
+
//user-id when the client could not resolve the host (dstIp 0.0.0.x, x != 0). Only
|
|
265
|
+
//decoded for such a SOCKS4a request, so bytes trailing a plain SOCKS4 request (e.g.
|
|
266
|
+
//padding) fall to raw instead of being misread as a domain; SOCKS4a round-trips exactly.
|
|
261
267
|
domain: {
|
|
262
268
|
type: 'string',
|
|
263
269
|
label: 'Domain',
|
|
264
270
|
default: '',
|
|
265
271
|
decode: function () {
|
|
266
|
-
if (!this.#isRequest()) {
|
|
272
|
+
if (!this.#isRequest() || !this.#isSocks4a()) {
|
|
267
273
|
this.instance.domain.setValue('');
|
|
268
274
|
return;
|
|
269
275
|
}
|
package/dist/headers/SSDP.js
CHANGED
|
@@ -124,15 +124,15 @@ class SSDP extends BaseHeader_1.BaseHeader {
|
|
|
124
124
|
//Display-only metadata parsed from the start-line on decode (no encode — populated by the
|
|
125
125
|
//message field above, never read back). isRequest distinguishes a Request-Line from a
|
|
126
126
|
//Status-Line; method/requestUri are for requests, statusCode/reasonPhrase for responses.
|
|
127
|
-
isRequest: { type: 'boolean', label: 'Is Request' },
|
|
127
|
+
isRequest: { type: 'boolean', label: 'Is Request', readOnly: true },
|
|
128
128
|
//Display-only Info-column text ("M-SEARCH *" / "200 OK"), set on decode; no encode, so it
|
|
129
129
|
//never affects the re-emitted bytes.
|
|
130
|
-
info: { type: 'string', label: 'Info' },
|
|
131
|
-
method: { type: 'string', label: 'Method' },
|
|
132
|
-
requestUri: { type: 'string', label: 'Request URI' },
|
|
133
|
-
version: { type: 'string', label: 'Version' },
|
|
134
|
-
statusCode: { type: 'integer', label: 'Status Code', minimum: 0, maximum: 999 },
|
|
135
|
-
reasonPhrase: { type: 'string', label: 'Reason Phrase' }
|
|
130
|
+
info: { type: 'string', label: 'Info', readOnly: true },
|
|
131
|
+
method: { type: 'string', label: 'Method', readOnly: true },
|
|
132
|
+
requestUri: { type: 'string', label: 'Request URI', readOnly: true },
|
|
133
|
+
version: { type: 'string', label: 'Version', readOnly: true },
|
|
134
|
+
statusCode: { type: 'integer', label: 'Status Code', readOnly: true, minimum: 0, maximum: 999 },
|
|
135
|
+
reasonPhrase: { type: 'string', label: 'Reason Phrase', readOnly: true }
|
|
136
136
|
}
|
|
137
137
|
};
|
|
138
138
|
}
|
package/dist/headers/SSH.js
CHANGED
|
@@ -109,11 +109,11 @@ class SSH extends BaseHeader_1.BaseHeader {
|
|
|
109
109
|
},
|
|
110
110
|
//Display-only metadata parsed from the identification line on decode (no encode —
|
|
111
111
|
//populated by `message` below for the identification shape, empty for a binary packet).
|
|
112
|
-
protoVersion: { type: 'string', label: 'Protocol Version', default: '' },
|
|
113
|
-
softwareVersion: { type: 'string', label: 'Software Version', default: '' },
|
|
114
|
-
identString: { type: 'string', label: 'Identification String', default: '' },
|
|
112
|
+
protoVersion: { type: 'string', label: 'Protocol Version', readOnly: true, default: '' },
|
|
113
|
+
softwareVersion: { type: 'string', label: 'Software Version', readOnly: true, default: '' },
|
|
114
|
+
identString: { type: 'string', label: 'Identification String', readOnly: true, default: '' },
|
|
115
115
|
//Drives the one-line summary: the software version for an identification, else 'packet'.
|
|
116
|
-
summaryInfo: { type: 'string', label: 'Summary', hidden: true, default: '' },
|
|
116
|
+
summaryInfo: { type: 'string', label: 'Summary', readOnly: true, hidden: true, default: '' },
|
|
117
117
|
//IDENTIFICATION shape: the whole line kept verbatim (byte-perfect) and re-emitted
|
|
118
118
|
//untouched. The display metadata above is parsed from it on decode; encode never
|
|
119
119
|
//reconstructs the line from that metadata.
|
|
@@ -148,6 +148,7 @@ class SSH extends BaseHeader_1.BaseHeader {
|
|
|
148
148
|
//whole message spans packet_length + 4 bytes. Big-endian (unlike ENIP's CIP order).
|
|
149
149
|
packetLength: {
|
|
150
150
|
type: 'integer',
|
|
151
|
+
autoCalculated: true,
|
|
151
152
|
label: 'Packet Length',
|
|
152
153
|
minimum: 0,
|
|
153
154
|
maximum: 4294967295,
|
package/dist/headers/STOMP.js
CHANGED
|
@@ -124,12 +124,12 @@ class STOMP extends BaseHeader_1.BaseHeader {
|
|
|
124
124
|
//`message` field below, never read back). command is the frame's COMMAND line;
|
|
125
125
|
//destination/content-type/content-length are the common headers, present when the frame
|
|
126
126
|
//carries them.
|
|
127
|
-
command: { type: 'string', label: 'Command', default: '' },
|
|
128
|
-
destination: { type: 'string', label: 'Destination', default: '' },
|
|
129
|
-
contentType: { type: 'string', label: 'Content Type', default: '' },
|
|
130
|
-
contentLength: { type: 'integer', label: 'Content Length', minimum: 0, default: 0 },
|
|
127
|
+
command: { type: 'string', label: 'Command', readOnly: true, default: '' },
|
|
128
|
+
destination: { type: 'string', label: 'Destination', readOnly: true, default: '' },
|
|
129
|
+
contentType: { type: 'string', label: 'Content Type', readOnly: true, default: '' },
|
|
130
|
+
contentLength: { type: 'integer', label: 'Content Length', readOnly: true, minimum: 0, default: 0 },
|
|
131
131
|
//Drives the one-line summary (COMMAND + destination when present).
|
|
132
|
-
summaryInfo: { type: 'string', label: 'Summary', hidden: true, default: '' },
|
|
132
|
+
summaryInfo: { type: 'string', label: 'Summary', readOnly: true, hidden: true, default: '' },
|
|
133
133
|
//The whole raw payload is the single source of truth: decoded verbatim to hex and
|
|
134
134
|
//re-emitted untouched (byte-perfect for any STOMP frame). The COMMAND line and common
|
|
135
135
|
//headers are parsed into the display-only metadata above, which carry no codec of their own.
|
package/dist/headers/STUN.js
CHANGED
|
@@ -48,6 +48,7 @@ class STUN extends BaseHeader_1.BaseHeader {
|
|
|
48
48
|
//from the encoded attributes after they are written.
|
|
49
49
|
messageLength: {
|
|
50
50
|
type: 'integer',
|
|
51
|
+
autoCalculated: true,
|
|
51
52
|
label: 'Message Length',
|
|
52
53
|
minimum: 0,
|
|
53
54
|
maximum: 65535,
|
|
@@ -90,6 +91,7 @@ class STUN extends BaseHeader_1.BaseHeader {
|
|
|
90
91
|
},
|
|
91
92
|
value: {
|
|
92
93
|
type: 'string',
|
|
94
|
+
byteAlignment: 4,
|
|
93
95
|
label: 'Value',
|
|
94
96
|
contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.HEX
|
|
95
97
|
},
|
package/dist/headers/Skinny.js
CHANGED
package/dist/headers/StatsD.js
CHANGED
|
@@ -108,10 +108,10 @@ class StatsD extends BaseHeader_1.BaseHeader {
|
|
|
108
108
|
},
|
|
109
109
|
//Display-only metadata parsed from the first metric line on decode (no encode — populated
|
|
110
110
|
//by the message field above, never read back). sampleRate is empty when absent.
|
|
111
|
-
metricName: { type: 'string', label: 'Metric Name' },
|
|
112
|
-
metricValue: { type: 'string', label: 'Metric Value' },
|
|
113
|
-
metricType: { type: 'string', label: 'Metric Type' },
|
|
114
|
-
sampleRate: { type: 'string', label: 'Sample Rate' }
|
|
111
|
+
metricName: { type: 'string', label: 'Metric Name', readOnly: true },
|
|
112
|
+
metricValue: { type: 'string', label: 'Metric Value', readOnly: true },
|
|
113
|
+
metricType: { type: 'string', label: 'Metric Type', readOnly: true },
|
|
114
|
+
sampleRate: { type: 'string', label: 'Sample Rate', readOnly: true }
|
|
115
115
|
}
|
|
116
116
|
};
|
|
117
117
|
}
|
package/dist/headers/SunRPC.js
CHANGED
package/dist/headers/Syslog.js
CHANGED
|
@@ -78,8 +78,8 @@ class Syslog extends BaseHeader_1.BaseHeader {
|
|
|
78
78
|
},
|
|
79
79
|
//Derived from PRI (display only; encode reconstructs PRI, not these): facility = PRI>>3,
|
|
80
80
|
//severity = PRI&7.
|
|
81
|
-
facility: { type: 'integer', label: 'Facility', minimum: 0, maximum: 23 },
|
|
82
|
-
severity: { type: 'integer', label: 'Severity', minimum: 0, maximum: 7 },
|
|
81
|
+
facility: { type: 'integer', label: 'Facility', readOnly: true, minimum: 0, maximum: 23 },
|
|
82
|
+
severity: { type: 'integer', label: 'Severity', readOnly: true, minimum: 0, maximum: 7 },
|
|
83
83
|
message: { type: 'string', label: 'Message' }
|
|
84
84
|
}
|
|
85
85
|
};
|
package/dist/headers/TCP.js
CHANGED
|
@@ -153,6 +153,7 @@ class TCP extends BaseHeader_1.BaseHeader {
|
|
|
153
153
|
},
|
|
154
154
|
hdrLen: {
|
|
155
155
|
type: 'integer',
|
|
156
|
+
autoCalculated: true,
|
|
156
157
|
label: 'Header Length',
|
|
157
158
|
minimum: 0,
|
|
158
159
|
maximum: 60,
|
|
@@ -333,6 +334,7 @@ class TCP extends BaseHeader_1.BaseHeader {
|
|
|
333
334
|
},
|
|
334
335
|
checksum: {
|
|
335
336
|
type: 'integer',
|
|
337
|
+
autoCalculated: true,
|
|
336
338
|
label: 'Checksum',
|
|
337
339
|
minimum: 0,
|
|
338
340
|
maximum: 65535,
|
|
@@ -388,6 +390,7 @@ class TCP extends BaseHeader_1.BaseHeader {
|
|
|
388
390
|
},
|
|
389
391
|
options: {
|
|
390
392
|
type: 'array',
|
|
393
|
+
byteAlignment: 4,
|
|
391
394
|
label: 'Options',
|
|
392
395
|
items: {
|
|
393
396
|
anyOf: [
|
|
@@ -790,7 +793,7 @@ class TCP extends BaseHeader_1.BaseHeader {
|
|
|
790
793
|
const mssBuffer = Buffer.concat([
|
|
791
794
|
(0, NumberToBuffer_1.UInt8ToBuffer)(2),
|
|
792
795
|
(0, NumberToBuffer_1.UInt8ToBuffer)(4),
|
|
793
|
-
(0, NumberToBuffer_1.UInt16ToBuffer)(optionMSS.mss)
|
|
796
|
+
(0, NumberToBuffer_1.UInt16ToBuffer)(optionMSS.mss ?? 0)
|
|
794
797
|
]);
|
|
795
798
|
this.writeBytes(optionOffset, mssBuffer);
|
|
796
799
|
optionOffset += mssBuffer.length;
|
|
@@ -801,7 +804,7 @@ class TCP extends BaseHeader_1.BaseHeader {
|
|
|
801
804
|
const wsBuffer = Buffer.concat([
|
|
802
805
|
(0, NumberToBuffer_1.UInt8ToBuffer)(3),
|
|
803
806
|
(0, NumberToBuffer_1.UInt8ToBuffer)(3),
|
|
804
|
-
(0, NumberToBuffer_1.UInt8ToBuffer)(optionWS.shift)
|
|
807
|
+
(0, NumberToBuffer_1.UInt8ToBuffer)(optionWS.shift ?? 0)
|
|
805
808
|
]);
|
|
806
809
|
this.writeBytes(optionOffset, wsBuffer);
|
|
807
810
|
optionOffset += wsBuffer.length;
|
|
@@ -822,7 +825,8 @@ class TCP extends BaseHeader_1.BaseHeader {
|
|
|
822
825
|
const kindBuffer = (0, NumberToBuffer_1.UInt8ToBuffer)(5);
|
|
823
826
|
const length = 2;
|
|
824
827
|
let blocksBuffer = Buffer.from([]);
|
|
825
|
-
optionSack.blocks
|
|
828
|
+
const sackBlocks = optionSack.blocks ?? [];
|
|
829
|
+
sackBlocks.forEach((block) => {
|
|
826
830
|
blocksBuffer = Buffer.concat([blocksBuffer, (0, NumberToBuffer_1.UInt64ToBuffer)((0, HexToNumber_1.HexToUInt64)(block))]);
|
|
827
831
|
});
|
|
828
832
|
const sackBuffer = Buffer.concat([kindBuffer, (0, NumberToBuffer_1.UInt8ToBuffer)(length + blocksBuffer.length), blocksBuffer]);
|
|
@@ -860,7 +864,7 @@ class TCP extends BaseHeader_1.BaseHeader {
|
|
|
860
864
|
case TCPOption.TCP_Authentication_Option: {
|
|
861
865
|
const optionTcpAo = optionItem;
|
|
862
866
|
const kindBuffer = (0, NumberToBuffer_1.UInt8ToBuffer)(29);
|
|
863
|
-
const dataBuffer = Buffer.from(optionTcpAo.data, 'hex');
|
|
867
|
+
const dataBuffer = Buffer.from(optionTcpAo.data ?? '', 'hex');
|
|
864
868
|
const lengthBuffer = (0, NumberToBuffer_1.UInt8ToBuffer)(dataBuffer.length + 2);
|
|
865
869
|
const tcpAoBuffer = Buffer.concat([kindBuffer, lengthBuffer, dataBuffer]);
|
|
866
870
|
this.writeBytes(optionOffset, tcpAoBuffer);
|
|
@@ -869,8 +873,16 @@ class TCP extends BaseHeader_1.BaseHeader {
|
|
|
869
873
|
}
|
|
870
874
|
default: {
|
|
871
875
|
const defaultOptionItem = optionItem;
|
|
872
|
-
const kind = defaultOptionItem.kind;
|
|
873
|
-
|
|
876
|
+
const kind = defaultOptionItem.kind ?? 0;
|
|
877
|
+
//Kinds 0 (EOL) and 1 (NOP) are single-octet options with no length/data
|
|
878
|
+
//(RFC 9293 §3.1), so a generic {kind: 0|1} emits just the kind octet.
|
|
879
|
+
if (kind === 0 || kind === 1) {
|
|
880
|
+
this.writeBytes(optionOffset, (0, NumberToBuffer_1.UInt8ToBuffer)(kind));
|
|
881
|
+
optionOffset += 1;
|
|
882
|
+
return;
|
|
883
|
+
}
|
|
884
|
+
//Data is optional: a generic option without data is the bare kind+length pair.
|
|
885
|
+
const hexBuffer = Buffer.from(defaultOptionItem.data === undefined || defaultOptionItem.data === null ? '' : defaultOptionItem.data.toString(), 'hex');
|
|
874
886
|
const length = hexBuffer.length + 2;
|
|
875
887
|
const defaultOptionBuffer = Buffer.concat([(0, NumberToBuffer_1.UInt8ToBuffer)(kind), (0, NumberToBuffer_1.UInt8ToBuffer)(length), hexBuffer]);
|
|
876
888
|
this.writeBytes(optionOffset, defaultOptionBuffer);
|
|
@@ -77,13 +77,15 @@ class TLS_Alert extends BaseHeader_1.BaseHeader {
|
|
|
77
77
|
this.instance.contentType.setValue((0, BufferToNumber_1.BufferToUInt8)(this.readBytes(0, 1)));
|
|
78
78
|
},
|
|
79
79
|
encode: () => {
|
|
80
|
-
const contentTyppe = this.instance.contentType.getValue(0, (nodePath) => this.recordError(nodePath, 'Not
|
|
80
|
+
const contentTyppe = this.instance.contentType.getValue(0, (nodePath) => this.recordError(nodePath, 'Not Found'));
|
|
81
81
|
this.writeBytes(0, (0, NumberToBuffer_1.UInt8ToBuffer)(contentTyppe));
|
|
82
82
|
}
|
|
83
83
|
},
|
|
84
84
|
version: {
|
|
85
85
|
type: 'string',
|
|
86
86
|
label: 'Legacy Version',
|
|
87
|
+
//Closed set: decode stores one of these names, or '0' for an unrecognized version.
|
|
88
|
+
enum: [...Object.values(TLSver), '0'],
|
|
87
89
|
minimum: 0,
|
|
88
90
|
maximum: 65535,
|
|
89
91
|
decode: () => {
|
|
@@ -121,7 +123,7 @@ class TLS_Alert extends BaseHeader_1.BaseHeader {
|
|
|
121
123
|
}
|
|
122
124
|
},
|
|
123
125
|
encode: () => {
|
|
124
|
-
const version = this.instance.version.getValue('0', (nodePath) => this.recordError(nodePath, 'Not
|
|
126
|
+
const version = this.instance.version.getValue('0', (nodePath) => this.recordError(nodePath, 'Not Found'));
|
|
125
127
|
switch (version) {
|
|
126
128
|
case TLSver.SSL_3_0:
|
|
127
129
|
{
|
|
@@ -154,6 +156,9 @@ class TLS_Alert extends BaseHeader_1.BaseHeader {
|
|
|
154
156
|
}
|
|
155
157
|
break;
|
|
156
158
|
default: {
|
|
159
|
+
//'0' is what decode stores for an unrecognized version; anything else is not a version.
|
|
160
|
+
if (`${version}` !== '0')
|
|
161
|
+
this.recordError(this.instance.version.getPath(), `Unknown TLS version '${version}', encoded as 0`, 'error');
|
|
157
162
|
this.writeBytes(1, (0, NumberToBuffer_1.UInt16ToBuffer)(0));
|
|
158
163
|
}
|
|
159
164
|
}
|
|
@@ -161,14 +166,14 @@ class TLS_Alert extends BaseHeader_1.BaseHeader {
|
|
|
161
166
|
},
|
|
162
167
|
length: {
|
|
163
168
|
type: 'integer',
|
|
164
|
-
label: '
|
|
169
|
+
label: 'Length',
|
|
165
170
|
minimum: 0,
|
|
166
|
-
maximum:
|
|
171
|
+
maximum: 65535,
|
|
167
172
|
decode: () => {
|
|
168
173
|
this.instance.length.setValue((0, BufferToNumber_1.BufferToUInt16)(this.readBytes(3, 2)));
|
|
169
174
|
},
|
|
170
175
|
encode: () => {
|
|
171
|
-
const length = (0, NumberToBuffer_1.UInt16ToBuffer)(this.instance.length.getValue(0, (nodePath) => this.recordError(nodePath, 'Not
|
|
176
|
+
const length = (0, NumberToBuffer_1.UInt16ToBuffer)(this.instance.length.getValue(0, (nodePath) => this.recordError(nodePath, 'Not Found')));
|
|
172
177
|
this.writeBytes(3, length);
|
|
173
178
|
}
|
|
174
179
|
},
|
|
@@ -179,7 +184,7 @@ class TLS_Alert extends BaseHeader_1.BaseHeader {
|
|
|
179
184
|
maximum: 255,
|
|
180
185
|
decode: () => {
|
|
181
186
|
this.instance.levelType.setValue((0, BufferToNumber_1.BufferToUInt8)(this.readBytes(5, 1)));
|
|
182
|
-
const type = this.instance.levelType.getValue(0, (nodePath) => this.recordError(nodePath, 'Not
|
|
187
|
+
const type = this.instance.levelType.getValue(0, (nodePath) => this.recordError(nodePath, 'Not Found'));
|
|
183
188
|
switch (type) {
|
|
184
189
|
case 1:
|
|
185
190
|
{
|
|
@@ -197,7 +202,7 @@ class TLS_Alert extends BaseHeader_1.BaseHeader {
|
|
|
197
202
|
}
|
|
198
203
|
},
|
|
199
204
|
encode: () => {
|
|
200
|
-
const type = this.instance.levelType.getValue('0', (nodePath) => this.recordError(nodePath, 'Not
|
|
205
|
+
const type = this.instance.levelType.getValue('0', (nodePath) => this.recordError(nodePath, 'Not Found'));
|
|
201
206
|
switch (type) {
|
|
202
207
|
case 'Warning':
|
|
203
208
|
{
|
|
@@ -212,8 +217,11 @@ class TLS_Alert extends BaseHeader_1.BaseHeader {
|
|
|
212
217
|
}
|
|
213
218
|
break;
|
|
214
219
|
default: {
|
|
220
|
+
//Not a known name: a numeric level (what decode stores for an unnamed one).
|
|
215
221
|
const type1 = parseInt(type, 10);
|
|
216
|
-
|
|
222
|
+
if (!/^\d+$/.test(`${type}`) || type1 > 255)
|
|
223
|
+
this.recordError(this.instance.levelType.getPath(), `Unknown alert level '${type}', encoded as 0`, 'error');
|
|
224
|
+
this.writeBytes(5, (0, NumberToBuffer_1.UInt8ToBuffer)(/^\d+$/.test(`${type}`) && type1 <= 255 ? type1 : 0));
|
|
217
225
|
}
|
|
218
226
|
}
|
|
219
227
|
}
|
|
@@ -225,7 +233,7 @@ class TLS_Alert extends BaseHeader_1.BaseHeader {
|
|
|
225
233
|
maximum: 255,
|
|
226
234
|
decode: () => {
|
|
227
235
|
this.instance.descriptionType.setValue((0, BufferToNumber_1.BufferToUInt8)(this.readBytes(6, 1)));
|
|
228
|
-
const type = this.instance.descriptionType.getValue(0, (nodePath) => this.recordError(nodePath, 'Not
|
|
236
|
+
const type = this.instance.descriptionType.getValue(0, (nodePath) => this.recordError(nodePath, 'Not Found'));
|
|
229
237
|
switch (type) {
|
|
230
238
|
case 0:
|
|
231
239
|
{
|
|
@@ -403,7 +411,7 @@ class TLS_Alert extends BaseHeader_1.BaseHeader {
|
|
|
403
411
|
}
|
|
404
412
|
},
|
|
405
413
|
encode: () => {
|
|
406
|
-
const type = this.instance.descriptionType.getValue('0', (nodePath) => this.recordError(nodePath, 'Not
|
|
414
|
+
const type = this.instance.descriptionType.getValue('0', (nodePath) => this.recordError(nodePath, 'Not Found'));
|
|
407
415
|
switch (type) {
|
|
408
416
|
case Description_type.code_0:
|
|
409
417
|
{
|
|
@@ -610,8 +618,12 @@ class TLS_Alert extends BaseHeader_1.BaseHeader {
|
|
|
610
618
|
}
|
|
611
619
|
break;
|
|
612
620
|
default: {
|
|
621
|
+
//Not a known name: a numeric description (what decode stores for an unnamed one).
|
|
613
622
|
const type1 = parseInt(type, 10);
|
|
614
|
-
const
|
|
623
|
+
const known = /^\d+$/.test(`${type}`) && type1 <= 255;
|
|
624
|
+
if (!known)
|
|
625
|
+
this.recordError(this.instance.descriptionType.getPath(), `Unknown alert description '${type}', encoded as 0`, 'error');
|
|
626
|
+
const type2 = (0, NumberToBuffer_1.UInt8ToBuffer)(known ? type1 : 0);
|
|
615
627
|
this.writeBytes(6, type2);
|
|
616
628
|
}
|
|
617
629
|
}
|