@netkitty/codec 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 (463) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/LICENSE +21 -0
  3. package/README.md +352 -0
  4. package/README.zh-CN.md +342 -0
  5. package/dist/Codec.d.ts +133 -0
  6. package/dist/Codec.js +632 -0
  7. package/dist/PacketHeaders.d.ts +189 -0
  8. package/dist/PacketHeaders.js +384 -0
  9. package/dist/abstracts/BaseHeader.d.ts +325 -0
  10. package/dist/abstracts/BaseHeader.js +734 -0
  11. package/dist/errors/CodecSchemaValidateError.d.ts +4 -0
  12. package/dist/errors/CodecSchemaValidateError.js +11 -0
  13. package/dist/headers/ADSAMS.d.ts +33 -0
  14. package/dist/headers/ADSAMS.js +208 -0
  15. package/dist/headers/AH.d.ts +28 -0
  16. package/dist/headers/AH.js +137 -0
  17. package/dist/headers/AMQP.d.ts +31 -0
  18. package/dist/headers/AMQP.js +316 -0
  19. package/dist/headers/ARP.d.ts +26 -0
  20. package/dist/headers/ARP.js +243 -0
  21. package/dist/headers/BACnetIP.d.ts +27 -0
  22. package/dist/headers/BACnetIP.js +97 -0
  23. package/dist/headers/BFD.d.ts +28 -0
  24. package/dist/headers/BFD.js +155 -0
  25. package/dist/headers/BGP.d.ts +27 -0
  26. package/dist/headers/BGP.js +111 -0
  27. package/dist/headers/BSAPIP.d.ts +33 -0
  28. package/dist/headers/BSAPIP.js +78 -0
  29. package/dist/headers/Babel.d.ts +32 -0
  30. package/dist/headers/Babel.js +224 -0
  31. package/dist/headers/BitTorrent.d.ts +28 -0
  32. package/dist/headers/BitTorrent.js +72 -0
  33. package/dist/headers/C37118.d.ts +26 -0
  34. package/dist/headers/C37118.js +147 -0
  35. package/dist/headers/CAPWAP.d.ts +38 -0
  36. package/dist/headers/CAPWAP.js +275 -0
  37. package/dist/headers/CDP.d.ts +25 -0
  38. package/dist/headers/CDP.js +117 -0
  39. package/dist/headers/CMS.d.ts +33 -0
  40. package/dist/headers/CMS.js +238 -0
  41. package/dist/headers/COTP.d.ts +30 -0
  42. package/dist/headers/COTP.js +193 -0
  43. package/dist/headers/CassandraCQL.d.ts +28 -0
  44. package/dist/headers/CassandraCQL.js +117 -0
  45. package/dist/headers/CoAP.d.ts +29 -0
  46. package/dist/headers/CoAP.js +140 -0
  47. package/dist/headers/Codesys.d.ts +32 -0
  48. package/dist/headers/Codesys.js +119 -0
  49. package/dist/headers/Collectd.d.ts +29 -0
  50. package/dist/headers/Collectd.js +154 -0
  51. package/dist/headers/DCCP.d.ts +30 -0
  52. package/dist/headers/DCCP.js +204 -0
  53. package/dist/headers/DHCP.d.ts +26 -0
  54. package/dist/headers/DHCP.js +148 -0
  55. package/dist/headers/DHCPFailover.d.ts +30 -0
  56. package/dist/headers/DHCPFailover.js +104 -0
  57. package/dist/headers/DHCPv6.d.ts +25 -0
  58. package/dist/headers/DHCPv6.js +145 -0
  59. package/dist/headers/DNP3.d.ts +27 -0
  60. package/dist/headers/DNP3.js +150 -0
  61. package/dist/headers/DNS.d.ts +55 -0
  62. package/dist/headers/DNS.js +309 -0
  63. package/dist/headers/DTLS.d.ts +33 -0
  64. package/dist/headers/DTLS.js +142 -0
  65. package/dist/headers/Diameter.d.ts +34 -0
  66. package/dist/headers/Diameter.js +229 -0
  67. package/dist/headers/EAPOL.d.ts +32 -0
  68. package/dist/headers/EAPOL.js +135 -0
  69. package/dist/headers/EIGRP.d.ts +28 -0
  70. package/dist/headers/EIGRP.js +165 -0
  71. package/dist/headers/ENIP.d.ts +31 -0
  72. package/dist/headers/ENIP.js +164 -0
  73. package/dist/headers/ESP.d.ts +27 -0
  74. package/dist/headers/ESP.js +140 -0
  75. package/dist/headers/Elasticsearch.d.ts +30 -0
  76. package/dist/headers/Elasticsearch.js +125 -0
  77. package/dist/headers/EtherCAT.d.ts +35 -0
  78. package/dist/headers/EtherCAT.js +150 -0
  79. package/dist/headers/EthernetII.d.ts +28 -0
  80. package/dist/headers/EthernetII.js +117 -0
  81. package/dist/headers/FCoE.d.ts +38 -0
  82. package/dist/headers/FCoE.js +210 -0
  83. package/dist/headers/FTP.d.ts +34 -0
  84. package/dist/headers/FTP.js +158 -0
  85. package/dist/headers/Finger.d.ts +41 -0
  86. package/dist/headers/Finger.js +135 -0
  87. package/dist/headers/FoundationFieldbusHSE.d.ts +43 -0
  88. package/dist/headers/FoundationFieldbusHSE.js +163 -0
  89. package/dist/headers/GELF.d.ts +35 -0
  90. package/dist/headers/GELF.js +261 -0
  91. package/dist/headers/GENEVE.d.ts +26 -0
  92. package/dist/headers/GENEVE.js +209 -0
  93. package/dist/headers/GESRTP.d.ts +32 -0
  94. package/dist/headers/GESRTP.js +141 -0
  95. package/dist/headers/GLBP.d.ts +29 -0
  96. package/dist/headers/GLBP.js +159 -0
  97. package/dist/headers/GRE.d.ts +27 -0
  98. package/dist/headers/GRE.js +181 -0
  99. package/dist/headers/GTPU.d.ts +25 -0
  100. package/dist/headers/GTPU.js +203 -0
  101. package/dist/headers/GTPv2C.d.ts +30 -0
  102. package/dist/headers/GTPv2C.js +281 -0
  103. package/dist/headers/GitProtocol.d.ts +34 -0
  104. package/dist/headers/GitProtocol.js +141 -0
  105. package/dist/headers/Goose.d.ts +115 -0
  106. package/dist/headers/Goose.js +1067 -0
  107. package/dist/headers/Gopher.d.ts +43 -0
  108. package/dist/headers/Gopher.js +182 -0
  109. package/dist/headers/HARTIP.d.ts +30 -0
  110. package/dist/headers/HARTIP.js +145 -0
  111. package/dist/headers/HSR.d.ts +27 -0
  112. package/dist/headers/HSR.js +105 -0
  113. package/dist/headers/HSRP.d.ts +26 -0
  114. package/dist/headers/HSRP.js +173 -0
  115. package/dist/headers/HTTP.d.ts +32 -0
  116. package/dist/headers/HTTP.js +153 -0
  117. package/dist/headers/HTTP2.d.ts +34 -0
  118. package/dist/headers/HTTP2.js +190 -0
  119. package/dist/headers/IAX2.d.ts +33 -0
  120. package/dist/headers/IAX2.js +274 -0
  121. package/dist/headers/ICMP.d.ts +15 -0
  122. package/dist/headers/ICMP.js +148 -0
  123. package/dist/headers/ICMPv6.d.ts +15 -0
  124. package/dist/headers/ICMPv6.js +129 -0
  125. package/dist/headers/IEC104_I_Frame.d.ts +23 -0
  126. package/dist/headers/IEC104_I_Frame.js +6489 -0
  127. package/dist/headers/IEC104_S_Frame.d.ts +26 -0
  128. package/dist/headers/IEC104_S_Frame.js +135 -0
  129. package/dist/headers/IEC104_U_Frame.d.ts +27 -0
  130. package/dist/headers/IEC104_U_Frame.js +176 -0
  131. package/dist/headers/IEC61850SampledValues.d.ts +20 -0
  132. package/dist/headers/IEC61850SampledValues.js +420 -0
  133. package/dist/headers/IGMP.d.ts +31 -0
  134. package/dist/headers/IGMP.js +274 -0
  135. package/dist/headers/IMAP.d.ts +32 -0
  136. package/dist/headers/IMAP.js +185 -0
  137. package/dist/headers/IPFIX.d.ts +29 -0
  138. package/dist/headers/IPFIX.js +156 -0
  139. package/dist/headers/IPv4.d.ts +20 -0
  140. package/dist/headers/IPv4.js +370 -0
  141. package/dist/headers/IPv6.d.ts +29 -0
  142. package/dist/headers/IPv6.js +209 -0
  143. package/dist/headers/IPv6HopByHopOptions.d.ts +81 -0
  144. package/dist/headers/IPv6HopByHopOptions.js +495 -0
  145. package/dist/headers/IRC.d.ts +34 -0
  146. package/dist/headers/IRC.js +175 -0
  147. package/dist/headers/ISAKMP.d.ts +29 -0
  148. package/dist/headers/ISAKMP.js +197 -0
  149. package/dist/headers/ISCSI.d.ts +39 -0
  150. package/dist/headers/ISCSI.js +289 -0
  151. package/dist/headers/ISIS.d.ts +25 -0
  152. package/dist/headers/ISIS.js +79 -0
  153. package/dist/headers/ISOSession.d.ts +27 -0
  154. package/dist/headers/ISOSession.js +343 -0
  155. package/dist/headers/Ident.d.ts +42 -0
  156. package/dist/headers/Ident.js +184 -0
  157. package/dist/headers/KNXnetIP.d.ts +30 -0
  158. package/dist/headers/KNXnetIP.js +135 -0
  159. package/dist/headers/Kafka.d.ts +35 -0
  160. package/dist/headers/Kafka.js +128 -0
  161. package/dist/headers/Kerberos.d.ts +30 -0
  162. package/dist/headers/Kerberos.js +217 -0
  163. package/dist/headers/L2TP.d.ts +26 -0
  164. package/dist/headers/L2TP.js +297 -0
  165. package/dist/headers/LACP.d.ts +31 -0
  166. package/dist/headers/LACP.js +151 -0
  167. package/dist/headers/LDAP.d.ts +31 -0
  168. package/dist/headers/LDAP.js +226 -0
  169. package/dist/headers/LDP.d.ts +31 -0
  170. package/dist/headers/LDP.js +138 -0
  171. package/dist/headers/LISP.d.ts +30 -0
  172. package/dist/headers/LISP.js +103 -0
  173. package/dist/headers/LLC.d.ts +27 -0
  174. package/dist/headers/LLC.js +81 -0
  175. package/dist/headers/LLDP.d.ts +26 -0
  176. package/dist/headers/LLDP.js +126 -0
  177. package/dist/headers/LLMNR.d.ts +23 -0
  178. package/dist/headers/LLMNR.js +40 -0
  179. package/dist/headers/LPD.d.ts +31 -0
  180. package/dist/headers/LPD.js +159 -0
  181. package/dist/headers/MACsec.d.ts +34 -0
  182. package/dist/headers/MACsec.js +178 -0
  183. package/dist/headers/MDNS.d.ts +26 -0
  184. package/dist/headers/MDNS.js +45 -0
  185. package/dist/headers/MGCP.d.ts +30 -0
  186. package/dist/headers/MGCP.js +155 -0
  187. package/dist/headers/MMS.d.ts +29 -0
  188. package/dist/headers/MMS.js +243 -0
  189. package/dist/headers/MPLS.d.ts +31 -0
  190. package/dist/headers/MPLS.js +145 -0
  191. package/dist/headers/MQTT.d.ts +30 -0
  192. package/dist/headers/MQTT.js +173 -0
  193. package/dist/headers/MQTTSN.d.ts +34 -0
  194. package/dist/headers/MQTTSN.js +177 -0
  195. package/dist/headers/MarkerProtocol.d.ts +32 -0
  196. package/dist/headers/MarkerProtocol.js +153 -0
  197. package/dist/headers/Megaco.d.ts +32 -0
  198. package/dist/headers/Megaco.js +144 -0
  199. package/dist/headers/Memcached.d.ts +44 -0
  200. package/dist/headers/Memcached.js +285 -0
  201. package/dist/headers/ModbusTCP.d.ts +25 -0
  202. package/dist/headers/ModbusTCP.js +99 -0
  203. package/dist/headers/ModbusUDP.d.ts +26 -0
  204. package/dist/headers/ModbusUDP.js +100 -0
  205. package/dist/headers/MongoDB.d.ts +33 -0
  206. package/dist/headers/MongoDB.js +143 -0
  207. package/dist/headers/MySQL.d.ts +30 -0
  208. package/dist/headers/MySQL.js +114 -0
  209. package/dist/headers/NATS.d.ts +29 -0
  210. package/dist/headers/NATS.js +135 -0
  211. package/dist/headers/NBDS.d.ts +34 -0
  212. package/dist/headers/NBDS.js +176 -0
  213. package/dist/headers/NBNS.d.ts +34 -0
  214. package/dist/headers/NBNS.js +78 -0
  215. package/dist/headers/NBSS.d.ts +36 -0
  216. package/dist/headers/NBSS.js +137 -0
  217. package/dist/headers/NFS.d.ts +36 -0
  218. package/dist/headers/NFS.js +273 -0
  219. package/dist/headers/NHRP.d.ts +32 -0
  220. package/dist/headers/NHRP.js +154 -0
  221. package/dist/headers/NNTP.d.ts +35 -0
  222. package/dist/headers/NNTP.js +162 -0
  223. package/dist/headers/NTP.d.ts +18 -0
  224. package/dist/headers/NTP.js +73 -0
  225. package/dist/headers/NetFlowV5.d.ts +28 -0
  226. package/dist/headers/NetFlowV5.js +205 -0
  227. package/dist/headers/OLSR.d.ts +31 -0
  228. package/dist/headers/OLSR.js +213 -0
  229. package/dist/headers/OPCUA.d.ts +33 -0
  230. package/dist/headers/OPCUA.js +165 -0
  231. package/dist/headers/OPCUAPubSub.d.ts +33 -0
  232. package/dist/headers/OPCUAPubSub.js +144 -0
  233. package/dist/headers/OSPF.d.ts +31 -0
  234. package/dist/headers/OSPF.js +365 -0
  235. package/dist/headers/OmronFINS.d.ts +31 -0
  236. package/dist/headers/OmronFINS.js +90 -0
  237. package/dist/headers/OpenFlow.d.ts +30 -0
  238. package/dist/headers/OpenFlow.js +113 -0
  239. package/dist/headers/OpenVPN.d.ts +35 -0
  240. package/dist/headers/OpenVPN.js +214 -0
  241. package/dist/headers/PCWorx.d.ts +35 -0
  242. package/dist/headers/PCWorx.js +115 -0
  243. package/dist/headers/PIM.d.ts +27 -0
  244. package/dist/headers/PIM.js +129 -0
  245. package/dist/headers/POP3.d.ts +31 -0
  246. package/dist/headers/POP3.js +152 -0
  247. package/dist/headers/POWERLINK.d.ts +28 -0
  248. package/dist/headers/POWERLINK.js +116 -0
  249. package/dist/headers/PPPoEDiscovery.d.ts +29 -0
  250. package/dist/headers/PPPoEDiscovery.js +198 -0
  251. package/dist/headers/PPPoESession.d.ts +28 -0
  252. package/dist/headers/PPPoESession.js +125 -0
  253. package/dist/headers/PPTP.d.ts +30 -0
  254. package/dist/headers/PPTP.js +122 -0
  255. package/dist/headers/PROFINETRT.d.ts +28 -0
  256. package/dist/headers/PROFINETRT.js +74 -0
  257. package/dist/headers/PTP.d.ts +34 -0
  258. package/dist/headers/PTP.js +213 -0
  259. package/dist/headers/PostgreSQL.d.ts +40 -0
  260. package/dist/headers/PostgreSQL.js +236 -0
  261. package/dist/headers/QUIC.d.ts +34 -0
  262. package/dist/headers/QUIC.js +308 -0
  263. package/dist/headers/RADIUS.d.ts +24 -0
  264. package/dist/headers/RADIUS.js +138 -0
  265. package/dist/headers/RDP.d.ts +27 -0
  266. package/dist/headers/RDP.js +93 -0
  267. package/dist/headers/RFB.d.ts +39 -0
  268. package/dist/headers/RFB.js +151 -0
  269. package/dist/headers/RGoose.d.ts +72 -0
  270. package/dist/headers/RGoose.js +340 -0
  271. package/dist/headers/RIP.d.ts +29 -0
  272. package/dist/headers/RIP.js +133 -0
  273. package/dist/headers/RIPng.d.ts +26 -0
  274. package/dist/headers/RIPng.js +140 -0
  275. package/dist/headers/RMCP.d.ts +26 -0
  276. package/dist/headers/RMCP.js +155 -0
  277. package/dist/headers/RSVP.d.ts +31 -0
  278. package/dist/headers/RSVP.js +263 -0
  279. package/dist/headers/RTCP.d.ts +34 -0
  280. package/dist/headers/RTCP.js +217 -0
  281. package/dist/headers/RTP.d.ts +33 -0
  282. package/dist/headers/RTP.js +291 -0
  283. package/dist/headers/RTPS.d.ts +33 -0
  284. package/dist/headers/RTPS.js +182 -0
  285. package/dist/headers/RTSP.d.ts +36 -0
  286. package/dist/headers/RTSP.js +184 -0
  287. package/dist/headers/RawData.d.ts +17 -0
  288. package/dist/headers/RawData.js +43 -0
  289. package/dist/headers/Redis.d.ts +32 -0
  290. package/dist/headers/Redis.js +202 -0
  291. package/dist/headers/Rlogin.d.ts +42 -0
  292. package/dist/headers/Rlogin.js +139 -0
  293. package/dist/headers/Rsync.d.ts +28 -0
  294. package/dist/headers/Rsync.js +117 -0
  295. package/dist/headers/S7comm.d.ts +36 -0
  296. package/dist/headers/S7comm.js +244 -0
  297. package/dist/headers/SCTP.d.ts +35 -0
  298. package/dist/headers/SCTP.js +174 -0
  299. package/dist/headers/SFlow.d.ts +29 -0
  300. package/dist/headers/SFlow.js +242 -0
  301. package/dist/headers/SIP.d.ts +27 -0
  302. package/dist/headers/SIP.js +146 -0
  303. package/dist/headers/SLMP.d.ts +36 -0
  304. package/dist/headers/SLMP.js +154 -0
  305. package/dist/headers/SLP.d.ts +30 -0
  306. package/dist/headers/SLP.js +207 -0
  307. package/dist/headers/SLPv1.d.ts +32 -0
  308. package/dist/headers/SLPv1.js +138 -0
  309. package/dist/headers/SMB1.d.ts +37 -0
  310. package/dist/headers/SMB1.js +200 -0
  311. package/dist/headers/SMB2.d.ts +36 -0
  312. package/dist/headers/SMB2.js +203 -0
  313. package/dist/headers/SMPP.d.ts +33 -0
  314. package/dist/headers/SMPP.js +119 -0
  315. package/dist/headers/SMTP.d.ts +33 -0
  316. package/dist/headers/SMTP.js +157 -0
  317. package/dist/headers/SNAP.d.ts +22 -0
  318. package/dist/headers/SNAP.js +68 -0
  319. package/dist/headers/SNMP.d.ts +28 -0
  320. package/dist/headers/SNMP.js +302 -0
  321. package/dist/headers/SOCKS4.d.ts +42 -0
  322. package/dist/headers/SOCKS4.js +302 -0
  323. package/dist/headers/SOCKS5.d.ts +45 -0
  324. package/dist/headers/SOCKS5.js +223 -0
  325. package/dist/headers/SSDP.d.ts +27 -0
  326. package/dist/headers/SSDP.js +161 -0
  327. package/dist/headers/SSH.d.ts +44 -0
  328. package/dist/headers/SSH.js +274 -0
  329. package/dist/headers/STOMP.d.ts +48 -0
  330. package/dist/headers/STOMP.js +177 -0
  331. package/dist/headers/STP.d.ts +26 -0
  332. package/dist/headers/STP.js +150 -0
  333. package/dist/headers/STUN.d.ts +25 -0
  334. package/dist/headers/STUN.js +183 -0
  335. package/dist/headers/SercosIII.d.ts +43 -0
  336. package/dist/headers/SercosIII.js +199 -0
  337. package/dist/headers/Skinny.d.ts +32 -0
  338. package/dist/headers/Skinny.js +139 -0
  339. package/dist/headers/StatsD.d.ts +27 -0
  340. package/dist/headers/StatsD.js +134 -0
  341. package/dist/headers/SunRPC.d.ts +34 -0
  342. package/dist/headers/SunRPC.js +268 -0
  343. package/dist/headers/Syslog.d.ts +21 -0
  344. package/dist/headers/Syslog.js +91 -0
  345. package/dist/headers/TCP.d.ts +19 -0
  346. package/dist/headers/TCP.js +905 -0
  347. package/dist/headers/TFTP.d.ts +28 -0
  348. package/dist/headers/TFTP.js +224 -0
  349. package/dist/headers/TLS_Alert.d.ts +24 -0
  350. package/dist/headers/TLS_Alert.js +639 -0
  351. package/dist/headers/TLS_ApplicationData.d.ts +24 -0
  352. package/dist/headers/TLS_ApplicationData.js +170 -0
  353. package/dist/headers/TLS_ChangeCipherSpec.d.ts +23 -0
  354. package/dist/headers/TLS_ChangeCipherSpec.js +168 -0
  355. package/dist/headers/TLS_Handshake.d.ts +65 -0
  356. package/dist/headers/TLS_Handshake.js +860 -0
  357. package/dist/headers/TLS_Heartbeat.d.ts +27 -0
  358. package/dist/headers/TLS_Heartbeat.js +247 -0
  359. package/dist/headers/TPKT.d.ts +26 -0
  360. package/dist/headers/TPKT.js +99 -0
  361. package/dist/headers/TacacsPlus.d.ts +27 -0
  362. package/dist/headers/TacacsPlus.js +133 -0
  363. package/dist/headers/Telnet.d.ts +40 -0
  364. package/dist/headers/Telnet.js +193 -0
  365. package/dist/headers/Teredo.d.ts +40 -0
  366. package/dist/headers/Teredo.js +251 -0
  367. package/dist/headers/TimeProtocol.d.ts +25 -0
  368. package/dist/headers/TimeProtocol.js +53 -0
  369. package/dist/headers/UDP.d.ts +19 -0
  370. package/dist/headers/UDP.js +171 -0
  371. package/dist/headers/VLAN_802dot1Q.d.ts +24 -0
  372. package/dist/headers/VLAN_802dot1Q.js +96 -0
  373. package/dist/headers/VRRP.d.ts +26 -0
  374. package/dist/headers/VRRP.js +309 -0
  375. package/dist/headers/VXLAN.d.ts +24 -0
  376. package/dist/headers/VXLAN.js +75 -0
  377. package/dist/headers/WCCP.d.ts +29 -0
  378. package/dist/headers/WCCP.js +117 -0
  379. package/dist/headers/WHOIS.d.ts +37 -0
  380. package/dist/headers/WHOIS.js +126 -0
  381. package/dist/headers/WSDiscovery.d.ts +29 -0
  382. package/dist/headers/WSDiscovery.js +118 -0
  383. package/dist/headers/WakeOnLAN.d.ts +30 -0
  384. package/dist/headers/WakeOnLAN.js +126 -0
  385. package/dist/headers/WebSocket.d.ts +26 -0
  386. package/dist/headers/WebSocket.js +173 -0
  387. package/dist/headers/WireGuard.d.ts +38 -0
  388. package/dist/headers/WireGuard.js +216 -0
  389. package/dist/headers/XMPP.d.ts +37 -0
  390. package/dist/headers/XMPP.js +149 -0
  391. package/dist/headers/Zabbix.d.ts +35 -0
  392. package/dist/headers/Zabbix.js +153 -0
  393. package/dist/headers/cms/AcsiPdu.d.ts +45 -0
  394. package/dist/headers/cms/AcsiPdu.js +112 -0
  395. package/dist/headers/cms/PerDecoder.d.ts +68 -0
  396. package/dist/headers/cms/PerDecoder.js +211 -0
  397. package/dist/headers/cms/PerReader.d.ts +64 -0
  398. package/dist/headers/cms/PerReader.js +155 -0
  399. package/dist/helper/BufferToHex.d.ts +5 -0
  400. package/dist/helper/BufferToHex.js +10 -0
  401. package/dist/helper/BufferToIP.d.ts +12 -0
  402. package/dist/helper/BufferToIP.js +23 -0
  403. package/dist/helper/BufferToNumber.d.ts +18 -0
  404. package/dist/helper/BufferToNumber.js +47 -0
  405. package/dist/helper/HexToBuffer.d.ts +7 -0
  406. package/dist/helper/HexToBuffer.js +27 -0
  407. package/dist/helper/HexToNumber.d.ts +18 -0
  408. package/dist/helper/HexToNumber.js +48 -0
  409. package/dist/helper/IPToBuffer.d.ts +12 -0
  410. package/dist/helper/IPToBuffer.js +34 -0
  411. package/dist/helper/NumberToBERBuffer.d.ts +18 -0
  412. package/dist/helper/NumberToBERBuffer.js +31 -0
  413. package/dist/helper/NumberToBERHex.d.ts +18 -0
  414. package/dist/helper/NumberToBERHex.js +52 -0
  415. package/dist/helper/NumberToBuffer.d.ts +18 -0
  416. package/dist/helper/NumberToBuffer.js +38 -0
  417. package/dist/helper/NumberToHex.d.ts +18 -0
  418. package/dist/helper/NumberToHex.js +35 -0
  419. package/dist/index.d.ts +52 -0
  420. package/dist/index.js +113 -0
  421. package/dist/lib/FlexibleObject.d.ts +27 -0
  422. package/dist/lib/FlexibleObject.js +113 -0
  423. package/dist/lib/GetBERIntegerLengthFromBuffer.d.ts +6 -0
  424. package/dist/lib/GetBERIntegerLengthFromBuffer.js +16 -0
  425. package/dist/lib/ProcessPacketPostHandlers.d.ts +13 -0
  426. package/dist/lib/ProcessPacketPostHandlers.js +53 -0
  427. package/dist/lib/SortPostHandlers.d.ts +7 -0
  428. package/dist/lib/SortPostHandlers.js +11 -0
  429. package/dist/lib/StringContentEncodingEnum.d.ts +10 -0
  430. package/dist/lib/StringContentEncodingEnum.js +14 -0
  431. package/dist/schema/ProtocolFieldJSONSchema.d.ts +35 -0
  432. package/dist/schema/ProtocolFieldJSONSchema.js +2 -0
  433. package/dist/schema/ProtocolFieldJSONSchemaDefinition.d.ts +2 -0
  434. package/dist/schema/ProtocolFieldJSONSchemaDefinition.js +2 -0
  435. package/dist/schema/ProtocolJSONSchema.d.ts +32 -0
  436. package/dist/schema/ProtocolJSONSchema.js +2 -0
  437. package/dist/types/CodecData.d.ts +7 -0
  438. package/dist/types/CodecData.js +2 -0
  439. package/dist/types/CodecDecodeResult.d.ts +10 -0
  440. package/dist/types/CodecDecodeResult.js +2 -0
  441. package/dist/types/CodecEncodeInput.d.ts +2 -0
  442. package/dist/types/CodecEncodeInput.js +2 -0
  443. package/dist/types/CodecEncodeResult.d.ts +5 -0
  444. package/dist/types/CodecEncodeResult.js +2 -0
  445. package/dist/types/CodecErrorInfo.d.ts +5 -0
  446. package/dist/types/CodecErrorInfo.js +2 -0
  447. package/dist/types/CodecModule.d.ts +2 -0
  448. package/dist/types/CodecModule.js +2 -0
  449. package/dist/types/CodecModuleConstructor.d.ts +2 -0
  450. package/dist/types/CodecModuleConstructor.js +2 -0
  451. package/dist/types/CodecSchema.d.ts +6 -0
  452. package/dist/types/CodecSchema.js +2 -0
  453. package/dist/types/DemuxProducer.d.ts +23 -0
  454. package/dist/types/DemuxProducer.js +2 -0
  455. package/dist/types/Dissection.d.ts +23 -0
  456. package/dist/types/Dissection.js +2 -0
  457. package/dist/types/HeaderTreeNode.d.ts +4 -0
  458. package/dist/types/HeaderTreeNode.js +2 -0
  459. package/dist/types/LayerGraph.d.ts +32 -0
  460. package/dist/types/LayerGraph.js +2 -0
  461. package/dist/types/PostHandlerItem.d.ts +4 -0
  462. package/dist/types/PostHandlerItem.js +2 -0
  463. package/package.json +141 -0
