Tnetstring
Tnetstring decoder used by the mitmproxy flow analyzer.
Format (https://tnetstrings.info/): <length>:<payload><type> Types: "," string, "#" integer, "^" float, "!" boolean, "~" null, "]" list, "}" dict.
mitmproxy ships a small extension over the base format: a ; type
byte denoting raw bytes alongside ,. We accept both and surface
them as Crystal String, which is what every caller of this module
wants today.
Constants
mitmproxy's tnetstring variant adds a separate ; type for raw
bytes alongside the standard , string type. Decoding both as
Crystal String is fine — they are interchangeable to the
consumer; we only need to handle the type byte either way.
Class methods
Encoder — currently used by specs to build flow fixtures programmatically, but kept in the production module so the implementation is exercised by the same tests as the decoder.
Parses one tnetstring value starting at byte offset pos.
Returns the decoded value and the next read position.