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.
Files changed (338) hide show
  1. package/.eslintrc.json +53 -0
  2. package/.idea/codeStyles/Project.xml +18 -0
  3. package/.idea/codeStyles/codeStyleConfig.xml +5 -0
  4. package/.idea/inspectionProfiles/Project_Default.xml +10 -0
  5. package/.idea/modules.xml +8 -0
  6. package/.idea/netkitty.iml +13 -0
  7. package/.idea/vcs.xml +6 -0
  8. package/LICENSE +21 -0
  9. package/README.md +2 -0
  10. package/binding.gyp +5 -0
  11. package/build/NetKitty.d.ts +31 -0
  12. package/build/NetKitty.d.ts.map +1 -0
  13. package/build/NetKitty.js +33 -0
  14. package/build/errors/ActionNotFoundError.d.ts +5 -0
  15. package/build/errors/ActionNotFoundError.d.ts.map +1 -0
  16. package/build/errors/ActionNotFoundError.js +12 -0
  17. package/build/errors/CodecSchemaValidateError.d.ts +5 -0
  18. package/build/errors/CodecSchemaValidateError.d.ts.map +1 -0
  19. package/build/errors/CodecSchemaValidateError.js +12 -0
  20. package/build/errors/DeviceNotFoundError.d.ts +5 -0
  21. package/build/errors/DeviceNotFoundError.d.ts.map +1 -0
  22. package/build/errors/DeviceNotFoundError.js +12 -0
  23. package/build/errors/NoAvailableCodecError.d.ts +5 -0
  24. package/build/errors/NoAvailableCodecError.d.ts.map +1 -0
  25. package/build/errors/NoAvailableCodecError.js +12 -0
  26. package/build/errors/NpcapLoadError.d.ts +5 -0
  27. package/build/errors/NpcapLoadError.d.ts.map +1 -0
  28. package/build/errors/NpcapLoadError.js +12 -0
  29. package/build/errors/SocketDownError.d.ts +5 -0
  30. package/build/errors/SocketDownError.d.ts.map +1 -0
  31. package/build/errors/SocketDownError.js +12 -0
  32. package/build/errors/UnknownPipeMessageTypeError.d.ts +5 -0
  33. package/build/errors/UnknownPipeMessageTypeError.d.ts.map +1 -0
  34. package/build/errors/UnknownPipeMessageTypeError.js +12 -0
  35. package/build/errors/common/ErrorCode.d.ts +31 -0
  36. package/build/errors/common/ErrorCode.d.ts.map +1 -0
  37. package/build/errors/common/ErrorCode.js +33 -0
  38. package/build/lib/GeneratePipeAddress.d.ts +7 -0
  39. package/build/lib/GeneratePipeAddress.d.ts.map +1 -0
  40. package/build/lib/GeneratePipeAddress.js +23 -0
  41. package/build/lib/GetBinding.d.ts +2 -0
  42. package/build/lib/GetBinding.d.ts.map +1 -0
  43. package/build/lib/GetBinding.js +6 -0
  44. package/build/lib/GetCaptureTemporaryDirectory.d.ts +7 -0
  45. package/build/lib/GetCaptureTemporaryDirectory.d.ts.map +1 -0
  46. package/build/lib/GetCaptureTemporaryDirectory.js +15 -0
  47. package/build/lib/GetDeviceCaptureTemporaryFilename.d.ts +8 -0
  48. package/build/lib/GetDeviceCaptureTemporaryFilename.d.ts.map +1 -0
  49. package/build/lib/GetDeviceCaptureTemporaryFilename.js +18 -0
  50. package/build/lib/codec/Codec.d.ts +33 -0
  51. package/build/lib/codec/Codec.d.ts.map +1 -0
  52. package/build/lib/codec/Codec.js +166 -0
  53. package/build/lib/codec/abstracts/BaseHeader.d.ts +204 -0
  54. package/build/lib/codec/abstracts/BaseHeader.d.ts.map +1 -0
  55. package/build/lib/codec/abstracts/BaseHeader.js +339 -0
  56. package/build/lib/codec/headers/ARP.d.ts +9 -0
  57. package/build/lib/codec/headers/ARP.d.ts.map +1 -0
  58. package/build/lib/codec/headers/ARP.js +223 -0
  59. package/build/lib/codec/headers/EthernetII.d.ts +9 -0
  60. package/build/lib/codec/headers/EthernetII.d.ts.map +1 -0
  61. package/build/lib/codec/headers/EthernetII.js +80 -0
  62. package/build/lib/codec/headers/Goose.d.ts +12 -0
  63. package/build/lib/codec/headers/Goose.d.ts.map +1 -0
  64. package/build/lib/codec/headers/Goose.js +701 -0
  65. package/build/lib/codec/headers/IEC61850SampledValues.d.ts +12 -0
  66. package/build/lib/codec/headers/IEC61850SampledValues.d.ts.map +1 -0
  67. package/build/lib/codec/headers/IEC61850SampledValues.js +369 -0
  68. package/build/lib/codec/headers/IPv4.d.ts +15 -0
  69. package/build/lib/codec/headers/IPv4.d.ts.map +1 -0
  70. package/build/lib/codec/headers/IPv4.js +338 -0
  71. package/build/lib/codec/headers/RawData.d.ts +9 -0
  72. package/build/lib/codec/headers/RawData.d.ts.map +1 -0
  73. package/build/lib/codec/headers/RawData.js +34 -0
  74. package/build/lib/codec/headers/TCP.d.ts +15 -0
  75. package/build/lib/codec/headers/TCP.d.ts.map +1 -0
  76. package/build/lib/codec/headers/TCP.js +897 -0
  77. package/build/lib/codec/headers/UDP.d.ts +15 -0
  78. package/build/lib/codec/headers/UDP.d.ts.map +1 -0
  79. package/build/lib/codec/headers/UDP.js +191 -0
  80. package/build/lib/codec/headers/VLAN_802dot1Q.d.ts +9 -0
  81. package/build/lib/codec/headers/VLAN_802dot1Q.d.ts.map +1 -0
  82. package/build/lib/codec/headers/VLAN_802dot1Q.js +77 -0
  83. package/build/lib/codec/lib/BufferToHex.d.ts +2 -0
  84. package/build/lib/codec/lib/BufferToHex.d.ts.map +1 -0
  85. package/build/lib/codec/lib/BufferToHex.js +6 -0
  86. package/build/lib/codec/lib/BufferToIP.d.ts +13 -0
  87. package/build/lib/codec/lib/BufferToIP.d.ts.map +1 -0
  88. package/build/lib/codec/lib/BufferToIP.js +21 -0
  89. package/build/lib/codec/lib/BufferToNumber.d.ts +10 -0
  90. package/build/lib/codec/lib/BufferToNumber.d.ts.map +1 -0
  91. package/build/lib/codec/lib/BufferToNumber.js +22 -0
  92. package/build/lib/codec/lib/FixHexString.d.ts +7 -0
  93. package/build/lib/codec/lib/FixHexString.d.ts.map +1 -0
  94. package/build/lib/codec/lib/FixHexString.js +11 -0
  95. package/build/lib/codec/lib/FlexibleObject.d.ts +28 -0
  96. package/build/lib/codec/lib/FlexibleObject.d.ts.map +1 -0
  97. package/build/lib/codec/lib/FlexibleObject.js +102 -0
  98. package/build/lib/codec/lib/HexToNumber.d.ts +10 -0
  99. package/build/lib/codec/lib/HexToNumber.d.ts.map +1 -0
  100. package/build/lib/codec/lib/HexToNumber.js +39 -0
  101. package/build/lib/codec/lib/IPToBuffer.d.ts +13 -0
  102. package/build/lib/codec/lib/IPToBuffer.d.ts.map +1 -0
  103. package/build/lib/codec/lib/IPToBuffer.js +28 -0
  104. package/build/lib/codec/lib/NumberToBERBuffer.d.ts +9 -0
  105. package/build/lib/codec/lib/NumberToBERBuffer.d.ts.map +1 -0
  106. package/build/lib/codec/lib/NumberToBERBuffer.js +20 -0
  107. package/build/lib/codec/lib/NumberToBERHex.d.ts +9 -0
  108. package/build/lib/codec/lib/NumberToBERHex.d.ts.map +1 -0
  109. package/build/lib/codec/lib/NumberToBERHex.js +23 -0
  110. package/build/lib/codec/lib/NumberToBuffer.d.ts +10 -0
  111. package/build/lib/codec/lib/NumberToBuffer.d.ts.map +1 -0
  112. package/build/lib/codec/lib/NumberToBuffer.js +22 -0
  113. package/build/lib/codec/lib/NumberToHex.d.ts +10 -0
  114. package/build/lib/codec/lib/NumberToHex.d.ts.map +1 -0
  115. package/build/lib/codec/lib/NumberToHex.js +26 -0
  116. package/build/lib/codec/lib/ProcessPacketPostHandlers.d.ts +14 -0
  117. package/build/lib/codec/lib/ProcessPacketPostHandlers.d.ts.map +1 -0
  118. package/build/lib/codec/lib/ProcessPacketPostHandlers.js +53 -0
  119. package/build/lib/codec/lib/SortPostHandlers.d.ts +8 -0
  120. package/build/lib/codec/lib/SortPostHandlers.d.ts.map +1 -0
  121. package/build/lib/codec/lib/SortPostHandlers.js +11 -0
  122. package/build/lib/codec/lib/StringContentEncodingEnum.d.ts +8 -0
  123. package/build/lib/codec/lib/StringContentEncodingEnum.d.ts.map +1 -0
  124. package/build/lib/codec/lib/StringContentEncodingEnum.js +11 -0
  125. package/build/lib/codec/types/CodecData.d.ts +7 -0
  126. package/build/lib/codec/types/CodecData.d.ts.map +1 -0
  127. package/build/lib/codec/types/CodecData.js +2 -0
  128. package/build/lib/codec/types/CodecDecodeResult.d.ts +9 -0
  129. package/build/lib/codec/types/CodecDecodeResult.d.ts.map +1 -0
  130. package/build/lib/codec/types/CodecDecodeResult.js +2 -0
  131. package/build/lib/codec/types/CodecEncodeInput.d.ts +5 -0
  132. package/build/lib/codec/types/CodecEncodeInput.d.ts.map +1 -0
  133. package/build/lib/codec/types/CodecEncodeInput.js +2 -0
  134. package/build/lib/codec/types/CodecEncodeResult.d.ts +6 -0
  135. package/build/lib/codec/types/CodecEncodeResult.d.ts.map +1 -0
  136. package/build/lib/codec/types/CodecEncodeResult.js +2 -0
  137. package/build/lib/codec/types/CodecErrorInfo.d.ts +6 -0
  138. package/build/lib/codec/types/CodecErrorInfo.d.ts.map +1 -0
  139. package/build/lib/codec/types/CodecErrorInfo.js +2 -0
  140. package/build/lib/codec/types/CodecModule.d.ts +3 -0
  141. package/build/lib/codec/types/CodecModule.d.ts.map +1 -0
  142. package/build/lib/codec/types/CodecModule.js +2 -0
  143. package/build/lib/codec/types/CodecModuleConstructor.d.ts +3 -0
  144. package/build/lib/codec/types/CodecModuleConstructor.d.ts.map +1 -0
  145. package/build/lib/codec/types/CodecModuleConstructor.js +2 -0
  146. package/build/lib/codec/types/CodecSchema.d.ts +7 -0
  147. package/build/lib/codec/types/CodecSchema.d.ts.map +1 -0
  148. package/build/lib/codec/types/CodecSchema.js +2 -0
  149. package/build/lib/codec/types/HeaderTreeNode.d.ts +5 -0
  150. package/build/lib/codec/types/HeaderTreeNode.d.ts.map +1 -0
  151. package/build/lib/codec/types/HeaderTreeNode.js +2 -0
  152. package/build/lib/codec/types/PostHandlerItem.d.ts +5 -0
  153. package/build/lib/codec/types/PostHandlerItem.d.ts.map +1 -0
  154. package/build/lib/codec/types/PostHandlerItem.js +2 -0
  155. package/build/lib/nodepcap/Capture.d.ts +75 -0
  156. package/build/lib/nodepcap/Capture.d.ts.map +1 -0
  157. package/build/lib/nodepcap/Capture.js +309 -0
  158. package/build/lib/nodepcap/GetNetworkInterfaces.d.ts +7 -0
  159. package/build/lib/nodepcap/GetNetworkInterfaces.d.ts.map +1 -0
  160. package/build/lib/nodepcap/GetNetworkInterfaces.js +22 -0
  161. package/build/lib/nodepcap/interfaces/IBindingCapture.d.ts +16 -0
  162. package/build/lib/nodepcap/interfaces/IBindingCapture.d.ts.map +1 -0
  163. package/build/lib/nodepcap/interfaces/IBindingCapture.js +2 -0
  164. package/build/lib/nodepcap/interfaces/IBindingCaptureOptions.d.ts +5 -0
  165. package/build/lib/nodepcap/interfaces/IBindingCaptureOptions.d.ts.map +1 -0
  166. package/build/lib/nodepcap/interfaces/IBindingCaptureOptions.js +2 -0
  167. package/build/lib/nodepcap/interfaces/ICaptureOptions.d.ts +19 -0
  168. package/build/lib/nodepcap/interfaces/ICaptureOptions.d.ts.map +1 -0
  169. package/build/lib/nodepcap/interfaces/ICaptureOptions.js +2 -0
  170. package/build/lib/nodepcap/interfaces/INetworkInterface.d.ts +5 -0
  171. package/build/lib/nodepcap/interfaces/INetworkInterface.d.ts.map +1 -0
  172. package/build/lib/nodepcap/interfaces/INetworkInterface.js +2 -0
  173. package/build/lib/nodepcap/lib/BindingCapture.d.ts +15 -0
  174. package/build/lib/nodepcap/lib/BindingCapture.d.ts.map +1 -0
  175. package/build/lib/nodepcap/lib/BindingCapture.js +35 -0
  176. package/build/lib/nodepcap/lib/GetNodePcapBinding.d.ts +2 -0
  177. package/build/lib/nodepcap/lib/GetNodePcapBinding.d.ts.map +1 -0
  178. package/build/lib/nodepcap/lib/GetNodePcapBinding.js +55 -0
  179. package/build/lib/nodepcap/lib/GetNodePcapBindingCapture.d.ts +3 -0
  180. package/build/lib/nodepcap/lib/GetNodePcapBindingCapture.d.ts.map +1 -0
  181. package/build/lib/nodepcap/lib/GetNodePcapBindingCapture.js +18 -0
  182. package/build/lib/nodepcap/workers/CaptureWorker.d.ts +2 -0
  183. package/build/lib/nodepcap/workers/CaptureWorker.d.ts.map +1 -0
  184. package/build/lib/nodepcap/workers/CaptureWorker.js +25 -0
  185. package/build/lib/pcap/PCAPGenerator.d.ts +34 -0
  186. package/build/lib/pcap/PCAPGenerator.d.ts.map +1 -0
  187. package/build/lib/pcap/PCAPGenerator.js +95 -0
  188. package/build/lib/pcap/PcapParser.d.ts +27 -0
  189. package/build/lib/pcap/PcapParser.d.ts.map +1 -0
  190. package/build/lib/pcap/PcapParser.js +149 -0
  191. package/build/lib/pcap/PcapReader.d.ts +87 -0
  192. package/build/lib/pcap/PcapReader.d.ts.map +1 -0
  193. package/build/lib/pcap/PcapReader.js +207 -0
  194. package/build/lib/pcap/PcapWriter.d.ts +29 -0
  195. package/build/lib/pcap/PcapWriter.d.ts.map +1 -0
  196. package/build/lib/pcap/PcapWriter.js +80 -0
  197. package/build/lib/pcap/interfaces/IPcapPacketInfo.d.ts +13 -0
  198. package/build/lib/pcap/interfaces/IPcapPacketInfo.d.ts.map +1 -0
  199. package/build/lib/pcap/interfaces/IPcapPacketInfo.js +2 -0
  200. package/build/lib/pipe/PipeClient.d.ts +35 -0
  201. package/build/lib/pipe/PipeClient.d.ts.map +1 -0
  202. package/build/lib/pipe/PipeClient.js +71 -0
  203. package/build/lib/pipe/PipeClientSocket.d.ts +39 -0
  204. package/build/lib/pipe/PipeClientSocket.d.ts.map +1 -0
  205. package/build/lib/pipe/PipeClientSocket.js +82 -0
  206. package/build/lib/pipe/PipeMessage.d.ts +27 -0
  207. package/build/lib/pipe/PipeMessage.d.ts.map +1 -0
  208. package/build/lib/pipe/PipeMessage.js +61 -0
  209. package/build/lib/pipe/PipeMessageHandler.d.ts +16 -0
  210. package/build/lib/pipe/PipeMessageHandler.d.ts.map +1 -0
  211. package/build/lib/pipe/PipeMessageHandler.js +95 -0
  212. package/build/lib/pipe/PipeServer.d.ts +25 -0
  213. package/build/lib/pipe/PipeServer.d.ts.map +1 -0
  214. package/build/lib/pipe/PipeServer.js +59 -0
  215. package/build/lib/schema/ProtocolFieldJSONSchema.d.ts +35 -0
  216. package/build/lib/schema/ProtocolFieldJSONSchema.d.ts.map +1 -0
  217. package/build/lib/schema/ProtocolFieldJSONSchema.js +2 -0
  218. package/build/lib/schema/ProtocolFieldJSONSchemaDefinition.d.ts +3 -0
  219. package/build/lib/schema/ProtocolFieldJSONSchemaDefinition.d.ts.map +1 -0
  220. package/build/lib/schema/ProtocolFieldJSONSchemaDefinition.js +2 -0
  221. package/build/lib/schema/ProtocolJSONSchema.d.ts +32 -0
  222. package/build/lib/schema/ProtocolJSONSchema.d.ts.map +1 -0
  223. package/build/lib/schema/ProtocolJSONSchema.js +2 -0
  224. package/build/tests/Test.spec.d.ts +2 -0
  225. package/build/tests/Test.spec.d.ts.map +1 -0
  226. package/build/tests/Test.spec.js +25 -0
  227. package/build/tests/units/CaptureTest.spec.d.ts +2 -0
  228. package/build/tests/units/CaptureTest.spec.d.ts.map +1 -0
  229. package/build/tests/units/CaptureTest.spec.js +31 -0
  230. package/build/tests/units/Codec.spec.d.ts +2 -0
  231. package/build/tests/units/Codec.spec.d.ts.map +1 -0
  232. package/build/tests/units/Codec.spec.js +70 -0
  233. package/cpp/nodepcap/deps/include/Packet32.h +429 -0
  234. package/cpp/nodepcap/deps/include/pcap/bluetooth.h +56 -0
  235. package/cpp/nodepcap/deps/include/pcap/bpf.h +292 -0
  236. package/cpp/nodepcap/deps/include/pcap/can_socketcan.h +56 -0
  237. package/cpp/nodepcap/deps/include/pcap/compiler-tests.h +163 -0
  238. package/cpp/nodepcap/deps/include/pcap/dlt.h +1514 -0
  239. package/cpp/nodepcap/deps/include/pcap/funcattrs.h +325 -0
  240. package/cpp/nodepcap/deps/include/pcap/ipnet.h +43 -0
  241. package/cpp/nodepcap/deps/include/pcap/namedb.h +84 -0
  242. package/cpp/nodepcap/deps/include/pcap/nflog.h +94 -0
  243. package/cpp/nodepcap/deps/include/pcap/pcap-inttypes.h +101 -0
  244. package/cpp/nodepcap/deps/include/pcap/pcap.h +1219 -0
  245. package/cpp/nodepcap/deps/include/pcap/sll.h +149 -0
  246. package/cpp/nodepcap/deps/include/pcap/socket.h +84 -0
  247. package/cpp/nodepcap/deps/include/pcap/usb.h +143 -0
  248. package/cpp/nodepcap/deps/include/pcap/vlan.h +46 -0
  249. package/cpp/nodepcap/deps/include/pcap-bpf.h +45 -0
  250. package/cpp/nodepcap/deps/include/pcap-namedb.h +40 -0
  251. package/cpp/nodepcap/deps/include/pcap.h +43 -0
  252. package/cpp/nodepcap/deps/lib/ARM64/Packet.lib +0 -0
  253. package/cpp/nodepcap/deps/lib/Packet.lib +0 -0
  254. package/cpp/nodepcap/deps/lib/wpcap.lib +0 -0
  255. package/cpp/nodepcap/deps/lib/x64/Packet.lib +0 -0
  256. package/cpp/nodepcap/deps/lib/x64/wpcap.lib +0 -0
  257. package/cpp/nodepcap/nodepcap.gypi +104 -0
  258. package/cpp/nodepcap/src/binding.cc +14 -0
  259. package/cpp/nodepcap/src/capture.cc +400 -0
  260. package/cpp/nodepcap/src/capture.h +53 -0
  261. package/cpp/nodepcap/src/utils.cc +218 -0
  262. package/cpp/nodepcap/src/utils.h +13 -0
  263. package/package.json +65 -0
  264. package/src/NetKitty.ts +31 -0
  265. package/src/errors/ActionNotFoundError.ts +6 -0
  266. package/src/errors/CodecSchemaValidateError.ts +6 -0
  267. package/src/errors/DeviceNotFoundError.ts +6 -0
  268. package/src/errors/NoAvailableCodecError.ts +6 -0
  269. package/src/errors/NpcapLoadError.ts +6 -0
  270. package/src/errors/SocketDownError.ts +6 -0
  271. package/src/errors/UnknownPipeMessageTypeError.ts +6 -0
  272. package/src/errors/common/ErrorCode.ts +30 -0
  273. package/src/lib/GeneratePipeAddress.ts +17 -0
  274. package/src/lib/GetBinding.ts +3 -0
  275. package/src/lib/GetCaptureTemporaryDirectory.ts +12 -0
  276. package/src/lib/GetDeviceCaptureTemporaryFilename.ts +13 -0
  277. package/src/lib/codec/Codec.ts +181 -0
  278. package/src/lib/codec/abstracts/BaseHeader.ts +413 -0
  279. package/src/lib/codec/headers/ARP.ts +218 -0
  280. package/src/lib/codec/headers/EthernetII.ts +77 -0
  281. package/src/lib/codec/headers/Goose.ts +658 -0
  282. package/src/lib/codec/headers/IEC61850SampledValues.ts +359 -0
  283. package/src/lib/codec/headers/IPv4.ts +329 -0
  284. package/src/lib/codec/headers/RawData.ts +34 -0
  285. package/src/lib/codec/headers/TCP.ts +931 -0
  286. package/src/lib/codec/headers/UDP.ts +180 -0
  287. package/src/lib/codec/headers/VLAN_802dot1Q.ts +74 -0
  288. package/src/lib/codec/lib/BufferToHex.ts +3 -0
  289. package/src/lib/codec/lib/BufferToIP.ts +19 -0
  290. package/src/lib/codec/lib/BufferToNumber.ts +31 -0
  291. package/src/lib/codec/lib/FixHexString.ts +8 -0
  292. package/src/lib/codec/lib/FlexibleObject.ts +100 -0
  293. package/src/lib/codec/lib/HexToNumber.ts +25 -0
  294. package/src/lib/codec/lib/IPToBuffer.ts +25 -0
  295. package/src/lib/codec/lib/NumberToBERBuffer.ts +19 -0
  296. package/src/lib/codec/lib/NumberToBERHex.ts +13 -0
  297. package/src/lib/codec/lib/NumberToBuffer.ts +21 -0
  298. package/src/lib/codec/lib/NumberToHex.ts +15 -0
  299. package/src/lib/codec/lib/ProcessPacketPostHandlers.ts +53 -0
  300. package/src/lib/codec/lib/SortPostHandlers.ts +10 -0
  301. package/src/lib/codec/lib/StringContentEncodingEnum.ts +7 -0
  302. package/src/lib/codec/types/CodecData.ts +7 -0
  303. package/src/lib/codec/types/CodecDecodeResult.ts +9 -0
  304. package/src/lib/codec/types/CodecEncodeInput.ts +5 -0
  305. package/src/lib/codec/types/CodecEncodeResult.ts +6 -0
  306. package/src/lib/codec/types/CodecErrorInfo.ts +5 -0
  307. package/src/lib/codec/types/CodecModule.ts +3 -0
  308. package/src/lib/codec/types/CodecModuleConstructor.ts +3 -0
  309. package/src/lib/codec/types/CodecSchema.ts +7 -0
  310. package/src/lib/codec/types/HeaderTreeNode.ts +5 -0
  311. package/src/lib/codec/types/PostHandlerItem.ts +4 -0
  312. package/src/lib/nodepcap/Capture.ts +291 -0
  313. package/src/lib/nodepcap/GetNetworkInterfaces.ts +18 -0
  314. package/src/lib/nodepcap/interfaces/IBindingCapture.ts +27 -0
  315. package/src/lib/nodepcap/interfaces/IBindingCaptureOptions.ts +4 -0
  316. package/src/lib/nodepcap/interfaces/ICaptureOptions.ts +19 -0
  317. package/src/lib/nodepcap/interfaces/INetworkInterface.ts +4 -0
  318. package/src/lib/nodepcap/lib/BindingCapture.ts +46 -0
  319. package/src/lib/nodepcap/lib/GetNodePcapBinding.ts +17 -0
  320. package/src/lib/nodepcap/lib/GetNodePcapBindingCapture.ts +15 -0
  321. package/src/lib/nodepcap/workers/CaptureWorker.ts +30 -0
  322. package/src/lib/pcap/PCAPGenerator.ts +118 -0
  323. package/src/lib/pcap/PcapParser.ts +170 -0
  324. package/src/lib/pcap/PcapReader.ts +239 -0
  325. package/src/lib/pcap/PcapWriter.ts +93 -0
  326. package/src/lib/pcap/interfaces/IPcapPacketInfo.ts +12 -0
  327. package/src/lib/pipe/PipeClient.ts +91 -0
  328. package/src/lib/pipe/PipeClientSocket.ts +99 -0
  329. package/src/lib/pipe/PipeMessage.ts +74 -0
  330. package/src/lib/pipe/PipeMessageHandler.ts +91 -0
  331. package/src/lib/pipe/PipeServer.ts +74 -0
  332. package/src/lib/schema/ProtocolFieldJSONSchema.ts +45 -0
  333. package/src/lib/schema/ProtocolFieldJSONSchemaDefinition.ts +3 -0
  334. package/src/lib/schema/ProtocolJSONSchema.ts +37 -0
  335. package/src/tests/Test.spec.ts +22 -0
  336. package/src/tests/units/CaptureTest.spec.ts +30 -0
  337. package/src/tests/units/Codec.spec.ts +85 -0
  338. package/tsconfig.json +41 -0
