@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,193 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Telnet = 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
+ /** The Interpret As Command escape (RFC 854): every in-band command begins with this byte. */
9
+ const IAC = 0xFF;
10
+ /** SE — the byte that ends a subnegotiation (paired as `IAC SE`, i.e. FF F0). */
11
+ const SE = 0xF0;
12
+ /** Command byte → mnemonic (RFC 854 §Commands; 255 is the escaped-IAC data byte, shown as "IAC"). */
13
+ const COMMAND_NAMES = {
14
+ 240: 'SE', 241: 'NOP', 242: 'DM', 243: 'BRK', 244: 'IP', 245: 'AO', 246: 'AYT',
15
+ 247: 'EC', 248: 'EL', 249: 'GA', 250: 'SB', 251: 'WILL', 252: 'WONT', 253: 'DO',
16
+ 254: 'DONT', 255: 'IAC'
17
+ };
18
+ /** Common Telnet option codes → name (display only; unknown options resolve to ''). */
19
+ const OPTION_NAMES = {
20
+ 0: 'Binary Transmission', 1: 'Echo', 3: 'Suppress Go Ahead', 5: 'Status',
21
+ 6: 'Timing Mark', 24: 'Terminal Type', 31: 'Window Size (NAWS)', 32: 'Terminal Speed',
22
+ 33: 'Remote Flow Control', 34: 'Linemode', 35: 'X Display Location', 36: 'Environment Option',
23
+ 39: 'New Environment Option'
24
+ };
25
+ /**
26
+ * Telnet — the Telnet Protocol (RFC 854), carried over TCP well-known port 23. Telnet is a raw byte
27
+ * stream that interleaves user data with in-band control commands. A command is introduced by the IAC
28
+ * (Interpret As Command) escape 0xFF and is followed by a command byte:
29
+ *
30
+ * 241 NOP · 242 DM · 243 BRK · 244 IP · 245 AO · 246 AYT · 247 EC · 248 EL · 249 GA (2-byte commands)
31
+ * 251 WILL · 252 WONT · 253 DO · 254 DONT (3-byte: FF <cmd> <option>)
32
+ * 250 SB … 240 SE (subnegotiation, ends at FF F0)
33
+ * 255 (escaped IAC — a literal 0xFF DATA byte)
34
+ *
35
+ * MINIMAL slice (mirrors the SSH/RFB verbatim-message pattern): the connection is a stream with no
36
+ * per-message framing, so the ENTIRE payload is the single source of truth — decoded verbatim to hex in
37
+ * the authoritative `message` field and re-emitted byte-for-byte on encode. On top of that, the leading
38
+ * run of IAC command sequences is parsed into DISPLAY-ONLY metadata: `commands` (an array of
39
+ * {command, option?}) and `isNegotiation` (true when the payload opens with an IAC byte). Those carry no
40
+ * codec of their own and never reconstruct the bytes — the message owns them. So any Telnet payload
41
+ * (option negotiation, subnegotiation, plain data, or a truncated fragment) round-trips exactly.
42
+ *
43
+ * Matching rationale (NO heuristicFallback): Telnet is claimed ONLY on the tcp:23 bucket. Telnet has NO
44
+ * distinctive off-port content signature — it is an arbitrary byte stream (a leading IAC is common but
45
+ * optional, and in binary mode the data can be anything), so recognizing it relies entirely on the
46
+ * well-known port. Joining the global content-heuristic chain would therefore let Telnet mislabel
47
+ * arbitrary TCP payloads on any port. Confining Telnet to tcp:23 keeps that impossible; alt-port Telnet
48
+ * is rare and falls losslessly to raw. For the same reason match() deliberately does NOT gate on a
49
+ * leading IAC or printable text: on the port-23 bucket every payload IS Telnet (including binary-mode
50
+ * data), so any non-empty payload is kept verbatim rather than dropped to raw.
51
+ */
52
+ class Telnet extends BaseHeader_1.BaseHeader {
53
+ constructor() {
54
+ super(...arguments);
55
+ this.id = 'telnet';
56
+ this.name = 'Telnet';
57
+ this.nickname = 'Telnet';
58
+ //Telnet is recognized ONLY on the well-known port 23 — deliberately NOT via heuristicFallback. Telnet
59
+ //is a raw byte stream with no distinctive off-port content signature (a leading IAC is common but
60
+ //optional, and binary-mode data is arbitrary), so its recognition depends entirely on the port bucket;
61
+ //joining the global heuristic chain would mislabel arbitrary TCP traffic. See the class doc.
62
+ this.matchKeys = ['tcpport:23'];
63
+ //A leaf header — the Telnet byte stream is the terminal session itself; nothing demuxes off it.
64
+ this.demuxProducers = [];
65
+ }
66
+ static #schemaCache;
67
+ get SCHEMA() {
68
+ return (Telnet.#schemaCache ??= Telnet.#buildSchema());
69
+ }
70
+ /** Bytes available to this header: Telnet rides on TCP, which has no per-message length. */
71
+ #payloadLength() {
72
+ const available = this.packet.length - this.startPos;
73
+ return available < 0 ? 0 : available;
74
+ }
75
+ /**
76
+ * Parse the leading run of IAC command sequences into the display-only `commands` array and set
77
+ * `isNegotiation`. Populated on decode only — these fields have no encode, so they never affect the
78
+ * re-emitted bytes and never mutate `message`. Never throws: a dangling/truncated IAC simply stops
79
+ * the walk, and a payload with no leading IAC yields an empty list.
80
+ */
81
+ #parseCommands(raw) {
82
+ const len = raw.length;
83
+ this.instance.isNegotiation.setValue(len >= 1 && raw[0] === IAC);
84
+ const commands = [];
85
+ let offset = 0;
86
+ while (offset < len && raw[offset] === IAC) {
87
+ //A dangling IAC at end-of-buffer is not a complete command — stop.
88
+ if (offset + 1 >= len)
89
+ break;
90
+ const cmd = raw[offset + 1];
91
+ //IAC IAC is an ESCAPED 0xFF data byte, not a command — the command run ends here.
92
+ if (cmd === IAC)
93
+ break;
94
+ const commandName = COMMAND_NAMES[cmd] ?? 'Unknown';
95
+ if (cmd >= 251 && cmd <= 254) {
96
+ //WILL/WONT/DO/DONT — a 3-byte command carrying an option byte.
97
+ if (offset + 2 >= len)
98
+ break;
99
+ const option = raw[offset + 2];
100
+ commands.push({ command: cmd, commandName: commandName, option: option, optionName: OPTION_NAMES[option] ?? '' });
101
+ offset += 3;
102
+ }
103
+ else if (cmd === 250) {
104
+ //SB — subnegotiation: `FF FA <option> …params… FF F0`. Capture the option, then skip to
105
+ //just past the terminating IAC SE (or to end-of-buffer if it is unterminated/truncated).
106
+ const option = offset + 2 < len ? raw[offset + 2] : undefined;
107
+ const entry = { command: cmd, commandName: commandName };
108
+ if (option !== undefined) {
109
+ entry.option = option;
110
+ entry.optionName = OPTION_NAMES[option] ?? '';
111
+ }
112
+ commands.push(entry);
113
+ let se = -1;
114
+ for (let i = offset + 2; i + 1 < len; i++) {
115
+ if (raw[i] === IAC && raw[i + 1] === SE) {
116
+ se = i;
117
+ break;
118
+ }
119
+ }
120
+ if (se === -1)
121
+ break;
122
+ offset = se + 2;
123
+ }
124
+ else {
125
+ //240 SE / 241..249 — a 2-byte command with no option.
126
+ commands.push({ command: cmd, commandName: commandName });
127
+ offset += 2;
128
+ }
129
+ }
130
+ this.instance.commands.setValue(commands);
131
+ }
132
+ static #buildSchema() {
133
+ return {
134
+ type: 'object',
135
+ summary: 'Telnet',
136
+ properties: {
137
+ //Display-only metadata parsed from the leading IAC command run on decode (no encode —
138
+ //populated by the `message` field below, never read back). isNegotiation flags a payload
139
+ //that opens with an IAC byte; commands lists the leading command sequences for the UI.
140
+ isNegotiation: { type: 'boolean', label: 'Is Negotiation', default: false },
141
+ commands: {
142
+ type: 'array',
143
+ label: 'IAC Commands',
144
+ items: {
145
+ type: 'object',
146
+ label: 'Command',
147
+ properties: {
148
+ command: { type: 'integer', label: 'Command', minimum: 0, maximum: 255 },
149
+ commandName: { type: 'string', label: 'Command Name' },
150
+ option: { type: 'integer', label: 'Option', minimum: 0, maximum: 255 },
151
+ optionName: { type: 'string', label: 'Option Name' }
152
+ }
153
+ }
154
+ },
155
+ //The whole raw payload is the single source of truth: decoded verbatim to hex and
156
+ //re-emitted untouched (byte-perfect for any Telnet payload). The leading IAC command run is
157
+ //parsed into the display-only metadata above, which carry no codec of their own.
158
+ message: {
159
+ type: 'string',
160
+ label: 'Message',
161
+ contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.HEX,
162
+ default: '',
163
+ decode: function () {
164
+ const available = this.#payloadLength();
165
+ if (available <= 0) {
166
+ this.instance.message.setValue('');
167
+ this.#parseCommands(Buffer.alloc(0));
168
+ return;
169
+ }
170
+ const raw = this.readBytes(0, available);
171
+ this.instance.message.setValue((0, BufferToHex_1.BufferToHex)(raw));
172
+ this.#parseCommands(raw);
173
+ },
174
+ encode: function () {
175
+ //Re-emit the authoritative payload verbatim — never reconstruct from metadata.
176
+ this.writeBytes(0, (0, HexToBuffer_1.HexToBuffer)(this.instance.message.getValue('')));
177
+ }
178
+ }
179
+ }
180
+ };
181
+ }
182
+ match() {
183
+ //Reached only on the tcp:23 bucket. Port 23 IS Telnet's, so any non-empty payload over TCP is
184
+ //claimed and kept verbatim (byte-perfect) — deliberately without an IAC/printable gate, so
185
+ //binary-mode Telnet data is never wrongly dropped to raw. An empty payload is not claimed.
186
+ if (!this.prevCodecModule)
187
+ return false;
188
+ if (this.prevCodecModule.id !== 'tcp')
189
+ return false;
190
+ return this.#payloadLength() >= 1;
191
+ }
192
+ }
193
+ exports.Telnet = Telnet;
@@ -0,0 +1,40 @@
1
+ import { BaseHeader } from '../abstracts/BaseHeader';
2
+ import { ProtocolJSONSchema } from '../schema/ProtocolJSONSchema';
3
+ import { DemuxProducer } from '../types/DemuxProducer';
4
+ /**
5
+ * Teredo — tunneling IPv6 over UDP through NATs (RFC 4380), UDP port 3544. A Teredo message carried in
6
+ * the UDP payload is an inner IPv6 packet, OPTIONALLY prefixed by one or both Teredo indication headers
7
+ * (RFC 4380 §5.1.1), always in this order:
8
+ *
9
+ * 1. Authentication indication (Indicator Type 0x0001): a 2-byte type, a 1-byte Client-ID length, a
10
+ * 1-byte Authentication-value length, the client identifier, the authentication value, an 8-byte
11
+ * nonce and a 1-byte confirmation. Total = 13 + ID-len + AU-len bytes.
12
+ * 2. Origin indication (Indicator Type 0x0000): a 2-byte type, the 2-byte mapped port and the 4-byte
13
+ * mapped IPv4 address of the sender as seen by the Teredo relay/server. Total = 8 bytes. Both the
14
+ * port and the address are OBFUSCATED on the wire by an exclusive-or (RFC 4380 §5.1.1): the port
15
+ * with 0xFFFF and the address with 0xFFFFFFFF. This codec stores the de-obfuscated (mapped) values
16
+ * for the editor and re-applies the exclusive-or on encode — XOR is exactly reversible, so the
17
+ * frame round-trips byte-for-byte.
18
+ *
19
+ * An indication header is detected purely by content: an inner IPv6 packet always begins with the
20
+ * version nibble 6 (first octet 0x6X), so the first two octets can never be 0x0000 or 0x0001 — the two
21
+ * indicator types are therefore unambiguous signatures at the start of the (post-authentication) payload.
22
+ *
23
+ * Minimal slice: the indication headers are parsed into structured fields; the inner IPv6 packet (and
24
+ * anything after the indications) is kept verbatim as `payload` hex and is NOT recursed into — routing
25
+ * it back through the IPv6 header would require changing IPv6.match to accept a Teredo parent, left to a
26
+ * later serial step. The ID-len / AU-len bytes are derived from the client-identifier / authentication-
27
+ * value byte lengths (kept consistent with the bytes actually written); the payload is bounded by the
28
+ * parent UDP length so trailing Ethernet padding is left to the codec's recursion / RawData. A
29
+ * well-formed message round-trips byte-for-byte.
30
+ */
31
+ export declare class Teredo extends BaseHeader {
32
+ #private;
33
+ get SCHEMA(): ProtocolJSONSchema;
34
+ readonly id: string;
35
+ readonly name: string;
36
+ readonly nickname: string;
37
+ readonly matchKeys: string[];
38
+ match(): boolean;
39
+ readonly demuxProducers: DemuxProducer[];
40
+ }
@@ -0,0 +1,251 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Teredo = 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 BufferToNumber_1 = require("../helper/BufferToNumber");
8
+ const NumberToBuffer_1 = require("../helper/NumberToBuffer");
9
+ const BufferToIP_1 = require("../helper/BufferToIP");
10
+ const IPToBuffer_1 = require("../helper/IPToBuffer");
11
+ const StringContentEncodingEnum_1 = require("../lib/StringContentEncodingEnum");
12
+ /**
13
+ * Teredo — tunneling IPv6 over UDP through NATs (RFC 4380), UDP port 3544. A Teredo message carried in
14
+ * the UDP payload is an inner IPv6 packet, OPTIONALLY prefixed by one or both Teredo indication headers
15
+ * (RFC 4380 §5.1.1), always in this order:
16
+ *
17
+ * 1. Authentication indication (Indicator Type 0x0001): a 2-byte type, a 1-byte Client-ID length, a
18
+ * 1-byte Authentication-value length, the client identifier, the authentication value, an 8-byte
19
+ * nonce and a 1-byte confirmation. Total = 13 + ID-len + AU-len bytes.
20
+ * 2. Origin indication (Indicator Type 0x0000): a 2-byte type, the 2-byte mapped port and the 4-byte
21
+ * mapped IPv4 address of the sender as seen by the Teredo relay/server. Total = 8 bytes. Both the
22
+ * port and the address are OBFUSCATED on the wire by an exclusive-or (RFC 4380 §5.1.1): the port
23
+ * with 0xFFFF and the address with 0xFFFFFFFF. This codec stores the de-obfuscated (mapped) values
24
+ * for the editor and re-applies the exclusive-or on encode — XOR is exactly reversible, so the
25
+ * frame round-trips byte-for-byte.
26
+ *
27
+ * An indication header is detected purely by content: an inner IPv6 packet always begins with the
28
+ * version nibble 6 (first octet 0x6X), so the first two octets can never be 0x0000 or 0x0001 — the two
29
+ * indicator types are therefore unambiguous signatures at the start of the (post-authentication) payload.
30
+ *
31
+ * Minimal slice: the indication headers are parsed into structured fields; the inner IPv6 packet (and
32
+ * anything after the indications) is kept verbatim as `payload` hex and is NOT recursed into — routing
33
+ * it back through the IPv6 header would require changing IPv6.match to accept a Teredo parent, left to a
34
+ * later serial step. The ID-len / AU-len bytes are derived from the client-identifier / authentication-
35
+ * value byte lengths (kept consistent with the bytes actually written); the payload is bounded by the
36
+ * parent UDP length so trailing Ethernet padding is left to the codec's recursion / RawData. A
37
+ * well-formed message round-trips byte-for-byte.
38
+ */
39
+ class Teredo extends BaseHeader_1.BaseHeader {
40
+ constructor() {
41
+ super(...arguments);
42
+ this.id = 'teredo';
43
+ this.name = 'Teredo IPv6 over UDP tunneling';
44
+ this.nickname = 'Teredo';
45
+ this.matchKeys = ['udpport:3544'];
46
+ //A leaf header — the inner IPv6 packet is kept as payload hex (not recursed, see class comment).
47
+ this.demuxProducers = [];
48
+ }
49
+ static #schemaCache;
50
+ get SCHEMA() {
51
+ return (Teredo.#schemaCache ??= Teredo.#buildSchema());
52
+ }
53
+ /** Clamp a number into [lo, hi] without throwing (mirrors the fieldUInt clamp contract). */
54
+ static #clamp(value, lo, hi) {
55
+ if (!Number.isFinite(value))
56
+ return lo;
57
+ if (value < lo)
58
+ return lo;
59
+ if (value > hi)
60
+ return hi;
61
+ return Math.trunc(value);
62
+ }
63
+ /**
64
+ * Byte length of the Authentication indication header as it exists on the wire / will be written,
65
+ * or 0 when absent. Derived from the client-identifier / authentication-value byte lengths (each
66
+ * capped at 255, a single ID-len/AU-len octet), so decode (where those equal the decoded lengths)
67
+ * and encode compute the SAME offsets for the origin header and the inner payload.
68
+ */
69
+ #authLength() {
70
+ if (this.instance.authentication.isUndefined())
71
+ return 0;
72
+ const authentication = this.instance.authentication;
73
+ const idLength = Math.min(255, (0, HexToBuffer_1.HexToBuffer)(authentication.clientId.getValue('')).length);
74
+ const auLength = Math.min(255, (0, HexToBuffer_1.HexToBuffer)(authentication.authData.getValue('')).length);
75
+ //2 (type) + 1 (ID-len) + 1 (AU-len) + idLength + auLength + 8 (nonce) + 1 (confirmation).
76
+ return 13 + idLength + auLength;
77
+ }
78
+ /** Byte length of the Origin indication header (fixed 8 bytes) or 0 when absent. */
79
+ #originLength() {
80
+ return this.instance.origin.isUndefined() ? 0 : 8;
81
+ }
82
+ /** Offset where the inner IPv6 payload begins: after whichever indication headers are present. */
83
+ #payloadStart() {
84
+ return this.#authLength() + this.#originLength();
85
+ }
86
+ /** End of this Teredo message within the captured bytes, bounded by the parent UDP payload (udp.length − 8). */
87
+ #payloadEnd() {
88
+ let end = this.packet.length - this.startPos;
89
+ const prev = this.prevCodecModule;
90
+ if (prev && prev.id === 'udp') {
91
+ const udpLength = prev.instance.length.getValue(0);
92
+ if (udpLength >= 8 && udpLength - 8 < end)
93
+ end = udpLength - 8;
94
+ }
95
+ return end < 0 ? 0 : end;
96
+ }
97
+ static #buildSchema() {
98
+ return {
99
+ type: 'object',
100
+ summary: 'Teredo IPv6-over-UDP',
101
+ properties: {
102
+ //Authentication indication (RFC 4380 §5.1.1), present only when the payload starts with
103
+ //Indicator Type 0x0001. The decode/encode logic lives on this parent object; the child
104
+ //properties are declarative (UI form metadata) so they are not decoded a second time.
105
+ authentication: {
106
+ type: 'object',
107
+ label: 'Authentication Indication',
108
+ properties: {
109
+ clientIdLength: { type: 'integer', label: 'Client ID Length', minimum: 0, maximum: 255 },
110
+ authDataLength: { type: 'integer', label: 'Authentication Value Length', minimum: 0, maximum: 255 },
111
+ clientId: { type: 'string', label: 'Client Identifier', contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.HEX },
112
+ authData: { type: 'string', label: 'Authentication Value', contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.HEX },
113
+ nonce: { type: 'string', label: 'Nonce', contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.HEX },
114
+ confirmation: { type: 'integer', label: 'Confirmation', minimum: 0, maximum: 255 }
115
+ },
116
+ decode: function () {
117
+ //Peek (dryRun) the indicator type — an inner IPv6 packet starts 0x6X, so only a
118
+ //genuine Authentication indication reads 0x0001 here.
119
+ if ((0, BufferToNumber_1.BufferToUInt16)(this.readBytes(0, 2, true)) !== 0x0001)
120
+ return;
121
+ const idLength = (0, BufferToNumber_1.BufferToUInt8)(this.readBytes(2, 1, true));
122
+ const auLength = (0, BufferToNumber_1.BufferToUInt8)(this.readBytes(3, 1, true));
123
+ //The WHOLE authentication header must fit inside the payload; otherwise this is a
124
+ //truncated/spoofed prefix — leave the bytes to `payload` so they round-trip verbatim.
125
+ if (13 + idLength + auLength > this.#payloadEnd())
126
+ return;
127
+ const clientId = this.readBytes(4, idLength);
128
+ const authData = this.readBytes(4 + idLength, auLength);
129
+ const nonce = this.readBytes(4 + idLength + auLength, 8);
130
+ const confirmation = (0, BufferToNumber_1.BufferToUInt8)(this.readBytes(12 + idLength + auLength, 1));
131
+ this.instance.authentication.setValue({
132
+ clientIdLength: idLength,
133
+ authDataLength: auLength,
134
+ clientId: (0, BufferToHex_1.BufferToHex)(clientId),
135
+ authData: (0, BufferToHex_1.BufferToHex)(authData),
136
+ nonce: (0, BufferToHex_1.BufferToHex)(nonce),
137
+ confirmation: confirmation
138
+ });
139
+ },
140
+ encode: function () {
141
+ if (this.instance.authentication.isUndefined())
142
+ return;
143
+ const authentication = this.instance.authentication;
144
+ //ID-len / AU-len are derived from (and capped to) the actual bytes written, so
145
+ //the length octets and the following data can never disagree.
146
+ const clientId = (0, HexToBuffer_1.HexToBuffer)(authentication.clientId.getValue('')).subarray(0, 255);
147
+ const authData = (0, HexToBuffer_1.HexToBuffer)(authentication.authData.getValue('')).subarray(0, 255);
148
+ //Nonce is a fixed 8-byte field; pad/truncate so #authLength's constant 13 holds.
149
+ let nonce = (0, HexToBuffer_1.HexToBuffer)(authentication.nonce.getValue(''));
150
+ if (nonce.length < 8)
151
+ nonce = Buffer.concat([nonce, Buffer.alloc(8 - nonce.length, 0)]);
152
+ else if (nonce.length > 8)
153
+ nonce = nonce.subarray(0, 8);
154
+ const confirmation = Teredo.#clamp(authentication.confirmation.getValue(0), 0, 255);
155
+ const idLength = clientId.length;
156
+ const auLength = authData.length;
157
+ this.writeBytes(0, (0, NumberToBuffer_1.UInt16ToBuffer)(0x0001));
158
+ this.writeBytes(2, (0, NumberToBuffer_1.UInt8ToBuffer)(idLength));
159
+ this.writeBytes(3, (0, NumberToBuffer_1.UInt8ToBuffer)(auLength));
160
+ this.writeBytes(4, clientId);
161
+ this.writeBytes(4 + idLength, authData);
162
+ this.writeBytes(4 + idLength + auLength, nonce);
163
+ this.writeBytes(12 + idLength + auLength, (0, NumberToBuffer_1.UInt8ToBuffer)(confirmation));
164
+ }
165
+ },
166
+ //Origin indication (RFC 4380 §5.1.1), present only when the payload (after any
167
+ //Authentication indication) starts with Indicator Type 0x0000. Port and address are
168
+ //stored de-obfuscated (mapped) and re-obfuscated (XOR) on encode.
169
+ origin: {
170
+ type: 'object',
171
+ label: 'Origin Indication',
172
+ properties: {
173
+ port: { type: 'integer', label: 'Mapped Port', minimum: 0, maximum: 65535 },
174
+ address: {
175
+ type: 'string',
176
+ label: 'Mapped Address',
177
+ minLength: 7,
178
+ maxLength: 15,
179
+ contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.IPv4
180
+ }
181
+ },
182
+ decode: function () {
183
+ const start = this.#authLength();
184
+ if ((0, BufferToNumber_1.BufferToUInt16)(this.readBytes(start, 2, true)) !== 0x0000)
185
+ return;
186
+ //A full 8-byte origin header must fit; otherwise leave the bytes to the payload.
187
+ if (start + 8 > this.#payloadEnd())
188
+ return;
189
+ const wirePort = (0, BufferToNumber_1.BufferToUInt16)(this.readBytes(start + 2, 2));
190
+ const wireAddress = this.readBytes(start + 4, 4);
191
+ const mappedAddress = Buffer.from([
192
+ wireAddress[0] ^ 0xff,
193
+ wireAddress[1] ^ 0xff,
194
+ wireAddress[2] ^ 0xff,
195
+ wireAddress[3] ^ 0xff
196
+ ]);
197
+ this.instance.origin.setValue({
198
+ port: (wirePort ^ 0xffff) & 0xffff,
199
+ address: (0, BufferToIP_1.BufferToIPv4)(mappedAddress)
200
+ });
201
+ },
202
+ encode: function () {
203
+ if (this.instance.origin.isUndefined())
204
+ return;
205
+ const start = this.#authLength();
206
+ const origin = this.instance.origin;
207
+ const port = Teredo.#clamp(origin.port.getValue(0, (nodePath) => this.recordError(nodePath, 'Not Found')), 0, 65535);
208
+ const address = origin.address.getValue('0.0.0.0', (nodePath) => this.recordError(nodePath, 'Not Found'));
209
+ const addressBuffer = (0, IPToBuffer_1.IPv4ToBuffer)(address);
210
+ const wireAddress = Buffer.from([
211
+ addressBuffer[0] ^ 0xff,
212
+ addressBuffer[1] ^ 0xff,
213
+ addressBuffer[2] ^ 0xff,
214
+ addressBuffer[3] ^ 0xff
215
+ ]);
216
+ this.writeBytes(start, (0, NumberToBuffer_1.UInt16ToBuffer)(0x0000));
217
+ this.writeBytes(start + 2, (0, NumberToBuffer_1.UInt16ToBuffer)((port ^ 0xffff) & 0xffff));
218
+ this.writeBytes(start + 4, wireAddress);
219
+ }
220
+ },
221
+ //The inner IPv6 packet (and anything after the indications), kept verbatim. Bounded by
222
+ //the parent UDP payload, so trailing padding is left to the codec's recursion / RawData.
223
+ //Not recursed into (would need an IPv6.match change) — a later serial step.
224
+ payload: {
225
+ type: 'string',
226
+ label: 'Payload',
227
+ contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.HEX,
228
+ decode: function () {
229
+ const start = this.#payloadStart();
230
+ const end = this.#payloadEnd();
231
+ this.instance.payload.setValue(end > start ? (0, BufferToHex_1.BufferToHex)(this.readBytes(start, end - start)) : '');
232
+ },
233
+ encode: function () {
234
+ const payload = this.instance.payload.getValue('');
235
+ if (payload)
236
+ this.writeBytes(this.#payloadStart(), (0, HexToBuffer_1.HexToBuffer)(payload));
237
+ }
238
+ }
239
+ }
240
+ };
241
+ }
242
+ match() {
243
+ //Teredo rides on UDP port 3544 (the port bucket selects this candidate). Confirm a UDP parent
244
+ //and at least one payload byte; the message is either an inner IPv6 packet or an indication
245
+ //header, both recognised by content inside decode.
246
+ if (!this.prevCodecModule || this.prevCodecModule.id !== 'udp')
247
+ return false;
248
+ return this.packet.length - this.startPos >= 1;
249
+ }
250
+ }
251
+ exports.Teredo = Teredo;
@@ -0,0 +1,25 @@
1
+ import { BaseHeader } from '../abstracts/BaseHeader';
2
+ import { ProtocolJSONSchema } from '../schema/ProtocolJSONSchema';
3
+ import { DemuxProducer } from '../types/DemuxProducer';
4
+ /**
5
+ * Time Protocol (RFC 868), TCP & UDP well-known port 37. A trivial time service: the server returns the
6
+ * time as the number of seconds since 00:00 (midnight) 1 January 1900 GMT, in a single 32-bit big-endian
7
+ * unsigned integer. Over TCP the client opens a connection and the server sends the 4 octets then closes;
8
+ * over UDP the client sends an empty datagram and the server replies with a 4-octet datagram. The request
9
+ * carries no payload, so only the 4-octet response is a Time Protocol message this codec claims.
10
+ *
11
+ * The whole message is exactly one field — `time`, the 32-bit seconds count — kept as a plain uint so any
12
+ * on-wire value (including the post-2036 wrap once the counter passes 0x80000000) round-trips byte-for-byte
13
+ * and can be re-encoded without an Ajv rejection. The response is exactly 4 octets; anything beyond is left
14
+ * to the codec's recursion / RawData. A well-formed message round-trips byte-for-byte.
15
+ */
16
+ export declare class TimeProtocol extends BaseHeader {
17
+ #private;
18
+ get SCHEMA(): ProtocolJSONSchema;
19
+ readonly id: string;
20
+ readonly name: string;
21
+ readonly nickname: string;
22
+ readonly matchKeys: string[];
23
+ match(): boolean;
24
+ readonly demuxProducers: DemuxProducer[];
25
+ }
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TimeProtocol = void 0;
4
+ const BaseHeader_1 = require("../abstracts/BaseHeader");
5
+ /**
6
+ * Time Protocol (RFC 868), TCP & UDP well-known port 37. A trivial time service: the server returns the
7
+ * time as the number of seconds since 00:00 (midnight) 1 January 1900 GMT, in a single 32-bit big-endian
8
+ * unsigned integer. Over TCP the client opens a connection and the server sends the 4 octets then closes;
9
+ * over UDP the client sends an empty datagram and the server replies with a 4-octet datagram. The request
10
+ * carries no payload, so only the 4-octet response is a Time Protocol message this codec claims.
11
+ *
12
+ * The whole message is exactly one field — `time`, the 32-bit seconds count — kept as a plain uint so any
13
+ * on-wire value (including the post-2036 wrap once the counter passes 0x80000000) round-trips byte-for-byte
14
+ * and can be re-encoded without an Ajv rejection. The response is exactly 4 octets; anything beyond is left
15
+ * to the codec's recursion / RawData. A well-formed message round-trips byte-for-byte.
16
+ */
17
+ class TimeProtocol extends BaseHeader_1.BaseHeader {
18
+ constructor() {
19
+ super(...arguments);
20
+ this.id = 'timeproto';
21
+ this.name = 'Time Protocol';
22
+ this.nickname = 'TIME';
23
+ this.matchKeys = ['tcpport:37', 'udpport:37'];
24
+ //A leaf header — the 4-octet time value is the entire message; nothing rides above it.
25
+ this.demuxProducers = [];
26
+ }
27
+ static #schemaCache;
28
+ get SCHEMA() {
29
+ return (TimeProtocol.#schemaCache ??= TimeProtocol.#buildSchema());
30
+ }
31
+ static #buildSchema() {
32
+ return {
33
+ type: 'object',
34
+ summary: 'TIME seconds=${time}',
35
+ properties: {
36
+ //Seconds since 1900-01-01 00:00:00 GMT, 32-bit big-endian unsigned (RFC 868). A plain uint
37
+ //so every on-wire value round-trips; the epoch/date rendering is UI enrichment for later.
38
+ time: this.fieldUInt('time', 0, 4, 'Seconds since 1900-01-01 00:00:00 GMT')
39
+ }
40
+ };
41
+ }
42
+ match() {
43
+ //Time Protocol rides on TCP/UDP port 37; the well-known port is the only signature (the payload
44
+ //is 4 opaque bytes with no magic). The request carries no payload, so require the full 4-octet
45
+ //response to be present — an empty request (0 bytes) is not claimed and falls through.
46
+ if (!this.prevCodecModule)
47
+ return false;
48
+ if (this.prevCodecModule.id !== 'tcp' && this.prevCodecModule.id !== 'udp')
49
+ return false;
50
+ return this.packet.length - this.startPos >= 4;
51
+ }
52
+ }
53
+ exports.TimeProtocol = TimeProtocol;
@@ -0,0 +1,19 @@
1
+ import { ProtocolJSONSchema } from '../schema/ProtocolJSONSchema';
2
+ import { BaseHeader } from '../abstracts/BaseHeader';
3
+ import { DemuxProducer } from '../types/DemuxProducer';
4
+ export declare class UDP extends BaseHeader {
5
+ #private;
6
+ /**
7
+ * Calculate UDP Checksum
8
+ * @protected
9
+ * @param udpHeaderBuffer
10
+ */
11
+ protected calculateUDPChecksum(udpHeaderBuffer: Buffer): number;
12
+ get SCHEMA(): ProtocolJSONSchema;
13
+ readonly id: string;
14
+ readonly matchKeys: string[];
15
+ readonly demuxProducers: DemuxProducer[];
16
+ readonly name: string;
17
+ readonly nickname: string;
18
+ match(): boolean;
19
+ }