@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.
- package/CHANGELOG.md +17 -0
- package/LICENSE +21 -0
- package/README.md +352 -0
- package/README.zh-CN.md +342 -0
- package/dist/Codec.d.ts +133 -0
- package/dist/Codec.js +632 -0
- package/dist/PacketHeaders.d.ts +189 -0
- package/dist/PacketHeaders.js +384 -0
- package/dist/abstracts/BaseHeader.d.ts +325 -0
- package/dist/abstracts/BaseHeader.js +734 -0
- package/dist/errors/CodecSchemaValidateError.d.ts +4 -0
- package/dist/errors/CodecSchemaValidateError.js +11 -0
- package/dist/headers/ADSAMS.d.ts +33 -0
- package/dist/headers/ADSAMS.js +208 -0
- package/dist/headers/AH.d.ts +28 -0
- package/dist/headers/AH.js +137 -0
- package/dist/headers/AMQP.d.ts +31 -0
- package/dist/headers/AMQP.js +316 -0
- package/dist/headers/ARP.d.ts +26 -0
- package/dist/headers/ARP.js +243 -0
- package/dist/headers/BACnetIP.d.ts +27 -0
- package/dist/headers/BACnetIP.js +97 -0
- package/dist/headers/BFD.d.ts +28 -0
- package/dist/headers/BFD.js +155 -0
- package/dist/headers/BGP.d.ts +27 -0
- package/dist/headers/BGP.js +111 -0
- package/dist/headers/BSAPIP.d.ts +33 -0
- package/dist/headers/BSAPIP.js +78 -0
- package/dist/headers/Babel.d.ts +32 -0
- package/dist/headers/Babel.js +224 -0
- package/dist/headers/BitTorrent.d.ts +28 -0
- package/dist/headers/BitTorrent.js +72 -0
- package/dist/headers/C37118.d.ts +26 -0
- package/dist/headers/C37118.js +147 -0
- package/dist/headers/CAPWAP.d.ts +38 -0
- package/dist/headers/CAPWAP.js +275 -0
- package/dist/headers/CDP.d.ts +25 -0
- package/dist/headers/CDP.js +117 -0
- package/dist/headers/CMS.d.ts +33 -0
- package/dist/headers/CMS.js +238 -0
- package/dist/headers/COTP.d.ts +30 -0
- package/dist/headers/COTP.js +193 -0
- package/dist/headers/CassandraCQL.d.ts +28 -0
- package/dist/headers/CassandraCQL.js +117 -0
- package/dist/headers/CoAP.d.ts +29 -0
- package/dist/headers/CoAP.js +140 -0
- package/dist/headers/Codesys.d.ts +32 -0
- package/dist/headers/Codesys.js +119 -0
- package/dist/headers/Collectd.d.ts +29 -0
- package/dist/headers/Collectd.js +154 -0
- package/dist/headers/DCCP.d.ts +30 -0
- package/dist/headers/DCCP.js +204 -0
- package/dist/headers/DHCP.d.ts +26 -0
- package/dist/headers/DHCP.js +148 -0
- package/dist/headers/DHCPFailover.d.ts +30 -0
- package/dist/headers/DHCPFailover.js +104 -0
- package/dist/headers/DHCPv6.d.ts +25 -0
- package/dist/headers/DHCPv6.js +145 -0
- package/dist/headers/DNP3.d.ts +27 -0
- package/dist/headers/DNP3.js +150 -0
- package/dist/headers/DNS.d.ts +55 -0
- package/dist/headers/DNS.js +309 -0
- package/dist/headers/DTLS.d.ts +33 -0
- package/dist/headers/DTLS.js +142 -0
- package/dist/headers/Diameter.d.ts +34 -0
- package/dist/headers/Diameter.js +229 -0
- package/dist/headers/EAPOL.d.ts +32 -0
- package/dist/headers/EAPOL.js +135 -0
- package/dist/headers/EIGRP.d.ts +28 -0
- package/dist/headers/EIGRP.js +165 -0
- package/dist/headers/ENIP.d.ts +31 -0
- package/dist/headers/ENIP.js +164 -0
- package/dist/headers/ESP.d.ts +27 -0
- package/dist/headers/ESP.js +140 -0
- package/dist/headers/Elasticsearch.d.ts +30 -0
- package/dist/headers/Elasticsearch.js +125 -0
- package/dist/headers/EtherCAT.d.ts +35 -0
- package/dist/headers/EtherCAT.js +150 -0
- package/dist/headers/EthernetII.d.ts +28 -0
- package/dist/headers/EthernetII.js +117 -0
- package/dist/headers/FCoE.d.ts +38 -0
- package/dist/headers/FCoE.js +210 -0
- package/dist/headers/FTP.d.ts +34 -0
- package/dist/headers/FTP.js +158 -0
- package/dist/headers/Finger.d.ts +41 -0
- package/dist/headers/Finger.js +135 -0
- package/dist/headers/FoundationFieldbusHSE.d.ts +43 -0
- package/dist/headers/FoundationFieldbusHSE.js +163 -0
- package/dist/headers/GELF.d.ts +35 -0
- package/dist/headers/GELF.js +261 -0
- package/dist/headers/GENEVE.d.ts +26 -0
- package/dist/headers/GENEVE.js +209 -0
- package/dist/headers/GESRTP.d.ts +32 -0
- package/dist/headers/GESRTP.js +141 -0
- package/dist/headers/GLBP.d.ts +29 -0
- package/dist/headers/GLBP.js +159 -0
- package/dist/headers/GRE.d.ts +27 -0
- package/dist/headers/GRE.js +181 -0
- package/dist/headers/GTPU.d.ts +25 -0
- package/dist/headers/GTPU.js +203 -0
- package/dist/headers/GTPv2C.d.ts +30 -0
- package/dist/headers/GTPv2C.js +281 -0
- package/dist/headers/GitProtocol.d.ts +34 -0
- package/dist/headers/GitProtocol.js +141 -0
- package/dist/headers/Goose.d.ts +115 -0
- package/dist/headers/Goose.js +1067 -0
- package/dist/headers/Gopher.d.ts +43 -0
- package/dist/headers/Gopher.js +182 -0
- package/dist/headers/HARTIP.d.ts +30 -0
- package/dist/headers/HARTIP.js +145 -0
- package/dist/headers/HSR.d.ts +27 -0
- package/dist/headers/HSR.js +105 -0
- package/dist/headers/HSRP.d.ts +26 -0
- package/dist/headers/HSRP.js +173 -0
- package/dist/headers/HTTP.d.ts +32 -0
- package/dist/headers/HTTP.js +153 -0
- package/dist/headers/HTTP2.d.ts +34 -0
- package/dist/headers/HTTP2.js +190 -0
- package/dist/headers/IAX2.d.ts +33 -0
- package/dist/headers/IAX2.js +274 -0
- package/dist/headers/ICMP.d.ts +15 -0
- package/dist/headers/ICMP.js +148 -0
- package/dist/headers/ICMPv6.d.ts +15 -0
- package/dist/headers/ICMPv6.js +129 -0
- package/dist/headers/IEC104_I_Frame.d.ts +23 -0
- package/dist/headers/IEC104_I_Frame.js +6489 -0
- package/dist/headers/IEC104_S_Frame.d.ts +26 -0
- package/dist/headers/IEC104_S_Frame.js +135 -0
- package/dist/headers/IEC104_U_Frame.d.ts +27 -0
- package/dist/headers/IEC104_U_Frame.js +176 -0
- package/dist/headers/IEC61850SampledValues.d.ts +20 -0
- package/dist/headers/IEC61850SampledValues.js +420 -0
- package/dist/headers/IGMP.d.ts +31 -0
- package/dist/headers/IGMP.js +274 -0
- package/dist/headers/IMAP.d.ts +32 -0
- package/dist/headers/IMAP.js +185 -0
- package/dist/headers/IPFIX.d.ts +29 -0
- package/dist/headers/IPFIX.js +156 -0
- package/dist/headers/IPv4.d.ts +20 -0
- package/dist/headers/IPv4.js +370 -0
- package/dist/headers/IPv6.d.ts +29 -0
- package/dist/headers/IPv6.js +209 -0
- package/dist/headers/IPv6HopByHopOptions.d.ts +81 -0
- package/dist/headers/IPv6HopByHopOptions.js +495 -0
- package/dist/headers/IRC.d.ts +34 -0
- package/dist/headers/IRC.js +175 -0
- package/dist/headers/ISAKMP.d.ts +29 -0
- package/dist/headers/ISAKMP.js +197 -0
- package/dist/headers/ISCSI.d.ts +39 -0
- package/dist/headers/ISCSI.js +289 -0
- package/dist/headers/ISIS.d.ts +25 -0
- package/dist/headers/ISIS.js +79 -0
- package/dist/headers/ISOSession.d.ts +27 -0
- package/dist/headers/ISOSession.js +343 -0
- package/dist/headers/Ident.d.ts +42 -0
- package/dist/headers/Ident.js +184 -0
- package/dist/headers/KNXnetIP.d.ts +30 -0
- package/dist/headers/KNXnetIP.js +135 -0
- package/dist/headers/Kafka.d.ts +35 -0
- package/dist/headers/Kafka.js +128 -0
- package/dist/headers/Kerberos.d.ts +30 -0
- package/dist/headers/Kerberos.js +217 -0
- package/dist/headers/L2TP.d.ts +26 -0
- package/dist/headers/L2TP.js +297 -0
- package/dist/headers/LACP.d.ts +31 -0
- package/dist/headers/LACP.js +151 -0
- package/dist/headers/LDAP.d.ts +31 -0
- package/dist/headers/LDAP.js +226 -0
- package/dist/headers/LDP.d.ts +31 -0
- package/dist/headers/LDP.js +138 -0
- package/dist/headers/LISP.d.ts +30 -0
- package/dist/headers/LISP.js +103 -0
- package/dist/headers/LLC.d.ts +27 -0
- package/dist/headers/LLC.js +81 -0
- package/dist/headers/LLDP.d.ts +26 -0
- package/dist/headers/LLDP.js +126 -0
- package/dist/headers/LLMNR.d.ts +23 -0
- package/dist/headers/LLMNR.js +40 -0
- package/dist/headers/LPD.d.ts +31 -0
- package/dist/headers/LPD.js +159 -0
- package/dist/headers/MACsec.d.ts +34 -0
- package/dist/headers/MACsec.js +178 -0
- package/dist/headers/MDNS.d.ts +26 -0
- package/dist/headers/MDNS.js +45 -0
- package/dist/headers/MGCP.d.ts +30 -0
- package/dist/headers/MGCP.js +155 -0
- package/dist/headers/MMS.d.ts +29 -0
- package/dist/headers/MMS.js +243 -0
- package/dist/headers/MPLS.d.ts +31 -0
- package/dist/headers/MPLS.js +145 -0
- package/dist/headers/MQTT.d.ts +30 -0
- package/dist/headers/MQTT.js +173 -0
- package/dist/headers/MQTTSN.d.ts +34 -0
- package/dist/headers/MQTTSN.js +177 -0
- package/dist/headers/MarkerProtocol.d.ts +32 -0
- package/dist/headers/MarkerProtocol.js +153 -0
- package/dist/headers/Megaco.d.ts +32 -0
- package/dist/headers/Megaco.js +144 -0
- package/dist/headers/Memcached.d.ts +44 -0
- package/dist/headers/Memcached.js +285 -0
- package/dist/headers/ModbusTCP.d.ts +25 -0
- package/dist/headers/ModbusTCP.js +99 -0
- package/dist/headers/ModbusUDP.d.ts +26 -0
- package/dist/headers/ModbusUDP.js +100 -0
- package/dist/headers/MongoDB.d.ts +33 -0
- package/dist/headers/MongoDB.js +143 -0
- package/dist/headers/MySQL.d.ts +30 -0
- package/dist/headers/MySQL.js +114 -0
- package/dist/headers/NATS.d.ts +29 -0
- package/dist/headers/NATS.js +135 -0
- package/dist/headers/NBDS.d.ts +34 -0
- package/dist/headers/NBDS.js +176 -0
- package/dist/headers/NBNS.d.ts +34 -0
- package/dist/headers/NBNS.js +78 -0
- package/dist/headers/NBSS.d.ts +36 -0
- package/dist/headers/NBSS.js +137 -0
- package/dist/headers/NFS.d.ts +36 -0
- package/dist/headers/NFS.js +273 -0
- package/dist/headers/NHRP.d.ts +32 -0
- package/dist/headers/NHRP.js +154 -0
- package/dist/headers/NNTP.d.ts +35 -0
- package/dist/headers/NNTP.js +162 -0
- package/dist/headers/NTP.d.ts +18 -0
- package/dist/headers/NTP.js +73 -0
- package/dist/headers/NetFlowV5.d.ts +28 -0
- package/dist/headers/NetFlowV5.js +205 -0
- package/dist/headers/OLSR.d.ts +31 -0
- package/dist/headers/OLSR.js +213 -0
- package/dist/headers/OPCUA.d.ts +33 -0
- package/dist/headers/OPCUA.js +165 -0
- package/dist/headers/OPCUAPubSub.d.ts +33 -0
- package/dist/headers/OPCUAPubSub.js +144 -0
- package/dist/headers/OSPF.d.ts +31 -0
- package/dist/headers/OSPF.js +365 -0
- package/dist/headers/OmronFINS.d.ts +31 -0
- package/dist/headers/OmronFINS.js +90 -0
- package/dist/headers/OpenFlow.d.ts +30 -0
- package/dist/headers/OpenFlow.js +113 -0
- package/dist/headers/OpenVPN.d.ts +35 -0
- package/dist/headers/OpenVPN.js +214 -0
- package/dist/headers/PCWorx.d.ts +35 -0
- package/dist/headers/PCWorx.js +115 -0
- package/dist/headers/PIM.d.ts +27 -0
- package/dist/headers/PIM.js +129 -0
- package/dist/headers/POP3.d.ts +31 -0
- package/dist/headers/POP3.js +152 -0
- package/dist/headers/POWERLINK.d.ts +28 -0
- package/dist/headers/POWERLINK.js +116 -0
- package/dist/headers/PPPoEDiscovery.d.ts +29 -0
- package/dist/headers/PPPoEDiscovery.js +198 -0
- package/dist/headers/PPPoESession.d.ts +28 -0
- package/dist/headers/PPPoESession.js +125 -0
- package/dist/headers/PPTP.d.ts +30 -0
- package/dist/headers/PPTP.js +122 -0
- package/dist/headers/PROFINETRT.d.ts +28 -0
- package/dist/headers/PROFINETRT.js +74 -0
- package/dist/headers/PTP.d.ts +34 -0
- package/dist/headers/PTP.js +213 -0
- package/dist/headers/PostgreSQL.d.ts +40 -0
- package/dist/headers/PostgreSQL.js +236 -0
- package/dist/headers/QUIC.d.ts +34 -0
- package/dist/headers/QUIC.js +308 -0
- package/dist/headers/RADIUS.d.ts +24 -0
- package/dist/headers/RADIUS.js +138 -0
- package/dist/headers/RDP.d.ts +27 -0
- package/dist/headers/RDP.js +93 -0
- package/dist/headers/RFB.d.ts +39 -0
- package/dist/headers/RFB.js +151 -0
- package/dist/headers/RGoose.d.ts +72 -0
- package/dist/headers/RGoose.js +340 -0
- package/dist/headers/RIP.d.ts +29 -0
- package/dist/headers/RIP.js +133 -0
- package/dist/headers/RIPng.d.ts +26 -0
- package/dist/headers/RIPng.js +140 -0
- package/dist/headers/RMCP.d.ts +26 -0
- package/dist/headers/RMCP.js +155 -0
- package/dist/headers/RSVP.d.ts +31 -0
- package/dist/headers/RSVP.js +263 -0
- package/dist/headers/RTCP.d.ts +34 -0
- package/dist/headers/RTCP.js +217 -0
- package/dist/headers/RTP.d.ts +33 -0
- package/dist/headers/RTP.js +291 -0
- package/dist/headers/RTPS.d.ts +33 -0
- package/dist/headers/RTPS.js +182 -0
- package/dist/headers/RTSP.d.ts +36 -0
- package/dist/headers/RTSP.js +184 -0
- package/dist/headers/RawData.d.ts +17 -0
- package/dist/headers/RawData.js +43 -0
- package/dist/headers/Redis.d.ts +32 -0
- package/dist/headers/Redis.js +202 -0
- package/dist/headers/Rlogin.d.ts +42 -0
- package/dist/headers/Rlogin.js +139 -0
- package/dist/headers/Rsync.d.ts +28 -0
- package/dist/headers/Rsync.js +117 -0
- package/dist/headers/S7comm.d.ts +36 -0
- package/dist/headers/S7comm.js +244 -0
- package/dist/headers/SCTP.d.ts +35 -0
- package/dist/headers/SCTP.js +174 -0
- package/dist/headers/SFlow.d.ts +29 -0
- package/dist/headers/SFlow.js +242 -0
- package/dist/headers/SIP.d.ts +27 -0
- package/dist/headers/SIP.js +146 -0
- package/dist/headers/SLMP.d.ts +36 -0
- package/dist/headers/SLMP.js +154 -0
- package/dist/headers/SLP.d.ts +30 -0
- package/dist/headers/SLP.js +207 -0
- package/dist/headers/SLPv1.d.ts +32 -0
- package/dist/headers/SLPv1.js +138 -0
- package/dist/headers/SMB1.d.ts +37 -0
- package/dist/headers/SMB1.js +200 -0
- package/dist/headers/SMB2.d.ts +36 -0
- package/dist/headers/SMB2.js +203 -0
- package/dist/headers/SMPP.d.ts +33 -0
- package/dist/headers/SMPP.js +119 -0
- package/dist/headers/SMTP.d.ts +33 -0
- package/dist/headers/SMTP.js +157 -0
- package/dist/headers/SNAP.d.ts +22 -0
- package/dist/headers/SNAP.js +68 -0
- package/dist/headers/SNMP.d.ts +28 -0
- package/dist/headers/SNMP.js +302 -0
- package/dist/headers/SOCKS4.d.ts +42 -0
- package/dist/headers/SOCKS4.js +302 -0
- package/dist/headers/SOCKS5.d.ts +45 -0
- package/dist/headers/SOCKS5.js +223 -0
- package/dist/headers/SSDP.d.ts +27 -0
- package/dist/headers/SSDP.js +161 -0
- package/dist/headers/SSH.d.ts +44 -0
- package/dist/headers/SSH.js +274 -0
- package/dist/headers/STOMP.d.ts +48 -0
- package/dist/headers/STOMP.js +177 -0
- package/dist/headers/STP.d.ts +26 -0
- package/dist/headers/STP.js +150 -0
- package/dist/headers/STUN.d.ts +25 -0
- package/dist/headers/STUN.js +183 -0
- package/dist/headers/SercosIII.d.ts +43 -0
- package/dist/headers/SercosIII.js +199 -0
- package/dist/headers/Skinny.d.ts +32 -0
- package/dist/headers/Skinny.js +139 -0
- package/dist/headers/StatsD.d.ts +27 -0
- package/dist/headers/StatsD.js +134 -0
- package/dist/headers/SunRPC.d.ts +34 -0
- package/dist/headers/SunRPC.js +268 -0
- package/dist/headers/Syslog.d.ts +21 -0
- package/dist/headers/Syslog.js +91 -0
- package/dist/headers/TCP.d.ts +19 -0
- package/dist/headers/TCP.js +905 -0
- package/dist/headers/TFTP.d.ts +28 -0
- package/dist/headers/TFTP.js +224 -0
- package/dist/headers/TLS_Alert.d.ts +24 -0
- package/dist/headers/TLS_Alert.js +639 -0
- package/dist/headers/TLS_ApplicationData.d.ts +24 -0
- package/dist/headers/TLS_ApplicationData.js +170 -0
- package/dist/headers/TLS_ChangeCipherSpec.d.ts +23 -0
- package/dist/headers/TLS_ChangeCipherSpec.js +168 -0
- package/dist/headers/TLS_Handshake.d.ts +65 -0
- package/dist/headers/TLS_Handshake.js +860 -0
- package/dist/headers/TLS_Heartbeat.d.ts +27 -0
- package/dist/headers/TLS_Heartbeat.js +247 -0
- package/dist/headers/TPKT.d.ts +26 -0
- package/dist/headers/TPKT.js +99 -0
- package/dist/headers/TacacsPlus.d.ts +27 -0
- package/dist/headers/TacacsPlus.js +133 -0
- package/dist/headers/Telnet.d.ts +40 -0
- package/dist/headers/Telnet.js +193 -0
- package/dist/headers/Teredo.d.ts +40 -0
- package/dist/headers/Teredo.js +251 -0
- package/dist/headers/TimeProtocol.d.ts +25 -0
- package/dist/headers/TimeProtocol.js +53 -0
- package/dist/headers/UDP.d.ts +19 -0
- package/dist/headers/UDP.js +171 -0
- package/dist/headers/VLAN_802dot1Q.d.ts +24 -0
- package/dist/headers/VLAN_802dot1Q.js +96 -0
- package/dist/headers/VRRP.d.ts +26 -0
- package/dist/headers/VRRP.js +309 -0
- package/dist/headers/VXLAN.d.ts +24 -0
- package/dist/headers/VXLAN.js +75 -0
- package/dist/headers/WCCP.d.ts +29 -0
- package/dist/headers/WCCP.js +117 -0
- package/dist/headers/WHOIS.d.ts +37 -0
- package/dist/headers/WHOIS.js +126 -0
- package/dist/headers/WSDiscovery.d.ts +29 -0
- package/dist/headers/WSDiscovery.js +118 -0
- package/dist/headers/WakeOnLAN.d.ts +30 -0
- package/dist/headers/WakeOnLAN.js +126 -0
- package/dist/headers/WebSocket.d.ts +26 -0
- package/dist/headers/WebSocket.js +173 -0
- package/dist/headers/WireGuard.d.ts +38 -0
- package/dist/headers/WireGuard.js +216 -0
- package/dist/headers/XMPP.d.ts +37 -0
- package/dist/headers/XMPP.js +149 -0
- package/dist/headers/Zabbix.d.ts +35 -0
- package/dist/headers/Zabbix.js +153 -0
- package/dist/headers/cms/AcsiPdu.d.ts +45 -0
- package/dist/headers/cms/AcsiPdu.js +112 -0
- package/dist/headers/cms/PerDecoder.d.ts +68 -0
- package/dist/headers/cms/PerDecoder.js +211 -0
- package/dist/headers/cms/PerReader.d.ts +64 -0
- package/dist/headers/cms/PerReader.js +155 -0
- package/dist/helper/BufferToHex.d.ts +5 -0
- package/dist/helper/BufferToHex.js +10 -0
- package/dist/helper/BufferToIP.d.ts +12 -0
- package/dist/helper/BufferToIP.js +23 -0
- package/dist/helper/BufferToNumber.d.ts +18 -0
- package/dist/helper/BufferToNumber.js +47 -0
- package/dist/helper/HexToBuffer.d.ts +7 -0
- package/dist/helper/HexToBuffer.js +27 -0
- package/dist/helper/HexToNumber.d.ts +18 -0
- package/dist/helper/HexToNumber.js +48 -0
- package/dist/helper/IPToBuffer.d.ts +12 -0
- package/dist/helper/IPToBuffer.js +34 -0
- package/dist/helper/NumberToBERBuffer.d.ts +18 -0
- package/dist/helper/NumberToBERBuffer.js +31 -0
- package/dist/helper/NumberToBERHex.d.ts +18 -0
- package/dist/helper/NumberToBERHex.js +52 -0
- package/dist/helper/NumberToBuffer.d.ts +18 -0
- package/dist/helper/NumberToBuffer.js +38 -0
- package/dist/helper/NumberToHex.d.ts +18 -0
- package/dist/helper/NumberToHex.js +35 -0
- package/dist/index.d.ts +52 -0
- package/dist/index.js +113 -0
- package/dist/lib/FlexibleObject.d.ts +27 -0
- package/dist/lib/FlexibleObject.js +113 -0
- package/dist/lib/GetBERIntegerLengthFromBuffer.d.ts +6 -0
- package/dist/lib/GetBERIntegerLengthFromBuffer.js +16 -0
- package/dist/lib/ProcessPacketPostHandlers.d.ts +13 -0
- package/dist/lib/ProcessPacketPostHandlers.js +53 -0
- package/dist/lib/SortPostHandlers.d.ts +7 -0
- package/dist/lib/SortPostHandlers.js +11 -0
- package/dist/lib/StringContentEncodingEnum.d.ts +10 -0
- package/dist/lib/StringContentEncodingEnum.js +14 -0
- package/dist/schema/ProtocolFieldJSONSchema.d.ts +35 -0
- package/dist/schema/ProtocolFieldJSONSchema.js +2 -0
- package/dist/schema/ProtocolFieldJSONSchemaDefinition.d.ts +2 -0
- package/dist/schema/ProtocolFieldJSONSchemaDefinition.js +2 -0
- package/dist/schema/ProtocolJSONSchema.d.ts +32 -0
- package/dist/schema/ProtocolJSONSchema.js +2 -0
- package/dist/types/CodecData.d.ts +7 -0
- package/dist/types/CodecData.js +2 -0
- package/dist/types/CodecDecodeResult.d.ts +10 -0
- package/dist/types/CodecDecodeResult.js +2 -0
- package/dist/types/CodecEncodeInput.d.ts +2 -0
- package/dist/types/CodecEncodeInput.js +2 -0
- package/dist/types/CodecEncodeResult.d.ts +5 -0
- package/dist/types/CodecEncodeResult.js +2 -0
- package/dist/types/CodecErrorInfo.d.ts +5 -0
- package/dist/types/CodecErrorInfo.js +2 -0
- package/dist/types/CodecModule.d.ts +2 -0
- package/dist/types/CodecModule.js +2 -0
- package/dist/types/CodecModuleConstructor.d.ts +2 -0
- package/dist/types/CodecModuleConstructor.js +2 -0
- package/dist/types/CodecSchema.d.ts +6 -0
- package/dist/types/CodecSchema.js +2 -0
- package/dist/types/DemuxProducer.d.ts +23 -0
- package/dist/types/DemuxProducer.js +2 -0
- package/dist/types/Dissection.d.ts +23 -0
- package/dist/types/Dissection.js +2 -0
- package/dist/types/HeaderTreeNode.d.ts +4 -0
- package/dist/types/HeaderTreeNode.js +2 -0
- package/dist/types/LayerGraph.d.ts +32 -0
- package/dist/types/LayerGraph.js +2 -0
- package/dist/types/PostHandlerItem.d.ts +4 -0
- package/dist/types/PostHandlerItem.js +2 -0
- package/package.json +141 -0
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RTPS = 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
|
+
* RTPS — the OMG DDSI-RTPS wire protocol (Real-Time Publish-Subscribe) that carries DDS traffic for
|
|
10
|
+
* industrial IoT / robotics. It rides UDP on dynamically negotiated ports (the well-known 7400-range
|
|
11
|
+
* discovery ports are only defaults), so selection is by content signature, not port: every RTPS
|
|
12
|
+
* message opens with a 20-byte header — the 4-byte magic 'RTPS' (0x52545053), a 2-byte protocol
|
|
13
|
+
* version, a 2-byte vendorId, and a 12-byte guidPrefix — followed by a sequence of submessages.
|
|
14
|
+
*
|
|
15
|
+
* Each submessage is a 4-byte submessage header — submessageId(1), flags(1), submessageLength(2) —
|
|
16
|
+
* then `submessageLength` body octets. The single most important quirk: the low bit of the flags octet
|
|
17
|
+
* is the EndiannessFlag, and it governs the byte order of THAT submessage's submessageLength field
|
|
18
|
+
* (little-endian when set, big-endian when clear). A submessageLength of 0 is legal for the final
|
|
19
|
+
* submessage and means "the rest of the message"; it is honored verbatim so the frame round-trips.
|
|
20
|
+
*
|
|
21
|
+
* The submessage bodies (DATA's serialized payload, ACKNACK bitmaps, INFO_TS timestamps, …) are cross-
|
|
22
|
+
* message, QoS- and type-dependent state, so they are kept verbatim as hex (byte-perfect) rather than
|
|
23
|
+
* sub-decoded. The whole message is bounded by the UDP payload (the parent UDP Length when present),
|
|
24
|
+
* and every submessageLength is honored on encode (a crafted message may lie), else derived from the
|
|
25
|
+
* body. A well-formed message round-trips byte-for-byte.
|
|
26
|
+
*/
|
|
27
|
+
class RTPS extends BaseHeader_1.BaseHeader {
|
|
28
|
+
constructor() {
|
|
29
|
+
super(...arguments);
|
|
30
|
+
this.id = 'rtps';
|
|
31
|
+
this.name = 'Real-Time Publish-Subscribe Wire Protocol';
|
|
32
|
+
this.nickname = 'RTPS';
|
|
33
|
+
//No demux keys: RTPS uses dynamically negotiated UDP ports, so it is a content-heuristic child
|
|
34
|
+
//recognized by its 'RTPS' magic rather than a well-known port.
|
|
35
|
+
this.matchKeys = [];
|
|
36
|
+
this.heuristicFallback = true;
|
|
37
|
+
//A leaf header — submessage bodies are QoS/type-dependent and kept verbatim, decoded later.
|
|
38
|
+
this.demuxProducers = [];
|
|
39
|
+
}
|
|
40
|
+
static #schemaCache;
|
|
41
|
+
get SCHEMA() {
|
|
42
|
+
return (RTPS.#schemaCache ??= RTPS.#buildSchema());
|
|
43
|
+
}
|
|
44
|
+
/** The EndiannessFlag is the low bit of the flags octet: set → little-endian submessage header. */
|
|
45
|
+
static #isLittleEndian(flags) {
|
|
46
|
+
return (flags & 0x01) === 0x01;
|
|
47
|
+
}
|
|
48
|
+
static #buildSchema() {
|
|
49
|
+
return {
|
|
50
|
+
type: 'object',
|
|
51
|
+
summary: 'RTPS v${protocolVersion} vendor=${vendorId}',
|
|
52
|
+
properties: {
|
|
53
|
+
//The 4-byte magic 'RTPS' (0x52545053). Kept verbatim so any variant round-trips; it is
|
|
54
|
+
//also the content signature match() gates on.
|
|
55
|
+
magic: this.fieldHex('magic', 0, 4, 'Magic'),
|
|
56
|
+
//Protocol version (major.minor), e.g. 0x0201 = RTPS 2.1. Two opaque octets.
|
|
57
|
+
protocolVersion: this.fieldHex('protocolVersion', 4, 2, 'Protocol Version'),
|
|
58
|
+
//Vendor ID (OMG-assigned), e.g. 0x0101 = RTI Connext. Two opaque octets.
|
|
59
|
+
vendorId: this.fieldHex('vendorId', 6, 2, 'Vendor ID'),
|
|
60
|
+
//The 12-byte GUID prefix identifying the participant that sent this message.
|
|
61
|
+
guidPrefix: this.fieldHex('guidPrefix', 8, 12, 'GUID Prefix'),
|
|
62
|
+
//The submessage sequence after the 20-byte header. Each is a 4-byte submessage header
|
|
63
|
+
//(id/flags/length) plus a verbatim body. Bounded by BOTH the declared submessageLength
|
|
64
|
+
//AND the bytes actually present (the UDP payload), so a lying length cannot spawn phantom
|
|
65
|
+
//submessages past the end of the buffer, and the loop always advances by at least 4.
|
|
66
|
+
submessages: {
|
|
67
|
+
type: 'array',
|
|
68
|
+
label: 'Submessages',
|
|
69
|
+
items: {
|
|
70
|
+
type: 'object',
|
|
71
|
+
label: 'Submessage',
|
|
72
|
+
properties: {
|
|
73
|
+
submessageId: {
|
|
74
|
+
type: 'integer',
|
|
75
|
+
label: 'Submessage ID',
|
|
76
|
+
minimum: 0,
|
|
77
|
+
maximum: 255
|
|
78
|
+
},
|
|
79
|
+
flags: {
|
|
80
|
+
type: 'integer',
|
|
81
|
+
label: 'Flags',
|
|
82
|
+
minimum: 0,
|
|
83
|
+
maximum: 255
|
|
84
|
+
},
|
|
85
|
+
submessageLength: {
|
|
86
|
+
type: 'integer',
|
|
87
|
+
label: 'Submessage Length',
|
|
88
|
+
minimum: 0,
|
|
89
|
+
maximum: 65535
|
|
90
|
+
},
|
|
91
|
+
body: {
|
|
92
|
+
type: 'string',
|
|
93
|
+
label: 'Body',
|
|
94
|
+
contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.HEX
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
},
|
|
98
|
+
decode: function () {
|
|
99
|
+
//Cap the submessage walk at the UDP payload end so trailing frame padding / a
|
|
100
|
+
//pipelined datagram is never absorbed. The parent UDP Length spans the 8-byte UDP
|
|
101
|
+
//header + payload, so the RTPS payload is (Length − 8) bytes; else fall back to the
|
|
102
|
+
//captured bytes.
|
|
103
|
+
let cap = this.packet.length - this.startPos;
|
|
104
|
+
if (this.prevCodecModule && this.prevCodecModule.id === 'udp') {
|
|
105
|
+
const payload = this.prevCodecModule.instance.length.getValue(0) - 8;
|
|
106
|
+
if (payload >= 0 && payload < cap)
|
|
107
|
+
cap = payload;
|
|
108
|
+
}
|
|
109
|
+
const submessages = [];
|
|
110
|
+
let offset = 20;
|
|
111
|
+
while (offset + 4 <= cap) {
|
|
112
|
+
const submessageId = this.readBytes(offset, 1)[0];
|
|
113
|
+
const flags = this.readBytes(offset + 1, 1)[0];
|
|
114
|
+
const lengthBytes = this.readBytes(offset + 2, 2);
|
|
115
|
+
const submessageLength = RTPS.#isLittleEndian(flags)
|
|
116
|
+
? (lengthBytes[0] | (lengthBytes[1] << 8))
|
|
117
|
+
: ((lengthBytes[0] << 8) | lengthBytes[1]);
|
|
118
|
+
offset += 4;
|
|
119
|
+
//A submessageLength of 0 means "the rest of the message" (only legal on the
|
|
120
|
+
//last submessage). Otherwise the body is `submessageLength` bytes, clamped to
|
|
121
|
+
//the bytes actually present so a lying length cannot read past the buffer.
|
|
122
|
+
let bodyLength = submessageLength === 0 ? cap - offset : submessageLength;
|
|
123
|
+
if (bodyLength > cap - offset)
|
|
124
|
+
bodyLength = cap - offset;
|
|
125
|
+
if (bodyLength < 0)
|
|
126
|
+
bodyLength = 0;
|
|
127
|
+
const body = bodyLength ? this.readBytes(offset, bodyLength) : Buffer.alloc(0);
|
|
128
|
+
offset += bodyLength;
|
|
129
|
+
submessages.push({
|
|
130
|
+
submessageId: submessageId,
|
|
131
|
+
flags: flags,
|
|
132
|
+
submessageLength: submessageLength,
|
|
133
|
+
body: (0, BufferToHex_1.BufferToHex)(body)
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
this.instance.submessages.setValue(submessages);
|
|
137
|
+
},
|
|
138
|
+
encode: function () {
|
|
139
|
+
const submessages = this.instance.submessages.getValue();
|
|
140
|
+
if (!submessages)
|
|
141
|
+
return;
|
|
142
|
+
let offset = 20;
|
|
143
|
+
submessages.forEach((submessage) => {
|
|
144
|
+
const submessageId = submessage.submessageId ? submessage.submessageId : 0;
|
|
145
|
+
const flags = submessage.flags ? submessage.flags : 0;
|
|
146
|
+
const body = (0, HexToBuffer_1.HexToBuffer)(submessage.body ? submessage.body : '');
|
|
147
|
+
//Honor an explicitly supplied submessageLength verbatim (a number, including a
|
|
148
|
+
//legal 0 = "rest of message"); derive from the body length only when absent.
|
|
149
|
+
const provided = submessage.submessageLength;
|
|
150
|
+
let submessageLength = (provided !== undefined && provided !== null) ? provided : body.length;
|
|
151
|
+
if (submessageLength > 65535)
|
|
152
|
+
submessageLength = 65535;
|
|
153
|
+
if (submessageLength < 0)
|
|
154
|
+
submessageLength = 0;
|
|
155
|
+
this.writeBytes(offset, Buffer.from([submessageId & 0xff, flags & 0xff]));
|
|
156
|
+
//submessageLength byte order follows this submessage's EndiannessFlag (flags bit 0).
|
|
157
|
+
const lengthBytes = RTPS.#isLittleEndian(flags)
|
|
158
|
+
? Buffer.from([submessageLength & 0xff, (submessageLength >> 8) & 0xff])
|
|
159
|
+
: Buffer.from([(submessageLength >> 8) & 0xff, submessageLength & 0xff]);
|
|
160
|
+
this.writeBytes(offset + 2, lengthBytes);
|
|
161
|
+
offset += 4;
|
|
162
|
+
if (body.length) {
|
|
163
|
+
this.writeBytes(offset, body);
|
|
164
|
+
offset += body.length;
|
|
165
|
+
}
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
match() {
|
|
173
|
+
//RTPS rides UDP on dynamic ports; require the parent to be UDP, the full 20-byte header to be
|
|
174
|
+
//present, and the 4-byte magic 'RTPS' (0x52545053) — a strong, distinctive content signature.
|
|
175
|
+
if (!this.prevCodecModule || this.prevCodecModule.id !== 'udp')
|
|
176
|
+
return false;
|
|
177
|
+
if (this.packet.length - this.startPos < 20)
|
|
178
|
+
return false;
|
|
179
|
+
return (0, BufferToHex_1.BufferToHex)(this.readBytes(0, 4, true)) === '52545053';
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
exports.RTPS = RTPS;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { BaseHeader } from '../abstracts/BaseHeader';
|
|
2
|
+
import { ProtocolJSONSchema } from '../schema/ProtocolJSONSchema';
|
|
3
|
+
import { DemuxProducer } from '../types/DemuxProducer';
|
|
4
|
+
/**
|
|
5
|
+
* RTSP — the Real Time Streaming Protocol (RFC 2326, obsoleted by RFC 7826), the control channel for
|
|
6
|
+
* streaming media ("network remote control" for A/V servers) carried as US-ASCII text over TCP port
|
|
7
|
+
* 554. RTSP borrows HTTP's syntax almost verbatim: a message is a start-line, then header lines, a
|
|
8
|
+
* CRLF, and an optional body (e.g. an SDP description for a DESCRIBE response). The start-line is either
|
|
9
|
+
* a Request-Line (`METHOD SP Request-URI SP RTSP-Version CRLF`) or a Status-Line (`RTSP-Version SP
|
|
10
|
+
* Status-Code SP Reason-Phrase CRLF`). The only visible difference from HTTP is the version token
|
|
11
|
+
* (`RTSP/1.0` instead of `HTTP/1.1`) and RTSP's own method set (DESCRIBE, SETUP, PLAY, …).
|
|
12
|
+
*
|
|
13
|
+
* Like HTTP and SIP, the message body is text whose full internal structure (arbitrary header fields, a
|
|
14
|
+
* body of any content-type, significant whitespace/header ordering/casing) is far richer than a form
|
|
15
|
+
* needs. So the ENTIRE raw message is kept verbatim as the authoritative `message` field (hex) and
|
|
16
|
+
* re-emitted untouched; only the start-line (plus the RTSP-specific CSeq sequence number) is parsed on
|
|
17
|
+
* decode into display-only metadata (method/uri/version or status-code/reason, and cseq). Encode never
|
|
18
|
+
* reconstructs the message from the parsed fields — it writes `message` back byte-for-byte — so any
|
|
19
|
+
* conformant (or even malformed) RTSP message round-trips exactly.
|
|
20
|
+
*
|
|
21
|
+
* Note: RTSP bodies (SDP, etc.) can span multiple TCP segments and RTSP can also interleave binary RTP
|
|
22
|
+
* over the same TCP connection ($-framed); reassembly/interleaving across segments is out of scope.
|
|
23
|
+
* This single-segment codec keeps whatever bytes are present in the current segment verbatim, which is
|
|
24
|
+
* byte-perfect for the single-packet case.
|
|
25
|
+
*/
|
|
26
|
+
export declare class RTSP extends BaseHeader {
|
|
27
|
+
#private;
|
|
28
|
+
get SCHEMA(): ProtocolJSONSchema;
|
|
29
|
+
readonly id: string;
|
|
30
|
+
readonly name: string;
|
|
31
|
+
readonly nickname: string;
|
|
32
|
+
readonly matchKeys: string[];
|
|
33
|
+
readonly heuristicFallback: boolean;
|
|
34
|
+
match(): boolean;
|
|
35
|
+
readonly demuxProducers: DemuxProducer[];
|
|
36
|
+
}
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var _a;
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.RTSP = 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
|
+
/** RTSP request methods (RFC 2326 / RFC 7826) used only to recognize a request start-line. */
|
|
10
|
+
const RTSP_METHODS = ['DESCRIBE', 'ANNOUNCE', 'GET_PARAMETER', 'OPTIONS', 'PAUSE', 'PLAY', 'RECORD', 'REDIRECT', 'SETUP', 'SET_PARAMETER', 'TEARDOWN'];
|
|
11
|
+
/**
|
|
12
|
+
* RTSP — the Real Time Streaming Protocol (RFC 2326, obsoleted by RFC 7826), the control channel for
|
|
13
|
+
* streaming media ("network remote control" for A/V servers) carried as US-ASCII text over TCP port
|
|
14
|
+
* 554. RTSP borrows HTTP's syntax almost verbatim: a message is a start-line, then header lines, a
|
|
15
|
+
* CRLF, and an optional body (e.g. an SDP description for a DESCRIBE response). The start-line is either
|
|
16
|
+
* a Request-Line (`METHOD SP Request-URI SP RTSP-Version CRLF`) or a Status-Line (`RTSP-Version SP
|
|
17
|
+
* Status-Code SP Reason-Phrase CRLF`). The only visible difference from HTTP is the version token
|
|
18
|
+
* (`RTSP/1.0` instead of `HTTP/1.1`) and RTSP's own method set (DESCRIBE, SETUP, PLAY, …).
|
|
19
|
+
*
|
|
20
|
+
* Like HTTP and SIP, the message body is text whose full internal structure (arbitrary header fields, a
|
|
21
|
+
* body of any content-type, significant whitespace/header ordering/casing) is far richer than a form
|
|
22
|
+
* needs. So the ENTIRE raw message is kept verbatim as the authoritative `message` field (hex) and
|
|
23
|
+
* re-emitted untouched; only the start-line (plus the RTSP-specific CSeq sequence number) is parsed on
|
|
24
|
+
* decode into display-only metadata (method/uri/version or status-code/reason, and cseq). Encode never
|
|
25
|
+
* reconstructs the message from the parsed fields — it writes `message` back byte-for-byte — so any
|
|
26
|
+
* conformant (or even malformed) RTSP message round-trips exactly.
|
|
27
|
+
*
|
|
28
|
+
* Note: RTSP bodies (SDP, etc.) can span multiple TCP segments and RTSP can also interleave binary RTP
|
|
29
|
+
* over the same TCP connection ($-framed); reassembly/interleaving across segments is out of scope.
|
|
30
|
+
* This single-segment codec keeps whatever bytes are present in the current segment verbatim, which is
|
|
31
|
+
* byte-perfect for the single-packet case.
|
|
32
|
+
*/
|
|
33
|
+
class RTSP extends BaseHeader_1.BaseHeader {
|
|
34
|
+
constructor() {
|
|
35
|
+
super(...arguments);
|
|
36
|
+
this.id = 'rtsp';
|
|
37
|
+
this.name = 'Real Time Streaming Protocol';
|
|
38
|
+
this.nickname = 'RTSP';
|
|
39
|
+
//The well-known port gives O(1) bucket dispatch, but RTSP (like HTTP) can run on arbitrary ports
|
|
40
|
+
//(8554 is common for test servers). heuristicFallback lets a non-listed port still be recognized by
|
|
41
|
+
//the start-line signature in match() below — the port is a fast path, not a whitelist. The signature
|
|
42
|
+
//is specific enough (a known method + space, or "RTSP/") that this does not claim arbitrary TCP
|
|
43
|
+
//traffic. See the HTTP header for the same rationale.
|
|
44
|
+
this.matchKeys = ['tcpport:554'];
|
|
45
|
+
this.heuristicFallback = true;
|
|
46
|
+
//A leaf header — the RTSP body (SDP, etc.) and the media session it controls are a higher-layer concern.
|
|
47
|
+
this.demuxProducers = [];
|
|
48
|
+
}
|
|
49
|
+
static #schemaCache;
|
|
50
|
+
get SCHEMA() {
|
|
51
|
+
return (_a.#schemaCache ??= _a.#buildSchema());
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Bytes of this header: RTSP rides on TCP, which has no per-message length, so take the rest of the
|
|
55
|
+
* segment. Body reassembly across segments is out of scope (see class doc).
|
|
56
|
+
*/
|
|
57
|
+
#payloadLength() {
|
|
58
|
+
const available = this.packet.length - this.startPos;
|
|
59
|
+
return available < 0 ? 0 : available;
|
|
60
|
+
}
|
|
61
|
+
/** The first line of the message (up to the first CRLF, or the whole payload if none). */
|
|
62
|
+
static #firstLine(text) {
|
|
63
|
+
const idx = text.indexOf('\r\n');
|
|
64
|
+
return idx >= 0 ? text.slice(0, idx) : text;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* The RTSP CSeq (sequence number): every RTSP request/response carries exactly one `CSeq:` header
|
|
68
|
+
* pairing a response to its request. Scan the header lines for it (case-insensitive) and return the
|
|
69
|
+
* first integer found, or 0 when absent/non-numeric. Display-only, like SIP's CSeq.
|
|
70
|
+
*/
|
|
71
|
+
static #parseCSeq(text) {
|
|
72
|
+
for (const line of text.split('\r\n')) {
|
|
73
|
+
const match = line.match(/^CSeq\s*:\s*(\d+)/i);
|
|
74
|
+
if (match)
|
|
75
|
+
return Number(match[1]);
|
|
76
|
+
}
|
|
77
|
+
return 0;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Parse the start-line into the display-only metadata fields. A Status-Line begins with the
|
|
81
|
+
* RTSP-Version ("RTSP/1.0"); anything else is treated as a Request-Line. Populated on decode only —
|
|
82
|
+
* these fields have no encode, so they never affect the re-emitted bytes and never mutate `message`.
|
|
83
|
+
* Never throws: a non-numeric status yields 0, missing tokens yield empty strings.
|
|
84
|
+
*/
|
|
85
|
+
#parseStartLine(text) {
|
|
86
|
+
this.instance.cseq.setValue(_a.#parseCSeq(text));
|
|
87
|
+
const line = _a.#firstLine(text);
|
|
88
|
+
if (line.startsWith('RTSP/')) {
|
|
89
|
+
//Status-Line: RTSP-Version SP Status-Code SP Reason-Phrase
|
|
90
|
+
const match = line.match(/^(\S+)\s+(\d{3})\s*(.*)$/);
|
|
91
|
+
this.instance.isRequest.setValue(false);
|
|
92
|
+
this.instance.method.setValue('');
|
|
93
|
+
this.instance.requestUri.setValue('');
|
|
94
|
+
this.instance.version.setValue(match ? match[1] : (line.split(' ')[0] || ''));
|
|
95
|
+
this.instance.statusCode.setValue(match ? Number(match[2]) : 0);
|
|
96
|
+
this.instance.reasonPhrase.setValue(match ? match[3] : '');
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
//Request-Line: METHOD SP Request-URI SP RTSP-Version
|
|
100
|
+
const parts = line.split(' ');
|
|
101
|
+
this.instance.isRequest.setValue(true);
|
|
102
|
+
this.instance.method.setValue(parts[0] ? parts[0] : '');
|
|
103
|
+
this.instance.requestUri.setValue(parts.length > 1 ? parts[1] : '');
|
|
104
|
+
//The RTSP-Version is the last whitespace-delimited token; the Request-URI itself has no spaces.
|
|
105
|
+
this.instance.version.setValue(parts.length > 2 ? parts[parts.length - 1] : '');
|
|
106
|
+
this.instance.statusCode.setValue(0);
|
|
107
|
+
this.instance.reasonPhrase.setValue('');
|
|
108
|
+
}
|
|
109
|
+
static #buildSchema() {
|
|
110
|
+
return {
|
|
111
|
+
type: 'object',
|
|
112
|
+
summary: 'RTSP ${method}${statusCode}',
|
|
113
|
+
properties: {
|
|
114
|
+
//The whole raw message is the single source of truth: decoded verbatim to hex and
|
|
115
|
+
//re-emitted untouched (byte-perfect for any RTSP message). The start-line + CSeq are
|
|
116
|
+
//parsed into the display-only metadata below, which carry no codec of their own.
|
|
117
|
+
message: {
|
|
118
|
+
type: 'string',
|
|
119
|
+
label: 'Message',
|
|
120
|
+
contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.HEX,
|
|
121
|
+
decode: function () {
|
|
122
|
+
const available = this.#payloadLength();
|
|
123
|
+
if (available <= 0) {
|
|
124
|
+
this.instance.message.setValue('');
|
|
125
|
+
this.#parseStartLine('');
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
const raw = this.readBytes(0, available);
|
|
129
|
+
this.instance.message.setValue((0, BufferToHex_1.BufferToHex)(raw));
|
|
130
|
+
this.#parseStartLine(raw.toString('latin1'));
|
|
131
|
+
},
|
|
132
|
+
encode: function () {
|
|
133
|
+
//Re-emit the authoritative message verbatim — never reconstruct from metadata.
|
|
134
|
+
this.writeBytes(0, (0, HexToBuffer_1.HexToBuffer)(this.instance.message.getValue('')));
|
|
135
|
+
}
|
|
136
|
+
},
|
|
137
|
+
//Display-only metadata parsed from the start-line on decode (no encode — populated by the
|
|
138
|
+
//message field above, never read back). isRequest distinguishes a Request-Line from a
|
|
139
|
+
//Status-Line; method/requestUri are for requests, statusCode/reasonPhrase for responses;
|
|
140
|
+
//cseq is RTSP's request/response sequence number (one per message).
|
|
141
|
+
isRequest: { type: 'boolean', label: 'Is Request' },
|
|
142
|
+
method: { type: 'string', label: 'Method' },
|
|
143
|
+
requestUri: { type: 'string', label: 'Request URI' },
|
|
144
|
+
version: { type: 'string', label: 'Version' },
|
|
145
|
+
statusCode: { type: 'integer', label: 'Status Code', minimum: 0, maximum: 999 },
|
|
146
|
+
reasonPhrase: { type: 'string', label: 'Reason Phrase' },
|
|
147
|
+
cseq: { type: 'integer', label: 'CSeq', minimum: 0 }
|
|
148
|
+
}
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
match() {
|
|
152
|
+
//RTSP rides on TCP as US-ASCII text. Recognize it by the start-line signature: a known request
|
|
153
|
+
//method followed by a space (the trailing space rejects e.g. "PLAYX"), or the "RTSP/" response
|
|
154
|
+
//version — so non-RTSP traffic on this port falls through to raw rather than claiming an
|
|
155
|
+
//un-decodable text layer.
|
|
156
|
+
//
|
|
157
|
+
//RTSP and HTTP both set heuristicFallback and both are text start-line protocols, so their
|
|
158
|
+
//signatures must stay disjoint: RTSP checks "RTSP/" and the RTSP method set, HTTP checks "HTTP/1."
|
|
159
|
+
//and the HTTP method set. DESCRIBE/SETUP/PLAY/… are not HTTP methods and "RTSP/" is not "HTTP/1.",
|
|
160
|
+
//so neither claims the other's traffic. The one overlap is OPTIONS, which is a method in BOTH
|
|
161
|
+
//sets: an "OPTIONS <uri> ..." line could be claimed by either at match() time. This is resolved by
|
|
162
|
+
//port bucket on the well-known port (554 → RTSP, 80 → HTTP wins its own bucket) and, on an
|
|
163
|
+
//arbitrary port reached via the heuristic chain, by registration order (first-registered wins).
|
|
164
|
+
//The ambiguity is cosmetic only: both headers keep the message verbatim byte-perfect regardless of
|
|
165
|
+
//which claims the OPTIONS line, so the round-trip bytes are identical either way; only the
|
|
166
|
+
//displayed protocol nickname differs.
|
|
167
|
+
if (!this.prevCodecModule)
|
|
168
|
+
return false;
|
|
169
|
+
if (this.prevCodecModule.id !== 'tcp')
|
|
170
|
+
return false;
|
|
171
|
+
if (this.#payloadLength() < 4)
|
|
172
|
+
return false;
|
|
173
|
+
const lead = this.readBytes(0, 16, true).toString('latin1');
|
|
174
|
+
if (lead.startsWith('RTSP/'))
|
|
175
|
+
return true;
|
|
176
|
+
for (const method of RTSP_METHODS) {
|
|
177
|
+
if (lead.startsWith(method + ' '))
|
|
178
|
+
return true;
|
|
179
|
+
}
|
|
180
|
+
return false;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
exports.RTSP = RTSP;
|
|
184
|
+
_a = RTSP;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { ProtocolJSONSchema } from '../schema/ProtocolJSONSchema';
|
|
2
|
+
import { BaseHeader } from '../abstracts/BaseHeader';
|
|
3
|
+
/**
|
|
4
|
+
* The forced catch-all header. The codec selects it as the final fallback when no
|
|
5
|
+
* demux-table or content-heuristic codec matches, so decode never fails: any bytes
|
|
6
|
+
* left unparsed at the current offset are captured verbatim into a single lower-case
|
|
7
|
+
* hex `data` field and re-emitted byte-for-byte on encode. Not a protocol
|
|
8
|
+
* (`isProtocol = false`); matches whenever there is a previous layer to trail.
|
|
9
|
+
*/
|
|
10
|
+
export declare class RawData extends BaseHeader {
|
|
11
|
+
readonly SCHEMA: ProtocolJSONSchema;
|
|
12
|
+
readonly id: string;
|
|
13
|
+
readonly name: string;
|
|
14
|
+
readonly nickname: string;
|
|
15
|
+
readonly isProtocol: boolean;
|
|
16
|
+
match(): boolean;
|
|
17
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RawData = void 0;
|
|
4
|
+
const BaseHeader_1 = require("../abstracts/BaseHeader");
|
|
5
|
+
const StringContentEncodingEnum_1 = require("../lib/StringContentEncodingEnum");
|
|
6
|
+
const BufferToHex_1 = require("../helper/BufferToHex");
|
|
7
|
+
/**
|
|
8
|
+
* The forced catch-all header. The codec selects it as the final fallback when no
|
|
9
|
+
* demux-table or content-heuristic codec matches, so decode never fails: any bytes
|
|
10
|
+
* left unparsed at the current offset are captured verbatim into a single lower-case
|
|
11
|
+
* hex `data` field and re-emitted byte-for-byte on encode. Not a protocol
|
|
12
|
+
* (`isProtocol = false`); matches whenever there is a previous layer to trail.
|
|
13
|
+
*/
|
|
14
|
+
class RawData extends BaseHeader_1.BaseHeader {
|
|
15
|
+
constructor() {
|
|
16
|
+
super(...arguments);
|
|
17
|
+
this.SCHEMA = {
|
|
18
|
+
type: 'object',
|
|
19
|
+
properties: {
|
|
20
|
+
data: {
|
|
21
|
+
type: 'string',
|
|
22
|
+
label: 'Raw',
|
|
23
|
+
contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.HEX,
|
|
24
|
+
decode: () => {
|
|
25
|
+
const dataLength = this.packet.length - this.startPos;
|
|
26
|
+
this.instance.data.setValue((0, BufferToHex_1.BufferToHex)(this.readBytes(0, dataLength)));
|
|
27
|
+
},
|
|
28
|
+
encode: () => {
|
|
29
|
+
this.writeBytes(0, Buffer.from(this.instance.data.getValue().toString(), 'hex'));
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
this.id = 'raw';
|
|
35
|
+
this.name = 'Raw Data';
|
|
36
|
+
this.nickname = 'Raw';
|
|
37
|
+
this.isProtocol = false;
|
|
38
|
+
}
|
|
39
|
+
match() {
|
|
40
|
+
return !!this.prevCodecModule;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
exports.RawData = RawData;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { BaseHeader } from '../abstracts/BaseHeader';
|
|
2
|
+
import { ProtocolJSONSchema } from '../schema/ProtocolJSONSchema';
|
|
3
|
+
import { DemuxProducer } from '../types/DemuxProducer';
|
|
4
|
+
/**
|
|
5
|
+
* Redis RESP — the REdis Serialization Protocol (RESP2/RESP3), carried over TCP well-known port 6379. RESP
|
|
6
|
+
* is a text-ish line protocol whose FIRST byte names the message type: `+` simple string (`+OK\r\n`), `-`
|
|
7
|
+
* error (`-ERR msg\r\n`), `:` integer (`:1000\r\n`), `$` bulk string (`$6\r\nfoobar\r\n`, or `$-1\r\n` null),
|
|
8
|
+
* `*` array (`*3\r\n$3\r\nSET\r\n$3\r\nfoo\r\n$3\r\nbar\r\n`). RESP3 adds `_` null, `#` boolean, `,` double,
|
|
9
|
+
* `(` big number, `!` blob error, `=` verbatim string, `%` map, `~` set, `>` push. Client commands are
|
|
10
|
+
* almost always arrays of bulk strings (`*` framing), so the first bulk-string element is the command verb.
|
|
11
|
+
*
|
|
12
|
+
* Like FTP, SMTP, POP3, IMAP, Syslog, SIP and HTTP, the message is text whose full internal structure
|
|
13
|
+
* (nested aggregates, binary-safe bulk strings, inline commands) is richer than a form needs. So the ENTIRE
|
|
14
|
+
* raw segment is kept verbatim as the authoritative `message` field (hex) and re-emitted untouched; only a
|
|
15
|
+
* little first-byte/first-line metadata is parsed on decode for display (respType/isRequest/command/preview).
|
|
16
|
+
* Encode never reconstructs the message from the parsed fields — it writes `message` back byte-for-byte — so
|
|
17
|
+
* any conformant (or even malformed) RESP frame round-trips exactly.
|
|
18
|
+
*
|
|
19
|
+
* Note: a single TCP segment may carry more than one RESP message (pipelined commands) or only part of a
|
|
20
|
+
* large bulk string; reassembly across segments is out of scope. This single-segment codec keeps whatever
|
|
21
|
+
* bytes are present verbatim, which is byte-perfect for the single-packet case.
|
|
22
|
+
*/
|
|
23
|
+
export declare class Redis extends BaseHeader {
|
|
24
|
+
#private;
|
|
25
|
+
get SCHEMA(): ProtocolJSONSchema;
|
|
26
|
+
readonly id: string;
|
|
27
|
+
readonly name: string;
|
|
28
|
+
readonly nickname: string;
|
|
29
|
+
readonly matchKeys: string[];
|
|
30
|
+
match(): boolean;
|
|
31
|
+
readonly demuxProducers: DemuxProducer[];
|
|
32
|
+
}
|