Adding decoders
Add public Go decoders under internal/decoder/packet or internal/decoder/stream. Use the matching v0.15.2 implementation as the API reference; historical CreateLayerEncoder examples no longer describe the current decoder constructors.
Protocol Buffer Definitions
Extend types/netcap.proto with a message and, when needed, a unique NC_ type enumeration. Preserve existing field/enum numbers and reserve removed ones. Timestamps use int64 Unix nanoseconds, not the old string representation.
Generate with the project's gogofaster plugin:
zeus gen-proto-devThe underlying invocation is protoc --proto_path=types --gogofaster_out=types/. types/netcap.proto. Use the generator version pinned by the checkout's tooling/dependencies and review the generated diff; --gogo_out is not interchangeable.
Encoder Implementation
Packet layer
internal/decoder/packet/arp.go
newGoPacketDecoder, typed handler, registered layer/type
Custom packet/aggregate
internal/decoder/packet/connection.go
Initialization, concurrency, bounded state and finalization
TCP/UDP stream
internal/decoder/stream/
Selector specificity, framing, directions, gaps and teardown
For ARP, decodeARP(*layers.ARP, int64) returns a protobuf message. The current imports use github.com/gopacket/gopacket and github.com/gogo/protobuf/proto. Do not copy obsolete examples importing the historical gopacket fork.
Stream parsers must bound buffered lengths before allocation, distinguish unsupported content from malformed framing, and retain gap/completeness semantics. A port number alone is not sufficient evidence to select an ambiguous protocol parser.
Audit Record Interface Implementation
Implement the actual types.AuditRecord interface in types/audit_record.go: CSV header/values, Time() int64, endpoints, metrics, JSON, packet context, encoding, analysis and NetcapType(). Keep display and wire timestamp units explicit.
Ensure CSV headers match values, nested fields render consistently, byte fields have a defined representation and SetPacketContext updates the record pointer.
Add Initializer
Register the message in internal/netio.InitRecord and the relevant decoder registry. Confirm dump -header, -fields, -json and selected CSV all work on a generated fixture. Add browser/API rendering only where that record is exposed.
Verification
Add meaningful tests for valid input, partial framing, oversized lengths, retransmissions/gaps and unsupported cases. Assert records/health artifacts, not merely absence of a panic. Run affected packages and relevant capture regressions, including worker invariance for shared state.
Last updated