@netkitty/codec 1.2.1 → 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 +159 -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.js +20 -8
- 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
|
@@ -26,6 +26,8 @@ class BitTorrent extends BaseHeader_1.BaseHeader {
|
|
|
26
26
|
//No fixed port — BitTorrent peers connect on dynamic/ephemeral ports. Selection is by the
|
|
27
27
|
//content signature (0x13 + "BitTorrent protocol") via heuristicFallback + match().
|
|
28
28
|
this.matchKeys = [];
|
|
29
|
+
//Editor graph: matched by content, so list it under these parents in allowedNextLayers().
|
|
30
|
+
this.heuristicParents = ['tcp'];
|
|
29
31
|
this.heuristicFallback = true;
|
|
30
32
|
//A leaf header — only the handshake is decoded; subsequent peer messages are left to raw.
|
|
31
33
|
this.demuxProducers = [];
|
|
@@ -41,10 +43,10 @@ class BitTorrent extends BaseHeader_1.BaseHeader {
|
|
|
41
43
|
properties: {
|
|
42
44
|
//Protocol string length — always 0x13 (19) for the BEP 3 handshake. Kept as a plain uint8
|
|
43
45
|
//(a crafted handshake may lie); the signature match already guards real traffic.
|
|
44
|
-
pstrlen: this.fieldUInt('pstrlen', 0, 1, 'Protocol String Length'),
|
|
46
|
+
pstrlen: { ...this.fieldUInt('pstrlen', 0, 1, 'Protocol String Length'), default: 19 },
|
|
45
47
|
//The 19-byte protocol identifier "BitTorrent protocol". Kept verbatim as hex so any
|
|
46
48
|
//byte edit round-trips; the human-readable form is UI enrichment for later.
|
|
47
|
-
pstr: this.fieldHex('pstr', 1, 19, 'Protocol String'),
|
|
49
|
+
pstr: { ...this.fieldHex('pstr', 1, 19, 'Protocol String'), default: '426974546f7272656e742070726f746f636f6c' },
|
|
48
50
|
//8 reserved bytes carrying extension bit-flags (BEP 4/5/6/10: DHT, Fast, Extension
|
|
49
51
|
//Protocol). Opaque here and re-emitted verbatim.
|
|
50
52
|
reserved: this.fieldHex('reserved', 20, 8, 'Reserved'),
|
package/dist/headers/C37118.js
CHANGED
package/dist/headers/CAPWAP.js
CHANGED
package/dist/headers/CDP.js
CHANGED
|
@@ -50,7 +50,7 @@ class CDP extends BaseHeader_1.BaseHeader {
|
|
|
50
50
|
type: 'object',
|
|
51
51
|
properties: {
|
|
52
52
|
type: { type: 'integer', label: 'Type', minimum: 0, maximum: 65535 },
|
|
53
|
-
length: { type: 'integer', label: 'Length', minimum: 0, maximum: 65535 },
|
|
53
|
+
length: { type: 'integer', label: 'Length', autoCalculated: true, minimum: 0, maximum: 65535 },
|
|
54
54
|
value: { type: 'string', label: 'Value', contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.HEX }
|
|
55
55
|
}
|
|
56
56
|
},
|
package/dist/headers/CMS.js
CHANGED
|
@@ -157,10 +157,10 @@ class CMS extends BaseHeader_1.BaseHeader {
|
|
|
157
157
|
//(DL/T 2811 §6.10) per the Service Code. Populated on decode by the serviceData closure
|
|
158
158
|
//above; it has no encode closure, so `serviceData` (hex) stays the authoritative encode
|
|
159
159
|
//form and the structured view can never perturb the re-emitted bytes.
|
|
160
|
-
serviceDataDecoded: { type: 'object', label: 'Service Data (decoded)' },
|
|
160
|
+
serviceDataDecoded: { type: 'object', label: 'Service Data (decoded)', readOnly: true, properties: {}, additionalProperties: true },
|
|
161
161
|
//Display-only best-effort readable identifiers extracted from a service data area that has
|
|
162
162
|
//no transcribed structure (the GB/T 33603 M-coded responses). No encode closure.
|
|
163
|
-
serviceDataStrings: { type: 'array', label: 'Readable Identifiers', items: { type: 'string' } }
|
|
163
|
+
serviceDataStrings: { type: 'array', label: 'Readable Identifiers', readOnly: true, items: { type: 'string' } }
|
|
164
164
|
}
|
|
165
165
|
};
|
|
166
166
|
}
|
package/dist/headers/COTP.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { BaseHeader } from '../abstracts/BaseHeader';
|
|
2
|
+
import { HeuristicParent } from '../types/LayerGraph';
|
|
2
3
|
import { ProtocolJSONSchema } from '../schema/ProtocolJSONSchema';
|
|
3
4
|
import { DemuxProducer } from '../types/DemuxProducer';
|
|
4
5
|
/**
|
|
@@ -25,6 +26,7 @@ export declare class COTP extends BaseHeader {
|
|
|
25
26
|
readonly name: string;
|
|
26
27
|
readonly nickname: string;
|
|
27
28
|
readonly matchKeys: string[];
|
|
29
|
+
readonly heuristicParents: HeuristicParent[];
|
|
28
30
|
match(): boolean;
|
|
29
31
|
readonly demuxProducers: DemuxProducer[];
|
|
30
32
|
}
|
package/dist/headers/COTP.js
CHANGED
|
@@ -32,6 +32,8 @@ class COTP extends BaseHeader_1.BaseHeader {
|
|
|
32
32
|
this.nickname = 'COTP';
|
|
33
33
|
//No demux keys: COTP is an unkeyed content-heuristic child that only rides on top of TPKT.
|
|
34
34
|
this.matchKeys = [];
|
|
35
|
+
//Editor graph: matched by content, so list it under these parents in allowedNextLayers().
|
|
36
|
+
this.heuristicParents = ['tpkt'];
|
|
35
37
|
//Effectively a leaf for now — the session/MMS layers above are kept verbatim and decoded later.
|
|
36
38
|
this.demuxProducers = [];
|
|
37
39
|
}
|
|
@@ -52,6 +54,7 @@ class COTP extends BaseHeader_1.BaseHeader {
|
|
|
52
54
|
//Honoured when supplied; else derived from the PDU Type + any verbatim header bytes.
|
|
53
55
|
li: {
|
|
54
56
|
type: 'integer',
|
|
57
|
+
autoCalculated: true,
|
|
55
58
|
label: 'Length Indicator',
|
|
56
59
|
minimum: 0,
|
|
57
60
|
maximum: 255,
|
|
@@ -76,11 +79,13 @@ class COTP extends BaseHeader_1.BaseHeader {
|
|
|
76
79
|
}
|
|
77
80
|
},
|
|
78
81
|
//Full PDU Type octet (high nibble = type code, low nibble kept verbatim), e.g. DT = 0xF0 = 240.
|
|
79
|
-
|
|
82
|
+
//Default DT (0xF0) with EOT set: the TPDU that carries S7comm / ISO-Session / MMS above it.
|
|
83
|
+
pduType: { ...this.fieldUInt('pduType', 1, 1, 'PDU Type'), default: 0xf0 },
|
|
80
84
|
//DT only: bit 7 of the octet at offset 2 — "end of TSDU". Meaningless for other types (left false).
|
|
81
85
|
eot: {
|
|
82
86
|
type: 'boolean',
|
|
83
87
|
label: 'EOT',
|
|
88
|
+
default: true,
|
|
84
89
|
decode: function () {
|
|
85
90
|
const dt = COTP.#isDT(this.instance.pduType.getValue(0));
|
|
86
91
|
this.instance.eot.setValue(dt ? !!this.readBits(2, 1, 0, 1) : false);
|
package/dist/headers/Codesys.js
CHANGED
package/dist/headers/Collectd.js
CHANGED
|
@@ -51,7 +51,7 @@ class Collectd extends BaseHeader_1.BaseHeader {
|
|
|
51
51
|
type: { type: 'integer', label: 'Type', minimum: 0, maximum: 65535 },
|
|
52
52
|
//On-wire Length INCLUDING the 4-byte part header (Type + Length). Honored
|
|
53
53
|
//verbatim on encode; derived as 4 + value bytes when omitted.
|
|
54
|
-
length: { type: 'integer', label: 'Length', minimum: 0, maximum: 65535 },
|
|
54
|
+
length: { type: 'integer', label: 'Length', autoCalculated: true, minimum: 0, maximum: 65535 },
|
|
55
55
|
value: { type: 'string', label: 'Value', contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.HEX }
|
|
56
56
|
}
|
|
57
57
|
},
|
package/dist/headers/DCCP.js
CHANGED
package/dist/headers/DNS.js
CHANGED
|
@@ -76,7 +76,7 @@ class DNS extends BaseHeader_1.BaseHeader {
|
|
|
76
76
|
label: 'Name',
|
|
77
77
|
properties: {
|
|
78
78
|
value: { type: 'string', label: 'Name' },
|
|
79
|
-
raw: { type: 'string', label: 'Raw', contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.HEX, hidden: true }
|
|
79
|
+
raw: { type: 'string', label: 'Raw', autoCalculated: true, contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.HEX, hidden: true }
|
|
80
80
|
}
|
|
81
81
|
};
|
|
82
82
|
return {
|
|
@@ -164,7 +164,7 @@ class DNS extends BaseHeader_1.BaseHeader {
|
|
|
164
164
|
label: 'Name',
|
|
165
165
|
properties: {
|
|
166
166
|
value: { type: 'string', label: 'Name' },
|
|
167
|
-
raw: { type: 'string', label: 'Raw', contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.HEX, hidden: true }
|
|
167
|
+
raw: { type: 'string', label: 'Raw', autoCalculated: true, contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.HEX, hidden: true }
|
|
168
168
|
}
|
|
169
169
|
};
|
|
170
170
|
return {
|
|
@@ -178,7 +178,7 @@ class DNS extends BaseHeader_1.BaseHeader {
|
|
|
178
178
|
type: { type: 'integer', label: 'Type', minimum: 0, maximum: 65535 },
|
|
179
179
|
class: { type: 'integer', label: 'Class', minimum: 0, maximum: 65535 },
|
|
180
180
|
ttl: { type: 'integer', label: 'Time to Live', minimum: 0, maximum: 4294967295 },
|
|
181
|
-
rdlength: { type: 'integer', label: 'Data Length', minimum: 0, maximum: 65535 },
|
|
181
|
+
rdlength: { type: 'integer', label: 'Data Length', readOnly: true, minimum: 0, maximum: 65535 },
|
|
182
182
|
rdata: { type: 'string', label: 'Data', contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.HEX }
|
|
183
183
|
}
|
|
184
184
|
},
|
package/dist/headers/DTLS.js
CHANGED
package/dist/headers/Diameter.js
CHANGED
|
@@ -68,6 +68,7 @@ class Diameter extends BaseHeader_1.BaseHeader {
|
|
|
68
68
|
version: this.fieldUInt('version', 0, 1, 'Version'),
|
|
69
69
|
messageLength: {
|
|
70
70
|
type: 'integer',
|
|
71
|
+
autoCalculated: true,
|
|
71
72
|
label: 'Message Length',
|
|
72
73
|
minimum: 0,
|
|
73
74
|
maximum: 16777215,
|
|
@@ -129,10 +130,10 @@ class Diameter extends BaseHeader_1.BaseHeader {
|
|
|
129
130
|
properties: {
|
|
130
131
|
code: { type: 'integer', label: 'AVP Code', minimum: 0, maximum: 4294967295 },
|
|
131
132
|
flags: { type: 'integer', label: 'AVP Flags', minimum: 0, maximum: 255 },
|
|
132
|
-
length: { type: 'integer', label: 'AVP Length', minimum: 0, maximum: 16777215 },
|
|
133
|
+
length: { type: 'integer', label: 'AVP Length', autoCalculated: true, minimum: 0, maximum: 16777215 },
|
|
133
134
|
vendorId: { type: 'integer', label: 'Vendor-Id', minimum: 0, maximum: 4294967295 },
|
|
134
135
|
data: { type: 'string', label: 'Data', contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.HEX },
|
|
135
|
-
padding: { type: 'string', label: 'Padding', contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.HEX }
|
|
136
|
+
padding: { type: 'string', label: 'Padding', autoCalculated: true, contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.HEX }
|
|
136
137
|
}
|
|
137
138
|
},
|
|
138
139
|
decode: function () {
|
package/dist/headers/EAPOL.js
CHANGED
|
@@ -52,7 +52,6 @@ class EAPOL extends BaseHeader_1.BaseHeader {
|
|
|
52
52
|
label: 'Packet Type',
|
|
53
53
|
minimum: 0,
|
|
54
54
|
maximum: 255,
|
|
55
|
-
enum: [0, 1, 2, 3, 4],
|
|
56
55
|
decode: function () {
|
|
57
56
|
this.instance.packetType.setValue(this.readBytes(1, 1)[0]);
|
|
58
57
|
},
|
|
@@ -72,6 +71,7 @@ class EAPOL extends BaseHeader_1.BaseHeader {
|
|
|
72
71
|
},
|
|
73
72
|
bodyLength: {
|
|
74
73
|
type: 'integer',
|
|
74
|
+
autoCalculated: true,
|
|
75
75
|
label: 'Body Length',
|
|
76
76
|
minimum: 0,
|
|
77
77
|
maximum: 65535,
|
package/dist/headers/EIGRP.js
CHANGED
|
@@ -83,7 +83,7 @@ class EIGRP extends BaseHeader_1.BaseHeader {
|
|
|
83
83
|
label: 'TLV',
|
|
84
84
|
properties: {
|
|
85
85
|
type: { type: 'integer', label: 'Type', minimum: 0, maximum: 65535 },
|
|
86
|
-
length: { type: 'integer', label: 'Length', minimum: 0, maximum: 65535 },
|
|
86
|
+
length: { type: 'integer', label: 'Length', autoCalculated: true, minimum: 0, maximum: 65535 },
|
|
87
87
|
value: { type: 'string', label: 'Value', contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.HEX }
|
|
88
88
|
}
|
|
89
89
|
},
|
package/dist/headers/ENIP.js
CHANGED
|
@@ -47,6 +47,7 @@ class Elasticsearch extends BaseHeader_1.BaseHeader {
|
|
|
47
47
|
magic: this.fieldHex('magic', 0, 2, 'Magic'),
|
|
48
48
|
messageLength: {
|
|
49
49
|
type: 'integer',
|
|
50
|
+
autoCalculated: true,
|
|
50
51
|
label: 'Message Length',
|
|
51
52
|
//Wire field: never constrain below the true lower bound. A truncated/crafted message
|
|
52
53
|
//may decode any value in [0, 0xffffffff]; keep the full uint32 range so a decoded
|
package/dist/headers/EtherCAT.js
CHANGED
|
@@ -57,6 +57,7 @@ class EtherCAT extends BaseHeader_1.BaseHeader {
|
|
|
57
57
|
//(so the three fields never clobber each other). reserved/type are decode-only.
|
|
58
58
|
length: {
|
|
59
59
|
type: 'integer',
|
|
60
|
+
autoCalculated: true,
|
|
60
61
|
label: 'Length',
|
|
61
62
|
minimum: 0,
|
|
62
63
|
//The on-wire field is 11 bits (max 0x7FF); the schema bound is left wider (uint16) so an
|
|
@@ -88,6 +88,8 @@ class EthernetII extends BaseHeader_1.BaseHeader {
|
|
|
88
88
|
this.instance.etherType.setValue(this.readBytes(12, 2).toString('hex').padStart(4, '0'));
|
|
89
89
|
},
|
|
90
90
|
encode: function () {
|
|
91
|
+
if (this.instance.etherType.isUndefined())
|
|
92
|
+
return this.encodeOmittedEtherType(this.instance.etherType, 12);
|
|
91
93
|
const etherType = this.instance.etherType.getValue((0, NumberToHex_1.UInt16ToHex)(0x0000), (nodePath) => this.recordError(nodePath, 'Not Found'));
|
|
92
94
|
const typeBuffer = Buffer.from(etherType, 'hex');
|
|
93
95
|
if (typeBuffer.length < 2)
|
|
@@ -99,6 +101,10 @@ class EthernetII extends BaseHeader_1.BaseHeader {
|
|
|
99
101
|
};
|
|
100
102
|
}
|
|
101
103
|
match() {
|
|
104
|
+
//Fewer bytes than the 14-octet header cannot be reproduced by these fields (encode always writes
|
|
105
|
+
//a whole header): leave them to raw so they round-trip byte-exact.
|
|
106
|
+
if (this.packet.length - this.startPos < 14)
|
|
107
|
+
return false;
|
|
102
108
|
if (!this.prevCodecModule)
|
|
103
109
|
return true;
|
|
104
110
|
//Tunnels that carry a bare Ethernet frame with no inner protocol-type field: claim their payload
|
package/dist/headers/FTP.js
CHANGED
|
@@ -126,12 +126,12 @@ class FTP extends BaseHeader_1.BaseHeader {
|
|
|
126
126
|
//message field above, never read back). isReply distinguishes a server reply from a
|
|
127
127
|
//client command; replyCode/isMultiline/replyText describe a reply, command/argument a
|
|
128
128
|
//command.
|
|
129
|
-
isReply: { type: 'boolean', label: 'Is Reply' },
|
|
130
|
-
replyCode: { type: 'integer', label: 'Reply Code', minimum: 0, maximum: 999 },
|
|
131
|
-
isMultiline: { type: 'boolean', label: 'Is Multiline' },
|
|
132
|
-
replyText: { type: 'string', label: 'Reply Text' },
|
|
133
|
-
command: { type: 'string', label: 'Command' },
|
|
134
|
-
argument: { type: 'string', label: 'Argument' }
|
|
129
|
+
isReply: { type: 'boolean', label: 'Is Reply', readOnly: true },
|
|
130
|
+
replyCode: { type: 'integer', label: 'Reply Code', readOnly: true, minimum: 0, maximum: 999 },
|
|
131
|
+
isMultiline: { type: 'boolean', label: 'Is Multiline', readOnly: true },
|
|
132
|
+
replyText: { type: 'string', label: 'Reply Text', readOnly: true },
|
|
133
|
+
command: { type: 'string', label: 'Command', readOnly: true },
|
|
134
|
+
argument: { type: 'string', label: 'Argument', readOnly: true }
|
|
135
135
|
}
|
|
136
136
|
};
|
|
137
137
|
}
|
package/dist/headers/Finger.js
CHANGED
|
@@ -90,10 +90,10 @@ class Finger extends BaseHeader_1.BaseHeader {
|
|
|
90
90
|
//Display-only metadata parsed from the first line on decode (no encode — populated by the
|
|
91
91
|
//`message` field below, never read back). isVerbose flags a query opening with "/W"; query
|
|
92
92
|
//is the username text with the verbose switch and surrounding whitespace removed.
|
|
93
|
-
isVerbose: { type: 'boolean', label: 'Is Verbose', default: false },
|
|
94
|
-
query: { type: 'string', label: 'Query', default: '' },
|
|
93
|
+
isVerbose: { type: 'boolean', label: 'Is Verbose', readOnly: true, default: false },
|
|
94
|
+
query: { type: 'string', label: 'Query', readOnly: true, default: '' },
|
|
95
95
|
//Drives the one-line summary: the query text, or 'list all' for the empty query.
|
|
96
|
-
summaryInfo: { type: 'string', label: 'Summary', hidden: true, default: '' },
|
|
96
|
+
summaryInfo: { type: 'string', label: 'Summary', readOnly: true, hidden: true, default: '' },
|
|
97
97
|
//The whole raw payload is the single source of truth: decoded verbatim to hex and re-emitted
|
|
98
98
|
//untouched (byte-perfect for any Finger payload). The first line is parsed into the
|
|
99
99
|
//display-only metadata above, which carry no codec of their own.
|
package/dist/headers/GELF.js
CHANGED
|
@@ -74,10 +74,13 @@ class GELF extends BaseHeader_1.BaseHeader {
|
|
|
74
74
|
//Discriminant chosen at decode from the leading magic (chunked / gzip / uncompressed).
|
|
75
75
|
//It writes no bytes; on encode it is honored when supplied, else inferred from which
|
|
76
76
|
//form-specific fields are present (a chunk has a Message ID; a gzip form has payload).
|
|
77
|
-
//
|
|
77
|
+
//A closed enum: decode only ever yields these three, and any other value would match no
|
|
78
|
+
//form-specific field, silently encoding an empty layer.
|
|
78
79
|
form: {
|
|
79
80
|
type: 'string',
|
|
81
|
+
autoCalculated: true,
|
|
80
82
|
label: 'Form',
|
|
83
|
+
enum: ['chunked', 'gzip', 'uncompressed'],
|
|
81
84
|
decode: function () {
|
|
82
85
|
this.instance.form.setValue(this.#detectForm());
|
|
83
86
|
},
|
|
@@ -91,6 +94,9 @@ class GELF extends BaseHeader_1.BaseHeader {
|
|
|
91
94
|
else
|
|
92
95
|
form = 'uncompressed';
|
|
93
96
|
}
|
|
97
|
+
if (form !== 'chunked' && form !== 'gzip' && form !== 'uncompressed') {
|
|
98
|
+
this.recordError(this.instance.form.getPath(), `Unknown form '${form}', no GELF payload encoded`, 'error');
|
|
99
|
+
}
|
|
94
100
|
this.instance.form.setValue(form);
|
|
95
101
|
}
|
|
96
102
|
},
|
package/dist/headers/GENEVE.js
CHANGED
|
@@ -58,7 +58,7 @@ class GENEVE extends BaseHeader_1.BaseHeader {
|
|
|
58
58
|
},
|
|
59
59
|
//Opt Len (options length in 4-byte units) — metadata; the value is derived from the
|
|
60
60
|
//options list by the `body` master on encode and read from the wire on decode.
|
|
61
|
-
optLen: { type: 'integer', label: 'Option Length', minimum: 0, maximum: 63 },
|
|
61
|
+
optLen: { type: 'integer', label: 'Option Length', readOnly: true, minimum: 0, maximum: 63 },
|
|
62
62
|
oam: {
|
|
63
63
|
type: 'boolean', label: 'OAM',
|
|
64
64
|
decode: function () { this.instance.oam.setValue(!!this.readBits(1, 1, 0, 1)); },
|
package/dist/headers/GLBP.js
CHANGED
|
@@ -70,7 +70,7 @@ class GLBP extends BaseHeader_1.BaseHeader {
|
|
|
70
70
|
label: 'TLV',
|
|
71
71
|
properties: {
|
|
72
72
|
type: { type: 'integer', label: 'Type', minimum: 0, maximum: 255 },
|
|
73
|
-
length: { type: 'integer', label: 'Length', minimum: 0, maximum: 255 },
|
|
73
|
+
length: { type: 'integer', label: 'Length', autoCalculated: true, minimum: 0, maximum: 255 },
|
|
74
74
|
value: { type: 'string', label: 'Value', contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.HEX }
|
|
75
75
|
}
|
|
76
76
|
},
|
package/dist/headers/GTPU.js
CHANGED
package/dist/headers/GTPv2C.js
CHANGED
|
@@ -116,8 +116,8 @@ class GitProtocol extends BaseHeader_1.BaseHeader {
|
|
|
116
116
|
//the message field above, never read back). firstPktLineLength is the declared 4-hex-char
|
|
117
117
|
//length prefix; firstCommand is the pkt-line payload up to the first NUL (the service
|
|
118
118
|
//command + repository path for a request line).
|
|
119
|
-
firstPktLineLength: { type: 'integer', label: 'First pkt-line Length', minimum: 0, maximum: 65535 },
|
|
120
|
-
firstCommand: { type: 'string', label: 'First Command' }
|
|
119
|
+
firstPktLineLength: { type: 'integer', label: 'First pkt-line Length', readOnly: true, minimum: 0, maximum: 65535 },
|
|
120
|
+
firstCommand: { type: 'string', label: 'First Command', readOnly: true }
|
|
121
121
|
}
|
|
122
122
|
};
|
|
123
123
|
}
|
package/dist/headers/Goose.js
CHANGED
|
@@ -57,6 +57,7 @@ class Goose extends BaseHeader_1.BaseHeader {
|
|
|
57
57
|
type: 'integer',
|
|
58
58
|
minimum: 0,
|
|
59
59
|
maximum: 65535,
|
|
60
|
+
autoCalculated: true,
|
|
60
61
|
label: 'Length',
|
|
61
62
|
decode: () => {
|
|
62
63
|
this.instance.length.setValue((0, BufferToNumber_1.BufferToUInt16)(this.readBytes(2, 2)));
|
|
@@ -133,9 +134,10 @@ class Goose extends BaseHeader_1.BaseHeader {
|
|
|
133
134
|
try {
|
|
134
135
|
const buffer = this.readBytes(8, readTLVBufferLength, true);
|
|
135
136
|
this.TLVInstance = node_tlv_1.default.parse(buffer);
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
137
|
+
//Consume exactly the outer TLV's own span (tag + length + value). Anything after
|
|
138
|
+
//it (Ethernet padding, trailing bytes) is not part of the goosePdu and must be
|
|
139
|
+
//left for the next layer (raw) so it survives re-encode.
|
|
140
|
+
const TLVBufferLength = this.TLVInstance.bTag.length + this.TLVInstance.bLength.length + this.TLVInstance.bValue.length;
|
|
139
141
|
this.TLVInstance = node_tlv_1.default.parse(this.readBytes(8, TLVBufferLength, false));
|
|
140
142
|
}
|
|
141
143
|
catch (e) {
|
|
@@ -188,7 +190,7 @@ class Goose extends BaseHeader_1.BaseHeader {
|
|
|
188
190
|
properties: {
|
|
189
191
|
gocbRef: {
|
|
190
192
|
type: 'string',
|
|
191
|
-
maxLength:
|
|
193
|
+
//Not a hard maxLength: a decoded over-long value must re-encode; encode flags it instead.
|
|
192
194
|
label: 'GoCBReference',
|
|
193
195
|
contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.ASCII,
|
|
194
196
|
decode: () => {
|
|
@@ -234,7 +236,7 @@ class Goose extends BaseHeader_1.BaseHeader {
|
|
|
234
236
|
},
|
|
235
237
|
datSet: {
|
|
236
238
|
type: 'string',
|
|
237
|
-
maxLength:
|
|
239
|
+
//Not a hard maxLength: a decoded over-long value must re-encode; encode flags it instead.
|
|
238
240
|
label: 'DatSet',
|
|
239
241
|
contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.ASCII,
|
|
240
242
|
decode: () => {
|
|
@@ -257,7 +259,7 @@ class Goose extends BaseHeader_1.BaseHeader {
|
|
|
257
259
|
},
|
|
258
260
|
goID: {
|
|
259
261
|
type: 'string',
|
|
260
|
-
maxLength:
|
|
262
|
+
//Not a hard maxLength: a decoded over-long value must re-encode; encode flags it instead.
|
|
261
263
|
label: 'GoID',
|
|
262
264
|
contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.ASCII,
|
|
263
265
|
decode: () => {
|
|
@@ -962,7 +964,13 @@ class Goose extends BaseHeader_1.BaseHeader {
|
|
|
962
964
|
return new node_tlv_1.default(0x85, Buffer.from((0, NumberToBERHex_1.Int32ToBERHex)(intValue), 'hex'));
|
|
963
965
|
}
|
|
964
966
|
case ItemDataType.INT64: {
|
|
965
|
-
|
|
967
|
+
let intValue = 0n;
|
|
968
|
+
try {
|
|
969
|
+
intValue = BigInt(dataItem.value ?? 0);
|
|
970
|
+
}
|
|
971
|
+
catch (e) {
|
|
972
|
+
this.recordError(errorNodePath, 'Invalid INT64 value');
|
|
973
|
+
}
|
|
966
974
|
if (intValue < BigInt('-9223372036854775808') || intValue > BigInt('9223372036854775807'))
|
|
967
975
|
this.recordError(errorNodePath, 'Invalid INT64 value');
|
|
968
976
|
return new node_tlv_1.default(0x85, Buffer.from((0, NumberToBERHex_1.Int64ToBERHex)(intValue), 'hex'));
|
|
@@ -1063,7 +1071,11 @@ class Goose extends BaseHeader_1.BaseHeader {
|
|
|
1063
1071
|
return new node_tlv_1.default(0x84, Buffer.from(BigInt(`0b${bitString}`).toString(16).padStart(octets * 2, '0'), 'hex'));
|
|
1064
1072
|
}
|
|
1065
1073
|
case ItemDataType.Structure: {
|
|
1066
|
-
|
|
1074
|
+
//A Structure without members (value omitted) is an empty SEQUENCE, not an error.
|
|
1075
|
+
const members = Array.isArray(dataItem.value) ? dataItem.value : [];
|
|
1076
|
+
if (dataItem.value !== undefined && !Array.isArray(dataItem.value))
|
|
1077
|
+
this.recordError(errorNodePath, 'Invalid Structure value, encoded as empty');
|
|
1078
|
+
return new node_tlv_1.default(0xa2, Buffer.concat(this.encodeDataTLVItem(members).map((tlv) => Buffer.concat([tlv.bTag, tlv.bLength, tlv.bValue]))));
|
|
1067
1079
|
}
|
|
1068
1080
|
default: {
|
|
1069
1081
|
this.recordError(errorNodePath, 'Invalid dataType, ignored');
|
package/dist/headers/Gopher.js
CHANGED
|
@@ -133,13 +133,13 @@ class Gopher extends BaseHeader_1.BaseHeader {
|
|
|
133
133
|
//Display-only metadata parsed on decode (no encode — populated by the `message` field
|
|
134
134
|
//below, never read back). isRequest is decided by the TCP port direction; selector and
|
|
135
135
|
//searchTerm apply to a request; itemCount to a response; hasTerminator flags the "." end.
|
|
136
|
-
isRequest: { type: 'boolean', label: 'Is Request', default: false },
|
|
137
|
-
selector: { type: 'string', label: 'Selector', default: '' },
|
|
138
|
-
searchTerm: { type: 'string', label: 'Search Term', default: '' },
|
|
139
|
-
itemCount: { type: 'integer', label: 'Item Count', minimum: 0, default: 0 },
|
|
140
|
-
hasTerminator: { type: 'boolean', label: 'Has Terminator', default: false },
|
|
136
|
+
isRequest: { type: 'boolean', label: 'Is Request', readOnly: true, default: false },
|
|
137
|
+
selector: { type: 'string', label: 'Selector', readOnly: true, default: '' },
|
|
138
|
+
searchTerm: { type: 'string', label: 'Search Term', readOnly: true, default: '' },
|
|
139
|
+
itemCount: { type: 'integer', label: 'Item Count', readOnly: true, minimum: 0, default: 0 },
|
|
140
|
+
hasTerminator: { type: 'boolean', label: 'Has Terminator', readOnly: true, default: false },
|
|
141
141
|
//Drives the one-line summary (request selector / response line count).
|
|
142
|
-
summaryInfo: { type: 'string', label: 'Summary', hidden: true, default: '' },
|
|
142
|
+
summaryInfo: { type: 'string', label: 'Summary', readOnly: true, hidden: true, default: '' },
|
|
143
143
|
//The whole raw payload is the single source of truth: decoded verbatim to hex and
|
|
144
144
|
//re-emitted untouched (byte-perfect for any Gopher payload). The first line is parsed into
|
|
145
145
|
//the display-only metadata above, which carry no codec of their own.
|
package/dist/headers/HARTIP.js
CHANGED
|
@@ -75,6 +75,7 @@ class HARTIP extends BaseHeader_1.BaseHeader {
|
|
|
75
75
|
sequenceNumber: this.fieldUInt('sequenceNumber', 4, 2, 'Sequence Number'),
|
|
76
76
|
byteCount: {
|
|
77
77
|
type: 'integer',
|
|
78
|
+
autoCalculated: true,
|
|
78
79
|
label: 'Byte Count',
|
|
79
80
|
//minimum 0 (not 8): a crafted/corrupt message may carry a Byte Count below the 8-byte
|
|
80
81
|
//header, and such a value must round-trip (honored verbatim) rather than being rejected
|
package/dist/headers/HSR.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.HSR = void 0;
|
|
4
4
|
const BaseHeader_1 = require("../abstracts/BaseHeader");
|
|
5
|
+
const StringContentEncodingEnum_1 = require("../lib/StringContentEncodingEnum");
|
|
5
6
|
const NumberToHex_1 = require("../helper/NumberToHex");
|
|
6
7
|
const BufferToHex_1 = require("../helper/BufferToHex");
|
|
7
8
|
/**
|
|
@@ -67,6 +68,7 @@ class HSR extends BaseHeader_1.BaseHeader {
|
|
|
67
68
|
minLength: 4,
|
|
68
69
|
maxLength: 4,
|
|
69
70
|
label: 'EtherType',
|
|
71
|
+
contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.HEX,
|
|
70
72
|
//The ORIGINAL EtherType of the carried frame. MUST be named `etherType` and stored as a
|
|
71
73
|
//lowercase 4-hex string exactly like VLAN/Ethernet, because L2 children (GOOSE, SV,
|
|
72
74
|
//VLAN, ARP) discriminate by reading prevCodecModule.instance.etherType — a different
|
package/dist/headers/HTTP.js
CHANGED
|
@@ -119,12 +119,12 @@ class HTTP extends BaseHeader_1.BaseHeader {
|
|
|
119
119
|
//Display-only metadata parsed from the start-line on decode (no encode — populated by the
|
|
120
120
|
//message field above, never read back). isRequest distinguishes a Request-Line from a
|
|
121
121
|
//Status-Line; method/requestUri are for requests, statusCode/reasonPhrase for responses.
|
|
122
|
-
isRequest: { type: 'boolean', label: 'Is Request' },
|
|
123
|
-
method: { type: 'string', label: 'Method' },
|
|
124
|
-
requestUri: { type: 'string', label: 'Request URI' },
|
|
125
|
-
version: { type: 'string', label: 'Version' },
|
|
126
|
-
statusCode: { type: 'integer', label: 'Status Code', minimum: 0, maximum: 999 },
|
|
127
|
-
reasonPhrase: { type: 'string', label: 'Reason Phrase' }
|
|
122
|
+
isRequest: { type: 'boolean', label: 'Is Request', readOnly: true },
|
|
123
|
+
method: { type: 'string', label: 'Method', readOnly: true },
|
|
124
|
+
requestUri: { type: 'string', label: 'Request URI', readOnly: true },
|
|
125
|
+
version: { type: 'string', label: 'Version', readOnly: true },
|
|
126
|
+
statusCode: { type: 'integer', label: 'Status Code', readOnly: true, minimum: 0, maximum: 999 },
|
|
127
|
+
reasonPhrase: { type: 'string', label: 'Reason Phrase', readOnly: true }
|
|
128
128
|
}
|
|
129
129
|
};
|
|
130
130
|
}
|
package/dist/headers/HTTP2.js
CHANGED
package/dist/headers/ICMP.js
CHANGED