netkitty 0.0.34 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (428) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/README.md +91 -2
  3. package/README.zh-CN.md +89 -0
  4. package/dist/analysis.d.ts +4 -0
  5. package/dist/{CodecHeaderExports.js → analysis.js} +4 -1
  6. package/dist/capture.d.ts +5 -0
  7. package/dist/capture.js +21 -0
  8. package/dist/codec.d.ts +5 -0
  9. package/dist/codec.js +21 -0
  10. package/dist/iface.d.ts +4 -0
  11. package/dist/iface.js +20 -0
  12. package/dist/pcap.d.ts +10 -0
  13. package/dist/pcap.js +27 -0
  14. package/dist/replay.d.ts +5 -0
  15. package/dist/replay.js +21 -0
  16. package/package.json +65 -57
  17. package/.eslintrc.json +0 -53
  18. package/.idea/codeStyles/Project.xml +0 -18
  19. package/.idea/codeStyles/codeStyleConfig.xml +0 -5
  20. package/.idea/inspectionProfiles/Project_Default.xml +0 -11
  21. package/.idea/modules.xml +0 -8
  22. package/.idea/netkitty.iml +0 -12
  23. package/.idea/vcs.xml +0 -6
  24. package/assets/NetKitty.png +0 -0
  25. package/binding.gyp +0 -5
  26. package/cpp/nodepcap/deps/include/Packet32.h +0 -429
  27. package/cpp/nodepcap/deps/include/pcap/bluetooth.h +0 -56
  28. package/cpp/nodepcap/deps/include/pcap/bpf.h +0 -292
  29. package/cpp/nodepcap/deps/include/pcap/can_socketcan.h +0 -56
  30. package/cpp/nodepcap/deps/include/pcap/compiler-tests.h +0 -163
  31. package/cpp/nodepcap/deps/include/pcap/dlt.h +0 -1514
  32. package/cpp/nodepcap/deps/include/pcap/funcattrs.h +0 -325
  33. package/cpp/nodepcap/deps/include/pcap/ipnet.h +0 -43
  34. package/cpp/nodepcap/deps/include/pcap/namedb.h +0 -84
  35. package/cpp/nodepcap/deps/include/pcap/nflog.h +0 -94
  36. package/cpp/nodepcap/deps/include/pcap/pcap-inttypes.h +0 -101
  37. package/cpp/nodepcap/deps/include/pcap/pcap.h +0 -1219
  38. package/cpp/nodepcap/deps/include/pcap/sll.h +0 -149
  39. package/cpp/nodepcap/deps/include/pcap/socket.h +0 -84
  40. package/cpp/nodepcap/deps/include/pcap/usb.h +0 -143
  41. package/cpp/nodepcap/deps/include/pcap/vlan.h +0 -46
  42. package/cpp/nodepcap/deps/include/pcap-bpf.h +0 -45
  43. package/cpp/nodepcap/deps/include/pcap-namedb.h +0 -40
  44. package/cpp/nodepcap/deps/include/pcap.h +0 -43
  45. package/cpp/nodepcap/deps/lib/ARM64/Packet.lib +0 -0
  46. package/cpp/nodepcap/deps/lib/Packet.lib +0 -0
  47. package/cpp/nodepcap/deps/lib/wpcap.lib +0 -0
  48. package/cpp/nodepcap/deps/lib/x64/Packet.lib +0 -0
  49. package/cpp/nodepcap/deps/lib/x64/wpcap.lib +0 -0
  50. package/cpp/nodepcap/nodepcap.gypi +0 -104
  51. package/cpp/nodepcap/src/binding.cc +0 -14
  52. package/cpp/nodepcap/src/capture.cc +0 -400
  53. package/cpp/nodepcap/src/capture.h +0 -53
  54. package/cpp/nodepcap/src/utils.cc +0 -218
  55. package/cpp/nodepcap/src/utils.h +0 -13
  56. package/dist/CodecExports.d.ts +0 -34
  57. package/dist/CodecExports.d.ts.map +0 -1
  58. package/dist/CodecExports.js +0 -23
  59. package/dist/CodecHeaderExports.d.ts +0 -2
  60. package/dist/CodecHeaderExports.d.ts.map +0 -1
  61. package/dist/HelperExports.d.ts +0 -11
  62. package/dist/HelperExports.d.ts.map +0 -1
  63. package/dist/HelperExports.js +0 -72
  64. package/dist/NetworkExports.d.ts +0 -13
  65. package/dist/NetworkExports.d.ts.map +0 -1
  66. package/dist/NetworkExports.js +0 -13
  67. package/dist/PcapExports.d.ts +0 -30
  68. package/dist/PcapExports.d.ts.map +0 -1
  69. package/dist/PcapExports.js +0 -33
  70. package/dist/errors/ActionNotFoundError.d.ts +0 -5
  71. package/dist/errors/ActionNotFoundError.d.ts.map +0 -1
  72. package/dist/errors/ActionNotFoundError.js +0 -12
  73. package/dist/errors/CodecSchemaValidateError.d.ts +0 -5
  74. package/dist/errors/CodecSchemaValidateError.d.ts.map +0 -1
  75. package/dist/errors/CodecSchemaValidateError.js +0 -12
  76. package/dist/errors/DeviceNotFoundError.d.ts +0 -5
  77. package/dist/errors/DeviceNotFoundError.d.ts.map +0 -1
  78. package/dist/errors/DeviceNotFoundError.js +0 -12
  79. package/dist/errors/NoAvailableCodecError.d.ts +0 -5
  80. package/dist/errors/NoAvailableCodecError.d.ts.map +0 -1
  81. package/dist/errors/NoAvailableCodecError.js +0 -12
  82. package/dist/errors/NpcapLoadError.d.ts +0 -5
  83. package/dist/errors/NpcapLoadError.d.ts.map +0 -1
  84. package/dist/errors/NpcapLoadError.js +0 -12
  85. package/dist/errors/SocketDownError.d.ts +0 -5
  86. package/dist/errors/SocketDownError.d.ts.map +0 -1
  87. package/dist/errors/SocketDownError.js +0 -12
  88. package/dist/errors/UnknownPipeMessageTypeError.d.ts +0 -5
  89. package/dist/errors/UnknownPipeMessageTypeError.d.ts.map +0 -1
  90. package/dist/errors/UnknownPipeMessageTypeError.js +0 -12
  91. package/dist/errors/common/ErrorCode.d.ts +0 -31
  92. package/dist/errors/common/ErrorCode.d.ts.map +0 -1
  93. package/dist/errors/common/ErrorCode.js +0 -33
  94. package/dist/lib/GeneratePipeAddress.d.ts +0 -7
  95. package/dist/lib/GeneratePipeAddress.d.ts.map +0 -1
  96. package/dist/lib/GeneratePipeAddress.js +0 -23
  97. package/dist/lib/GetBinding.d.ts +0 -2
  98. package/dist/lib/GetBinding.d.ts.map +0 -1
  99. package/dist/lib/GetBinding.js +0 -6
  100. package/dist/lib/GetCaptureTemporaryDirectory.d.ts +0 -7
  101. package/dist/lib/GetCaptureTemporaryDirectory.d.ts.map +0 -1
  102. package/dist/lib/GetCaptureTemporaryDirectory.js +0 -15
  103. package/dist/lib/GetDeviceCaptureTemporaryFilename.d.ts +0 -8
  104. package/dist/lib/GetDeviceCaptureTemporaryFilename.d.ts.map +0 -1
  105. package/dist/lib/GetDeviceCaptureTemporaryFilename.js +0 -18
  106. package/dist/lib/codec/Codec.d.ts +0 -32
  107. package/dist/lib/codec/Codec.d.ts.map +0 -1
  108. package/dist/lib/codec/Codec.js +0 -183
  109. package/dist/lib/codec/PacketHeaders.d.ts +0 -22
  110. package/dist/lib/codec/PacketHeaders.d.ts.map +0 -1
  111. package/dist/lib/codec/PacketHeaders.js +0 -47
  112. package/dist/lib/codec/abstracts/BaseHeader.d.ts +0 -217
  113. package/dist/lib/codec/abstracts/BaseHeader.d.ts.map +0 -1
  114. package/dist/lib/codec/abstracts/BaseHeader.js +0 -356
  115. package/dist/lib/codec/headers/ARP.d.ts +0 -10
  116. package/dist/lib/codec/headers/ARP.d.ts.map +0 -1
  117. package/dist/lib/codec/headers/ARP.js +0 -224
  118. package/dist/lib/codec/headers/EthernetII.d.ts +0 -10
  119. package/dist/lib/codec/headers/EthernetII.d.ts.map +0 -1
  120. package/dist/lib/codec/headers/EthernetII.js +0 -81
  121. package/dist/lib/codec/headers/Goose.d.ts +0 -104
  122. package/dist/lib/codec/headers/Goose.d.ts.map +0 -1
  123. package/dist/lib/codec/headers/Goose.js +0 -975
  124. package/dist/lib/codec/headers/ICMP.d.ts +0 -15
  125. package/dist/lib/codec/headers/ICMP.d.ts.map +0 -1
  126. package/dist/lib/codec/headers/ICMP.js +0 -147
  127. package/dist/lib/codec/headers/ICMPv6.d.ts +0 -15
  128. package/dist/lib/codec/headers/ICMPv6.d.ts.map +0 -1
  129. package/dist/lib/codec/headers/ICMPv6.js +0 -128
  130. package/dist/lib/codec/headers/IEC104_I_Frame.d.ts +0 -10
  131. package/dist/lib/codec/headers/IEC104_I_Frame.d.ts.map +0 -1
  132. package/dist/lib/codec/headers/IEC104_I_Frame.js +0 -6411
  133. package/dist/lib/codec/headers/IEC104_S_Frame.d.ts +0 -10
  134. package/dist/lib/codec/headers/IEC104_S_Frame.d.ts.map +0 -1
  135. package/dist/lib/codec/headers/IEC104_S_Frame.js +0 -105
  136. package/dist/lib/codec/headers/IEC104_U_Frame.d.ts +0 -10
  137. package/dist/lib/codec/headers/IEC104_U_Frame.d.ts.map +0 -1
  138. package/dist/lib/codec/headers/IEC104_U_Frame.js +0 -155
  139. package/dist/lib/codec/headers/IEC61850SampledValues.d.ts +0 -13
  140. package/dist/lib/codec/headers/IEC61850SampledValues.d.ts.map +0 -1
  141. package/dist/lib/codec/headers/IEC61850SampledValues.js +0 -370
  142. package/dist/lib/codec/headers/IPv4.d.ts +0 -16
  143. package/dist/lib/codec/headers/IPv4.d.ts.map +0 -1
  144. package/dist/lib/codec/headers/IPv4.js +0 -339
  145. package/dist/lib/codec/headers/IPv6.d.ts +0 -10
  146. package/dist/lib/codec/headers/IPv6.d.ts.map +0 -1
  147. package/dist/lib/codec/headers/IPv6.js +0 -177
  148. package/dist/lib/codec/headers/IPv6HopByHopOptions.d.ts +0 -71
  149. package/dist/lib/codec/headers/IPv6HopByHopOptions.d.ts.map +0 -1
  150. package/dist/lib/codec/headers/IPv6HopByHopOptions.js +0 -497
  151. package/dist/lib/codec/headers/RawData.d.ts +0 -11
  152. package/dist/lib/codec/headers/RawData.d.ts.map +0 -1
  153. package/dist/lib/codec/headers/RawData.js +0 -36
  154. package/dist/lib/codec/headers/TCP.d.ts +0 -16
  155. package/dist/lib/codec/headers/TCP.d.ts.map +0 -1
  156. package/dist/lib/codec/headers/TCP.js +0 -899
  157. package/dist/lib/codec/headers/TLS_Alert.d.ts +0 -10
  158. package/dist/lib/codec/headers/TLS_Alert.d.ts.map +0 -1
  159. package/dist/lib/codec/headers/TLS_Alert.js +0 -624
  160. package/dist/lib/codec/headers/TLS_ApplicationData.d.ts +0 -10
  161. package/dist/lib/codec/headers/TLS_ApplicationData.d.ts.map +0 -1
  162. package/dist/lib/codec/headers/TLS_ApplicationData.js +0 -155
  163. package/dist/lib/codec/headers/TLS_ChangeCipherSpec.d.ts +0 -10
  164. package/dist/lib/codec/headers/TLS_ChangeCipherSpec.d.ts.map +0 -1
  165. package/dist/lib/codec/headers/TLS_ChangeCipherSpec.js +0 -154
  166. package/dist/lib/codec/headers/TLS_Handshake.d.ts +0 -10
  167. package/dist/lib/codec/headers/TLS_Handshake.d.ts.map +0 -1
  168. package/dist/lib/codec/headers/TLS_Handshake.js +0 -339
  169. package/dist/lib/codec/headers/TLS_Heartbeat.d.ts +0 -10
  170. package/dist/lib/codec/headers/TLS_Heartbeat.d.ts.map +0 -1
  171. package/dist/lib/codec/headers/TLS_Heartbeat.js +0 -206
  172. package/dist/lib/codec/headers/UDP.d.ts +0 -16
  173. package/dist/lib/codec/headers/UDP.d.ts.map +0 -1
  174. package/dist/lib/codec/headers/UDP.js +0 -192
  175. package/dist/lib/codec/headers/VLAN_802dot1Q.d.ts +0 -10
  176. package/dist/lib/codec/headers/VLAN_802dot1Q.d.ts.map +0 -1
  177. package/dist/lib/codec/headers/VLAN_802dot1Q.js +0 -82
  178. package/dist/lib/codec/lib/FlexibleObject.d.ts +0 -28
  179. package/dist/lib/codec/lib/FlexibleObject.d.ts.map +0 -1
  180. package/dist/lib/codec/lib/FlexibleObject.js +0 -102
  181. package/dist/lib/codec/lib/GetBERIntegerLengthFromBuffer.d.ts +0 -7
  182. package/dist/lib/codec/lib/GetBERIntegerLengthFromBuffer.d.ts.map +0 -1
  183. package/dist/lib/codec/lib/GetBERIntegerLengthFromBuffer.js +0 -16
  184. package/dist/lib/codec/lib/ProcessPacketPostHandlers.d.ts +0 -14
  185. package/dist/lib/codec/lib/ProcessPacketPostHandlers.d.ts.map +0 -1
  186. package/dist/lib/codec/lib/ProcessPacketPostHandlers.js +0 -53
  187. package/dist/lib/codec/lib/SortPostHandlers.d.ts +0 -8
  188. package/dist/lib/codec/lib/SortPostHandlers.d.ts.map +0 -1
  189. package/dist/lib/codec/lib/SortPostHandlers.js +0 -11
  190. package/dist/lib/codec/lib/StringContentEncodingEnum.d.ts +0 -11
  191. package/dist/lib/codec/lib/StringContentEncodingEnum.d.ts.map +0 -1
  192. package/dist/lib/codec/lib/StringContentEncodingEnum.js +0 -14
  193. package/dist/lib/codec/types/CodecData.d.ts +0 -7
  194. package/dist/lib/codec/types/CodecData.d.ts.map +0 -1
  195. package/dist/lib/codec/types/CodecData.js +0 -2
  196. package/dist/lib/codec/types/CodecDecodeResult.d.ts +0 -11
  197. package/dist/lib/codec/types/CodecDecodeResult.d.ts.map +0 -1
  198. package/dist/lib/codec/types/CodecDecodeResult.js +0 -2
  199. package/dist/lib/codec/types/CodecEncodeInput.d.ts +0 -9
  200. package/dist/lib/codec/types/CodecEncodeInput.d.ts.map +0 -1
  201. package/dist/lib/codec/types/CodecEncodeInput.js +0 -2
  202. package/dist/lib/codec/types/CodecEncodeResult.d.ts +0 -6
  203. package/dist/lib/codec/types/CodecEncodeResult.d.ts.map +0 -1
  204. package/dist/lib/codec/types/CodecEncodeResult.js +0 -2
  205. package/dist/lib/codec/types/CodecErrorInfo.d.ts +0 -6
  206. package/dist/lib/codec/types/CodecErrorInfo.d.ts.map +0 -1
  207. package/dist/lib/codec/types/CodecErrorInfo.js +0 -2
  208. package/dist/lib/codec/types/CodecModule.d.ts +0 -3
  209. package/dist/lib/codec/types/CodecModule.d.ts.map +0 -1
  210. package/dist/lib/codec/types/CodecModule.js +0 -2
  211. package/dist/lib/codec/types/CodecModuleConstructor.d.ts +0 -3
  212. package/dist/lib/codec/types/CodecModuleConstructor.d.ts.map +0 -1
  213. package/dist/lib/codec/types/CodecModuleConstructor.js +0 -2
  214. package/dist/lib/codec/types/CodecSchema.d.ts +0 -7
  215. package/dist/lib/codec/types/CodecSchema.d.ts.map +0 -1
  216. package/dist/lib/codec/types/CodecSchema.js +0 -2
  217. package/dist/lib/codec/types/HeaderTreeNode.d.ts +0 -5
  218. package/dist/lib/codec/types/HeaderTreeNode.d.ts.map +0 -1
  219. package/dist/lib/codec/types/HeaderTreeNode.js +0 -2
  220. package/dist/lib/codec/types/PostHandlerItem.d.ts +0 -5
  221. package/dist/lib/codec/types/PostHandlerItem.d.ts.map +0 -1
  222. package/dist/lib/codec/types/PostHandlerItem.js +0 -2
  223. package/dist/lib/helper/BufferToHex.d.ts +0 -2
  224. package/dist/lib/helper/BufferToHex.d.ts.map +0 -1
  225. package/dist/lib/helper/BufferToHex.js +0 -6
  226. package/dist/lib/helper/BufferToIP.d.ts +0 -13
  227. package/dist/lib/helper/BufferToIP.d.ts.map +0 -1
  228. package/dist/lib/helper/BufferToIP.js +0 -21
  229. package/dist/lib/helper/BufferToNumber.d.ts +0 -10
  230. package/dist/lib/helper/BufferToNumber.d.ts.map +0 -1
  231. package/dist/lib/helper/BufferToNumber.js +0 -22
  232. package/dist/lib/helper/HexToBuffer.d.ts +0 -8
  233. package/dist/lib/helper/HexToBuffer.d.ts.map +0 -1
  234. package/dist/lib/helper/HexToBuffer.js +0 -27
  235. package/dist/lib/helper/HexToNumber.d.ts +0 -10
  236. package/dist/lib/helper/HexToNumber.d.ts.map +0 -1
  237. package/dist/lib/helper/HexToNumber.js +0 -39
  238. package/dist/lib/helper/IPToBuffer.d.ts +0 -13
  239. package/dist/lib/helper/IPToBuffer.d.ts.map +0 -1
  240. package/dist/lib/helper/IPToBuffer.js +0 -28
  241. package/dist/lib/helper/NumberToBERBuffer.d.ts +0 -10
  242. package/dist/lib/helper/NumberToBERBuffer.d.ts.map +0 -1
  243. package/dist/lib/helper/NumberToBERBuffer.js +0 -22
  244. package/dist/lib/helper/NumberToBERHex.d.ts +0 -10
  245. package/dist/lib/helper/NumberToBERHex.d.ts.map +0 -1
  246. package/dist/lib/helper/NumberToBERHex.js +0 -27
  247. package/dist/lib/helper/NumberToBuffer.d.ts +0 -10
  248. package/dist/lib/helper/NumberToBuffer.d.ts.map +0 -1
  249. package/dist/lib/helper/NumberToBuffer.js +0 -22
  250. package/dist/lib/helper/NumberToHex.d.ts +0 -10
  251. package/dist/lib/helper/NumberToHex.d.ts.map +0 -1
  252. package/dist/lib/helper/NumberToHex.js +0 -26
  253. package/dist/lib/nodepcap/Capture.d.ts +0 -81
  254. package/dist/lib/nodepcap/Capture.d.ts.map +0 -1
  255. package/dist/lib/nodepcap/Capture.js +0 -323
  256. package/dist/lib/nodepcap/GetNetworkInterfaces.d.ts +0 -7
  257. package/dist/lib/nodepcap/GetNetworkInterfaces.d.ts.map +0 -1
  258. package/dist/lib/nodepcap/GetNetworkInterfaces.js +0 -22
  259. package/dist/lib/nodepcap/interfaces/IBindingCapture.d.ts +0 -16
  260. package/dist/lib/nodepcap/interfaces/IBindingCapture.d.ts.map +0 -1
  261. package/dist/lib/nodepcap/interfaces/IBindingCapture.js +0 -2
  262. package/dist/lib/nodepcap/interfaces/IBindingCaptureOptions.d.ts +0 -5
  263. package/dist/lib/nodepcap/interfaces/IBindingCaptureOptions.d.ts.map +0 -1
  264. package/dist/lib/nodepcap/interfaces/IBindingCaptureOptions.js +0 -2
  265. package/dist/lib/nodepcap/interfaces/ICaptureOptions.d.ts +0 -23
  266. package/dist/lib/nodepcap/interfaces/ICaptureOptions.d.ts.map +0 -1
  267. package/dist/lib/nodepcap/interfaces/ICaptureOptions.js +0 -2
  268. package/dist/lib/nodepcap/interfaces/INetworkInterface.d.ts +0 -5
  269. package/dist/lib/nodepcap/interfaces/INetworkInterface.d.ts.map +0 -1
  270. package/dist/lib/nodepcap/interfaces/INetworkInterface.js +0 -2
  271. package/dist/lib/nodepcap/lib/BindingCapture.d.ts +0 -15
  272. package/dist/lib/nodepcap/lib/BindingCapture.d.ts.map +0 -1
  273. package/dist/lib/nodepcap/lib/BindingCapture.js +0 -35
  274. package/dist/lib/nodepcap/lib/GetNodePcapBinding.d.ts +0 -2
  275. package/dist/lib/nodepcap/lib/GetNodePcapBinding.d.ts.map +0 -1
  276. package/dist/lib/nodepcap/lib/GetNodePcapBinding.js +0 -55
  277. package/dist/lib/nodepcap/lib/GetNodePcapBindingCapture.d.ts +0 -3
  278. package/dist/lib/nodepcap/lib/GetNodePcapBindingCapture.d.ts.map +0 -1
  279. package/dist/lib/nodepcap/lib/GetNodePcapBindingCapture.js +0 -18
  280. package/dist/lib/nodepcap/workers/CaptureWorker.d.ts +0 -2
  281. package/dist/lib/nodepcap/workers/CaptureWorker.d.ts.map +0 -1
  282. package/dist/lib/nodepcap/workers/CaptureWorker.js +0 -25
  283. package/dist/lib/pcap/PCAPGenerator.d.ts +0 -34
  284. package/dist/lib/pcap/PCAPGenerator.d.ts.map +0 -1
  285. package/dist/lib/pcap/PCAPGenerator.js +0 -101
  286. package/dist/lib/pcap/PcapParser.d.ts +0 -27
  287. package/dist/lib/pcap/PcapParser.d.ts.map +0 -1
  288. package/dist/lib/pcap/PcapParser.js +0 -149
  289. package/dist/lib/pcap/PcapReader.d.ts +0 -112
  290. package/dist/lib/pcap/PcapReader.d.ts.map +0 -1
  291. package/dist/lib/pcap/PcapReader.js +0 -263
  292. package/dist/lib/pcap/PcapWriter.d.ts +0 -29
  293. package/dist/lib/pcap/PcapWriter.d.ts.map +0 -1
  294. package/dist/lib/pcap/PcapWriter.js +0 -86
  295. package/dist/lib/pcap/interfaces/IPcapPacketInfo.d.ts +0 -13
  296. package/dist/lib/pcap/interfaces/IPcapPacketInfo.d.ts.map +0 -1
  297. package/dist/lib/pcap/interfaces/IPcapPacketInfo.js +0 -2
  298. package/dist/lib/pipe/PipeClient.d.ts +0 -35
  299. package/dist/lib/pipe/PipeClient.d.ts.map +0 -1
  300. package/dist/lib/pipe/PipeClient.js +0 -71
  301. package/dist/lib/pipe/PipeClientSocket.d.ts +0 -39
  302. package/dist/lib/pipe/PipeClientSocket.d.ts.map +0 -1
  303. package/dist/lib/pipe/PipeClientSocket.js +0 -82
  304. package/dist/lib/pipe/PipeMessage.d.ts +0 -27
  305. package/dist/lib/pipe/PipeMessage.d.ts.map +0 -1
  306. package/dist/lib/pipe/PipeMessage.js +0 -61
  307. package/dist/lib/pipe/PipeMessageHandler.d.ts +0 -16
  308. package/dist/lib/pipe/PipeMessageHandler.d.ts.map +0 -1
  309. package/dist/lib/pipe/PipeMessageHandler.js +0 -95
  310. package/dist/lib/pipe/PipeServer.d.ts +0 -25
  311. package/dist/lib/pipe/PipeServer.d.ts.map +0 -1
  312. package/dist/lib/pipe/PipeServer.js +0 -59
  313. package/dist/lib/schema/ProtocolFieldJSONSchema.d.ts +0 -35
  314. package/dist/lib/schema/ProtocolFieldJSONSchema.d.ts.map +0 -1
  315. package/dist/lib/schema/ProtocolFieldJSONSchema.js +0 -2
  316. package/dist/lib/schema/ProtocolFieldJSONSchemaDefinition.d.ts +0 -3
  317. package/dist/lib/schema/ProtocolFieldJSONSchemaDefinition.d.ts.map +0 -1
  318. package/dist/lib/schema/ProtocolFieldJSONSchemaDefinition.js +0 -2
  319. package/dist/lib/schema/ProtocolJSONSchema.d.ts +0 -32
  320. package/dist/lib/schema/ProtocolJSONSchema.d.ts.map +0 -1
  321. package/dist/lib/schema/ProtocolJSONSchema.js +0 -2
  322. package/dist/tests/Test.spec.d.ts +0 -2
  323. package/dist/tests/Test.spec.d.ts.map +0 -1
  324. package/dist/tests/Test.spec.js +0 -25
  325. package/dist/tests/units/CaptureTest.spec.d.ts +0 -2
  326. package/dist/tests/units/CaptureTest.spec.d.ts.map +0 -1
  327. package/dist/tests/units/CaptureTest.spec.js +0 -32
  328. package/dist/tests/units/Codec.spec.d.ts +0 -2
  329. package/dist/tests/units/Codec.spec.d.ts.map +0 -1
  330. package/dist/tests/units/Codec.spec.js +0 -86
  331. package/dist/tests/units/ReadPCAP.spec.d.ts +0 -2
  332. package/dist/tests/units/ReadPCAP.spec.d.ts.map +0 -1
  333. package/dist/tests/units/ReadPCAP.spec.js +0 -14
  334. package/src/CodecExports.ts +0 -33
  335. package/src/CodecHeaderExports.ts +0 -1
  336. package/src/HelperExports.ts +0 -78
  337. package/src/NetworkExports.ts +0 -12
  338. package/src/PcapExports.ts +0 -32
  339. package/src/errors/ActionNotFoundError.ts +0 -6
  340. package/src/errors/CodecSchemaValidateError.ts +0 -6
  341. package/src/errors/DeviceNotFoundError.ts +0 -6
  342. package/src/errors/NoAvailableCodecError.ts +0 -6
  343. package/src/errors/NpcapLoadError.ts +0 -6
  344. package/src/errors/SocketDownError.ts +0 -6
  345. package/src/errors/UnknownPipeMessageTypeError.ts +0 -6
  346. package/src/errors/common/ErrorCode.ts +0 -30
  347. package/src/lib/GeneratePipeAddress.ts +0 -17
  348. package/src/lib/GetBinding.ts +0 -3
  349. package/src/lib/GetCaptureTemporaryDirectory.ts +0 -12
  350. package/src/lib/GetDeviceCaptureTemporaryFilename.ts +0 -13
  351. package/src/lib/codec/Codec.ts +0 -164
  352. package/src/lib/codec/PacketHeaders.ts +0 -23
  353. package/src/lib/codec/abstracts/BaseHeader.ts +0 -435
  354. package/src/lib/codec/headers/ARP.ts +0 -220
  355. package/src/lib/codec/headers/EthernetII.ts +0 -79
  356. package/src/lib/codec/headers/Goose.ts +0 -1003
  357. package/src/lib/codec/headers/ICMP.ts +0 -151
  358. package/src/lib/codec/headers/ICMPv6.ts +0 -128
  359. package/src/lib/codec/headers/IEC104_I_Frame.ts +0 -7373
  360. package/src/lib/codec/headers/IEC104_S_Frame.ts +0 -97
  361. package/src/lib/codec/headers/IEC104_U_Frame.ts +0 -139
  362. package/src/lib/codec/headers/IEC61850SampledValues.ts +0 -361
  363. package/src/lib/codec/headers/IPv4.ts +0 -331
  364. package/src/lib/codec/headers/IPv6.ts +0 -176
  365. package/src/lib/codec/headers/IPv6HopByHopOptions.ts +0 -532
  366. package/src/lib/codec/headers/RawData.ts +0 -38
  367. package/src/lib/codec/headers/TCP.ts +0 -934
  368. package/src/lib/codec/headers/TLS_Alert.ts +0 -539
  369. package/src/lib/codec/headers/TLS_ApplicationData.ts +0 -145
  370. package/src/lib/codec/headers/TLS_ChangeCipherSpec.ts +0 -146
  371. package/src/lib/codec/headers/TLS_Handshake.ts +0 -313
  372. package/src/lib/codec/headers/TLS_Heartbeat.ts +0 -188
  373. package/src/lib/codec/headers/UDP.ts +0 -182
  374. package/src/lib/codec/headers/VLAN_802dot1Q.ts +0 -79
  375. package/src/lib/codec/lib/FlexibleObject.ts +0 -100
  376. package/src/lib/codec/lib/GetBERIntegerLengthFromBuffer.ts +0 -12
  377. package/src/lib/codec/lib/ProcessPacketPostHandlers.ts +0 -53
  378. package/src/lib/codec/lib/SortPostHandlers.ts +0 -10
  379. package/src/lib/codec/lib/StringContentEncodingEnum.ts +0 -10
  380. package/src/lib/codec/types/CodecData.ts +0 -7
  381. package/src/lib/codec/types/CodecDecodeResult.ts +0 -11
  382. package/src/lib/codec/types/CodecEncodeInput.ts +0 -9
  383. package/src/lib/codec/types/CodecEncodeResult.ts +0 -6
  384. package/src/lib/codec/types/CodecErrorInfo.ts +0 -5
  385. package/src/lib/codec/types/CodecModule.ts +0 -3
  386. package/src/lib/codec/types/CodecModuleConstructor.ts +0 -3
  387. package/src/lib/codec/types/CodecSchema.ts +0 -7
  388. package/src/lib/codec/types/HeaderTreeNode.ts +0 -5
  389. package/src/lib/codec/types/PostHandlerItem.ts +0 -4
  390. package/src/lib/helper/BufferToHex.ts +0 -3
  391. package/src/lib/helper/BufferToIP.ts +0 -19
  392. package/src/lib/helper/BufferToNumber.ts +0 -31
  393. package/src/lib/helper/HexToBuffer.ts +0 -22
  394. package/src/lib/helper/HexToNumber.ts +0 -25
  395. package/src/lib/helper/IPToBuffer.ts +0 -25
  396. package/src/lib/helper/NumberToBERBuffer.ts +0 -21
  397. package/src/lib/helper/NumberToBERHex.ts +0 -17
  398. package/src/lib/helper/NumberToBuffer.ts +0 -21
  399. package/src/lib/helper/NumberToHex.ts +0 -15
  400. package/src/lib/nodepcap/Capture.ts +0 -304
  401. package/src/lib/nodepcap/GetNetworkInterfaces.ts +0 -18
  402. package/src/lib/nodepcap/interfaces/IBindingCapture.ts +0 -27
  403. package/src/lib/nodepcap/interfaces/IBindingCaptureOptions.ts +0 -4
  404. package/src/lib/nodepcap/interfaces/ICaptureOptions.ts +0 -24
  405. package/src/lib/nodepcap/interfaces/INetworkInterface.ts +0 -4
  406. package/src/lib/nodepcap/lib/BindingCapture.ts +0 -46
  407. package/src/lib/nodepcap/lib/GetNodePcapBinding.ts +0 -17
  408. package/src/lib/nodepcap/lib/GetNodePcapBindingCapture.ts +0 -15
  409. package/src/lib/nodepcap/workers/CaptureWorker.ts +0 -30
  410. package/src/lib/pcap/PCAPGenerator.ts +0 -123
  411. package/src/lib/pcap/PcapParser.ts +0 -170
  412. package/src/lib/pcap/PcapReader.ts +0 -306
  413. package/src/lib/pcap/PcapWriter.ts +0 -98
  414. package/src/lib/pcap/interfaces/IPcapPacketInfo.ts +0 -12
  415. package/src/lib/pipe/PipeClient.ts +0 -91
  416. package/src/lib/pipe/PipeClientSocket.ts +0 -99
  417. package/src/lib/pipe/PipeMessage.ts +0 -74
  418. package/src/lib/pipe/PipeMessageHandler.ts +0 -91
  419. package/src/lib/pipe/PipeServer.ts +0 -74
  420. package/src/lib/schema/ProtocolFieldJSONSchema.ts +0 -45
  421. package/src/lib/schema/ProtocolFieldJSONSchemaDefinition.ts +0 -3
  422. package/src/lib/schema/ProtocolJSONSchema.ts +0 -37
  423. package/src/tests/Test.spec.ts +0 -22
  424. package/src/tests/units/CaptureTest.spec.ts +0 -31
  425. package/src/tests/units/Codec.spec.ts +0 -102
  426. package/src/tests/units/ReadPCAP.spec.ts +0 -13
  427. package/test.pcap +0 -0
  428. package/tsconfig.json +0 -42
