netkitty 0.0.17 → 0.0.19
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/CodecExports.d.ts +33 -0
- package/dist/CodecExports.d.ts.map +1 -0
- package/dist/CodecExports.js +23 -0
- package/dist/CodecHeaderExports.d.ts +2 -0
- package/dist/CodecHeaderExports.d.ts.map +1 -0
- package/dist/CodecHeaderExports.js +17 -0
- package/dist/HelperExports.d.ts +11 -0
- package/dist/HelperExports.d.ts.map +1 -0
- package/dist/HelperExports.js +72 -0
- package/dist/NetKitty.d.ts +1 -0
- package/dist/NetKitty.d.ts.map +1 -0
- package/dist/NetKitty.js +90 -0
- package/dist/NetworkExports.d.ts +13 -0
- package/dist/NetworkExports.d.ts.map +1 -0
- package/dist/NetworkExports.js +13 -0
- package/dist/PcapExports.d.ts +17 -0
- package/dist/PcapExports.d.ts.map +1 -0
- package/dist/PcapExports.js +18 -0
- package/dist/errors/ActionNotFoundError.d.ts +5 -0
- package/dist/errors/ActionNotFoundError.d.ts.map +1 -0
- package/dist/errors/ActionNotFoundError.js +12 -0
- package/dist/errors/CodecSchemaValidateError.d.ts +5 -0
- package/dist/errors/CodecSchemaValidateError.d.ts.map +1 -0
- package/dist/errors/CodecSchemaValidateError.js +12 -0
- package/dist/errors/DeviceNotFoundError.d.ts +5 -0
- package/dist/errors/DeviceNotFoundError.d.ts.map +1 -0
- package/dist/errors/DeviceNotFoundError.js +12 -0
- package/dist/errors/NoAvailableCodecError.d.ts +5 -0
- package/dist/errors/NoAvailableCodecError.d.ts.map +1 -0
- package/dist/errors/NoAvailableCodecError.js +12 -0
- package/dist/errors/NpcapLoadError.d.ts +5 -0
- package/dist/errors/NpcapLoadError.d.ts.map +1 -0
- package/dist/errors/NpcapLoadError.js +12 -0
- package/dist/errors/SocketDownError.d.ts +5 -0
- package/dist/errors/SocketDownError.d.ts.map +1 -0
- package/dist/errors/SocketDownError.js +12 -0
- package/dist/errors/UnknownPipeMessageTypeError.d.ts +5 -0
- package/dist/errors/UnknownPipeMessageTypeError.d.ts.map +1 -0
- package/dist/errors/UnknownPipeMessageTypeError.js +12 -0
- package/dist/errors/common/ErrorCode.d.ts +31 -0
- package/dist/errors/common/ErrorCode.d.ts.map +1 -0
- package/dist/errors/common/ErrorCode.js +33 -0
- package/dist/lib/GeneratePipeAddress.d.ts +7 -0
- package/dist/lib/GeneratePipeAddress.d.ts.map +1 -0
- package/dist/lib/GeneratePipeAddress.js +23 -0
- package/dist/lib/GetBinding.d.ts +2 -0
- package/dist/lib/GetBinding.d.ts.map +1 -0
- package/dist/lib/GetBinding.js +6 -0
- package/dist/lib/GetCaptureTemporaryDirectory.d.ts +7 -0
- package/dist/lib/GetCaptureTemporaryDirectory.d.ts.map +1 -0
- package/dist/lib/GetCaptureTemporaryDirectory.js +15 -0
- package/dist/lib/GetDeviceCaptureTemporaryFilename.d.ts +8 -0
- package/dist/lib/GetDeviceCaptureTemporaryFilename.d.ts.map +1 -0
- package/dist/lib/GetDeviceCaptureTemporaryFilename.js +18 -0
- package/dist/lib/codec/Codec.d.ts +32 -0
- package/dist/lib/codec/Codec.d.ts.map +1 -0
- package/dist/lib/codec/Codec.js +183 -0
- package/dist/lib/codec/PacketHeaders.d.ts +14 -0
- package/dist/lib/codec/PacketHeaders.d.ts.map +1 -0
- package/dist/lib/codec/PacketHeaders.js +29 -0
- package/dist/lib/codec/abstracts/BaseHeader.d.ts +217 -0
- package/dist/lib/codec/abstracts/BaseHeader.d.ts.map +1 -0
- package/dist/lib/codec/abstracts/BaseHeader.js +356 -0
- package/dist/lib/codec/headers/ARP.d.ts +10 -0
- package/dist/lib/codec/headers/ARP.d.ts.map +1 -0
- package/dist/lib/codec/headers/ARP.js +224 -0
- package/dist/lib/codec/headers/EthernetII.d.ts +10 -0
- package/dist/lib/codec/headers/EthernetII.d.ts.map +1 -0
- package/dist/lib/codec/headers/EthernetII.js +81 -0
- package/dist/lib/codec/headers/Goose.d.ts +13 -0
- package/dist/lib/codec/headers/Goose.d.ts.map +1 -0
- package/dist/lib/codec/headers/Goose.js +720 -0
- package/dist/lib/codec/headers/ICMP.d.ts +15 -0
- package/dist/lib/codec/headers/ICMP.d.ts.map +1 -0
- package/dist/lib/codec/headers/ICMP.js +147 -0
- package/dist/lib/codec/headers/ICMPv6.d.ts +15 -0
- package/dist/lib/codec/headers/ICMPv6.d.ts.map +1 -0
- package/dist/lib/codec/headers/ICMPv6.js +128 -0
- package/dist/lib/codec/headers/IEC61850SampledValues.d.ts +13 -0
- package/dist/lib/codec/headers/IEC61850SampledValues.d.ts.map +1 -0
- package/dist/lib/codec/headers/IEC61850SampledValues.js +370 -0
- package/dist/lib/codec/headers/IPv4.d.ts +16 -0
- package/dist/lib/codec/headers/IPv4.d.ts.map +1 -0
- package/dist/lib/codec/headers/IPv4.js +339 -0
- package/dist/lib/codec/headers/IPv6.d.ts +10 -0
- package/dist/lib/codec/headers/IPv6.d.ts.map +1 -0
- package/dist/lib/codec/headers/IPv6.js +177 -0
- package/dist/lib/codec/headers/IPv6HopByHopOptions.d.ts +71 -0
- package/dist/lib/codec/headers/IPv6HopByHopOptions.d.ts.map +1 -0
- package/dist/lib/codec/headers/IPv6HopByHopOptions.js +497 -0
- package/dist/lib/codec/headers/RawData.d.ts +11 -0
- package/dist/lib/codec/headers/RawData.d.ts.map +1 -0
- package/dist/lib/codec/headers/RawData.js +36 -0
- package/dist/lib/codec/headers/TCP.d.ts +16 -0
- package/dist/lib/codec/headers/TCP.d.ts.map +1 -0
- package/dist/lib/codec/headers/TCP.js +899 -0
- package/dist/lib/codec/headers/UDP.d.ts +16 -0
- package/dist/lib/codec/headers/UDP.d.ts.map +1 -0
- package/dist/lib/codec/headers/UDP.js +192 -0
- package/dist/lib/codec/headers/VLAN_802dot1Q.d.ts +10 -0
- package/dist/lib/codec/headers/VLAN_802dot1Q.d.ts.map +1 -0
- package/dist/lib/codec/headers/VLAN_802dot1Q.js +78 -0
- package/dist/lib/codec/lib/FlexibleObject.d.ts +28 -0
- package/dist/lib/codec/lib/FlexibleObject.d.ts.map +1 -0
- package/dist/lib/codec/lib/FlexibleObject.js +102 -0
- package/dist/lib/codec/lib/ProcessPacketPostHandlers.d.ts +14 -0
- package/dist/lib/codec/lib/ProcessPacketPostHandlers.d.ts.map +1 -0
- package/dist/lib/codec/lib/ProcessPacketPostHandlers.js +53 -0
- package/dist/lib/codec/lib/SortPostHandlers.d.ts +8 -0
- package/dist/lib/codec/lib/SortPostHandlers.d.ts.map +1 -0
- package/dist/lib/codec/lib/SortPostHandlers.js +11 -0
- package/dist/lib/codec/lib/StringContentEncodingEnum.d.ts +11 -0
- package/dist/lib/codec/lib/StringContentEncodingEnum.d.ts.map +1 -0
- package/dist/lib/codec/lib/StringContentEncodingEnum.js +14 -0
- package/dist/lib/codec/types/CodecData.d.ts +7 -0
- package/dist/lib/codec/types/CodecData.d.ts.map +1 -0
- package/dist/lib/codec/types/CodecData.js +2 -0
- package/dist/lib/codec/types/CodecDecodeResult.d.ts +11 -0
- package/dist/lib/codec/types/CodecDecodeResult.d.ts.map +1 -0
- package/dist/lib/codec/types/CodecDecodeResult.js +2 -0
- package/dist/lib/codec/types/CodecEncodeInput.d.ts +9 -0
- package/dist/lib/codec/types/CodecEncodeInput.d.ts.map +1 -0
- package/dist/lib/codec/types/CodecEncodeInput.js +2 -0
- package/dist/lib/codec/types/CodecEncodeResult.d.ts +6 -0
- package/dist/lib/codec/types/CodecEncodeResult.d.ts.map +1 -0
- package/dist/lib/codec/types/CodecEncodeResult.js +2 -0
- package/dist/lib/codec/types/CodecErrorInfo.d.ts +6 -0
- package/dist/lib/codec/types/CodecErrorInfo.d.ts.map +1 -0
- package/dist/lib/codec/types/CodecErrorInfo.js +2 -0
- package/dist/lib/codec/types/CodecModule.d.ts +3 -0
- package/dist/lib/codec/types/CodecModule.d.ts.map +1 -0
- package/dist/lib/codec/types/CodecModule.js +2 -0
- package/dist/lib/codec/types/CodecModuleConstructor.d.ts +3 -0
- package/dist/lib/codec/types/CodecModuleConstructor.d.ts.map +1 -0
- package/dist/lib/codec/types/CodecModuleConstructor.js +2 -0
- package/dist/lib/codec/types/CodecSchema.d.ts +7 -0
- package/dist/lib/codec/types/CodecSchema.d.ts.map +1 -0
- package/dist/lib/codec/types/CodecSchema.js +2 -0
- package/dist/lib/codec/types/HeaderTreeNode.d.ts +5 -0
- package/dist/lib/codec/types/HeaderTreeNode.d.ts.map +1 -0
- package/dist/lib/codec/types/HeaderTreeNode.js +2 -0
- package/dist/lib/codec/types/PostHandlerItem.d.ts +5 -0
- package/dist/lib/codec/types/PostHandlerItem.d.ts.map +1 -0
- package/dist/lib/codec/types/PostHandlerItem.js +2 -0
- package/dist/lib/helper/BufferToHex.d.ts +2 -0
- package/dist/lib/helper/BufferToHex.d.ts.map +1 -0
- package/dist/lib/helper/BufferToHex.js +6 -0
- package/dist/lib/helper/BufferToIP.d.ts +13 -0
- package/dist/lib/helper/BufferToIP.d.ts.map +1 -0
- package/dist/lib/helper/BufferToIP.js +21 -0
- package/dist/lib/helper/BufferToNumber.d.ts +10 -0
- package/dist/lib/helper/BufferToNumber.d.ts.map +1 -0
- package/dist/lib/helper/BufferToNumber.js +22 -0
- package/dist/lib/helper/HexToBuffer.d.ts +8 -0
- package/dist/lib/helper/HexToBuffer.d.ts.map +1 -0
- package/dist/lib/helper/HexToBuffer.js +27 -0
- package/dist/lib/helper/HexToNumber.d.ts +10 -0
- package/dist/lib/helper/HexToNumber.d.ts.map +1 -0
- package/dist/lib/helper/HexToNumber.js +39 -0
- package/dist/lib/helper/IPToBuffer.d.ts +13 -0
- package/dist/lib/helper/IPToBuffer.d.ts.map +1 -0
- package/dist/lib/helper/IPToBuffer.js +28 -0
- package/dist/lib/helper/NumberToBERBuffer.d.ts +9 -0
- package/dist/lib/helper/NumberToBERBuffer.d.ts.map +1 -0
- package/dist/lib/helper/NumberToBERBuffer.js +20 -0
- package/dist/lib/helper/NumberToBERHex.d.ts +9 -0
- package/dist/lib/helper/NumberToBERHex.d.ts.map +1 -0
- package/dist/lib/helper/NumberToBERHex.js +23 -0
- package/dist/lib/helper/NumberToBuffer.d.ts +10 -0
- package/dist/lib/helper/NumberToBuffer.d.ts.map +1 -0
- package/dist/lib/helper/NumberToBuffer.js +22 -0
- package/dist/lib/helper/NumberToHex.d.ts +10 -0
- package/dist/lib/helper/NumberToHex.d.ts.map +1 -0
- package/dist/lib/helper/NumberToHex.js +26 -0
- package/dist/lib/nodepcap/Capture.d.ts +75 -0
- package/dist/lib/nodepcap/Capture.d.ts.map +1 -0
- package/dist/lib/nodepcap/Capture.js +309 -0
- package/dist/lib/nodepcap/GetNetworkInterfaces.d.ts +7 -0
- package/dist/lib/nodepcap/GetNetworkInterfaces.d.ts.map +1 -0
- package/dist/lib/nodepcap/GetNetworkInterfaces.js +22 -0
- package/dist/lib/nodepcap/interfaces/IBindingCapture.d.ts +16 -0
- package/dist/lib/nodepcap/interfaces/IBindingCapture.d.ts.map +1 -0
- package/dist/lib/nodepcap/interfaces/IBindingCapture.js +2 -0
- package/dist/lib/nodepcap/interfaces/IBindingCaptureOptions.d.ts +5 -0
- package/dist/lib/nodepcap/interfaces/IBindingCaptureOptions.d.ts.map +1 -0
- package/dist/lib/nodepcap/interfaces/IBindingCaptureOptions.js +2 -0
- package/dist/lib/nodepcap/interfaces/ICaptureOptions.d.ts +19 -0
- package/dist/lib/nodepcap/interfaces/ICaptureOptions.d.ts.map +1 -0
- package/dist/lib/nodepcap/interfaces/ICaptureOptions.js +2 -0
- package/dist/lib/nodepcap/interfaces/INetworkInterface.d.ts +5 -0
- package/dist/lib/nodepcap/interfaces/INetworkInterface.d.ts.map +1 -0
- package/dist/lib/nodepcap/interfaces/INetworkInterface.js +2 -0
- package/dist/lib/nodepcap/lib/BindingCapture.d.ts +15 -0
- package/dist/lib/nodepcap/lib/BindingCapture.d.ts.map +1 -0
- package/dist/lib/nodepcap/lib/BindingCapture.js +35 -0
- package/dist/lib/nodepcap/lib/GetNodePcapBinding.d.ts +2 -0
- package/dist/lib/nodepcap/lib/GetNodePcapBinding.d.ts.map +1 -0
- package/dist/lib/nodepcap/lib/GetNodePcapBinding.js +55 -0
- package/dist/lib/nodepcap/lib/GetNodePcapBindingCapture.d.ts +3 -0
- package/dist/lib/nodepcap/lib/GetNodePcapBindingCapture.d.ts.map +1 -0
- package/dist/lib/nodepcap/lib/GetNodePcapBindingCapture.js +18 -0
- package/dist/lib/nodepcap/workers/CaptureWorker.d.ts +2 -0
- package/dist/lib/nodepcap/workers/CaptureWorker.d.ts.map +1 -0
- package/dist/lib/nodepcap/workers/CaptureWorker.js +25 -0
- package/dist/lib/pcap/PCAPGenerator.d.ts +34 -0
- package/dist/lib/pcap/PCAPGenerator.d.ts.map +1 -0
- package/dist/lib/pcap/PCAPGenerator.js +95 -0
- package/dist/lib/pcap/PcapParser.d.ts +27 -0
- package/dist/lib/pcap/PcapParser.d.ts.map +1 -0
- package/dist/lib/pcap/PcapParser.js +149 -0
- package/dist/lib/pcap/PcapReader.d.ts +89 -0
- package/dist/lib/pcap/PcapReader.d.ts.map +1 -0
- package/dist/lib/pcap/PcapReader.js +209 -0
- package/dist/lib/pcap/PcapWriter.d.ts +29 -0
- package/dist/lib/pcap/PcapWriter.d.ts.map +1 -0
- package/dist/lib/pcap/PcapWriter.js +80 -0
- package/dist/lib/pcap/interfaces/IPcapPacketInfo.d.ts +13 -0
- package/dist/lib/pcap/interfaces/IPcapPacketInfo.d.ts.map +1 -0
- package/dist/lib/pcap/interfaces/IPcapPacketInfo.js +2 -0
- package/dist/lib/pipe/PipeClient.d.ts +35 -0
- package/dist/lib/pipe/PipeClient.d.ts.map +1 -0
- package/dist/lib/pipe/PipeClient.js +71 -0
- package/dist/lib/pipe/PipeClientSocket.d.ts +39 -0
- package/dist/lib/pipe/PipeClientSocket.d.ts.map +1 -0
- package/dist/lib/pipe/PipeClientSocket.js +82 -0
- package/dist/lib/pipe/PipeMessage.d.ts +27 -0
- package/dist/lib/pipe/PipeMessage.d.ts.map +1 -0
- package/dist/lib/pipe/PipeMessage.js +61 -0
- package/dist/lib/pipe/PipeMessageHandler.d.ts +16 -0
- package/dist/lib/pipe/PipeMessageHandler.d.ts.map +1 -0
- package/dist/lib/pipe/PipeMessageHandler.js +95 -0
- package/dist/lib/pipe/PipeServer.d.ts +25 -0
- package/dist/lib/pipe/PipeServer.d.ts.map +1 -0
- package/dist/lib/pipe/PipeServer.js +59 -0
- package/dist/lib/schema/ProtocolFieldJSONSchema.d.ts +35 -0
- package/dist/lib/schema/ProtocolFieldJSONSchema.d.ts.map +1 -0
- package/dist/lib/schema/ProtocolFieldJSONSchema.js +2 -0
- package/dist/lib/schema/ProtocolFieldJSONSchemaDefinition.d.ts +3 -0
- package/dist/lib/schema/ProtocolFieldJSONSchemaDefinition.d.ts.map +1 -0
- package/dist/lib/schema/ProtocolFieldJSONSchemaDefinition.js +2 -0
- package/dist/lib/schema/ProtocolJSONSchema.d.ts +32 -0
- package/dist/lib/schema/ProtocolJSONSchema.d.ts.map +1 -0
- package/dist/lib/schema/ProtocolJSONSchema.js +2 -0
- package/dist/tests/Test.spec.d.ts +2 -0
- package/dist/tests/Test.spec.d.ts.map +1 -0
- package/dist/tests/Test.spec.js +25 -0
- package/dist/tests/units/CaptureTest.spec.d.ts +2 -0
- package/dist/tests/units/CaptureTest.spec.d.ts.map +1 -0
- package/dist/tests/units/CaptureTest.spec.js +31 -0
- package/dist/tests/units/Codec.spec.d.ts +2 -0
- package/dist/tests/units/Codec.spec.d.ts.map +1 -0
- package/dist/tests/units/Codec.spec.js +73 -0
- package/dist/tests/units/ReadPCAP.spec.d.ts +2 -0
- package/dist/tests/units/ReadPCAP.spec.d.ts.map +1 -0
- package/dist/tests/units/ReadPCAP.spec.js +14 -0
- package/package.json +6 -6
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { ProtocolJSONSchema } from '../../schema/ProtocolJSONSchema';
|
|
2
|
+
import { BaseHeader } from '../abstracts/BaseHeader';
|
|
3
|
+
export declare class UDP extends BaseHeader {
|
|
4
|
+
/**
|
|
5
|
+
* Calculate UDP Checksum
|
|
6
|
+
* @protected
|
|
7
|
+
* @param udpHeaderBuffer
|
|
8
|
+
*/
|
|
9
|
+
protected calculateUDPChecksum(udpHeaderBuffer: Buffer): number;
|
|
10
|
+
SCHEMA: ProtocolJSONSchema;
|
|
11
|
+
readonly id: string;
|
|
12
|
+
readonly name: string;
|
|
13
|
+
readonly nickname: string;
|
|
14
|
+
match(): boolean;
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=UDP.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"UDP.d.ts","sourceRoot":"","sources":["../../../../src/lib/codec/headers/UDP.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,kBAAkB,EAAC,MAAM,iCAAiC,CAAA;AAClE,OAAO,EAAC,UAAU,EAAC,MAAM,yBAAyB,CAAA;AAMlD,qBAAa,GAAI,SAAQ,UAAU;IAE/B;;;;OAIG;IACH,SAAS,CAAC,oBAAoB,CAAC,eAAe,EAAE,MAAM,GAAG,MAAM;IA8CxD,MAAM,EAAE,kBAAkB,CA2GhC;IAED,SAAgB,EAAE,EAAE,MAAM,CAAQ;IAElC,SAAgB,IAAI,EAAE,MAAM,CAA2B;IAEvD,SAAgB,QAAQ,EAAE,MAAM,CAAQ;IAEjC,KAAK,IAAI,OAAO;CAM1B"}
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UDP = void 0;
|
|
4
|
+
const BaseHeader_1 = require("../abstracts/BaseHeader");
|
|
5
|
+
const BufferToNumber_1 = require("../../helper/BufferToNumber");
|
|
6
|
+
const NumberToBuffer_1 = require("../../helper/NumberToBuffer");
|
|
7
|
+
const IPToBuffer_1 = require("../../helper/IPToBuffer");
|
|
8
|
+
class UDP extends BaseHeader_1.BaseHeader {
|
|
9
|
+
constructor() {
|
|
10
|
+
super(...arguments);
|
|
11
|
+
this.SCHEMA = {
|
|
12
|
+
type: 'object',
|
|
13
|
+
properties: {
|
|
14
|
+
srcport: {
|
|
15
|
+
type: 'integer',
|
|
16
|
+
label: 'Source Port',
|
|
17
|
+
minimum: 0,
|
|
18
|
+
maximum: 65535,
|
|
19
|
+
decode: () => {
|
|
20
|
+
this.instance.srcport.setValue((0, BufferToNumber_1.BufferToUInt16)(this.readBytes(0, 2)));
|
|
21
|
+
},
|
|
22
|
+
encode: () => {
|
|
23
|
+
let srcport = this.instance.srcport.getValue(0, (nodePath) => this.recordError(nodePath, 'Not Found'));
|
|
24
|
+
if (srcport > 65535) {
|
|
25
|
+
this.recordError(this.instance.srcport.getPath(), 'Maximum value is 65535');
|
|
26
|
+
srcport = 65535;
|
|
27
|
+
}
|
|
28
|
+
if (srcport < 0) {
|
|
29
|
+
this.recordError(this.instance.srcport.getPath(), 'Minimum value is 0');
|
|
30
|
+
srcport = 0;
|
|
31
|
+
}
|
|
32
|
+
this.instance.srcport.setValue(srcport);
|
|
33
|
+
this.writeBytes(0, (0, NumberToBuffer_1.UInt16ToBuffer)(srcport));
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
dstport: {
|
|
37
|
+
type: 'integer',
|
|
38
|
+
label: 'Destination Port',
|
|
39
|
+
minimum: 0,
|
|
40
|
+
maximum: 65535,
|
|
41
|
+
decode: () => {
|
|
42
|
+
this.instance.dstport.setValue((0, BufferToNumber_1.BufferToUInt16)(this.readBytes(2, 2)));
|
|
43
|
+
},
|
|
44
|
+
encode: () => {
|
|
45
|
+
let dstport = this.instance.dstport.getValue(0, (nodePath) => this.recordError(nodePath, 'Not Found'));
|
|
46
|
+
if (dstport > 65535) {
|
|
47
|
+
this.recordError(this.instance.dstport.getPath(), 'Maximum value is 65535');
|
|
48
|
+
dstport = 65535;
|
|
49
|
+
}
|
|
50
|
+
if (dstport < 0) {
|
|
51
|
+
this.recordError(this.instance.dstport.getPath(), 'Minimum value is 0');
|
|
52
|
+
dstport = 0;
|
|
53
|
+
}
|
|
54
|
+
this.instance.dstport.setValue(dstport);
|
|
55
|
+
this.writeBytes(2, (0, NumberToBuffer_1.UInt16ToBuffer)(dstport));
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
length: {
|
|
59
|
+
type: 'integer',
|
|
60
|
+
label: 'Length',
|
|
61
|
+
minimum: 0,
|
|
62
|
+
maximum: 65535,
|
|
63
|
+
decode: () => {
|
|
64
|
+
this.instance.length.setValue((0, BufferToNumber_1.BufferToUInt16)(this.readBytes(4, 2)));
|
|
65
|
+
},
|
|
66
|
+
encode: () => {
|
|
67
|
+
let length = this.instance.length.getValue(0);
|
|
68
|
+
if (length) {
|
|
69
|
+
this.instance.length.setValue(length);
|
|
70
|
+
this.writeBytes(4, (0, NumberToBuffer_1.UInt16ToBuffer)(length));
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
this.instance.length.setValue(length);
|
|
74
|
+
this.writeBytes(4, (0, NumberToBuffer_1.UInt16ToBuffer)(length));
|
|
75
|
+
this.addPostPacketEncodeHandler(() => {
|
|
76
|
+
let startCount = false;
|
|
77
|
+
let udpLength = 0;
|
|
78
|
+
this.codecModules.forEach((codecModule) => {
|
|
79
|
+
if (codecModule === this)
|
|
80
|
+
startCount = true;
|
|
81
|
+
if (startCount)
|
|
82
|
+
udpLength += codecModule.length;
|
|
83
|
+
});
|
|
84
|
+
this.instance.length.setValue(udpLength);
|
|
85
|
+
this.writeBytes(4, (0, NumberToBuffer_1.UInt16ToBuffer)(udpLength));
|
|
86
|
+
}, 1);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
},
|
|
90
|
+
checksum: {
|
|
91
|
+
type: 'integer',
|
|
92
|
+
label: 'Checksum',
|
|
93
|
+
minimum: 0,
|
|
94
|
+
maximum: 65535,
|
|
95
|
+
decode: () => {
|
|
96
|
+
this.instance.checksum.setValue((0, BufferToNumber_1.BufferToUInt16)(this.readBytes(6, 2)));
|
|
97
|
+
},
|
|
98
|
+
encode: () => {
|
|
99
|
+
const checksum = this.instance.checksum.getValue(0);
|
|
100
|
+
if (checksum) {
|
|
101
|
+
this.instance.checksum.setValue(checksum);
|
|
102
|
+
this.writeBytes(6, (0, NumberToBuffer_1.UInt16ToBuffer)(checksum));
|
|
103
|
+
}
|
|
104
|
+
else {
|
|
105
|
+
this.writeBytes(6, (0, NumberToBuffer_1.UInt16ToBuffer)(checksum));
|
|
106
|
+
this.instance.checksum.setValue(checksum);
|
|
107
|
+
this.addPostPacketEncodeHandler(() => {
|
|
108
|
+
let startCount = false;
|
|
109
|
+
let udpHeaderWithDataLength = 0;
|
|
110
|
+
this.codecModules.forEach((codecModule) => {
|
|
111
|
+
if (codecModule === this)
|
|
112
|
+
startCount = true;
|
|
113
|
+
if (startCount)
|
|
114
|
+
udpHeaderWithDataLength += codecModule.length;
|
|
115
|
+
});
|
|
116
|
+
const calcChecksum = this.calculateUDPChecksum(this.packet.subarray(this.startPos, this.startPos + udpHeaderWithDataLength));
|
|
117
|
+
this.instance.checksum.setValue(calcChecksum);
|
|
118
|
+
this.writeBytes(6, (0, NumberToBuffer_1.UInt16ToBuffer)(calcChecksum));
|
|
119
|
+
}, 2);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
this.id = 'udp';
|
|
126
|
+
this.name = 'User Datagram Protocol';
|
|
127
|
+
this.nickname = 'UDP';
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Calculate UDP Checksum
|
|
131
|
+
* @protected
|
|
132
|
+
* @param udpHeaderBuffer
|
|
133
|
+
*/
|
|
134
|
+
calculateUDPChecksum(udpHeaderBuffer) {
|
|
135
|
+
const udpHeaderLength = udpHeaderBuffer.length;
|
|
136
|
+
const ipVersion = this.prevCodecModule.instance.version.getValue();
|
|
137
|
+
let pseudoHeaderBuffer = Buffer.from([]);
|
|
138
|
+
const sourceIp = this.prevCodecModule.instance.sip.getValue();
|
|
139
|
+
const destinationIp = this.prevCodecModule.instance.dip.getValue();
|
|
140
|
+
if (ipVersion === 4) {
|
|
141
|
+
//4 Bytes
|
|
142
|
+
const sourceIPv4Buffer = Buffer.from(sourceIp.split('.').map((value) => parseInt(value)));
|
|
143
|
+
const destinationIPv4Buffer = Buffer.from(destinationIp.split('.').map((value) => parseInt(value)));
|
|
144
|
+
//IPv4 Pseudo header
|
|
145
|
+
pseudoHeaderBuffer = Buffer.concat([
|
|
146
|
+
sourceIPv4Buffer,
|
|
147
|
+
destinationIPv4Buffer,
|
|
148
|
+
(0, NumberToBuffer_1.UInt8ToBuffer)(0), //Reserved field
|
|
149
|
+
(0, NumberToBuffer_1.UInt8ToBuffer)(17), //Protocol type (UDP = 17)
|
|
150
|
+
Buffer.from([(udpHeaderLength >> 8) & 0xFF]),
|
|
151
|
+
Buffer.from([udpHeaderLength & 0xFF])
|
|
152
|
+
]);
|
|
153
|
+
}
|
|
154
|
+
else if (ipVersion === 6) {
|
|
155
|
+
//16 Bytes
|
|
156
|
+
const sourceIPv6Buffer = (0, IPToBuffer_1.IPv6ToBuffer)(sourceIp);
|
|
157
|
+
const destinationIPv6Buffer = (0, IPToBuffer_1.IPv6ToBuffer)(destinationIp);
|
|
158
|
+
//IPv6 Pseudo header
|
|
159
|
+
pseudoHeaderBuffer = Buffer.concat([
|
|
160
|
+
sourceIPv6Buffer,
|
|
161
|
+
destinationIPv6Buffer,
|
|
162
|
+
(0, NumberToBuffer_1.UInt8ToBuffer)(0), //Reserved field
|
|
163
|
+
(0, NumberToBuffer_1.UInt8ToBuffer)(0), //Reserved field
|
|
164
|
+
(0, NumberToBuffer_1.UInt8ToBuffer)(0), //Reserved field
|
|
165
|
+
(0, NumberToBuffer_1.UInt8ToBuffer)(17), //Protocol type (UDP = 17)
|
|
166
|
+
Buffer.from([(udpHeaderLength >> 8) & 0xFF]),
|
|
167
|
+
Buffer.from([udpHeaderLength & 0xFF])
|
|
168
|
+
]);
|
|
169
|
+
}
|
|
170
|
+
else {
|
|
171
|
+
return 0;
|
|
172
|
+
}
|
|
173
|
+
let dataBuffer = Buffer.concat([pseudoHeaderBuffer, udpHeaderBuffer]);
|
|
174
|
+
if (dataBuffer.length % 2)
|
|
175
|
+
dataBuffer = Buffer.concat([dataBuffer, Buffer.from('00', 'hex')]);
|
|
176
|
+
const data = Uint8Array.from(dataBuffer);
|
|
177
|
+
let sum = 0;
|
|
178
|
+
for (let i = 0; i < data.length; i += 2)
|
|
179
|
+
sum += (data[i] << 8) + (data[i + 1] || 0);
|
|
180
|
+
while (sum > 0xFFFF)
|
|
181
|
+
sum = (sum & 0xFFFF) + (sum >>> 16);
|
|
182
|
+
return (~sum) & 0xFFFF;
|
|
183
|
+
}
|
|
184
|
+
match() {
|
|
185
|
+
if (!this.prevCodecModule)
|
|
186
|
+
return false;
|
|
187
|
+
if (this.prevCodecModule.instance.protocol.getValue() === 0x11)
|
|
188
|
+
return true;
|
|
189
|
+
return false;
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
exports.UDP = UDP;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ProtocolJSONSchema } from '../../schema/ProtocolJSONSchema';
|
|
2
|
+
import { BaseHeader } from '../abstracts/BaseHeader';
|
|
3
|
+
export declare class VLAN_802dot1Q extends BaseHeader {
|
|
4
|
+
SCHEMA: ProtocolJSONSchema;
|
|
5
|
+
readonly id: string;
|
|
6
|
+
readonly name: string;
|
|
7
|
+
readonly nickname: string;
|
|
8
|
+
match(): boolean;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=VLAN_802dot1Q.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"VLAN_802dot1Q.d.ts","sourceRoot":"","sources":["../../../../src/lib/codec/headers/VLAN_802dot1Q.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,kBAAkB,EAAC,MAAM,iCAAiC,CAAA;AAClE,OAAO,EAAC,UAAU,EAAC,MAAM,yBAAyB,CAAA;AAIlD,qBAAa,aAAc,SAAQ,UAAU;IAClC,MAAM,EAAE,kBAAkB,CAwDhC;IAED,SAAgB,EAAE,EAAE,MAAM,CAAS;IAEnC,SAAgB,IAAI,EAAE,MAAM,CAAuB;IAEnD,SAAgB,QAAQ,EAAE,MAAM,CAAS;IAElC,KAAK,IAAI,OAAO;CAI1B"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.VLAN_802dot1Q = void 0;
|
|
4
|
+
const BaseHeader_1 = require("../abstracts/BaseHeader");
|
|
5
|
+
const NumberToHex_1 = require("../../helper/NumberToHex");
|
|
6
|
+
const BufferToHex_1 = require("../../helper/BufferToHex");
|
|
7
|
+
class VLAN_802dot1Q extends BaseHeader_1.BaseHeader {
|
|
8
|
+
constructor() {
|
|
9
|
+
super(...arguments);
|
|
10
|
+
this.SCHEMA = {
|
|
11
|
+
type: 'object',
|
|
12
|
+
properties: {
|
|
13
|
+
priority: {
|
|
14
|
+
type: 'integer',
|
|
15
|
+
minimum: 0,
|
|
16
|
+
maximum: 7,
|
|
17
|
+
default: 0,
|
|
18
|
+
decode: () => {
|
|
19
|
+
this.instance.priority.setValue(this.readBits(0, 2, 0, 3));
|
|
20
|
+
},
|
|
21
|
+
encode: () => {
|
|
22
|
+
const priorityValue = this.instance.priority.getValue(0);
|
|
23
|
+
this.instance.priority.setValue(priorityValue);
|
|
24
|
+
this.writeBits(0, 2, 0, 3, priorityValue);
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
dei: {
|
|
28
|
+
type: 'boolean',
|
|
29
|
+
decode: () => {
|
|
30
|
+
this.instance.dei.setValue(!!this.readBits(0, 2, 3, 1));
|
|
31
|
+
},
|
|
32
|
+
encode: () => {
|
|
33
|
+
const dei = !!this.instance.dei.getValue();
|
|
34
|
+
this.instance.dei.setValue(dei);
|
|
35
|
+
this.writeBits(0, 2, 3, 1, dei ? 1 : 0);
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
id: {
|
|
39
|
+
type: 'integer',
|
|
40
|
+
minimum: 0,
|
|
41
|
+
maximum: 4095,
|
|
42
|
+
decode: () => {
|
|
43
|
+
this.instance.id.setValue(this.readBits(0, 2, 4, 12));
|
|
44
|
+
},
|
|
45
|
+
encode: () => {
|
|
46
|
+
const vlanId = this.instance.id.getValue(0);
|
|
47
|
+
this.instance.id.setValue(vlanId);
|
|
48
|
+
this.writeBits(0, 2, 4, 12, vlanId);
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
etherType: {
|
|
52
|
+
type: 'string',
|
|
53
|
+
minLength: 4,
|
|
54
|
+
maxLength: 4,
|
|
55
|
+
decode: () => {
|
|
56
|
+
this.instance.etherType.setValue((0, BufferToHex_1.BufferToHex)(this.readBytes(2, 2)));
|
|
57
|
+
},
|
|
58
|
+
encode: () => {
|
|
59
|
+
let etherType = this.instance.etherType.getValue((0, NumberToHex_1.UInt16ToHex)(0x0000), (nodePath) => this.recordError(nodePath, 'Not Found'));
|
|
60
|
+
const typeBuffer = Buffer.from(etherType, 'hex');
|
|
61
|
+
if (typeBuffer.length < 2)
|
|
62
|
+
typeBuffer.fill(0, 0, 1);
|
|
63
|
+
this.writeBytes(2, typeBuffer.subarray(0, 2));
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
this.id = 'vlan';
|
|
69
|
+
this.name = '802.1Q Virtual LAN';
|
|
70
|
+
this.nickname = 'VLAN';
|
|
71
|
+
}
|
|
72
|
+
match() {
|
|
73
|
+
if (!this.prevCodecModule)
|
|
74
|
+
return false;
|
|
75
|
+
return this.prevCodecModule.instance.etherType.getValue() === (0, NumberToHex_1.UInt16ToHex)(0x8100);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
exports.VLAN_802dot1Q = VLAN_802dot1Q;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export declare class FlexibleObject {
|
|
2
|
+
#private;
|
|
3
|
+
constructor(data?: object, parent?: FlexibleObject, paths?: string[]);
|
|
4
|
+
/**
|
|
5
|
+
* Set object node value
|
|
6
|
+
* @param value
|
|
7
|
+
*/
|
|
8
|
+
setValue(value: any): void;
|
|
9
|
+
/**
|
|
10
|
+
* Get object node value
|
|
11
|
+
* @param defaultValue
|
|
12
|
+
* @param onUndefinedCallback
|
|
13
|
+
* @param getPathIndex
|
|
14
|
+
*/
|
|
15
|
+
getValue<T = any>(defaultValue?: T, onUndefinedCallback?: (nodePath: string) => void, getPathIndex?: number): T;
|
|
16
|
+
/**
|
|
17
|
+
* Is current object's value undefined
|
|
18
|
+
*/
|
|
19
|
+
isUndefined(): boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Get current object path
|
|
22
|
+
* The index parameter indicates array item if this object is an array
|
|
23
|
+
* @param index
|
|
24
|
+
*/
|
|
25
|
+
getPath(index?: number): string;
|
|
26
|
+
[p: string]: FlexibleObject;
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=FlexibleObject.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FlexibleObject.d.ts","sourceRoot":"","sources":["../../../../src/lib/codec/lib/FlexibleObject.ts"],"names":[],"mappings":"AAAA,qBAAa,cAAc;;gBAgBX,IAAI,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,cAAc,EAAE,KAAK,CAAC,EAAE,MAAM,EAAE;IAiBpE;;;OAGG;IAEI,QAAQ,CAAC,KAAK,EAAE,GAAG,GAAG,IAAI;IAYjC;;;;;OAKG;IAEI,QAAQ,CAAC,CAAC,GAAG,GAAG,EAAE,YAAY,CAAC,EAAE,CAAC,EAAE,mBAAmB,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,EAAE,YAAY,CAAC,EAAE,MAAM,GAAG,CAAC;IAqBtH;;OAEG;IAEI,WAAW,IAAI,OAAO;IAI7B;;;;OAIG;IAEI,OAAO,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM;IAMtC,CAAC,CAAC,EAAE,MAAM,GAAG,cAAc,CAAA;CAC9B"}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FlexibleObject = void 0;
|
|
4
|
+
class FlexibleObject {
|
|
5
|
+
#parent;
|
|
6
|
+
#paths;
|
|
7
|
+
#data;
|
|
8
|
+
#undefined = true;
|
|
9
|
+
#markFlexibleObjectDefined() {
|
|
10
|
+
if (!this.#undefined)
|
|
11
|
+
return;
|
|
12
|
+
this.#undefined = false;
|
|
13
|
+
if (this.#parent)
|
|
14
|
+
this.#parent.#markFlexibleObjectDefined();
|
|
15
|
+
}
|
|
16
|
+
constructor(data, parent, paths) {
|
|
17
|
+
this.#parent = parent;
|
|
18
|
+
this.#data = {};
|
|
19
|
+
this.#paths = paths ? paths : [];
|
|
20
|
+
if (data !== undefined)
|
|
21
|
+
this.setValue(data);
|
|
22
|
+
return new Proxy(this, {
|
|
23
|
+
get: (target, p) => {
|
|
24
|
+
if (this[p])
|
|
25
|
+
return (...args) => this[p](...args);
|
|
26
|
+
if (target.#data[p] === undefined)
|
|
27
|
+
target.#data[p] = new FlexibleObject(target.#data[p], this, [...this.#paths, p]);
|
|
28
|
+
return target.#data[p];
|
|
29
|
+
},
|
|
30
|
+
set: (target, p, newValue) => {
|
|
31
|
+
return false;
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Set object node value
|
|
37
|
+
* @param value
|
|
38
|
+
*/
|
|
39
|
+
// @ts-ignore
|
|
40
|
+
setValue(value) {
|
|
41
|
+
if (typeof value === 'object' && !Array.isArray(value)) {
|
|
42
|
+
Object.keys(value).forEach(key => {
|
|
43
|
+
this.#data[key] = new FlexibleObject(this.#data[key], this, [...this.#paths, key]);
|
|
44
|
+
this.#data[key].setValue(value[key]);
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
this.#data = value;
|
|
49
|
+
}
|
|
50
|
+
this.#markFlexibleObjectDefined();
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Get object node value
|
|
54
|
+
* @param defaultValue
|
|
55
|
+
* @param onUndefinedCallback
|
|
56
|
+
* @param getPathIndex
|
|
57
|
+
*/
|
|
58
|
+
// @ts-ignore
|
|
59
|
+
getValue(defaultValue, onUndefinedCallback, getPathIndex) {
|
|
60
|
+
if (this.#undefined) {
|
|
61
|
+
if (onUndefinedCallback)
|
|
62
|
+
onUndefinedCallback(this.getPath(getPathIndex));
|
|
63
|
+
if (defaultValue !== undefined) {
|
|
64
|
+
return defaultValue;
|
|
65
|
+
}
|
|
66
|
+
return undefined;
|
|
67
|
+
}
|
|
68
|
+
if (typeof this.#data === 'object' && !Array.isArray(this.#data)) {
|
|
69
|
+
const dumpObject = {};
|
|
70
|
+
Object.keys(this.#data).forEach((key) => {
|
|
71
|
+
const dumpResult = this.#data[key].getValue();
|
|
72
|
+
if (dumpResult === undefined)
|
|
73
|
+
return;
|
|
74
|
+
dumpObject[key] = dumpResult;
|
|
75
|
+
});
|
|
76
|
+
return dumpObject;
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
return this.#undefined ? undefined : this.#data;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Is current object's value undefined
|
|
84
|
+
*/
|
|
85
|
+
// @ts-ignore
|
|
86
|
+
isUndefined() {
|
|
87
|
+
return this.#undefined;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Get current object path
|
|
91
|
+
* The index parameter indicates array item if this object is an array
|
|
92
|
+
* @param index
|
|
93
|
+
*/
|
|
94
|
+
// @ts-ignore
|
|
95
|
+
getPath(index) {
|
|
96
|
+
const objPath = this.#paths.join('.');
|
|
97
|
+
if (index === undefined)
|
|
98
|
+
return objPath;
|
|
99
|
+
return `${objPath}[${index}]`;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
exports.FlexibleObject = FlexibleObject;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { PostHandlerItem } from '../types/PostHandlerItem';
|
|
2
|
+
/**
|
|
3
|
+
* Process packet post encode handlers
|
|
4
|
+
* @param handlerItemsArray
|
|
5
|
+
* @constructor
|
|
6
|
+
*/
|
|
7
|
+
export declare function ProcessPacketEncodePostHandlers(handlerItemsArray: PostHandlerItem[][]): PostHandlerItem[];
|
|
8
|
+
/**
|
|
9
|
+
* Process packet post decode handlers
|
|
10
|
+
* @param handlerItemsArray
|
|
11
|
+
* @constructor
|
|
12
|
+
*/
|
|
13
|
+
export declare function ProcessPacketDecodePostHandlers(handlerItemsArray: PostHandlerItem[][]): PostHandlerItem[];
|
|
14
|
+
//# sourceMappingURL=ProcessPacketPostHandlers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ProcessPacketPostHandlers.d.ts","sourceRoot":"","sources":["../../../../src/lib/codec/lib/ProcessPacketPostHandlers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,eAAe,EAAC,MAAM,0BAA0B,CAAA;AAoCxD;;;;GAIG;AACH,wBAAgB,+BAA+B,CAAC,iBAAiB,EAAE,eAAe,EAAE,EAAE,GAAG,eAAe,EAAE,CAEzG;AAED;;;;GAIG;AACH,wBAAgB,+BAA+B,CAAC,iBAAiB,EAAE,eAAe,EAAE,EAAE,GAAG,eAAe,EAAE,CAEzG"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ProcessPacketEncodePostHandlers = ProcessPacketEncodePostHandlers;
|
|
4
|
+
exports.ProcessPacketDecodePostHandlers = ProcessPacketDecodePostHandlers;
|
|
5
|
+
const SortPostHandlers_1 = require("./SortPostHandlers");
|
|
6
|
+
/**
|
|
7
|
+
* Process packet post handlers
|
|
8
|
+
* @param handlerItemsArray
|
|
9
|
+
* @param asc
|
|
10
|
+
*/
|
|
11
|
+
function processPacketPostHandlers(handlerItemsArray, asc) {
|
|
12
|
+
let indexFactor = 10;
|
|
13
|
+
return handlerItemsArray
|
|
14
|
+
.map((handlerItems) => {
|
|
15
|
+
return (0, SortPostHandlers_1.SortPostHandlers)(handlerItems).map((handlerItem, index) => {
|
|
16
|
+
handlerItem.priority = index + 1;
|
|
17
|
+
let factor = 10;
|
|
18
|
+
let priority = handlerItem.priority;
|
|
19
|
+
while (priority > 1) {
|
|
20
|
+
priority /= 10;
|
|
21
|
+
factor *= 10;
|
|
22
|
+
}
|
|
23
|
+
indexFactor = indexFactor < factor ? factor : indexFactor;
|
|
24
|
+
return handlerItem;
|
|
25
|
+
});
|
|
26
|
+
})
|
|
27
|
+
.map((handlerItems, headerIndex) => {
|
|
28
|
+
const basePriority = (headerIndex + 1) * indexFactor;
|
|
29
|
+
const unsortedItems = handlerItems.map((handlerItem) => {
|
|
30
|
+
handlerItem.priority = basePriority + handlerItem.priority;
|
|
31
|
+
return handlerItem;
|
|
32
|
+
});
|
|
33
|
+
return asc ?
|
|
34
|
+
unsortedItems.sort((a, b) => a.priority - b.priority) :
|
|
35
|
+
unsortedItems.sort((a, b) => b.priority - a.priority);
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Process packet post encode handlers
|
|
40
|
+
* @param handlerItemsArray
|
|
41
|
+
* @constructor
|
|
42
|
+
*/
|
|
43
|
+
function ProcessPacketEncodePostHandlers(handlerItemsArray) {
|
|
44
|
+
return processPacketPostHandlers(handlerItemsArray, true).reverse().flat();
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Process packet post decode handlers
|
|
48
|
+
* @param handlerItemsArray
|
|
49
|
+
* @constructor
|
|
50
|
+
*/
|
|
51
|
+
function ProcessPacketDecodePostHandlers(handlerItemsArray) {
|
|
52
|
+
return processPacketPostHandlers(handlerItemsArray, true).flat();
|
|
53
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { PostHandlerItem } from '../types/PostHandlerItem';
|
|
2
|
+
/**
|
|
3
|
+
* Sort post handlers
|
|
4
|
+
* @param handlers
|
|
5
|
+
* @constructor
|
|
6
|
+
*/
|
|
7
|
+
export declare function SortPostHandlers(handlers: PostHandlerItem[]): PostHandlerItem[];
|
|
8
|
+
//# sourceMappingURL=SortPostHandlers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SortPostHandlers.d.ts","sourceRoot":"","sources":["../../../../src/lib/codec/lib/SortPostHandlers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,eAAe,EAAC,MAAM,0BAA0B,CAAA;AAExD;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,eAAe,EAAE,GAAG,eAAe,EAAE,CAE/E"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SortPostHandlers = SortPostHandlers;
|
|
4
|
+
/**
|
|
5
|
+
* Sort post handlers
|
|
6
|
+
* @param handlers
|
|
7
|
+
* @constructor
|
|
8
|
+
*/
|
|
9
|
+
function SortPostHandlers(handlers) {
|
|
10
|
+
return handlers.sort((a, b) => a.priority - b.priority);
|
|
11
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StringContentEncodingEnum.d.ts","sourceRoot":"","sources":["../../../../src/lib/codec/lib/StringContentEncodingEnum.ts"],"names":[],"mappings":"AAAA,oBAAY,yBAAyB;IACjC,MAAM,WAAW;IACjB,GAAG,QAAQ;IACX,IAAI,SAAS;IACb,IAAI,SAAS;IACb,GAAG,QAAQ;IACX,KAAK,UAAU;IACf,IAAI,SAAS;IACb,MAAM,WAAW;CACpB"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.StringContentEncodingEnum = void 0;
|
|
4
|
+
var StringContentEncodingEnum;
|
|
5
|
+
(function (StringContentEncodingEnum) {
|
|
6
|
+
StringContentEncodingEnum["BINARY"] = "binary";
|
|
7
|
+
StringContentEncodingEnum["HEX"] = "hex";
|
|
8
|
+
StringContentEncodingEnum["IPv4"] = "ipv4";
|
|
9
|
+
StringContentEncodingEnum["IPv6"] = "ipv6";
|
|
10
|
+
StringContentEncodingEnum["MAC"] = "mac";
|
|
11
|
+
StringContentEncodingEnum["ASCII"] = "ascii";
|
|
12
|
+
StringContentEncodingEnum["UTF8"] = "utf8";
|
|
13
|
+
StringContentEncodingEnum["BIGINT"] = "bigint";
|
|
14
|
+
})(StringContentEncodingEnum || (exports.StringContentEncodingEnum = StringContentEncodingEnum = {}));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CodecData.d.ts","sourceRoot":"","sources":["../../../../src/lib/codec/types/CodecData.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,eAAe,EAAC,MAAM,mBAAmB,CAAA;AAEjD,MAAM,MAAM,SAAS,GAAG;IACpB,MAAM,EAAE,MAAM,CAAA;IACd,QAAQ,EAAE,MAAM,CAAA;IAChB,YAAY,EAAE,eAAe,EAAE,EAAE,CAAA;CACpC,CAAA"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { HeaderTreeNode } from './HeaderTreeNode';
|
|
2
|
+
import { CodecErrorInfo } from './CodecErrorInfo';
|
|
3
|
+
export type CodecDecodeResult = {
|
|
4
|
+
id: string;
|
|
5
|
+
name: string;
|
|
6
|
+
nickname: string;
|
|
7
|
+
protocol: boolean;
|
|
8
|
+
errors: CodecErrorInfo[];
|
|
9
|
+
data: HeaderTreeNode;
|
|
10
|
+
};
|
|
11
|
+
//# sourceMappingURL=CodecDecodeResult.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CodecDecodeResult.d.ts","sourceRoot":"","sources":["../../../../src/lib/codec/types/CodecDecodeResult.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,cAAc,EAAC,MAAM,kBAAkB,CAAA;AAC/C,OAAO,EAAC,cAAc,EAAC,MAAM,kBAAkB,CAAA;AAE/C,MAAM,MAAM,iBAAiB,GAAG;IAC5B,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,MAAM,CAAA;IACZ,QAAQ,EAAE,MAAM,CAAA;IAChB,QAAQ,EAAE,OAAO,CAAA;IACjB,MAAM,EAAE,cAAc,EAAE,CAAA;IACxB,IAAI,EAAE,cAAc,CAAA;CACvB,CAAA"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { CodecDecodeResult } from './CodecDecodeResult';
|
|
2
|
+
import { CodecErrorInfo } from './CodecErrorInfo';
|
|
3
|
+
export type CodecEncodeInput = {
|
|
4
|
+
name?: string;
|
|
5
|
+
nickname?: string;
|
|
6
|
+
protocol?: boolean;
|
|
7
|
+
errors?: CodecErrorInfo[];
|
|
8
|
+
} & CodecDecodeResult;
|
|
9
|
+
//# sourceMappingURL=CodecEncodeInput.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CodecEncodeInput.d.ts","sourceRoot":"","sources":["../../../../src/lib/codec/types/CodecEncodeInput.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,iBAAiB,EAAC,MAAM,qBAAqB,CAAA;AACrD,OAAO,EAAC,cAAc,EAAC,MAAM,kBAAkB,CAAA;AAE/C,MAAM,MAAM,gBAAgB,GAAG;IAC3B,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,MAAM,CAAC,EAAE,cAAc,EAAE,CAAA;CAC5B,GAAG,iBAAiB,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CodecEncodeResult.d.ts","sourceRoot":"","sources":["../../../../src/lib/codec/types/CodecEncodeResult.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,cAAc,EAAC,MAAM,kBAAkB,CAAA;AAE/C,MAAM,MAAM,iBAAiB,GAAG;IAC5B,MAAM,EAAE,MAAM,CAAA;IACd,MAAM,EAAE,cAAc,EAAE,CAAA;CAC3B,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CodecErrorInfo.d.ts","sourceRoot":"","sources":["../../../../src/lib/codec/types/CodecErrorInfo.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,cAAc,GAAG;IACzB,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,MAAM,CAAA;CAClB,CAAA"}
|