@@ -0,0 +1,338 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.IPv4 = void 0;
4
+ const BaseHeader_1 = require("../abstracts/BaseHeader");
5
+ const NumberToHex_1 = require("../lib/NumberToHex");
6
+ const StringContentEncodingEnum_1 = require("../lib/StringContentEncodingEnum");
7
+ const FixHexString_1 = require("../lib/FixHexString");
8
+ const BufferToNumber_1 = require("../lib/BufferToNumber");
9
+ const NumberToBuffer_1 = require("../lib/NumberToBuffer");
10
+ const BufferToHex_1 = require("../lib/BufferToHex");
11
+ const IPToBuffer_1 = require("../lib/IPToBuffer");
12
+ const BufferToIP_1 = require("../lib/BufferToIP");
13
+ class IPv4 extends BaseHeader_1.BaseHeader {
14
+ constructor() {
15
+ super(...arguments);
16
+ this.SCHEMA = {
17
+ type: 'object',
18
+ properties: {
19
+ version: {
20
+ type: 'integer',
21
+ label: 'Version',
22
+ minimum: 0,
23
+ maximum: 15,
24
+ decode: () => {
25
+ this.instance.version.setValue(this.readBits(0, 1, 0, 4));
26
+ if (this.instance.version.getValue() !== 4)
27
+ this.recordError(this.instance.version.getPath(), 'IPv4 version should be 4');
28
+ },
29
+ encode: () => {
30
+ let version = this.instance.version.getValue(4);
31
+ version = version > 15 ? 15 : version;
32
+ version = version < 0 ? 0 : version;
33
+ if (version !== 4)
34
+ this.recordError(this.instance.version.getPath(), 'IPv4 version should be 4');
35
+ this.instance.version.setValue(version);
36
+ this.writeBits(0, 1, 0, 4, version);
37
+ }
38
+ },
39
+ hdrLen: {
40
+ type: 'integer',
41
+ label: 'Header Length',
42
+ minimum: 20,
43
+ maximum: 60,
44
+ decode: () => {
45
+ this.instance.hdrLen.setValue(this.readBits(0, 1, 4, 4) * 4);
46
+ },
47
+ encode: () => {
48
+ let headerLength = this.instance.hdrLen.getValue(0);
49
+ if (headerLength)
50
+ headerLength = headerLength ? Math.floor(headerLength / 4) : 0;
51
+ this.writeBits(0, 1, 4, 4, headerLength);
52
+ if (!headerLength)
53
+ this.addPostSelfEncodeHandler(() => {
54
+ this.instance.hdrLen.setValue(this.length);
55
+ this.writeBits(0, 1, 4, 4, Math.floor(this.length / 4));
56
+ }, 10);
57
+ }
58
+ },
59
+ dsfield: {
60
+ type: 'object',
61
+ label: 'Differentiated Services Field',
62
+ properties: {
63
+ dscp: {
64
+ type: 'integer',
65
+ minimum: 0,
66
+ maximum: 63,
67
+ label: 'Differentiated Services Codepoint',
68
+ decode: () => {
69
+ this.instance.dsfield.dscp.setValue(this.readBits(1, 1, 0, 6));
70
+ },
71
+ encode: () => {
72
+ const dscp = this.instance.dsfield.dscp.getValue(0);
73
+ this.instance.dsfield.dscp.setValue(dscp);
74
+ this.writeBits(1, 1, 0, 6, dscp);
75
+ }
76
+ },
77
+ ecn: {
78
+ type: 'integer',
79
+ label: 'Explicit Congestion Notification',
80
+ decode: () => {
81
+ this.instance.dsfield.ecn.setValue(this.readBits(1, 1, 6, 2));
82
+ },
83
+ encode: () => {
84
+ const ecn = this.instance.dsfield.ecn.getValue(0);
85
+ this.instance.dsfield.ecn.setValue(ecn);
86
+ this.writeBits(1, 1, 6, 2, ecn);
87
+ }
88
+ }
89
+ }
90
+ },
91
+ length: {
92
+ type: 'integer',
93
+ label: 'Total Length',
94
+ minimum: 0,
95
+ maximum: 65535,
96
+ decode: () => {
97
+ this.instance.length.setValue((0, BufferToNumber_1.BufferToUInt16)(this.readBytes(2, 2)));
98
+ },
99
+ encode: () => {
100
+ //This field's real value needs down stream codec invoke recode to fill
101
+ let length = this.instance.length.getValue(0);
102
+ if (length) {
103
+ this.writeBytes(2, (0, NumberToBuffer_1.UInt16ToBuffer)(length));
104
+ }
105
+ else {
106
+ this.writeBytes(2, (0, NumberToBuffer_1.UInt16ToBuffer)(length));
107
+ this.addPostPacketEncodeHandler(() => {
108
+ let startCount = false;
109
+ let totalLength = 0;
110
+ this.codecModules.forEach((codecModule) => {
111
+ if (codecModule === this)
112
+ startCount = true;
113
+ if (startCount)
114
+ totalLength += codecModule.length;
115
+ });
116
+ this.instance.length.setValue(totalLength);
117
+ this.writeBytes(2, (0, NumberToBuffer_1.UInt16ToBuffer)(totalLength));
118
+ }, 1);
119
+ }
120
+ }
121
+ },
122
+ id: {
123
+ type: 'integer',
124
+ label: 'Identification',
125
+ minimum: 0,
126
+ maximum: 65535,
127
+ decode: () => {
128
+ this.instance.id.setValue((0, BufferToNumber_1.BufferToUInt16)(this.readBytes(4, 2)));
129
+ },
130
+ encode: () => {
131
+ const id = this.instance.id.getValue(0, (nodePath) => this.recordError(nodePath, 'Not Found'));
132
+ this.instance.id.setValue(id);
133
+ this.writeBytes(4, (0, NumberToBuffer_1.UInt16ToBuffer)(id));
134
+ }
135
+ },
136
+ flags: {
137
+ type: 'object',
138
+ label: 'Flags',
139
+ properties: {
140
+ rb: {
141
+ type: 'integer',
142
+ enum: [0, 1],
143
+ label: 'Reserved bit',
144
+ decode: () => {
145
+ this.instance.flags.rb.setValue(this.readBits(6, 1, 0, 1));
146
+ },
147
+ encode: () => {
148
+ const rb = this.instance.flags.rb.getValue(0, (nodePath) => this.recordError(nodePath, 'Not Found'));
149
+ this.instance.flags.rb.setValue(rb);
150
+ this.writeBits(6, 1, 0, 1, rb);
151
+ }
152
+ },
153
+ df: {
154
+ type: 'integer',
155
+ enum: [0, 1],
156
+ label: 'Don\'t fragment',
157
+ decode: () => {
158
+ this.instance.flags.df.setValue(this.readBits(6, 1, 1, 1));
159
+ },
160
+ encode: () => {
161
+ const df = this.instance.flags.df.getValue(1, (nodePath) => this.recordError(nodePath, 'Not Found'));
162
+ this.instance.flags.df.setValue(df);
163
+ this.writeBits(6, 1, 1, 1, df);
164
+ }
165
+ },
166
+ mf: {
167
+ type: 'integer',
168
+ enum: [0, 1],
169
+ label: 'More fragments',
170
+ decode: () => {
171
+ this.instance.flags.mf.setValue(this.readBits(6, 1, 2, 1));
172
+ },
173
+ encode: () => {
174
+ const mf = this.instance.flags.mf.getValue(0, (nodePath) => this.recordError(nodePath, 'Not Found'));
175
+ this.instance.flags.mf.setValue(mf);
176
+ this.writeBits(6, 1, 2, 1, mf);
177
+ }
178
+ }
179
+ }
180
+ },
181
+ fragOffset: {
182
+ type: 'integer',
183
+ minimum: 0,
184
+ maximum: 8191,
185
+ label: 'Fragment Offset',
186
+ decode: () => {
187
+ this.instance.fragOffset.setValue(this.readBits(6, 2, 3, 13));
188
+ },
189
+ encode: () => {
190
+ const fragOffset = this.instance.fragOffset.getValue(0, (nodePath) => this.recordError(nodePath, 'Not Found'));
191
+ this.instance.fragOffset.setValue(fragOffset);
192
+ this.writeBits(6, 2, 3, 13, fragOffset);
193
+ }
194
+ },
195
+ ttl: {
196
+ type: 'integer',
197
+ minimum: 0,
198
+ maximum: 255,
199
+ label: 'Time to Live',
200
+ decode: () => {
201
+ this.instance.ttl.setValue((0, BufferToNumber_1.BufferToUInt8)(this.readBytes(8, 1)));
202
+ },
203
+ encode: () => {
204
+ const ttl = this.instance.ttl.getValue(0, (nodePath) => this.recordError(nodePath, 'Not Found'));
205
+ this.instance.ttl.setValue(ttl);
206
+ this.writeBytes(8, (0, NumberToBuffer_1.UInt8ToBuffer)(ttl));
207
+ }
208
+ },
209
+ protocol: {
210
+ type: 'integer',
211
+ label: 'Protocol',
212
+ minimum: 0,
213
+ maximum: 255,
214
+ decode: () => {
215
+ this.instance.protocol.setValue((0, BufferToNumber_1.BufferToUInt8)(this.readBytes(9, 1)));
216
+ },
217
+ encode: () => {
218
+ const protocol = this.instance.protocol.getValue(0, (nodePath) => this.recordError(nodePath, 'Not Found'));
219
+ this.instance.protocol.setValue(protocol);
220
+ this.writeBytes(9, (0, NumberToBuffer_1.UInt8ToBuffer)(protocol));
221
+ }
222
+ },
223
+ checksum: {
224
+ type: 'integer',
225
+ label: 'Header Checksum',
226
+ minimum: 0,
227
+ maximum: 65535,
228
+ decode: () => {
229
+ this.instance.checksum.setValue((0, BufferToNumber_1.BufferToUInt16)(this.readBytes(10, 2)));
230
+ },
231
+ encode: () => {
232
+ let checksum = this.instance.checksum.getValue(0);
233
+ checksum = checksum > 65535 ? 65535 : checksum;
234
+ checksum = checksum < 0 ? 0 : checksum;
235
+ if (checksum) {
236
+ this.instance.checksum.setValue(checksum);
237
+ this.writeBytes(10, (0, NumberToBuffer_1.UInt16ToBuffer)(checksum));
238
+ }
239
+ else {
240
+ this.instance.checksum.setValue(checksum);
241
+ this.writeBytes(10, (0, NumberToBuffer_1.UInt16ToBuffer)(checksum));
242
+ this.addPostPacketEncodeHandler(() => {
243
+ const calcChecksum = this.calculateIPv4Checksum(this.packet.subarray(this.startPos, this.endPos));
244
+ this.instance.checksum.setValue(calcChecksum);
245
+ this.writeBytes(10, (0, NumberToBuffer_1.UInt16ToBuffer)(calcChecksum));
246
+ }, 2);
247
+ }
248
+ }
249
+ },
250
+ sip: {
251
+ type: 'string',
252
+ label: 'Source Address',
253
+ minLength: 7,
254
+ maxLength: 15,
255
+ contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.UTF8,
256
+ decode: () => {
257
+ const sipBuffer = this.readBytes(12, 4);
258
+ this.instance.sip.setValue((0, BufferToIP_1.BufferToIPv4)(sipBuffer));
259
+ },
260
+ encode: () => {
261
+ const sipStr = this.instance.sip.getValue('0.0.0.0', (nodePath) => this.recordError(nodePath, 'Not Found'));
262
+ this.instance.sip.setValue(sipStr);
263
+ this.writeBytes(12, (0, IPToBuffer_1.IPv4ToBuffer)(sipStr));
264
+ }
265
+ },
266
+ dip: {
267
+ type: 'string',
268
+ minLength: 7,
269
+ maxLength: 15,
270
+ label: 'Destination Address',
271
+ contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.UTF8,
272
+ decode: () => {
273
+ const dipBuffer = this.readBytes(16, 4);
274
+ this.instance.dip.setValue((0, BufferToIP_1.BufferToIPv4)(dipBuffer));
275
+ },
276
+ encode: () => {
277
+ const dipStr = this.instance.dip.getValue('0.0.0.0', (nodePath) => this.recordError(nodePath, 'Not Found'));
278
+ this.instance.dip.setValue(dipStr);
279
+ this.writeBytes(16, (0, IPToBuffer_1.IPv4ToBuffer)(dipStr));
280
+ }
281
+ },
282
+ options: {
283
+ type: 'string',
284
+ label: 'Options',
285
+ minLength: 0,
286
+ maxLength: 40 * 2,
287
+ contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.HEX,
288
+ decode: () => {
289
+ if (this.length < (this.instance.hdrLen.getValue())) {
290
+ this.instance.options.setValue((0, BufferToHex_1.BufferToHex)(this.readBytes(this.length, (this.instance.hdrLen.getValue()) - this.length)));
291
+ }
292
+ },
293
+ encode: () => {
294
+ if (!this.instance.options.isUndefined()) {
295
+ let optionsBuffer = Buffer.from((0, FixHexString_1.FixHexString)(this.instance.options.getValue()), 'hex');
296
+ if (optionsBuffer.length > 40)
297
+ optionsBuffer = optionsBuffer.subarray(0, 40);
298
+ const estimateHdrLen = this.length + optionsBuffer.length;
299
+ if (estimateHdrLen % 4) {
300
+ /**
301
+ * IPv4 Header should have a length that a multiple of 32 bits
302
+ * @see https://learningnetwork.cisco.com/s/question/0D53i00000Kt6hHCAR/padding-field-on-ipv4-header
303
+ */
304
+ optionsBuffer = Buffer.concat([optionsBuffer, Buffer.from([0x00])]);
305
+ }
306
+ this.writeBytes(this.length, optionsBuffer);
307
+ }
308
+ }
309
+ }
310
+ }
311
+ };
312
+ this.id = 'ipv4';
313
+ this.name = 'Internet Protocol Version 4';
314
+ }
315
+ /**
316
+ * Calculate IPv4 header checksum
317
+ * @param headerBuffer
318
+ * @protected
319
+ */
320
+ calculateIPv4Checksum(headerBuffer) {
321
+ const header = Uint8Array.from(headerBuffer);
322
+ let sum = 0;
323
+ for (let i = 0; i < header.length; i += 2) {
324
+ let word = (header[i] << 8) + (header[i + 1] || 0);
325
+ sum += word;
326
+ }
327
+ while (sum >>> 16) {
328
+ sum = (sum & 0xFFFF) + (sum >>> 16);
329
+ }
330
+ return (~sum) & 0xFFFF;
331
+ }
332
+ match() {
333
+ if (!this.prevCodecModule)
334
+ return false;
335
+ return this.prevCodecModule.instance.etherType.getValue() === (0, NumberToHex_1.UInt16ToHex)(0x0800);
336
+ }
337
+ }
338
+ exports.IPv4 = IPv4;
@@ -0,0 +1,9 @@
1
+ import { ProtocolJSONSchema } from '../../schema/ProtocolJSONSchema';
2
+ import { BaseHeader } from '../abstracts/BaseHeader';
3
+ export declare class RawData extends BaseHeader {
4
+ readonly SCHEMA: ProtocolJSONSchema;
5
+ readonly id: string;
6
+ readonly name: string;
7
+ match(): boolean;
8
+ }
9
+ //# sourceMappingURL=RawData.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RawData.d.ts","sourceRoot":"","sources":["../../../../src/lib/codec/headers/RawData.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,kBAAkB,EAAC,MAAM,iCAAiC,CAAA;AAClE,OAAO,EAAC,UAAU,EAAC,MAAM,yBAAyB,CAAA;AAIlD,qBAAa,OAAQ,SAAQ,UAAU;IAEnC,SAAgB,MAAM,EAAE,kBAAkB,CAgBzC;IAED,SAAgB,EAAE,EAAE,MAAM,CAAQ;IAElC,SAAgB,IAAI,EAAE,MAAM,CAAa;IAElC,KAAK,IAAI,OAAO;CAI1B"}
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RawData = void 0;
4
+ const BaseHeader_1 = require("../abstracts/BaseHeader");
5
+ const StringContentEncodingEnum_1 = require("../lib/StringContentEncodingEnum");
6
+ const BufferToHex_1 = require("../lib/BufferToHex");
7
+ class RawData extends BaseHeader_1.BaseHeader {
8
+ constructor() {
9
+ super(...arguments);
10
+ this.SCHEMA = {
11
+ type: 'object',
12
+ properties: {
13
+ data: {
14
+ type: 'string',
15
+ label: 'Raw',
16
+ contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.HEX,
17
+ decode: () => {
18
+ const dataLength = this.packet.length - this.startPos;
19
+ this.instance.data.setValue((0, BufferToHex_1.BufferToHex)(this.readBytes(0, dataLength)));
20
+ },
21
+ encode: () => {
22
+ this.writeBytes(0, Buffer.from(this.instance.data.getValue().toString(), 'hex'));
23
+ }
24
+ }
25
+ }
26
+ };
27
+ this.id = 'raw';
28
+ this.name = 'Raw Data';
29
+ }
30
+ match() {
31
+ return !!this.prevCodecModule;
32
+ }
33
+ }
34
+ exports.RawData = RawData;
@@ -0,0 +1,15 @@
1
+ import { ProtocolJSONSchema } from '../../schema/ProtocolJSONSchema';
2
+ import { BaseHeader } from '../abstracts/BaseHeader';
3
+ export declare class TCP extends BaseHeader {
4
+ /**
5
+ * Calculate TCP Checksum
6
+ * @param tcpHeaderBuffer
7
+ * @protected
8
+ */
9
+ protected calculateTCPChecksum(tcpHeaderBuffer: Buffer): number;
10
+ SCHEMA: ProtocolJSONSchema;
11
+ id: string;
12
+ name: string;
13
+ match(): boolean;
14
+ }
15
+ //# sourceMappingURL=TCP.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TCP.d.ts","sourceRoot":"","sources":["../../../../src/lib/codec/headers/TCP.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,kBAAkB,EAAC,MAAM,iCAAiC,CAAA;AAClE,OAAO,EAAC,UAAU,EAAC,MAAM,yBAAyB,CAAA;AAkFlD,qBAAa,GAAI,SAAQ,UAAU;IAE/B;;;;OAIG;IACH,SAAS,CAAC,oBAAoB,CAAC,eAAe,EAAE,MAAM,GAAG,MAAM;IA6CxD,MAAM,EAAE,kBAAkB,CA+wBhC;IAEM,EAAE,EAAE,MAAM,CAAQ;IAElB,IAAI,EAAE,MAAM,CAAkC;IAE9C,KAAK,IAAI,OAAO;CAM1B"}