@@ -1,182 +0,0 @@
1
- import {ProtocolJSONSchema} from '../../schema/ProtocolJSONSchema'
2
- import {BaseHeader} from '../abstracts/BaseHeader'
3
- import {BufferToUInt16} from '../../helper/BufferToNumber'
4
- import {UInt16ToBuffer, UInt8ToBuffer} from '../../helper/NumberToBuffer'
5
- import {IPv6ToBuffer} from '../../helper/IPToBuffer'
6
- import {CodecModule} from '../types/CodecModule'
7
-
8
- export class UDP extends BaseHeader {
9
-
10
- /**
11
- * Calculate UDP Checksum
12
- * @protected
13
- * @param udpHeaderBuffer
14
- */
15
- protected calculateUDPChecksum(udpHeaderBuffer: Buffer): number {
16
- const udpHeaderLength: number = udpHeaderBuffer.length
17
- const ipVersion: number = this.prevCodecModule.instance.version.getValue()
18
- let pseudoHeaderBuffer: Buffer = Buffer.from([])
19
- const sourceIp: string = this.prevCodecModule.instance.sip.getValue()
20
- const destinationIp: string = this.prevCodecModule.instance.dip.getValue()
21
- if (ipVersion === 4) {
22
- //4 Bytes
23
- const sourceIPv4Buffer: Buffer = Buffer.from(sourceIp.split('.').map((value: string): number => parseInt(value)))
24
- const destinationIPv4Buffer: Buffer = Buffer.from(destinationIp.split('.').map((value: string): number => parseInt(value)))
25
- //IPv4 Pseudo header
26
- pseudoHeaderBuffer = Buffer.concat([
27
- sourceIPv4Buffer,
28
- destinationIPv4Buffer,
29
- UInt8ToBuffer(0), //Reserved field
30
- UInt8ToBuffer(17), //Protocol type (UDP = 17)
31
- Buffer.from([(udpHeaderLength >> 8) & 0xFF]),
32
- Buffer.from([udpHeaderLength & 0xFF])
33
- ])
34
- } else if (ipVersion === 6) {
35
- //16 Bytes
36
- const sourceIPv6Buffer: Buffer = IPv6ToBuffer(sourceIp)
37
- const destinationIPv6Buffer: Buffer = IPv6ToBuffer(destinationIp)
38
- //IPv6 Pseudo header
39
- pseudoHeaderBuffer = Buffer.concat([
40
- sourceIPv6Buffer,
41
- destinationIPv6Buffer,
42
- UInt8ToBuffer(0), //Reserved field
43
- UInt8ToBuffer(0), //Reserved field
44
- UInt8ToBuffer(0), //Reserved field
45
- UInt8ToBuffer(17), //Protocol type (UDP = 17)
46
- Buffer.from([(udpHeaderLength >> 8) & 0xFF]),
47
- Buffer.from([udpHeaderLength & 0xFF])
48
- ])
49
- } else {
50
- return 0
51
- }
52
- let dataBuffer: Buffer = Buffer.concat([pseudoHeaderBuffer, udpHeaderBuffer])
53
- if (dataBuffer.length % 2) dataBuffer = Buffer.concat([dataBuffer, Buffer.from('00', 'hex')])
54
- const data: Uint8Array = Uint8Array.from(dataBuffer)
55
- let sum: number = 0
56
- for (let i: number = 0; i < data.length; i += 2) sum += (data[i] << 8) + (data[i + 1] || 0)
57
- while (sum > 0xFFFF) sum = (sum & 0xFFFF) + (sum >>> 16)
58
- return (~sum) & 0xFFFF
59
- }
60
-
61
- public SCHEMA: ProtocolJSONSchema = {
62
- type: 'object',
63
- properties: {
64
- srcport: {
65
- type: 'integer',
66
- label: 'Source Port',
67
- minimum: 0,
68
- maximum: 65535,
69
- decode: (): void => {
70
- this.instance.srcport.setValue(BufferToUInt16(this.readBytes(0, 2)))
71
- },
72
- encode: (): void => {
73
- let srcport: number = this.instance.srcport.getValue(0, (nodePath: string): void => this.recordError(nodePath, 'Not Found'))
74
- if (srcport > 65535) {
75
- this.recordError(this.instance.srcport.getPath(), 'Maximum value is 65535')
76
- srcport = 65535
77
- }
78
- if (srcport < 0) {
79
- this.recordError(this.instance.srcport.getPath(), 'Minimum value is 0')
80
- srcport = 0
81
- }
82
- this.instance.srcport.setValue(srcport)
83
- this.writeBytes(0, UInt16ToBuffer(srcport))
84
- }
85
- },
86
- dstport: {
87
- type: 'integer',
88
- label: 'Destination Port',
89
- minimum: 0,
90
- maximum: 65535,
91
- decode: (): void => {
92
- this.instance.dstport.setValue(BufferToUInt16(this.readBytes(2, 2)))
93
- },
94
- encode: (): void => {
95
- let dstport: number = this.instance.dstport.getValue(0, (nodePath: string): void => this.recordError(nodePath, 'Not Found'))
96
- if (dstport > 65535) {
97
- this.recordError(this.instance.dstport.getPath(), 'Maximum value is 65535')
98
- dstport = 65535
99
- }
100
- if (dstport < 0) {
101
- this.recordError(this.instance.dstport.getPath(), 'Minimum value is 0')
102
- dstport = 0
103
- }
104
- this.instance.dstport.setValue(dstport)
105
- this.writeBytes(2, UInt16ToBuffer(dstport))
106
- }
107
- },
108
- length: {
109
- type: 'integer',
110
- label: 'Length',
111
- minimum: 0,
112
- maximum: 65535,
113
- decode: (): void => {
114
- this.instance.length.setValue(BufferToUInt16(this.readBytes(4, 2)))
115
- },
116
- encode: (): void => {
117
- let length: number = this.instance.length.getValue(0)
118
- if (length) {
119
- this.instance.length.setValue(length)
120
- this.writeBytes(4, UInt16ToBuffer(length))
121
- } else {
122
- this.instance.length.setValue(length)
123
- this.writeBytes(4, UInt16ToBuffer(length))
124
- this.addPostPacketEncodeHandler((): void => {
125
- let startCount: boolean = false
126
- let udpLength: number = 0
127
- this.codecModules.forEach((codecModule: CodecModule): void => {
128
- if (codecModule === this) startCount = true
129
- if (startCount) udpLength += codecModule.length
130
- })
131
- this.instance.length.setValue(udpLength)
132
- this.writeBytes(4, UInt16ToBuffer(udpLength))
133
- }, 1)
134
- }
135
- }
136
- },
137
- checksum: {
138
- type: 'integer',
139
- label: 'Checksum',
140
- minimum: 0,
141
- maximum: 65535,
142
- decode: (): void => {
143
- this.instance.checksum.setValue(BufferToUInt16(this.readBytes(6, 2)))
144
- },
145
- encode: (): void => {
146
- const checksum: number = this.instance.checksum.getValue(0)
147
- if (checksum) {
148
- this.instance.checksum.setValue(checksum)
149
- this.writeBytes(6, UInt16ToBuffer(checksum))
150
- } else {
151
- this.writeBytes(6, UInt16ToBuffer(checksum))
152
- this.instance.checksum.setValue(checksum)
153
- this.addPostPacketEncodeHandler((): void => {
154
- let startCount: boolean = false
155
- let udpHeaderWithDataLength: number = 0
156
- this.codecModules.forEach((codecModule: CodecModule): void => {
157
- if (codecModule === this) startCount = true
158
- if (startCount) udpHeaderWithDataLength += codecModule.length
159
- })
160
- const calcChecksum: number = this.calculateUDPChecksum(this.packet.subarray(this.startPos, this.startPos + udpHeaderWithDataLength))
161
- this.instance.checksum.setValue(calcChecksum)
162
- this.writeBytes(6, UInt16ToBuffer(calcChecksum))
163
- }, 2)
164
- }
165
- }
166
- }
167
- }
168
- }
169
-
170
- public readonly id: string = 'udp'
171
-
172
- public readonly name: string = 'User Datagram Protocol'
173
-
174
- public readonly nickname: string = 'UDP'
175
-
176
- public match(): boolean {
177
- if (!this.prevCodecModule) return false
178
- if (this.prevCodecModule.instance.protocol.getValue() === 0x11) return true
179
- return false
180
- }
181
-
182
- }
@@ -1,79 +0,0 @@
1
- import {ProtocolJSONSchema} from '../../schema/ProtocolJSONSchema'
2
- import {BaseHeader} from '../abstracts/BaseHeader'
3
- import {UInt16ToHex} from '../../helper/NumberToHex'
4
- import {BufferToHex} from '../../helper/BufferToHex'
5
-
6
- export class VLAN_802dot1Q extends BaseHeader {
7
- public SCHEMA: ProtocolJSONSchema = {
8
- type: 'object',
9
- properties: {
10
- priority: {
11
- type: 'integer',
12
- minimum: 0,
13
- maximum: 7,
14
- default: 0,
15
- label: 'Priority',
16
- decode: (): void => {
17
- this.instance.priority.setValue(this.readBits(0, 2, 0, 3))
18
- },
19
- encode: (): void => {
20
- const priorityValue: number = this.instance.priority.getValue(0)
21
- this.instance.priority.setValue(priorityValue)
22
- this.writeBits(0, 2, 0, 3, priorityValue)
23
- }
24
- },
25
- dei: {
26
- type: 'boolean',
27
- label: 'DEI',
28
- decode: (): void => {
29
- this.instance.dei.setValue(!!this.readBits(0, 2, 3, 1))
30
- },
31
- encode: (): void => {
32
- const dei: boolean = !!this.instance.dei.getValue()
33
- this.instance.dei.setValue(dei)
34
- this.writeBits(0, 2, 3, 1, dei ? 1 : 0)
35
- }
36
- },
37
- id: {
38
- type: 'integer',
39
- minimum: 0,
40
- maximum: 4095,
41
- label: 'ID',
42
- decode: (): void => {
43
- this.instance.id.setValue(this.readBits(0, 2, 4, 12))
44
- },
45
- encode: (): void => {
46
- const vlanId: number = 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
- label: 'EtherType',
56
- decode: (): void => {
57
- this.instance.etherType.setValue(BufferToHex(this.readBytes(2, 2)))
58
- },
59
- encode: (): void => {
60
- const etherType: string = this.instance.etherType.getValue(UInt16ToHex(0x0000), (nodePath: string): void => this.recordError(nodePath, 'Not Found'))
61
- const typeBuffer: Buffer = Buffer.from(etherType, 'hex')
62
- if (typeBuffer.length < 2) typeBuffer.fill(0, 0, 1)
63
- this.writeBytes(2, typeBuffer.subarray(0, 2))
64
- }
65
- }
66
- }
67
- }
68
-
69
- public readonly id: string = 'vlan'
70
-
71
- public readonly name: string = '802.1Q Virtual LAN'
72
-
73
- public readonly nickname: string = 'VLAN'
74
-
75
- public match(): boolean {
76
- if (!this.prevCodecModule) return false
77
- return this.prevCodecModule.instance.etherType.getValue() === UInt16ToHex(0x8100)
78
- }
79
- }
@@ -1,100 +0,0 @@
1
- export class FlexibleObject {
2
-
3
- readonly #parent: FlexibleObject | undefined
4
-
5
- readonly #paths: string[]
6
-
7
- #data: any
8
-
9
- #undefined: boolean = true
10
-
11
- #markFlexibleObjectDefined(): void {
12
- if (!this.#undefined) return
13
- this.#undefined = false
14
- if (this.#parent) this.#parent.#markFlexibleObjectDefined()
15
- }
16
-
17
- constructor(data?: object, parent?: FlexibleObject, paths?: string[]) {
18
- this.#parent = parent
19
- this.#data = {}
20
- this.#paths = paths ? paths : []
21
- if (data !== undefined) this.setValue(data)
22
- return new Proxy(this, {
23
- get: (target: FlexibleObject, p: string): any => {
24
- if (this[p]) return (...args: any[]): any => (this[p] as any)(...args)
25
- if (target.#data[p] === undefined) target.#data[p] = new FlexibleObject(target.#data[p], this, [...this.#paths, p])
26
- return target.#data[p]
27
- },
28
- set: (target: FlexibleObject, p: string, newValue: any): boolean => {
29
- return false
30
- }
31
- })
32
- }
33
-
34
- /**
35
- * Set object node value
36
- * @param value
37
- */
38
- // @ts-ignore
39
- public setValue(value: any): void {
40
- if (typeof value === 'object' && !Array.isArray(value)) {
41
- Object.keys(value).forEach(key => {
42
- this.#data[key] = new FlexibleObject(this.#data[key], this, [...this.#paths, key])
43
- this.#data[key].setValue(value[key])
44
- })
45
- } else {
46
- this.#data = value
47
- }
48
- this.#markFlexibleObjectDefined()
49
- }
50
-
51
- /**
52
- * Get object node value
53
- * @param defaultValue
54
- * @param onUndefinedCallback
55
- * @param getPathIndex
56
- */
57
- // @ts-ignore
58
- public getValue<T = any>(defaultValue?: T, onUndefinedCallback?: (nodePath: string) => void, getPathIndex?: number): T {
59
- if (this.#undefined) {
60
- if (onUndefinedCallback) onUndefinedCallback(this.getPath(getPathIndex))
61
- if (defaultValue !== undefined) {
62
- return defaultValue
63
- }
64
- return undefined as any
65
- }
66
- if (typeof this.#data === 'object' && !Array.isArray(this.#data)) {
67
- const dumpObject: object = {}
68
- Object.keys(this.#data).forEach((key: string): void => {
69
- const dumpResult: any = this.#data[key].getValue()
70
- if (dumpResult === undefined) return
71
- dumpObject[key] = dumpResult
72
- })
73
- return dumpObject as any
74
- } else {
75
- return this.#undefined ? undefined as any : this.#data
76
- }
77
- }
78
-
79
- /**
80
- * Is current object's value undefined
81
- */
82
- // @ts-ignore
83
- public isUndefined(): boolean {
84
- return this.#undefined
85
- }
86
-
87
- /**
88
- * Get current object path
89
- * The index parameter indicates array item if this object is an array
90
- * @param index
91
- */
92
- // @ts-ignore
93
- public getPath(index?: number): string {
94
- const objPath: string = this.#paths.join('.')
95
- if (index === undefined) return objPath
96
- return `${objPath}[${index}]`
97
- }
98
-
99
- [p: string]: FlexibleObject
100
- }
@@ -1,12 +0,0 @@
1
- /**
2
- * Get BER encoded integer real length from buffer
3
- * @param buffer
4
- * @constructor
5
- */
6
- export function GetBERIntegerLengthFromBuffer(buffer: Buffer): number {
7
- if (buffer[0] === 0) {
8
- return buffer.length - 1
9
- } else {
10
- return buffer.length
11
- }
12
- }
@@ -1,53 +0,0 @@
1
- import {PostHandlerItem} from '../types/PostHandlerItem'
2
- import {SortPostHandlers} from './SortPostHandlers'
3
-
4
- /**
5
- * Process packet post handlers
6
- * @param handlerItemsArray
7
- * @param asc
8
- */
9
- function processPacketPostHandlers(handlerItemsArray: PostHandlerItem[][], asc: boolean): PostHandlerItem[][] {
10
- let indexFactor: number = 10
11
- return handlerItemsArray
12
- .map((handlerItems: PostHandlerItem[]): PostHandlerItem[] => {
13
- return SortPostHandlers(handlerItems).map((handlerItem: PostHandlerItem, index: number): PostHandlerItem => {
14
- handlerItem.priority = index + 1
15
- let factor: number = 10
16
- let priority: number = handlerItem.priority
17
- while (priority > 1) {
18
- priority /= 10
19
- factor *= 10
20
- }
21
- indexFactor = indexFactor < factor ? factor : indexFactor
22
- return handlerItem
23
- })
24
- })
25
- .map((handlerItems: PostHandlerItem[], headerIndex: number): PostHandlerItem[] => {
26
- const basePriority: number = (headerIndex + 1) * indexFactor
27
- const unsortedItems: PostHandlerItem[] = handlerItems.map((handlerItem: PostHandlerItem): PostHandlerItem => {
28
- handlerItem.priority = basePriority + handlerItem.priority
29
- return handlerItem
30
- })
31
- return asc ?
32
- unsortedItems.sort((a: PostHandlerItem, b: PostHandlerItem): number => a.priority - b.priority) :
33
- unsortedItems.sort((a: PostHandlerItem, b: PostHandlerItem): number => b.priority - a.priority)
34
- })
35
- }
36
-
37
- /**
38
- * Process packet post encode handlers
39
- * @param handlerItemsArray
40
- * @constructor
41
- */
42
- export function ProcessPacketEncodePostHandlers(handlerItemsArray: PostHandlerItem[][]): PostHandlerItem[] {
43
- return processPacketPostHandlers(handlerItemsArray, true).reverse().flat()
44
- }
45
-
46
- /**
47
- * Process packet post decode handlers
48
- * @param handlerItemsArray
49
- * @constructor
50
- */
51
- export function ProcessPacketDecodePostHandlers(handlerItemsArray: PostHandlerItem[][]): PostHandlerItem[] {
52
- return processPacketPostHandlers(handlerItemsArray, true).flat()
53
- }
@@ -1,10 +0,0 @@
1
- import {PostHandlerItem} from '../types/PostHandlerItem'
2
-
3
- /**
4
- * Sort post handlers
5
- * @param handlers
6
- * @constructor
7
- */
8
- export function SortPostHandlers(handlers: PostHandlerItem[]): PostHandlerItem[] {
9
- return handlers.sort((a: PostHandlerItem, b: PostHandlerItem): number => a.priority - b.priority)
10
- }
@@ -1,10 +0,0 @@
1
- export enum StringContentEncodingEnum {
2
- BINARY = 'binary',
3
- HEX = 'hex',
4
- IPv4 = 'ipv4',
5
- IPv6 = 'ipv6',
6
- MAC = 'mac',
7
- ASCII = 'ascii',
8
- UTF8 = 'utf8',
9
- BIGINT = 'bigint'
10
- }
@@ -1,7 +0,0 @@
1
- import {PostHandlerItem} from './PostHandlerItem'
2
-
3
- export type CodecData = {
4
- packet: Buffer
5
- startPos: number
6
- postHandlers: PostHandlerItem[][]
7
- }
@@ -1,11 +0,0 @@
1
- import {HeaderTreeNode} from './HeaderTreeNode'
2
- import {CodecErrorInfo} from './CodecErrorInfo'
3
-
4
- export type CodecDecodeResult = {
5
- id: string
6
- name: string
7
- nickname: string
8
- protocol: boolean
9
- errors: CodecErrorInfo[]
10
- data: HeaderTreeNode
11
- }
@@ -1,9 +0,0 @@
1
- import {CodecDecodeResult} from './CodecDecodeResult'
2
- import {CodecErrorInfo} from './CodecErrorInfo'
3
-
4
- export type CodecEncodeInput = {
5
- name?: string
6
- nickname?: string
7
- protocol?: boolean
8
- errors?: CodecErrorInfo[]
9
- } & CodecDecodeResult
@@ -1,6 +0,0 @@
1
- import {CodecErrorInfo} from './CodecErrorInfo'
2
-
3
- export type CodecEncodeResult = {
4
- packet: Buffer
5
- errors: CodecErrorInfo[]
6
- }
@@ -1,5 +0,0 @@
1
- export type CodecErrorInfo = {
2
- id: string
3
- path: string
4
- message: string
5
- }
@@ -1,3 +0,0 @@
1
- import {BaseHeader} from '../abstracts/BaseHeader'
2
-
3
- export type CodecModule<T extends BaseHeader = BaseHeader> = T
@@ -1,3 +0,0 @@
1
- import {BaseHeader} from '../abstracts/BaseHeader'
2
-
3
- export type CodecModuleConstructor<T extends typeof BaseHeader = typeof BaseHeader> = T
@@ -1,7 +0,0 @@
1
- import {ProtocolJSONSchema} from '../../schema/ProtocolJSONSchema'
2
-
3
- export type CodecSchema = {
4
- readonly id: string
5
- readonly name: string
6
- readonly schema: ProtocolJSONSchema
7
- }
@@ -1,5 +0,0 @@
1
- export type HeaderTreeNodeField = string | number | boolean | HeaderTreeNode
2
-
3
- export type HeaderTreeNode = {
4
- [field: string]: HeaderTreeNodeField | HeaderTreeNodeField[]
5
- }
@@ -1,4 +0,0 @@
1
- export type PostHandlerItem = {
2
- priority: number
3
- handler: () => void | Promise<void>
4
- }
@@ -1,3 +0,0 @@
1
- export function BufferToHex(buffer: Buffer): string {
2
- return buffer.toString('hex').padStart(buffer.length * 2, '0')
3
- }
@@ -1,19 +0,0 @@
1
- import {Address4, Address6} from 'ip-address'
2
-
3
- /**
4
- * Convert Buffer to IPv4 string
5
- * @param buffer
6
- * @constructor
7
- */
8
- export function BufferToIPv4(buffer: Buffer): string {
9
- return Address4.fromBigInt(BigInt(`0x${Buffer.alloc(4, buffer).toString('hex').padStart(8, '0')}`)).address
10
- }
11
-
12
- /**
13
- * Convert Buffer to IPv6 string
14
- * @param buffer
15
- * @constructor
16
- */
17
- export function BufferToIPv6(buffer: Buffer): string {
18
- return Address6.fromBigInt(BigInt(`0x${Buffer.alloc(16, buffer).toString('hex').padStart(32, '0')}`)).address
19
- }
@@ -1,31 +0,0 @@
1
- import {
2
- HexToFloat32,
3
- HexToInt16,
4
- HexToInt32,
5
- HexToInt64,
6
- HexToInt8,
7
- HexToUInt16,
8
- HexToUInt32,
9
- HexToUInt64,
10
- HexToUInt8
11
- } from './HexToNumber'
12
-
13
- export const BufferToInt8: (buffer: Buffer) => number = (buffer: Buffer): number => HexToInt8(buffer.toString('hex'))
14
- export const BufferToInt16: (buffer: Buffer) => number = (buffer: Buffer): number => HexToInt16(buffer.toString('hex'))
15
- export const BufferToInt32: (buffer: Buffer) => number = (buffer: Buffer): number => HexToInt32(buffer.toString('hex'))
16
- export const BufferToInt64: (buffer: Buffer) => bigint = (buffer: Buffer): bigint => HexToInt64(buffer.toString('hex'))
17
- export const BufferToUInt8: (buffer: Buffer) => number = (buffer: Buffer): number => HexToUInt8(buffer.toString('hex'))
18
- export const BufferToUInt16: (buffer: Buffer) => number = (buffer: Buffer): number => HexToUInt16(buffer.toString('hex'))
19
- export const BufferToUInt32: (buffer: Buffer) => number = (buffer: Buffer): number => HexToUInt32(buffer.toString('hex'))
20
- export const BufferToUInt64: (buffer: Buffer) => bigint = (buffer: Buffer): bigint => HexToUInt64(buffer.toString('hex'))
21
- export const BufferToFloat32: (buffer: Buffer) => number = (buffer: Buffer): number => HexToFloat32(buffer.toString('hex'))
22
-
23
-
24
-
25
-
26
-
27
-
28
-
29
-
30
-
31
-
@@ -1,22 +0,0 @@
1
- /**
2
- * Convert hex to buffer
3
- * @param hex
4
- * @param bufferLength
5
- * @constructor
6
- */
7
- export function HexToBuffer(hex: string, bufferLength?: number): Buffer {
8
- if (!hex) return Buffer.alloc(0)
9
- const inputHex: string = hex.length % 2 ? hex.padStart(hex.length + 1, '0') : hex
10
- const outputBufferLength: number = bufferLength ? bufferLength : inputHex.length / 2
11
- let buffer: Buffer = Buffer.from(inputHex, 'hex')
12
- if (buffer.length > outputBufferLength) {
13
- buffer.subarray(0, outputBufferLength)
14
- } else if (buffer.length < outputBufferLength) {
15
- const paddingLength: number = outputBufferLength - buffer.length
16
- buffer = Buffer.concat([
17
- Buffer.alloc(paddingLength, 0x00),
18
- buffer
19
- ])
20
- }
21
- return buffer
22
- }
@@ -1,25 +0,0 @@
1
- export const HexToInt8: (hex: string) => number = (hex: string): number => Int8Array.from([parseInt(hex, 16)])[0]
2
- export const HexToInt16: (hex: string) => number = (hex: string): number => Int16Array.from([parseInt(hex, 16)])[0]
3
- export const HexToInt32: (hex: string) => number = (hex: string): number => Int32Array.from([parseInt(hex, 16)])[0]
4
- export const HexToInt64: (hex: string) => bigint = (hex: string): bigint => {
5
- const INT64_MAX: bigint = BigInt('9223372036854775807')
6
- const INT64_MIN: bigint = BigInt('-9223372036854775808')
7
- const bigIntValue: bigint = BigInt(`0x${hex}`)
8
- if (bigIntValue < INT64_MIN || bigIntValue > INT64_MAX) return INT64_MAX
9
- return bigIntValue
10
- }
11
- export const HexToUInt8: (hex: string) => number = (hex: string): number => Uint8Array.from([parseInt(hex, 16)])[0]
12
- export const HexToUInt16: (hex: string) => number = (hex: string): number => Uint16Array.from([parseInt(hex, 16)])[0]
13
- export const HexToUInt32: (hex: string) => number = (hex: string): number => Uint32Array.from([parseInt(hex, 16)])[0]
14
- export const HexToUInt64: (hex: string) => bigint = (hex: string): bigint => {
15
- const INT64_MAX: bigint = BigInt('18446744073709551615')
16
- const bigIntValue: bigint = BigInt(`0x${hex}`)
17
- if (bigIntValue < 0n || bigIntValue > INT64_MAX) return INT64_MAX
18
- return bigIntValue
19
- }
20
- export const HexToFloat32: (hex: string) => number = (hex: string): number => {
21
- const buffer = new ArrayBuffer(4)
22
- const dataView = new DataView(buffer)
23
- dataView.setUint32(0, parseInt(hex, 16), false)
24
- return dataView.getFloat32(0, false)
25
- }
@@ -1,25 +0,0 @@
1
- import {Address6} from 'ip-address'
2
- import {UInt32ToBuffer} from './NumberToBuffer'
3
-
4
- /**
5
- * Convert IPv4 string to Buffer
6
- * @param ipv4
7
- * @constructor
8
- */
9
- export function IPv4ToBuffer(ipv4: string): Buffer {
10
- const numArr: number[] = ipv4.split('.').map((value: string): number => parseInt(value)).map((value: number): number => value ? value : 0)
11
- return UInt32ToBuffer(parseInt(Buffer.from(numArr).toString('hex'), 16))
12
- }
13
-
14
- /**
15
- * Convert IPv6 string to Buffer
16
- * @param ipv6
17
- * @constructor
18
- */
19
- export function IPv6ToBuffer(ipv6: string): Buffer {
20
- try {
21
- return Buffer.from(new Address6(ipv6).toByteArray())
22
- } catch (e) {
23
- return Buffer.alloc(16, 0)
24
- }
25
- }