@@ -0,0 +1,143 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MongoDB = void 0;
4
+ const BaseHeader_1 = require("../abstracts/BaseHeader");
5
+ const BufferToHex_1 = require("../helper/BufferToHex");
6
+ const HexToBuffer_1 = require("../helper/HexToBuffer");
7
+ const StringContentEncodingEnum_1 = require("../lib/StringContentEncodingEnum");
8
+ /**
9
+ * MongoDB Wire Protocol (TCP port 27017). Every message begins with a fixed 16-byte standard message
10
+ * header — messageLength, requestID, responseTo, opCode — followed by an opCode-specific body. The
11
+ * messageLength counts the WHOLE message including the 16-byte header; requestID / responseTo tie a
12
+ * request to its reply; opCode selects the body layout (2013 OP_MSG — the modern, general-purpose
13
+ * message; 2004 OP_QUERY and 1 OP_REPLY — the legacy request/reply pair; plus OP_UPDATE/INSERT/… ).
14
+ *
15
+ * ⚠️ Every multi-byte field in the MongoDB wire protocol is LITTLE-ENDIAN. There is no little-endian
16
+ * helper in this codebase, so the four uint32 header fields are read and written byte-by-byte in their
17
+ * closures (`|` yields a signed int32, so the read applies `>>> 0` to the whole expression to keep a
18
+ * high-bit-set value unsigned).
19
+ *
20
+ * The body layout differs per opCode (OP_MSG's flagBits + sections of BSON, OP_QUERY's collection name /
21
+ * query document, OP_REPLY's cursor + returned documents) and BSON sub-parsing is cross-message,
22
+ * opCode-dependent state, so this single-message codec keeps the body verbatim as `body` hex
23
+ * (byte-perfect) and does not sub-decode it. The messageLength is auto-computed from the body on encode
24
+ * when not supplied, else honored verbatim (a crafted message may lie); the message is bounded by
25
+ * messageLength so a second pipelined message or trailing bytes are left to the codec's recursion /
26
+ * RawData. A well-formed message round-trips byte-for-byte.
27
+ */
28
+ class MongoDB extends BaseHeader_1.BaseHeader {
29
+ constructor() {
30
+ super(...arguments);
31
+ this.id = 'mongodb';
32
+ this.name = 'MongoDB Wire Protocol';
33
+ this.nickname = 'MongoDB';
34
+ this.matchKeys = ['tcpport:27017'];
35
+ //A leaf header — the opCode-specific body (BSON sections/documents) requires cross-message,
36
+ //opCode-dependent parsing.
37
+ this.demuxProducers = [];
38
+ }
39
+ static #schemaCache;
40
+ get SCHEMA() {
41
+ return (MongoDB.#schemaCache ??= MongoDB.#buildSchema());
42
+ }
43
+ /** A little-endian unsigned 32-bit field of 4 octets at `offset` (MongoDB on-wire byte order). */
44
+ static #fieldUInt32LE(name, offset, label) {
45
+ return {
46
+ type: 'integer',
47
+ label: label,
48
+ minimum: 0,
49
+ maximum: 4294967295,
50
+ decode: function () {
51
+ const b = this.readBytes(offset, 4);
52
+ this.instance[name].setValue((b[0] | (b[1] << 8) | (b[2] << 16) | (b[3] << 24)) >>> 0);
53
+ },
54
+ encode: function () {
55
+ const node = this.instance[name];
56
+ let value = node.getValue(0, (nodePath) => this.recordError(nodePath, 'Not Found'));
57
+ if (value > 4294967295) {
58
+ this.recordError(node.getPath(), 'Maximum value is 4294967295');
59
+ value = 4294967295;
60
+ }
61
+ if (value < 0) {
62
+ this.recordError(node.getPath(), 'Minimum value is 0');
63
+ value = 0;
64
+ }
65
+ node.setValue(value);
66
+ this.writeBytes(offset, Buffer.from([value & 0xff, (value >> 8) & 0xff, (value >> 16) & 0xff, (value >>> 24) & 0xff]));
67
+ }
68
+ };
69
+ }
70
+ static #buildSchema() {
71
+ return {
72
+ type: 'object',
73
+ summary: 'MongoDB opCode=${opCode} len=${messageLength}',
74
+ properties: {
75
+ //All multi-byte fields are LITTLE-ENDIAN.
76
+ //messageLength counts the WHOLE message including this 16-byte header. Honored when
77
+ //supplied (a crafted message may lie); else derived from the header + body byte length.
78
+ messageLength: {
79
+ type: 'integer',
80
+ label: 'Message Length',
81
+ minimum: 0,
82
+ maximum: 4294967295,
83
+ decode: function () {
84
+ const b = this.readBytes(0, 4);
85
+ this.instance.messageLength.setValue((b[0] | (b[1] << 8) | (b[2] << 16) | (b[3] << 24)) >>> 0);
86
+ },
87
+ encode: function () {
88
+ const provided = this.instance.messageLength.getValue();
89
+ let value = (provided !== undefined && provided !== null)
90
+ ? provided
91
+ : 16 + (0, HexToBuffer_1.HexToBuffer)(this.instance.body.getValue('')).length;
92
+ if (value > 4294967295) {
93
+ this.recordError(this.instance.messageLength.getPath(), 'Maximum value is 4294967295');
94
+ value = 4294967295;
95
+ }
96
+ if (value < 0) {
97
+ this.recordError(this.instance.messageLength.getPath(), 'Minimum value is 0');
98
+ value = 0;
99
+ }
100
+ this.instance.messageLength.setValue(value);
101
+ this.writeBytes(0, Buffer.from([value & 0xff, (value >> 8) & 0xff, (value >> 16) & 0xff, (value >>> 24) & 0xff]));
102
+ }
103
+ },
104
+ requestID: this.#fieldUInt32LE('requestID', 4, 'Request ID'),
105
+ responseTo: this.#fieldUInt32LE('responseTo', 8, 'Response To'),
106
+ //opCode selects the body layout (2013 OP_MSG, 2004 OP_QUERY, 1 OP_REPLY, …). Kept as a
107
+ //plain little-endian uint32 — byte-perfect and editable; an unknown/crafted opCode is a
108
+ //valid packet, so no enum constraint is imposed (it would reject a legal decoded value).
109
+ opCode: this.#fieldUInt32LE('opCode', 12, 'Op Code'),
110
+ //The opCode-specific body after the 16-byte header, kept verbatim. Bounded by the message
111
+ //messageLength (the message ends at offset messageLength) and the captured bytes, so
112
+ //trailing / pipelined data is left to the codec's recursion / RawData.
113
+ body: {
114
+ type: 'string',
115
+ label: 'Body',
116
+ contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.HEX,
117
+ decode: function () {
118
+ const remaining = this.packet.length - this.startPos;
119
+ const length = this.instance.messageLength.getValue(0);
120
+ let end = length;
121
+ if (end > remaining)
122
+ end = remaining;
123
+ this.instance.body.setValue(end > 16 ? (0, BufferToHex_1.BufferToHex)(this.readBytes(16, end - 16)) : '');
124
+ },
125
+ encode: function () {
126
+ const body = this.instance.body.getValue('');
127
+ if (body)
128
+ this.writeBytes(16, (0, HexToBuffer_1.HexToBuffer)(body));
129
+ }
130
+ }
131
+ }
132
+ };
133
+ }
134
+ match() {
135
+ //MongoDB rides on TCP port 27017. The standard message header carries no strong content magic
136
+ //(the fields are counters / an opCode), so the well-known port is the signature: require the
137
+ //full 16-byte header to be present.
138
+ if (!this.prevCodecModule || this.prevCodecModule.id !== 'tcp')
139
+ return false;
140
+ return this.packet.length - this.startPos >= 16;
141
+ }
142
+ }
143
+ exports.MongoDB = MongoDB;
@@ -0,0 +1,30 @@
1
+ import { BaseHeader } from '../abstracts/BaseHeader';
2
+ import { ProtocolJSONSchema } from '../schema/ProtocolJSONSchema';
3
+ import { DemuxProducer } from '../types/DemuxProducer';
4
+ /**
5
+ * MySQL client/server protocol (MySQL / MariaDB wire protocol), TCP port 3306. Every message is framed by
6
+ * a 4-byte packet header — a 3-byte payload length followed by a 1-byte sequence id — then exactly
7
+ * `payloadLength` bytes of payload. The payload's meaning is connection-phase- and command-dependent
8
+ * (handshake, auth, command, resultset) and is cross-message stateful, so this single-message codec
9
+ * structures only the 4-byte packet header and keeps the payload verbatim as `payload` hex (byte-perfect).
10
+ *
11
+ * ⚠️ Unlike most of the codec's protocols, the 3-byte payload length is LITTLE-ENDIAN (the MySQL wire
12
+ * protocol is little-endian throughout). There is no little-endian helper in this codebase, so the length
13
+ * is read and written byte-by-byte in its closure: `b[0] | (b[1] << 8) | (b[2] << 16)` (max 0xFFFFFF, so
14
+ * no sign issue — the value is always < 2^24). See ENIP.ts for the same hand-written little-endian pattern.
15
+ *
16
+ * The payload is bounded by the length field (it ends at offset 4 + payloadLength) and by the captured
17
+ * bytes, so a pipelined second MySQL packet or trailing bytes in the same segment are left to the codec's
18
+ * recursion / RawData. The length is auto-computed from the payload on encode when not supplied, else
19
+ * honored verbatim (a crafted message may carry any length). A well-formed message round-trips byte-for-byte.
20
+ */
21
+ export declare class MySQL extends BaseHeader {
22
+ #private;
23
+ get SCHEMA(): ProtocolJSONSchema;
24
+ readonly id: string;
25
+ readonly name: string;
26
+ readonly nickname: string;
27
+ readonly matchKeys: string[];
28
+ match(): boolean;
29
+ readonly demuxProducers: DemuxProducer[];
30
+ }
@@ -0,0 +1,114 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MySQL = void 0;
4
+ const BaseHeader_1 = require("../abstracts/BaseHeader");
5
+ const BufferToHex_1 = require("../helper/BufferToHex");
6
+ const HexToBuffer_1 = require("../helper/HexToBuffer");
7
+ const StringContentEncodingEnum_1 = require("../lib/StringContentEncodingEnum");
8
+ /**
9
+ * MySQL client/server protocol (MySQL / MariaDB wire protocol), TCP port 3306. Every message is framed by
10
+ * a 4-byte packet header — a 3-byte payload length followed by a 1-byte sequence id — then exactly
11
+ * `payloadLength` bytes of payload. The payload's meaning is connection-phase- and command-dependent
12
+ * (handshake, auth, command, resultset) and is cross-message stateful, so this single-message codec
13
+ * structures only the 4-byte packet header and keeps the payload verbatim as `payload` hex (byte-perfect).
14
+ *
15
+ * ⚠️ Unlike most of the codec's protocols, the 3-byte payload length is LITTLE-ENDIAN (the MySQL wire
16
+ * protocol is little-endian throughout). There is no little-endian helper in this codebase, so the length
17
+ * is read and written byte-by-byte in its closure: `b[0] | (b[1] << 8) | (b[2] << 16)` (max 0xFFFFFF, so
18
+ * no sign issue — the value is always < 2^24). See ENIP.ts for the same hand-written little-endian pattern.
19
+ *
20
+ * The payload is bounded by the length field (it ends at offset 4 + payloadLength) and by the captured
21
+ * bytes, so a pipelined second MySQL packet or trailing bytes in the same segment are left to the codec's
22
+ * recursion / RawData. The length is auto-computed from the payload on encode when not supplied, else
23
+ * honored verbatim (a crafted message may carry any length). A well-formed message round-trips byte-for-byte.
24
+ */
25
+ class MySQL extends BaseHeader_1.BaseHeader {
26
+ constructor() {
27
+ super(...arguments);
28
+ this.id = 'mysql';
29
+ this.name = 'MySQL Protocol';
30
+ this.nickname = 'MySQL';
31
+ //MySQL is recognized ONLY on its well-known port bucket (tcp:3306) — deliberately NOT via
32
+ //heuristicFallback. The 4-byte packet header (a 3-byte length + a sequence id) carries no reliable
33
+ //mid-stream content signature: any TCP segment could begin with a plausible little-endian length, so a
34
+ //global heuristic would mislabel unrelated traffic as MySQL. Confining MySQL to its tcp:3306 bucket (as
35
+ //FTP/SMTP/POP3 are confined to theirs) keeps that collision impossible; alt-port MySQL is rare and
36
+ //falls losslessly to raw.
37
+ this.matchKeys = ['tcpport:3306'];
38
+ //A leaf header — the payload is phase/command-dependent, cross-message state; kept as hex, not demuxed.
39
+ this.demuxProducers = [];
40
+ }
41
+ static #schemaCache;
42
+ get SCHEMA() {
43
+ return (MySQL.#schemaCache ??= MySQL.#buildSchema());
44
+ }
45
+ static #buildSchema() {
46
+ return {
47
+ type: 'object',
48
+ summary: 'MySQL seq=${sequenceId} len=${payloadLength}',
49
+ properties: {
50
+ //The 3-byte payload length is LITTLE-ENDIAN (MySQL wire byte order); read/written by hand.
51
+ payloadLength: {
52
+ type: 'integer',
53
+ label: 'Payload Length',
54
+ minimum: 0,
55
+ maximum: 0xffffff,
56
+ decode: function () {
57
+ const b = this.readBytes(0, 3);
58
+ this.instance.payloadLength.setValue(b[0] | (b[1] << 8) | (b[2] << 16));
59
+ },
60
+ encode: function () {
61
+ //The length counts only the payload that follows the 4-byte packet header.
62
+ //Honored when supplied (a crafted message may lie); else derived from the payload.
63
+ const provided = this.instance.payloadLength.getValue();
64
+ let value = (provided !== undefined && provided !== null)
65
+ ? provided
66
+ : (0, HexToBuffer_1.HexToBuffer)(this.instance.payload.getValue('')).length;
67
+ if (value > 0xffffff) {
68
+ this.recordError(this.instance.payloadLength.getPath(), 'Maximum value is 16777215');
69
+ value = 0xffffff;
70
+ }
71
+ if (value < 0) {
72
+ this.recordError(this.instance.payloadLength.getPath(), 'Minimum value is 0');
73
+ value = 0;
74
+ }
75
+ this.instance.payloadLength.setValue(value);
76
+ //3-byte little-endian: low byte first. value < 2^24, so value >> 16 is a plain
77
+ //non-negative byte — no sign issue.
78
+ this.writeBytes(0, Buffer.from([value & 0xff, (value >> 8) & 0xff, (value >> 16) & 0xff]));
79
+ }
80
+ },
81
+ sequenceId: this.fieldUInt('sequenceId', 3, 1, 'Sequence ID'),
82
+ //The message payload after the 4-byte packet header, kept verbatim. Bounded by the length
83
+ //field (the message ends at offset 4 + payloadLength) and the captured bytes, so a pipelined
84
+ //second packet or trailing bytes are left to the codec's recursion / RawData.
85
+ payload: {
86
+ type: 'string',
87
+ label: 'Payload',
88
+ contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.HEX,
89
+ decode: function () {
90
+ const remaining = this.packet.length - this.startPos;
91
+ const length = this.instance.payloadLength.getValue(0);
92
+ let end = 4 + length;
93
+ if (end > remaining)
94
+ end = remaining;
95
+ this.instance.payload.setValue(end > 4 ? (0, BufferToHex_1.BufferToHex)(this.readBytes(4, end - 4)) : '');
96
+ },
97
+ encode: function () {
98
+ const payload = this.instance.payload.getValue('');
99
+ if (payload)
100
+ this.writeBytes(4, (0, HexToBuffer_1.HexToBuffer)(payload));
101
+ }
102
+ }
103
+ }
104
+ };
105
+ }
106
+ match() {
107
+ //MySQL rides on TCP port 3306. The packet header carries no strong content magic, so the
108
+ //well-known port is the signature: require at least the full 4-byte packet header to be present.
109
+ if (!this.prevCodecModule || this.prevCodecModule.id !== 'tcp')
110
+ return false;
111
+ return this.packet.length - this.startPos >= 4;
112
+ }
113
+ }
114
+ exports.MySQL = MySQL;
@@ -0,0 +1,29 @@
1
+ import { BaseHeader } from '../abstracts/BaseHeader';
2
+ import { ProtocolJSONSchema } from '../schema/ProtocolJSONSchema';
3
+ import { DemuxProducer } from '../types/DemuxProducer';
4
+ /**
5
+ * NATS — the client/server text protocol of the NATS messaging system, carried over TCP (well-known
6
+ * port 4222). A NATS message is US-ASCII text: an operation verb, optional arguments on the control line
7
+ * terminated by CRLF, and — for the publish/deliver verbs — a payload body also terminated by CRLF. The
8
+ * control operations are `INFO {json}`, `CONNECT {json}`, `PUB subject [reply] #bytes`,
9
+ * `HPUB ...`, `SUB subject [queue] sid`, `UNSUB sid [max]`, `MSG subject sid [reply] #bytes`,
10
+ * `HMSG ...`, `PING`, `PONG`, `+OK`, and `-ERR message`.
11
+ *
12
+ * Like SIP/HTTP, the message body is text whose full internal structure (arbitrary JSON options, subject
13
+ * hierarchies, header blocks, binary-safe payloads, significant whitespace) is far richer than a form
14
+ * needs, and TCP may coalesce or split messages so no per-message length is authoritative. So the ENTIRE
15
+ * raw segment is kept verbatim as the authoritative `message` field (hex) and re-emitted untouched; only
16
+ * the leading operation and its control line are parsed on decode into display-only metadata. Encode
17
+ * never reconstructs the message from the parsed fields — it writes `message` back byte-for-byte — so
18
+ * any conformant (or even malformed) NATS message round-trips exactly.
19
+ */
20
+ export declare class NATS extends BaseHeader {
21
+ #private;
22
+ get SCHEMA(): ProtocolJSONSchema;
23
+ readonly id: string;
24
+ readonly name: string;
25
+ readonly nickname: string;
26
+ readonly matchKeys: string[];
27
+ match(): boolean;
28
+ readonly demuxProducers: DemuxProducer[];
29
+ }
@@ -0,0 +1,135 @@
1
+ "use strict";
2
+ var _a;
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.NATS = void 0;
5
+ const BaseHeader_1 = require("../abstracts/BaseHeader");
6
+ const BufferToHex_1 = require("../helper/BufferToHex");
7
+ const HexToBuffer_1 = require("../helper/HexToBuffer");
8
+ const StringContentEncodingEnum_1 = require("../lib/StringContentEncodingEnum");
9
+ /**
10
+ * NATS control operations (the client/server protocol verbs). Operations that carry arguments on the
11
+ * control line are followed by a space; the standalone operations are followed by CRLF. The set is used
12
+ * only to recognize the leading operation of a message. NATS treats the verbs case-insensitively.
13
+ */
14
+ const NATS_ARG_OPS = ['CONNECT', 'INFO', 'HPUB', 'PUB', 'HMSG', 'MSG', 'SUB', 'UNSUB', '-ERR'];
15
+ const NATS_SOLO_OPS = ['PING', 'PONG', '+OK'];
16
+ /**
17
+ * NATS — the client/server text protocol of the NATS messaging system, carried over TCP (well-known
18
+ * port 4222). A NATS message is US-ASCII text: an operation verb, optional arguments on the control line
19
+ * terminated by CRLF, and — for the publish/deliver verbs — a payload body also terminated by CRLF. The
20
+ * control operations are `INFO {json}`, `CONNECT {json}`, `PUB subject [reply] #bytes`,
21
+ * `HPUB ...`, `SUB subject [queue] sid`, `UNSUB sid [max]`, `MSG subject sid [reply] #bytes`,
22
+ * `HMSG ...`, `PING`, `PONG`, `+OK`, and `-ERR message`.
23
+ *
24
+ * Like SIP/HTTP, the message body is text whose full internal structure (arbitrary JSON options, subject
25
+ * hierarchies, header blocks, binary-safe payloads, significant whitespace) is far richer than a form
26
+ * needs, and TCP may coalesce or split messages so no per-message length is authoritative. So the ENTIRE
27
+ * raw segment is kept verbatim as the authoritative `message` field (hex) and re-emitted untouched; only
28
+ * the leading operation and its control line are parsed on decode into display-only metadata. Encode
29
+ * never reconstructs the message from the parsed fields — it writes `message` back byte-for-byte — so
30
+ * any conformant (or even malformed) NATS message round-trips exactly.
31
+ */
32
+ class NATS extends BaseHeader_1.BaseHeader {
33
+ constructor() {
34
+ super(...arguments);
35
+ this.id = 'nats';
36
+ this.name = 'NATS Client Protocol';
37
+ this.nickname = 'NATS';
38
+ this.matchKeys = ['tcpport:4222'];
39
+ //A leaf header — the NATS payload body and the subscription/exchange it belongs to are higher-layer
40
+ //concerns; the raw message is kept verbatim.
41
+ this.demuxProducers = [];
42
+ }
43
+ static #schemaCache;
44
+ get SCHEMA() {
45
+ return (_a.#schemaCache ??= _a.#buildSchema());
46
+ }
47
+ /**
48
+ * Bytes of this header: NATS rides on TCP, which has no per-message length, so take the rest of the
49
+ * segment. Reassembly / message framing across segments is out of scope (see class doc).
50
+ */
51
+ #payloadLength() {
52
+ const available = this.packet.length - this.startPos;
53
+ return available < 0 ? 0 : available;
54
+ }
55
+ /** The first line of the message (up to the first CRLF, or the whole payload if none). */
56
+ static #firstLine(text) {
57
+ const idx = text.indexOf('\r\n');
58
+ return idx >= 0 ? text.slice(0, idx) : text;
59
+ }
60
+ /**
61
+ * Parse the control line into the display-only metadata fields: the leading operation verb
62
+ * (upper-cased, as NATS is case-insensitive) and the remaining control-line arguments. Populated on
63
+ * decode only — these fields have no encode, so they never affect the re-emitted bytes and never
64
+ * mutate `message`. Never throws: a missing operation yields empty strings.
65
+ */
66
+ #parseControlLine(text) {
67
+ const line = _a.#firstLine(text);
68
+ //The operation is the first whitespace-delimited token (space or tab); the rest is the argument
69
+ //list (JSON for INFO/CONNECT, subject/sid/#bytes for PUB/MSG/SUB, message for -ERR, or empty).
70
+ const spaceIdx = line.search(/[ \t]/);
71
+ const operation = spaceIdx >= 0 ? line.slice(0, spaceIdx) : line;
72
+ const args = spaceIdx >= 0 ? line.slice(spaceIdx + 1) : '';
73
+ this.instance.operation.setValue(operation.toUpperCase());
74
+ this.instance.controlArguments.setValue(args);
75
+ }
76
+ static #buildSchema() {
77
+ return {
78
+ type: 'object',
79
+ summary: 'NATS ${operation}',
80
+ properties: {
81
+ //The whole raw segment is the single source of truth: decoded verbatim to hex and
82
+ //re-emitted untouched (byte-perfect for any NATS message). The control line is parsed into
83
+ //the display-only metadata below, which carry no codec of their own.
84
+ message: {
85
+ type: 'string',
86
+ label: 'Message',
87
+ contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.HEX,
88
+ decode: function () {
89
+ const available = this.#payloadLength();
90
+ if (available <= 0) {
91
+ this.instance.message.setValue('');
92
+ this.#parseControlLine('');
93
+ return;
94
+ }
95
+ const raw = this.readBytes(0, available);
96
+ this.instance.message.setValue((0, BufferToHex_1.BufferToHex)(raw));
97
+ this.#parseControlLine(raw.toString('latin1'));
98
+ },
99
+ encode: function () {
100
+ //Re-emit the authoritative message verbatim — never reconstruct from metadata.
101
+ this.writeBytes(0, (0, HexToBuffer_1.HexToBuffer)(this.instance.message.getValue('')));
102
+ }
103
+ },
104
+ //Display-only metadata parsed from the control line on decode (no encode — populated by the
105
+ //message field above, never read back). operation is the leading verb (upper-cased);
106
+ //controlArguments is the remainder of the control line (empty for PING/PONG/+OK).
107
+ operation: { type: 'string', label: 'Operation' },
108
+ controlArguments: { type: 'string', label: 'Arguments' }
109
+ }
110
+ };
111
+ }
112
+ match() {
113
+ //NATS rides on TCP port 4222 as US-ASCII text. Recognize it by the operation signature: a known
114
+ //argument-carrying verb followed by a space, or a standalone verb followed by CRLF — so non-NATS
115
+ //traffic on port 4222 falls through to raw rather than claiming an un-decodable text layer. The
116
+ //verbs are matched case-insensitively (NATS is case-insensitive). No heuristicFallback: selection
117
+ //stays strictly port-bucketed like the other text TCP payload codecs.
118
+ if (!this.prevCodecModule || this.prevCodecModule.id !== 'tcp')
119
+ return false;
120
+ if (this.#payloadLength() <= 0)
121
+ return false;
122
+ const lead = this.readBytes(0, 12, true).toString('latin1').toUpperCase();
123
+ for (const op of NATS_ARG_OPS) {
124
+ if (lead.startsWith(op + ' '))
125
+ return true;
126
+ }
127
+ for (const op of NATS_SOLO_OPS) {
128
+ if (lead.startsWith(op + '\r'))
129
+ return true;
130
+ }
131
+ return false;
132
+ }
133
+ }
134
+ exports.NATS = NATS;
135
+ _a = NATS;
@@ -0,0 +1,34 @@
1
+ import { BaseHeader } from '../abstracts/BaseHeader';
2
+ import { ProtocolJSONSchema } from '../schema/ProtocolJSONSchema';
3
+ import { DemuxProducer } from '../types/DemuxProducer';
4
+ /**
5
+ * NBDS — NetBIOS Datagram Service (RFC 1002 §4.4), the NetBIOS-over-TCP/IP datagram service on UDP 138.
6
+ * Every NBDS packet opens with a fixed 10-byte common prefix — a 1-byte Message Type, a 1-byte Flags
7
+ * octet (MORE/FIRST fragment bits + 2-bit Source End-Node Type + reserved bits), a 2-byte Datagram ID,
8
+ * the 4-byte Source IP and the 2-byte Source Port of the originating node.
9
+ *
10
+ * What follows the prefix depends on the Message Type. The DIRECT_UNIQUE (0x10), DIRECT_GROUP (0x11)
11
+ * and BROADCAST (0x12) datagrams add a 2-byte Datagram Length and a 2-byte Packet Offset (fragmentation
12
+ * offset), then the second-level-encoded Source and Destination NetBIOS names followed by the user data
13
+ * (an SMB mailslot payload, e.g. a browser announcement). DATAGRAM ERROR (0x13) carries a 1-byte error
14
+ * code; the QUERY messages (0x14/0x15/0x16) carry only a destination name. So only the Direct/Broadcast
15
+ * types have the Datagram-Length / Packet-Offset words — they are structured for those types and left out
16
+ * of the byte stream otherwise (mirroring COTP's DT-only fields).
17
+ *
18
+ * The names + user data (for Direct/Broadcast) or the type-specific remainder (for the other types) are
19
+ * kept verbatim as `body` hex, bounded by the UDP payload length so trailing bytes are not absorbed:
20
+ * decoding the second-level NetBIOS names and handing the user data to SMB is a later enrichment. Message
21
+ * Type is stored as the raw octet (fieldUInt — no enum, so a crafted/unknown type still round-trips) and
22
+ * the Datagram Length is honored on encode when supplied, else derived from the body. A well-formed
23
+ * datagram of any type round-trips byte-for-byte.
24
+ */
25
+ export declare class NBDS extends BaseHeader {
26
+ #private;
27
+ get SCHEMA(): ProtocolJSONSchema;
28
+ readonly id: string;
29
+ readonly name: string;
30
+ readonly nickname: string;
31
+ readonly matchKeys: string[];
32
+ match(): boolean;
33
+ readonly demuxProducers: DemuxProducer[];
34
+ }