netkitty 0.0.1
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/.eslintrc.json +53 -0
- package/.idea/codeStyles/Project.xml +18 -0
- package/.idea/codeStyles/codeStyleConfig.xml +5 -0
- package/.idea/inspectionProfiles/Project_Default.xml +10 -0
- package/.idea/modules.xml +8 -0
- package/.idea/netkitty.iml +13 -0
- package/.idea/vcs.xml +6 -0
- package/LICENSE +21 -0
- package/README.md +2 -0
- package/binding.gyp +5 -0
- package/build/NetKitty.d.ts +31 -0
- package/build/NetKitty.d.ts.map +1 -0
- package/build/NetKitty.js +33 -0
- package/build/errors/ActionNotFoundError.d.ts +5 -0
- package/build/errors/ActionNotFoundError.d.ts.map +1 -0
- package/build/errors/ActionNotFoundError.js +12 -0
- package/build/errors/CodecSchemaValidateError.d.ts +5 -0
- package/build/errors/CodecSchemaValidateError.d.ts.map +1 -0
- package/build/errors/CodecSchemaValidateError.js +12 -0
- package/build/errors/DeviceNotFoundError.d.ts +5 -0
- package/build/errors/DeviceNotFoundError.d.ts.map +1 -0
- package/build/errors/DeviceNotFoundError.js +12 -0
- package/build/errors/NoAvailableCodecError.d.ts +5 -0
- package/build/errors/NoAvailableCodecError.d.ts.map +1 -0
- package/build/errors/NoAvailableCodecError.js +12 -0
- package/build/errors/NpcapLoadError.d.ts +5 -0
- package/build/errors/NpcapLoadError.d.ts.map +1 -0
- package/build/errors/NpcapLoadError.js +12 -0
- package/build/errors/SocketDownError.d.ts +5 -0
- package/build/errors/SocketDownError.d.ts.map +1 -0
- package/build/errors/SocketDownError.js +12 -0
- package/build/errors/UnknownPipeMessageTypeError.d.ts +5 -0
- package/build/errors/UnknownPipeMessageTypeError.d.ts.map +1 -0
- package/build/errors/UnknownPipeMessageTypeError.js +12 -0
- package/build/errors/common/ErrorCode.d.ts +31 -0
- package/build/errors/common/ErrorCode.d.ts.map +1 -0
- package/build/errors/common/ErrorCode.js +33 -0
- package/build/lib/GeneratePipeAddress.d.ts +7 -0
- package/build/lib/GeneratePipeAddress.d.ts.map +1 -0
- package/build/lib/GeneratePipeAddress.js +23 -0
- package/build/lib/GetBinding.d.ts +2 -0
- package/build/lib/GetBinding.d.ts.map +1 -0
- package/build/lib/GetBinding.js +6 -0
- package/build/lib/GetCaptureTemporaryDirectory.d.ts +7 -0
- package/build/lib/GetCaptureTemporaryDirectory.d.ts.map +1 -0
- package/build/lib/GetCaptureTemporaryDirectory.js +15 -0
- package/build/lib/GetDeviceCaptureTemporaryFilename.d.ts +8 -0
- package/build/lib/GetDeviceCaptureTemporaryFilename.d.ts.map +1 -0
- package/build/lib/GetDeviceCaptureTemporaryFilename.js +18 -0
- package/build/lib/codec/Codec.d.ts +33 -0
- package/build/lib/codec/Codec.d.ts.map +1 -0
- package/build/lib/codec/Codec.js +166 -0
- package/build/lib/codec/abstracts/BaseHeader.d.ts +204 -0
- package/build/lib/codec/abstracts/BaseHeader.d.ts.map +1 -0
- package/build/lib/codec/abstracts/BaseHeader.js +339 -0
- package/build/lib/codec/headers/ARP.d.ts +9 -0
- package/build/lib/codec/headers/ARP.d.ts.map +1 -0
- package/build/lib/codec/headers/ARP.js +223 -0
- package/build/lib/codec/headers/EthernetII.d.ts +9 -0
- package/build/lib/codec/headers/EthernetII.d.ts.map +1 -0
- package/build/lib/codec/headers/EthernetII.js +80 -0
- package/build/lib/codec/headers/Goose.d.ts +12 -0
- package/build/lib/codec/headers/Goose.d.ts.map +1 -0
- package/build/lib/codec/headers/Goose.js +701 -0
- package/build/lib/codec/headers/IEC61850SampledValues.d.ts +12 -0
- package/build/lib/codec/headers/IEC61850SampledValues.d.ts.map +1 -0
- package/build/lib/codec/headers/IEC61850SampledValues.js +369 -0
- package/build/lib/codec/headers/IPv4.d.ts +15 -0
- package/build/lib/codec/headers/IPv4.d.ts.map +1 -0
- package/build/lib/codec/headers/IPv4.js +338 -0
- package/build/lib/codec/headers/RawData.d.ts +9 -0
- package/build/lib/codec/headers/RawData.d.ts.map +1 -0
- package/build/lib/codec/headers/RawData.js +34 -0
- package/build/lib/codec/headers/TCP.d.ts +15 -0
- package/build/lib/codec/headers/TCP.d.ts.map +1 -0
- package/build/lib/codec/headers/TCP.js +897 -0
- package/build/lib/codec/headers/UDP.d.ts +15 -0
- package/build/lib/codec/headers/UDP.d.ts.map +1 -0
- package/build/lib/codec/headers/UDP.js +191 -0
- package/build/lib/codec/headers/VLAN_802dot1Q.d.ts +9 -0
- package/build/lib/codec/headers/VLAN_802dot1Q.d.ts.map +1 -0
- package/build/lib/codec/headers/VLAN_802dot1Q.js +77 -0
- package/build/lib/codec/lib/BufferToHex.d.ts +2 -0
- package/build/lib/codec/lib/BufferToHex.d.ts.map +1 -0
- package/build/lib/codec/lib/BufferToHex.js +6 -0
- package/build/lib/codec/lib/BufferToIP.d.ts +13 -0
- package/build/lib/codec/lib/BufferToIP.d.ts.map +1 -0
- package/build/lib/codec/lib/BufferToIP.js +21 -0
- package/build/lib/codec/lib/BufferToNumber.d.ts +10 -0
- package/build/lib/codec/lib/BufferToNumber.d.ts.map +1 -0
- package/build/lib/codec/lib/BufferToNumber.js +22 -0
- package/build/lib/codec/lib/FixHexString.d.ts +7 -0
- package/build/lib/codec/lib/FixHexString.d.ts.map +1 -0
- package/build/lib/codec/lib/FixHexString.js +11 -0
- package/build/lib/codec/lib/FlexibleObject.d.ts +28 -0
- package/build/lib/codec/lib/FlexibleObject.d.ts.map +1 -0
- package/build/lib/codec/lib/FlexibleObject.js +102 -0
- package/build/lib/codec/lib/HexToNumber.d.ts +10 -0
- package/build/lib/codec/lib/HexToNumber.d.ts.map +1 -0
- package/build/lib/codec/lib/HexToNumber.js +39 -0
- package/build/lib/codec/lib/IPToBuffer.d.ts +13 -0
- package/build/lib/codec/lib/IPToBuffer.d.ts.map +1 -0
- package/build/lib/codec/lib/IPToBuffer.js +28 -0
- package/build/lib/codec/lib/NumberToBERBuffer.d.ts +9 -0
- package/build/lib/codec/lib/NumberToBERBuffer.d.ts.map +1 -0
- package/build/lib/codec/lib/NumberToBERBuffer.js +20 -0
- package/build/lib/codec/lib/NumberToBERHex.d.ts +9 -0
- package/build/lib/codec/lib/NumberToBERHex.d.ts.map +1 -0
- package/build/lib/codec/lib/NumberToBERHex.js +23 -0
- package/build/lib/codec/lib/NumberToBuffer.d.ts +10 -0
- package/build/lib/codec/lib/NumberToBuffer.d.ts.map +1 -0
- package/build/lib/codec/lib/NumberToBuffer.js +22 -0
- package/build/lib/codec/lib/NumberToHex.d.ts +10 -0
- package/build/lib/codec/lib/NumberToHex.d.ts.map +1 -0
- package/build/lib/codec/lib/NumberToHex.js +26 -0
- package/build/lib/codec/lib/ProcessPacketPostHandlers.d.ts +14 -0
- package/build/lib/codec/lib/ProcessPacketPostHandlers.d.ts.map +1 -0
- package/build/lib/codec/lib/ProcessPacketPostHandlers.js +53 -0
- package/build/lib/codec/lib/SortPostHandlers.d.ts +8 -0
- package/build/lib/codec/lib/SortPostHandlers.d.ts.map +1 -0
- package/build/lib/codec/lib/SortPostHandlers.js +11 -0
- package/build/lib/codec/lib/StringContentEncodingEnum.d.ts +8 -0
- package/build/lib/codec/lib/StringContentEncodingEnum.d.ts.map +1 -0
- package/build/lib/codec/lib/StringContentEncodingEnum.js +11 -0
- package/build/lib/codec/types/CodecData.d.ts +7 -0
- package/build/lib/codec/types/CodecData.d.ts.map +1 -0
- package/build/lib/codec/types/CodecData.js +2 -0
- package/build/lib/codec/types/CodecDecodeResult.d.ts +9 -0
- package/build/lib/codec/types/CodecDecodeResult.d.ts.map +1 -0
- package/build/lib/codec/types/CodecDecodeResult.js +2 -0
- package/build/lib/codec/types/CodecEncodeInput.d.ts +5 -0
- package/build/lib/codec/types/CodecEncodeInput.d.ts.map +1 -0
- package/build/lib/codec/types/CodecEncodeInput.js +2 -0
- package/build/lib/codec/types/CodecEncodeResult.d.ts +6 -0
- package/build/lib/codec/types/CodecEncodeResult.d.ts.map +1 -0
- package/build/lib/codec/types/CodecEncodeResult.js +2 -0
- package/build/lib/codec/types/CodecErrorInfo.d.ts +6 -0
- package/build/lib/codec/types/CodecErrorInfo.d.ts.map +1 -0
- package/build/lib/codec/types/CodecErrorInfo.js +2 -0
- package/build/lib/codec/types/CodecModule.d.ts +3 -0
- package/build/lib/codec/types/CodecModule.d.ts.map +1 -0
- package/build/lib/codec/types/CodecModule.js +2 -0
- package/build/lib/codec/types/CodecModuleConstructor.d.ts +3 -0
- package/build/lib/codec/types/CodecModuleConstructor.d.ts.map +1 -0
- package/build/lib/codec/types/CodecModuleConstructor.js +2 -0
- package/build/lib/codec/types/CodecSchema.d.ts +7 -0
- package/build/lib/codec/types/CodecSchema.d.ts.map +1 -0
- package/build/lib/codec/types/CodecSchema.js +2 -0
- package/build/lib/codec/types/HeaderTreeNode.d.ts +5 -0
- package/build/lib/codec/types/HeaderTreeNode.d.ts.map +1 -0
- package/build/lib/codec/types/HeaderTreeNode.js +2 -0
- package/build/lib/codec/types/PostHandlerItem.d.ts +5 -0
- package/build/lib/codec/types/PostHandlerItem.d.ts.map +1 -0
- package/build/lib/codec/types/PostHandlerItem.js +2 -0
- package/build/lib/nodepcap/Capture.d.ts +75 -0
- package/build/lib/nodepcap/Capture.d.ts.map +1 -0
- package/build/lib/nodepcap/Capture.js +309 -0
- package/build/lib/nodepcap/GetNetworkInterfaces.d.ts +7 -0
- package/build/lib/nodepcap/GetNetworkInterfaces.d.ts.map +1 -0
- package/build/lib/nodepcap/GetNetworkInterfaces.js +22 -0
- package/build/lib/nodepcap/interfaces/IBindingCapture.d.ts +16 -0
- package/build/lib/nodepcap/interfaces/IBindingCapture.d.ts.map +1 -0
- package/build/lib/nodepcap/interfaces/IBindingCapture.js +2 -0
- package/build/lib/nodepcap/interfaces/IBindingCaptureOptions.d.ts +5 -0
- package/build/lib/nodepcap/interfaces/IBindingCaptureOptions.d.ts.map +1 -0
- package/build/lib/nodepcap/interfaces/IBindingCaptureOptions.js +2 -0
- package/build/lib/nodepcap/interfaces/ICaptureOptions.d.ts +19 -0
- package/build/lib/nodepcap/interfaces/ICaptureOptions.d.ts.map +1 -0
- package/build/lib/nodepcap/interfaces/ICaptureOptions.js +2 -0
- package/build/lib/nodepcap/interfaces/INetworkInterface.d.ts +5 -0
- package/build/lib/nodepcap/interfaces/INetworkInterface.d.ts.map +1 -0
- package/build/lib/nodepcap/interfaces/INetworkInterface.js +2 -0
- package/build/lib/nodepcap/lib/BindingCapture.d.ts +15 -0
- package/build/lib/nodepcap/lib/BindingCapture.d.ts.map +1 -0
- package/build/lib/nodepcap/lib/BindingCapture.js +35 -0
- package/build/lib/nodepcap/lib/GetNodePcapBinding.d.ts +2 -0
- package/build/lib/nodepcap/lib/GetNodePcapBinding.d.ts.map +1 -0
- package/build/lib/nodepcap/lib/GetNodePcapBinding.js +55 -0
- package/build/lib/nodepcap/lib/GetNodePcapBindingCapture.d.ts +3 -0
- package/build/lib/nodepcap/lib/GetNodePcapBindingCapture.d.ts.map +1 -0
- package/build/lib/nodepcap/lib/GetNodePcapBindingCapture.js +18 -0
- package/build/lib/nodepcap/workers/CaptureWorker.d.ts +2 -0
- package/build/lib/nodepcap/workers/CaptureWorker.d.ts.map +1 -0
- package/build/lib/nodepcap/workers/CaptureWorker.js +25 -0
- package/build/lib/pcap/PCAPGenerator.d.ts +34 -0
- package/build/lib/pcap/PCAPGenerator.d.ts.map +1 -0
- package/build/lib/pcap/PCAPGenerator.js +95 -0
- package/build/lib/pcap/PcapParser.d.ts +27 -0
- package/build/lib/pcap/PcapParser.d.ts.map +1 -0
- package/build/lib/pcap/PcapParser.js +149 -0
- package/build/lib/pcap/PcapReader.d.ts +87 -0
- package/build/lib/pcap/PcapReader.d.ts.map +1 -0
- package/build/lib/pcap/PcapReader.js +207 -0
- package/build/lib/pcap/PcapWriter.d.ts +29 -0
- package/build/lib/pcap/PcapWriter.d.ts.map +1 -0
- package/build/lib/pcap/PcapWriter.js +80 -0
- package/build/lib/pcap/interfaces/IPcapPacketInfo.d.ts +13 -0
- package/build/lib/pcap/interfaces/IPcapPacketInfo.d.ts.map +1 -0
- package/build/lib/pcap/interfaces/IPcapPacketInfo.js +2 -0
- package/build/lib/pipe/PipeClient.d.ts +35 -0
- package/build/lib/pipe/PipeClient.d.ts.map +1 -0
- package/build/lib/pipe/PipeClient.js +71 -0
- package/build/lib/pipe/PipeClientSocket.d.ts +39 -0
- package/build/lib/pipe/PipeClientSocket.d.ts.map +1 -0
- package/build/lib/pipe/PipeClientSocket.js +82 -0
- package/build/lib/pipe/PipeMessage.d.ts +27 -0
- package/build/lib/pipe/PipeMessage.d.ts.map +1 -0
- package/build/lib/pipe/PipeMessage.js +61 -0
- package/build/lib/pipe/PipeMessageHandler.d.ts +16 -0
- package/build/lib/pipe/PipeMessageHandler.d.ts.map +1 -0
- package/build/lib/pipe/PipeMessageHandler.js +95 -0
- package/build/lib/pipe/PipeServer.d.ts +25 -0
- package/build/lib/pipe/PipeServer.d.ts.map +1 -0
- package/build/lib/pipe/PipeServer.js +59 -0
- package/build/lib/schema/ProtocolFieldJSONSchema.d.ts +35 -0
- package/build/lib/schema/ProtocolFieldJSONSchema.d.ts.map +1 -0
- package/build/lib/schema/ProtocolFieldJSONSchema.js +2 -0
- package/build/lib/schema/ProtocolFieldJSONSchemaDefinition.d.ts +3 -0
- package/build/lib/schema/ProtocolFieldJSONSchemaDefinition.d.ts.map +1 -0
- package/build/lib/schema/ProtocolFieldJSONSchemaDefinition.js +2 -0
- package/build/lib/schema/ProtocolJSONSchema.d.ts +32 -0
- package/build/lib/schema/ProtocolJSONSchema.d.ts.map +1 -0
- package/build/lib/schema/ProtocolJSONSchema.js +2 -0
- package/build/tests/Test.spec.d.ts +2 -0
- package/build/tests/Test.spec.d.ts.map +1 -0
- package/build/tests/Test.spec.js +25 -0
- package/build/tests/units/CaptureTest.spec.d.ts +2 -0
- package/build/tests/units/CaptureTest.spec.d.ts.map +1 -0
- package/build/tests/units/CaptureTest.spec.js +31 -0
- package/build/tests/units/Codec.spec.d.ts +2 -0
- package/build/tests/units/Codec.spec.d.ts.map +1 -0
- package/build/tests/units/Codec.spec.js +70 -0
- package/cpp/nodepcap/deps/include/Packet32.h +429 -0
- package/cpp/nodepcap/deps/include/pcap/bluetooth.h +56 -0
- package/cpp/nodepcap/deps/include/pcap/bpf.h +292 -0
- package/cpp/nodepcap/deps/include/pcap/can_socketcan.h +56 -0
- package/cpp/nodepcap/deps/include/pcap/compiler-tests.h +163 -0
- package/cpp/nodepcap/deps/include/pcap/dlt.h +1514 -0
- package/cpp/nodepcap/deps/include/pcap/funcattrs.h +325 -0
- package/cpp/nodepcap/deps/include/pcap/ipnet.h +43 -0
- package/cpp/nodepcap/deps/include/pcap/namedb.h +84 -0
- package/cpp/nodepcap/deps/include/pcap/nflog.h +94 -0
- package/cpp/nodepcap/deps/include/pcap/pcap-inttypes.h +101 -0
- package/cpp/nodepcap/deps/include/pcap/pcap.h +1219 -0
- package/cpp/nodepcap/deps/include/pcap/sll.h +149 -0
- package/cpp/nodepcap/deps/include/pcap/socket.h +84 -0
- package/cpp/nodepcap/deps/include/pcap/usb.h +143 -0
- package/cpp/nodepcap/deps/include/pcap/vlan.h +46 -0
- package/cpp/nodepcap/deps/include/pcap-bpf.h +45 -0
- package/cpp/nodepcap/deps/include/pcap-namedb.h +40 -0
- package/cpp/nodepcap/deps/include/pcap.h +43 -0
- package/cpp/nodepcap/deps/lib/ARM64/Packet.lib +0 -0
- package/cpp/nodepcap/deps/lib/Packet.lib +0 -0
- package/cpp/nodepcap/deps/lib/wpcap.lib +0 -0
- package/cpp/nodepcap/deps/lib/x64/Packet.lib +0 -0
- package/cpp/nodepcap/deps/lib/x64/wpcap.lib +0 -0
- package/cpp/nodepcap/nodepcap.gypi +104 -0
- package/cpp/nodepcap/src/binding.cc +14 -0
- package/cpp/nodepcap/src/capture.cc +400 -0
- package/cpp/nodepcap/src/capture.h +53 -0
- package/cpp/nodepcap/src/utils.cc +218 -0
- package/cpp/nodepcap/src/utils.h +13 -0
- package/package.json +65 -0
- package/src/NetKitty.ts +31 -0
- package/src/errors/ActionNotFoundError.ts +6 -0
- package/src/errors/CodecSchemaValidateError.ts +6 -0
- package/src/errors/DeviceNotFoundError.ts +6 -0
- package/src/errors/NoAvailableCodecError.ts +6 -0
- package/src/errors/NpcapLoadError.ts +6 -0
- package/src/errors/SocketDownError.ts +6 -0
- package/src/errors/UnknownPipeMessageTypeError.ts +6 -0
- package/src/errors/common/ErrorCode.ts +30 -0
- package/src/lib/GeneratePipeAddress.ts +17 -0
- package/src/lib/GetBinding.ts +3 -0
- package/src/lib/GetCaptureTemporaryDirectory.ts +12 -0
- package/src/lib/GetDeviceCaptureTemporaryFilename.ts +13 -0
- package/src/lib/codec/Codec.ts +181 -0
- package/src/lib/codec/abstracts/BaseHeader.ts +413 -0
- package/src/lib/codec/headers/ARP.ts +218 -0
- package/src/lib/codec/headers/EthernetII.ts +77 -0
- package/src/lib/codec/headers/Goose.ts +658 -0
- package/src/lib/codec/headers/IEC61850SampledValues.ts +359 -0
- package/src/lib/codec/headers/IPv4.ts +329 -0
- package/src/lib/codec/headers/RawData.ts +34 -0
- package/src/lib/codec/headers/TCP.ts +931 -0
- package/src/lib/codec/headers/UDP.ts +180 -0
- package/src/lib/codec/headers/VLAN_802dot1Q.ts +74 -0
- package/src/lib/codec/lib/BufferToHex.ts +3 -0
- package/src/lib/codec/lib/BufferToIP.ts +19 -0
- package/src/lib/codec/lib/BufferToNumber.ts +31 -0
- package/src/lib/codec/lib/FixHexString.ts +8 -0
- package/src/lib/codec/lib/FlexibleObject.ts +100 -0
- package/src/lib/codec/lib/HexToNumber.ts +25 -0
- package/src/lib/codec/lib/IPToBuffer.ts +25 -0
- package/src/lib/codec/lib/NumberToBERBuffer.ts +19 -0
- package/src/lib/codec/lib/NumberToBERHex.ts +13 -0
- package/src/lib/codec/lib/NumberToBuffer.ts +21 -0
- package/src/lib/codec/lib/NumberToHex.ts +15 -0
- package/src/lib/codec/lib/ProcessPacketPostHandlers.ts +53 -0
- package/src/lib/codec/lib/SortPostHandlers.ts +10 -0
- package/src/lib/codec/lib/StringContentEncodingEnum.ts +7 -0
- package/src/lib/codec/types/CodecData.ts +7 -0
- package/src/lib/codec/types/CodecDecodeResult.ts +9 -0
- package/src/lib/codec/types/CodecEncodeInput.ts +5 -0
- package/src/lib/codec/types/CodecEncodeResult.ts +6 -0
- package/src/lib/codec/types/CodecErrorInfo.ts +5 -0
- package/src/lib/codec/types/CodecModule.ts +3 -0
- package/src/lib/codec/types/CodecModuleConstructor.ts +3 -0
- package/src/lib/codec/types/CodecSchema.ts +7 -0
- package/src/lib/codec/types/HeaderTreeNode.ts +5 -0
- package/src/lib/codec/types/PostHandlerItem.ts +4 -0
- package/src/lib/nodepcap/Capture.ts +291 -0
- package/src/lib/nodepcap/GetNetworkInterfaces.ts +18 -0
- package/src/lib/nodepcap/interfaces/IBindingCapture.ts +27 -0
- package/src/lib/nodepcap/interfaces/IBindingCaptureOptions.ts +4 -0
- package/src/lib/nodepcap/interfaces/ICaptureOptions.ts +19 -0
- package/src/lib/nodepcap/interfaces/INetworkInterface.ts +4 -0
- package/src/lib/nodepcap/lib/BindingCapture.ts +46 -0
- package/src/lib/nodepcap/lib/GetNodePcapBinding.ts +17 -0
- package/src/lib/nodepcap/lib/GetNodePcapBindingCapture.ts +15 -0
- package/src/lib/nodepcap/workers/CaptureWorker.ts +30 -0
- package/src/lib/pcap/PCAPGenerator.ts +118 -0
- package/src/lib/pcap/PcapParser.ts +170 -0
- package/src/lib/pcap/PcapReader.ts +239 -0
- package/src/lib/pcap/PcapWriter.ts +93 -0
- package/src/lib/pcap/interfaces/IPcapPacketInfo.ts +12 -0
- package/src/lib/pipe/PipeClient.ts +91 -0
- package/src/lib/pipe/PipeClientSocket.ts +99 -0
- package/src/lib/pipe/PipeMessage.ts +74 -0
- package/src/lib/pipe/PipeMessageHandler.ts +91 -0
- package/src/lib/pipe/PipeServer.ts +74 -0
- package/src/lib/schema/ProtocolFieldJSONSchema.ts +45 -0
- package/src/lib/schema/ProtocolFieldJSONSchemaDefinition.ts +3 -0
- package/src/lib/schema/ProtocolJSONSchema.ts +37 -0
- package/src/tests/Test.spec.ts +22 -0
- package/src/tests/units/CaptureTest.spec.ts +30 -0
- package/src/tests/units/Codec.spec.ts +85 -0
- package/tsconfig.json +41 -0
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import {randomInt} from 'node:crypto'
|
|
2
|
+
|
|
3
|
+
export enum PipeMessageType {
|
|
4
|
+
EVENT,
|
|
5
|
+
REQUEST,
|
|
6
|
+
RESPONSE_OK,
|
|
7
|
+
RESPONSE_ERR
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export interface IPipeMessage {
|
|
11
|
+
messageId: string
|
|
12
|
+
type: PipeMessageType
|
|
13
|
+
payload: any
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export class PipeMessage {
|
|
17
|
+
|
|
18
|
+
#serialized: string
|
|
19
|
+
|
|
20
|
+
#structured: IPipeMessage
|
|
21
|
+
|
|
22
|
+
protected set structured(structured: IPipeMessage) {
|
|
23
|
+
this.#structured = structured
|
|
24
|
+
this.#serialized = JSON.stringify(this.#structured)
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
protected get structured(): IPipeMessage {
|
|
28
|
+
return this.#structured
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
public get messageId(): string {
|
|
32
|
+
return this.structured.messageId
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
public set type(type: PipeMessageType) {
|
|
36
|
+
const structured: IPipeMessage = this.structured
|
|
37
|
+
structured.type = type
|
|
38
|
+
this.structured = structured
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
public get type(): PipeMessageType {
|
|
42
|
+
return this.structured.type
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
public set payload(payload: any) {
|
|
46
|
+
const structured: IPipeMessage = this.structured
|
|
47
|
+
structured.payload = payload
|
|
48
|
+
this.structured = structured
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
public get payload(): any {
|
|
52
|
+
return this.structured.payload
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
constructor(serialized?: string) {
|
|
56
|
+
if (serialized) {
|
|
57
|
+
this.#serialized = serialized
|
|
58
|
+
this.#structured = JSON.parse(serialized)
|
|
59
|
+
} else {
|
|
60
|
+
this.structured = {
|
|
61
|
+
messageId: `PIPE_MSG_${Date.now().toString(16)}${randomInt(10000000, 99999999)}`,
|
|
62
|
+
type: PipeMessageType.EVENT,
|
|
63
|
+
payload: null
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Serialized pipe message
|
|
70
|
+
*/
|
|
71
|
+
public serialize(): string {
|
|
72
|
+
return this.#serialized
|
|
73
|
+
}
|
|
74
|
+
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import {MessageClient, MessageConnection, MessageEvent} from 'socket-ipc'
|
|
2
|
+
import {PipeMessage, PipeMessageType} from './PipeMessage'
|
|
3
|
+
import EventEmitter from 'events'
|
|
4
|
+
import {PipeClient} from './PipeClient'
|
|
5
|
+
import {PipeClientSocket} from './PipeClientSocket'
|
|
6
|
+
import {UnknownPipeMessageTypeError} from '../../errors/UnknownPipeMessageTypeError'
|
|
7
|
+
import {ActionNotFoundError} from '../../errors/ActionNotFoundError'
|
|
8
|
+
|
|
9
|
+
export class PipeMessageHandler extends EventEmitter {
|
|
10
|
+
|
|
11
|
+
readonly #owner: PipeClient | PipeClientSocket
|
|
12
|
+
|
|
13
|
+
readonly #socket: MessageConnection | MessageClient
|
|
14
|
+
|
|
15
|
+
constructor(owner: PipeClient | PipeClientSocket, socket: MessageConnection)
|
|
16
|
+
constructor(owner: PipeClient | PipeClientSocket, socket: MessageClient)
|
|
17
|
+
constructor(owner: PipeClient | PipeClientSocket, socket: MessageConnection | MessageClient) {
|
|
18
|
+
super()
|
|
19
|
+
this.#owner = owner
|
|
20
|
+
this.#socket = socket
|
|
21
|
+
if (this.#socket instanceof MessageConnection) {
|
|
22
|
+
this.#socket.on('message', (message: MessageEvent): void => this.onMessageHandler(message))
|
|
23
|
+
} else {
|
|
24
|
+
this.#socket.on('message', (message: MessageEvent): void => this.onMessageHandler(message))
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* On pipe message handler
|
|
30
|
+
* @param message
|
|
31
|
+
* @protected
|
|
32
|
+
*/
|
|
33
|
+
protected onMessageHandler(message: MessageEvent): void {
|
|
34
|
+
const pipeMessage: PipeMessage = new PipeMessage(message.data as string)
|
|
35
|
+
switch (pipeMessage.type) {
|
|
36
|
+
case PipeMessageType.EVENT: {
|
|
37
|
+
const args: any[] = pipeMessage.payload as any[]
|
|
38
|
+
const eventName: string = args.shift()
|
|
39
|
+
this.#owner.emit(eventName, ...args)
|
|
40
|
+
}
|
|
41
|
+
break
|
|
42
|
+
case PipeMessageType.REQUEST: {
|
|
43
|
+
const args: any[] = pipeMessage.payload as any[]
|
|
44
|
+
const actionName: string = args.shift()
|
|
45
|
+
const action: (...args: any[]) => Promise<any> = this.#owner.actions[actionName]
|
|
46
|
+
if (action) {
|
|
47
|
+
action.call(this.#owner, ...args)
|
|
48
|
+
.then(response => {
|
|
49
|
+
pipeMessage.type = PipeMessageType.RESPONSE_OK
|
|
50
|
+
pipeMessage.payload = response
|
|
51
|
+
this.#socket.send(pipeMessage.serialize())
|
|
52
|
+
})
|
|
53
|
+
.catch((error: NodeJS.ErrnoException): void => {
|
|
54
|
+
pipeMessage.type = PipeMessageType.RESPONSE_ERR
|
|
55
|
+
pipeMessage.payload = {
|
|
56
|
+
message: error.message,
|
|
57
|
+
errno: error.errno,
|
|
58
|
+
code: error.code
|
|
59
|
+
}
|
|
60
|
+
this.#socket.send(pipeMessage.serialize())
|
|
61
|
+
})
|
|
62
|
+
} else {
|
|
63
|
+
pipeMessage.type = PipeMessageType.RESPONSE_ERR
|
|
64
|
+
const actionNotFoundError = new ActionNotFoundError(`Action ${actionName} not found`)
|
|
65
|
+
pipeMessage.payload = {
|
|
66
|
+
message: actionNotFoundError.message,
|
|
67
|
+
errno: actionNotFoundError.errno,
|
|
68
|
+
code: actionNotFoundError.code
|
|
69
|
+
}
|
|
70
|
+
this.#socket.send(pipeMessage.serialize())
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
break
|
|
74
|
+
case PipeMessageType.RESPONSE_OK: {
|
|
75
|
+
this.#owner.emit(pipeMessage.messageId, pipeMessage.payload)
|
|
76
|
+
}
|
|
77
|
+
break
|
|
78
|
+
case PipeMessageType.RESPONSE_ERR: {
|
|
79
|
+
const responseError: NodeJS.ErrnoException = new Error()
|
|
80
|
+
responseError.message = pipeMessage.payload.message
|
|
81
|
+
responseError.errno = pipeMessage.payload.errno
|
|
82
|
+
responseError.code = pipeMessage.payload.code
|
|
83
|
+
this.#owner.emit(pipeMessage.messageId, responseError)
|
|
84
|
+
}
|
|
85
|
+
break
|
|
86
|
+
default: {
|
|
87
|
+
this.#owner.emit('error', new UnknownPipeMessageTypeError(`Unknown pipe message type ${pipeMessage.type}`))
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import {GeneratePipeAddress} from '../GeneratePipeAddress'
|
|
2
|
+
import EventEmitter from 'events'
|
|
3
|
+
import {MessageConnection, MessageEvent, MessageServer} from 'socket-ipc'
|
|
4
|
+
import {PipeClientSocket} from './PipeClientSocket'
|
|
5
|
+
|
|
6
|
+
export interface IPipeServerOptions {
|
|
7
|
+
actions?: Record<string, (...args: any[]) => Promise<any>>
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export class PipeServer extends EventEmitter {
|
|
11
|
+
|
|
12
|
+
readonly #server: MessageServer
|
|
13
|
+
|
|
14
|
+
readonly #clientSocketMap: Map<string, PipeClientSocket> = new Map()
|
|
15
|
+
|
|
16
|
+
protected readonly actions: Record<string, (...args: any[]) => Promise<any>> = {}
|
|
17
|
+
|
|
18
|
+
public readonly socketPath: string
|
|
19
|
+
|
|
20
|
+
public get clients(): Map<string, PipeClientSocket> {
|
|
21
|
+
return this.#clientSocketMap
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
constructor(options?: IPipeServerOptions) {
|
|
25
|
+
super()
|
|
26
|
+
this.actions = options?.actions ? options.actions : {}
|
|
27
|
+
this.socketPath = GeneratePipeAddress()
|
|
28
|
+
this.#server = new MessageServer({path: this.socketPath})
|
|
29
|
+
this.#server.on('connection', (connection: MessageConnection): void => {
|
|
30
|
+
connection.once('message', (message: MessageEvent) => {
|
|
31
|
+
const base64Id: string = message.data.toString()
|
|
32
|
+
const clientId: string = Buffer.from(base64Id, 'base64').toString()
|
|
33
|
+
const clientSocket: PipeClientSocket = new PipeClientSocket({
|
|
34
|
+
id: clientId,
|
|
35
|
+
connection: connection,
|
|
36
|
+
actions: this.actions
|
|
37
|
+
})
|
|
38
|
+
this.#clientSocketMap.set(clientId, clientSocket)
|
|
39
|
+
clientSocket.once('disconnect', (): void => {
|
|
40
|
+
this.#clientSocketMap.delete(clientSocket.id)
|
|
41
|
+
this.emit('disconnect', clientSocket)
|
|
42
|
+
})
|
|
43
|
+
this.emit('connect', clientSocket)
|
|
44
|
+
})
|
|
45
|
+
})
|
|
46
|
+
this.#server.start().then((): boolean => this.emit('ready'))
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Dispose pipe server
|
|
51
|
+
*/
|
|
52
|
+
public dispose(): void {
|
|
53
|
+
this.#server.stop()
|
|
54
|
+
this.#clientSocketMap.clear()
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
public on(eventName: 'ready', listener: () => void): this
|
|
58
|
+
public on(eventName: 'connect', listener: (clientSocket: PipeClientSocket) => void): this
|
|
59
|
+
public on(eventName: 'disconnect', listener: (clientSocket: PipeClientSocket) => void): this
|
|
60
|
+
public on(eventName: string, listener: (...args: any) => void): this
|
|
61
|
+
public on(eventName: string, listener: (...args: any) => void): this {
|
|
62
|
+
super.on(eventName, listener)
|
|
63
|
+
return this
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
public once(eventName: 'ready', listener: () => void): this
|
|
67
|
+
public once(eventName: 'connect', listener: (clientSocket: PipeClientSocket) => void): this
|
|
68
|
+
public once(eventName: 'disconnect', listener: (clientSocket: PipeClientSocket) => void): this
|
|
69
|
+
public once(eventName: string, listener: (...args: any) => void): this
|
|
70
|
+
public once(eventName: string, listener: (...args: any) => void): this {
|
|
71
|
+
super.once(eventName, listener)
|
|
72
|
+
return this
|
|
73
|
+
}
|
|
74
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import {JSONSchema7} from 'json-schema'
|
|
2
|
+
import {ProtocolFieldJSONSchemaDefinition} from './ProtocolFieldJSONSchemaDefinition'
|
|
3
|
+
|
|
4
|
+
export interface ProtocolFieldJSONSchema extends JSONSchema7 {
|
|
5
|
+
|
|
6
|
+
encode?: () => void | Promise<void>
|
|
7
|
+
|
|
8
|
+
decode?: () => void | Promise<void>
|
|
9
|
+
|
|
10
|
+
label?: string
|
|
11
|
+
|
|
12
|
+
$defs?: {
|
|
13
|
+
[key: string]: ProtocolFieldJSONSchemaDefinition;
|
|
14
|
+
} | undefined;
|
|
15
|
+
|
|
16
|
+
items?: ProtocolFieldJSONSchemaDefinition | ProtocolFieldJSONSchemaDefinition[] | undefined;
|
|
17
|
+
|
|
18
|
+
additionalItems?: ProtocolFieldJSONSchemaDefinition | undefined;
|
|
19
|
+
contains?: ProtocolFieldJSONSchemaDefinition | undefined;
|
|
20
|
+
|
|
21
|
+
properties?: {
|
|
22
|
+
[key: string]: ProtocolFieldJSONSchemaDefinition;
|
|
23
|
+
} | undefined;
|
|
24
|
+
patternProperties?: {
|
|
25
|
+
[key: string]: ProtocolFieldJSONSchemaDefinition;
|
|
26
|
+
} | undefined;
|
|
27
|
+
additionalProperties?: ProtocolFieldJSONSchemaDefinition | undefined;
|
|
28
|
+
dependencies?: {
|
|
29
|
+
[key: string]: ProtocolFieldJSONSchemaDefinition | string[];
|
|
30
|
+
} | undefined;
|
|
31
|
+
propertyNames?: ProtocolFieldJSONSchemaDefinition | undefined;
|
|
32
|
+
|
|
33
|
+
if?: ProtocolFieldJSONSchemaDefinition | undefined;
|
|
34
|
+
then?: ProtocolFieldJSONSchemaDefinition | undefined;
|
|
35
|
+
else?: ProtocolFieldJSONSchemaDefinition | undefined;
|
|
36
|
+
|
|
37
|
+
allOf?: ProtocolFieldJSONSchemaDefinition[] | undefined;
|
|
38
|
+
anyOf?: ProtocolFieldJSONSchemaDefinition[] | undefined;
|
|
39
|
+
oneOf?: ProtocolFieldJSONSchemaDefinition[] | undefined;
|
|
40
|
+
not?: ProtocolFieldJSONSchemaDefinition | undefined;
|
|
41
|
+
|
|
42
|
+
definitions?: {
|
|
43
|
+
[key: string]: ProtocolFieldJSONSchemaDefinition;
|
|
44
|
+
} | undefined;
|
|
45
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import {JSONSchema7, JSONSchema7Definition} from 'json-schema'
|
|
2
|
+
import {ProtocolFieldJSONSchemaDefinition} from './ProtocolFieldJSONSchemaDefinition'
|
|
3
|
+
|
|
4
|
+
export interface ProtocolJSONSchema extends JSONSchema7 {
|
|
5
|
+
$defs?: {
|
|
6
|
+
[key: string]: JSONSchema7Definition;
|
|
7
|
+
} | undefined;
|
|
8
|
+
|
|
9
|
+
items?: ProtocolFieldJSONSchemaDefinition | ProtocolFieldJSONSchemaDefinition[] | undefined;
|
|
10
|
+
additionalItems?: JSONSchema7Definition | undefined;
|
|
11
|
+
contains?: ProtocolFieldJSONSchemaDefinition | undefined;
|
|
12
|
+
|
|
13
|
+
properties?: {
|
|
14
|
+
[key: string]: ProtocolFieldJSONSchemaDefinition;
|
|
15
|
+
} | undefined;
|
|
16
|
+
patternProperties?: {
|
|
17
|
+
[key: string]: ProtocolFieldJSONSchemaDefinition;
|
|
18
|
+
} | undefined;
|
|
19
|
+
additionalProperties?: ProtocolFieldJSONSchemaDefinition | undefined;
|
|
20
|
+
dependencies?: {
|
|
21
|
+
[key: string]: ProtocolFieldJSONSchemaDefinition | string[];
|
|
22
|
+
} | undefined;
|
|
23
|
+
propertyNames?: ProtocolFieldJSONSchemaDefinition | undefined;
|
|
24
|
+
|
|
25
|
+
if?: ProtocolFieldJSONSchemaDefinition | undefined;
|
|
26
|
+
then?: ProtocolFieldJSONSchemaDefinition | undefined;
|
|
27
|
+
else?: ProtocolFieldJSONSchemaDefinition | undefined;
|
|
28
|
+
|
|
29
|
+
allOf?: ProtocolFieldJSONSchemaDefinition[] | undefined;
|
|
30
|
+
anyOf?: ProtocolFieldJSONSchemaDefinition[] | undefined;
|
|
31
|
+
oneOf?: ProtocolFieldJSONSchemaDefinition[] | undefined;
|
|
32
|
+
not?: ProtocolFieldJSONSchemaDefinition | undefined;
|
|
33
|
+
|
|
34
|
+
definitions?: {
|
|
35
|
+
[key: string]: ProtocolFieldJSONSchemaDefinition;
|
|
36
|
+
} | undefined;
|
|
37
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import inquirer from 'inquirer'
|
|
2
|
+
import {readdirSync} from 'node:fs'
|
|
3
|
+
import path from 'node:path'
|
|
4
|
+
import {fork} from 'node:child_process'
|
|
5
|
+
|
|
6
|
+
const unitDir: string = path.resolve(__dirname, './units')
|
|
7
|
+
const unitModules: string[] = readdirSync(unitDir).filter(unit => unit.endsWith('spec.js')).map(unit => path.resolve(unitDir, unit))
|
|
8
|
+
|
|
9
|
+
inquirer
|
|
10
|
+
.prompt([
|
|
11
|
+
{
|
|
12
|
+
type: 'list',
|
|
13
|
+
name: 'unit',
|
|
14
|
+
message: 'Select an unit to test',
|
|
15
|
+
choices: unitModules.map(unitPath => path.basename(unitPath, '.spec.js'))
|
|
16
|
+
}
|
|
17
|
+
])
|
|
18
|
+
.then(async (answers) => {
|
|
19
|
+
const [selectedModule] = unitModules.filter(unitPath => path.basename(unitPath, '.spec.js') === answers.unit)
|
|
20
|
+
fork(selectedModule)
|
|
21
|
+
})
|
|
22
|
+
.catch(console.error)
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import {Capture} from '../../lib/nodepcap/Capture'
|
|
2
|
+
import {PcapReader} from '../../lib/pcap/PcapReader'
|
|
3
|
+
|
|
4
|
+
(async (): Promise<void> => {
|
|
5
|
+
const capture = new Capture({device: 'en0'})
|
|
6
|
+
const pcapReader: PcapReader = new PcapReader({filename: capture.temporaryFilename, watch: true})
|
|
7
|
+
pcapReader.on('packet', async (info) => {
|
|
8
|
+
// const buf = await pcapReader.readPacket(info.offset, info.length)
|
|
9
|
+
// console.log(info.index, buf.length)
|
|
10
|
+
console.log(info.index)
|
|
11
|
+
})
|
|
12
|
+
await capture.start()
|
|
13
|
+
await pcapReader.start()
|
|
14
|
+
console.log('started')
|
|
15
|
+
await new Promise(resolve => setTimeout(resolve, 10000))
|
|
16
|
+
await pcapReader.start()
|
|
17
|
+
console.log('restarted')
|
|
18
|
+
await new Promise(resolve => setTimeout(resolve, 60000))
|
|
19
|
+
console.time('paused')
|
|
20
|
+
await capture.pause()
|
|
21
|
+
console.timeEnd('paused')
|
|
22
|
+
await new Promise(resolve => setTimeout(resolve, 300000))
|
|
23
|
+
console.time('resumed')
|
|
24
|
+
await capture.resume()
|
|
25
|
+
console.timeEnd('resumed')
|
|
26
|
+
await new Promise(resolve => setTimeout(resolve, 60000))
|
|
27
|
+
console.time('stopped')
|
|
28
|
+
await capture.stop()
|
|
29
|
+
console.timeEnd('stopped')
|
|
30
|
+
})()
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import {Codec} from '../../lib/codec/Codec'
|
|
2
|
+
import {FlexibleObject} from '../../lib/codec/lib/FlexibleObject'
|
|
3
|
+
import {UInt8ToHex} from '../../lib/codec/lib/NumberToHex'
|
|
4
|
+
|
|
5
|
+
async function DecodeAndEncode(packet: string): Promise<void> {
|
|
6
|
+
const packetBuffer: Buffer = Buffer.from(packet, 'base64')
|
|
7
|
+
console.log('packetBuffer:', packetBuffer.toString('hex'))
|
|
8
|
+
const codec = new Codec()
|
|
9
|
+
const decodeResult = await codec.decode(packetBuffer)
|
|
10
|
+
// console.log(JSON.stringify(decodeResult, null, 2))
|
|
11
|
+
for (let i = 0; i < 100000; i++) {
|
|
12
|
+
const encodeResult = await codec.encode(decodeResult)
|
|
13
|
+
}
|
|
14
|
+
// const encodeResult = await codec.encode(decodeResult)
|
|
15
|
+
// console.log('encodeResult:', encodeResult.packet.toString('hex'))
|
|
16
|
+
// console.log('packetBuffer===encodeResult', packetBuffer.toString('hex') === encodeResult.packet.toString('hex'))
|
|
17
|
+
// const decodeResult1 = await codec.decode(encodeResult.packet)
|
|
18
|
+
// console.log(JSON.stringify(decodeResult1, null, 2))
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
async function GOOSE_Codec(packet: string): Promise<void> {
|
|
22
|
+
await DecodeAndEncode(packet)
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
async function IEC61850SampleValues_Codec(packet: string): Promise<void> {
|
|
26
|
+
await DecodeAndEncode(packet)
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
async function IPv4_Codec(packet: string): Promise<void> {
|
|
30
|
+
await DecodeAndEncode(packet)
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
async function ARP_Codec(packet: string): Promise<void> {
|
|
34
|
+
await DecodeAndEncode(packet)
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
async function TCP_Codec(packet: string): Promise<void> {
|
|
38
|
+
await DecodeAndEncode(packet)
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
async function UDP_Codec(packet: string): Promise<void> {
|
|
42
|
+
await DecodeAndEncode(packet)
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
(async (): Promise<void> => {
|
|
46
|
+
console.time('GOOSE')
|
|
47
|
+
await GOOSE_Codec('AaD0CC93AKD0CC93iLgAAQCRAAAAAGGBhoAaR0VEZXZpY2VGNjUwL0xMTjAkR08kZ2NiMDGBAwCcQIIYR0VEZXZpY2VGNjUwL0xMTjAkR09PU0UxgwtGNjUwX0dPT1NFMYQIOG6780IXKAqFAQGGAQuHAQCIAQGJAQCKAQirIIMBAIQDAwAAgwEAhAMDAACDAQCEAwMAAIMBAIQDAwAA')
|
|
48
|
+
console.timeEnd('GOOSE')
|
|
49
|
+
|
|
50
|
+
console.time('IEC61850SampleValues')
|
|
51
|
+
await IEC61850SampleValues_Codec('AQzNBAAByv7A/+5piLpAAQBmAAAAAGBcgAEBolcwVYAENDAwMYICCDaDBAAAAAGFAQKHQAADpBwAAAAAAAAgrAAAAAD//DyAAAAAAAAAAUgAACAAAPOi+AAAAAAAC1wyAAAAAP8BRogAAAAAAABFsgAAIAA=')
|
|
52
|
+
console.timeEnd('IEC61850SampleValues')
|
|
53
|
+
|
|
54
|
+
// await IPv4_Codec('AQBeAAD7RvyxjrRvCABFAABDFi9AAP8Rwg7AqAHI4AAA+61EFOkALwQ6AAAAAAABAAAAAAAACl9seXJhLW1kbnMEX3VkcAVsb2NhbAAADIAB')
|
|
55
|
+
console.time('IPv4')
|
|
56
|
+
await IPv4_Codec('AAAAAAAAAAAAAAAACABLAABseDcAAEABdS1/AAABfwAAAYYWAAAAAgIQAAIAAAACAAQABQAGAO8AAAAAKVCMCgABkk2uRRMODAAICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8gISIjJCUmJygpKissLS4vMDEyMzQ1Njc=')
|
|
57
|
+
console.timeEnd('IPv4')
|
|
58
|
+
|
|
59
|
+
console.time('ARP')
|
|
60
|
+
await ARP_Codec('////////AFDCV7MQCAYAAQgABgQAAQBQwlezEMCorNcAAAAAAADAqKwBAAAAAAAAAAAAAAAWOgAFAgAA')
|
|
61
|
+
console.timeEnd('ARP')
|
|
62
|
+
|
|
63
|
+
// await TCP_Codec('jrqXwYfpMsUZ/NE3CABFAABAAABAAEAG7RnAqAGf3LWuof8nAbtj7USXAAAAALAC//8W3wAAAgQFtAEDAwYBAQgKrHN8owAAAAAEAgAA')
|
|
64
|
+
console.time('TCP')
|
|
65
|
+
await TCP_Codec('MsUZ/NE3jrqXwYfpCABFAAJtAABAADMGCAYr+E9GwKgBnwBQxWyUVlJ28OAPzYAYAf/ikQAAAQEICu648gfnwk9J+s/+/j/vP/v7/uz/7O/72352Oswm1bo1vf3hf+t/9vf8CRLU/Od/3l/1X/49/yCJC4U2G3u23cjEvL4q2un8J8mR/z0kh/7ZG/ILfmG2WOl67ld1+dnvvvdM/VjS/nm9zEqiLcsVyZhIHfokx4F6iHXqBsfc0VBOtoXhIKYQx/K//EP/esL9v/gr/jzAuQUY0AhOI6A5Kn109O03b16+fk8YIPQvojT7dbYsswl7mx8dHZ8RYhSz/ed/xJ9NM/o1INb5rLjI63FWELRX/+hfzX9RzEmD/a/+qj/IgY1xAsCanqbV6pqXCYnkPNP/1d//N1KQm/4jf/Xezt79lKj2n/89fypNA6lJfLBDy4whQoTPJKfhjRdF0ZJ3fTmeLgnW3/LXnJ28/M//sj9y52Bn99P9g4f/+Z/4dwKdNKVv/vM//K+jWf3P/4Y/mr5P7+3u7FJURotwuw/2PuVmwM9D3CgV+tX+/viu6BL8avUQfT+sJDltSOZi9pJ0LSmhO+P1JJPfbeKjq9joIzzwsNLPxQFts4t064L+peDgjjj9ikAs6MBMiedKbyyyJanRmjkAECja+D1IK36+/el3Hj57svfqwbN9WFWB5uDSb1gpZlcYDvdzoEzqu/cR+8Y0AC+Vh24oi2fbiONMzgKn3po7h5ze4VYf/3RDyTvYhKdkQ7bugBTuS1q+PC8uqMHHPrpsLTyMiVY0Q5Nqdk1/PL47bxfwDQpiDQqC/h9WtstCH04AAA0KMA0KDQo=')
|
|
66
|
+
console.timeEnd('TCP')
|
|
67
|
+
|
|
68
|
+
// await TCP_Codec('MsUZ/NE3jrqXwYfpCABFAAAoAABAAEAG4N0NQoppwKgBnwG7wHisAGbXAAAAAFAEAACA4gAA')
|
|
69
|
+
console.time('UDP')
|
|
70
|
+
await UDP_Codec('////////CAAnzP1BCABFAAD/uTJAAEAR+6XAqAHGwKgB/wCKAIoA62oQEQp9csCoAcYAigDVAAAgRkFGRUZEQ0FDQUNBQ0FDQUNBQ0FDQUNBQ0FDQUNBQUEAIEZIRVBGQ0VMRUhGQ0VQRkZGQUNBQ0FDQUNBQ0FDQUJOAP9TTUIlAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEQAAOwAAAAAAAAAAAAAAAAAAAAAAAAA7AFYAAwABAAEAAgBMAFxNQUlMU0xPVFxCUk9XU0UAAe2A/AoAUFRTAAAAAAAAAAAAAAAAAAYBA5qBAA8BVapwdHMgc2VydmVyIChTYW1iYSwgVWJ1bnR1KQA=')
|
|
71
|
+
console.timeEnd('UDP')
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
// const fobj = new FlexibleObject({
|
|
75
|
+
// cc1: true
|
|
76
|
+
// })
|
|
77
|
+
// fobj.cc2.bb3.setValue(true)
|
|
78
|
+
//
|
|
79
|
+
// fobj.c1.b1.ccc1.setValue('1')
|
|
80
|
+
// fobj.c1.b1.ccc2.setValue(2)
|
|
81
|
+
// fobj.c1.b1.ccc3.setValue(true)
|
|
82
|
+
// // console.log(fobj.cc2.bb4.getValue(), fobj.cc2.bb4.isUndefined())
|
|
83
|
+
// console.log(JSON.stringify(fobj.getValue(), null, 2))
|
|
84
|
+
// console.log(fobj.c1.b1.ccc4.hhh6.getPath())
|
|
85
|
+
})()
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2022",
|
|
4
|
+
"lib": [
|
|
5
|
+
"ES2022"
|
|
6
|
+
],
|
|
7
|
+
"declaration": true,
|
|
8
|
+
"moduleDetection": "auto",
|
|
9
|
+
"module": "Node16",
|
|
10
|
+
"moduleResolution": "Node16",
|
|
11
|
+
"allowSyntheticDefaultImports": true,
|
|
12
|
+
"types": [
|
|
13
|
+
"reflect-metadata",
|
|
14
|
+
"node"
|
|
15
|
+
],
|
|
16
|
+
"useDefineForClassFields": false,
|
|
17
|
+
"preserveConstEnums": true,
|
|
18
|
+
"emitDecoratorMetadata": true,
|
|
19
|
+
"experimentalDecorators": true,
|
|
20
|
+
"resolveJsonModule": true,
|
|
21
|
+
"allowJs": true,
|
|
22
|
+
"esModuleInterop": true,
|
|
23
|
+
"forceConsistentCasingInFileNames": true,
|
|
24
|
+
"strict": true,
|
|
25
|
+
"noImplicitAny": false,
|
|
26
|
+
"strictPropertyInitialization": false,
|
|
27
|
+
"noUnusedLocals": false,
|
|
28
|
+
"noUnusedParameters": false,
|
|
29
|
+
"skipLibCheck": true,
|
|
30
|
+
"allowArbitraryExtensions": true,
|
|
31
|
+
"isolatedModules": true,
|
|
32
|
+
"declarationMap": true,
|
|
33
|
+
"outDir": "build",
|
|
34
|
+
"rootDir": "src",
|
|
35
|
+
},
|
|
36
|
+
"exclude": [
|
|
37
|
+
"node_modules",
|
|
38
|
+
"build",
|
|
39
|
+
"data"
|
|
40
|
+
]
|
|
41
|
+
}
|