customtype

command
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 30, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Command customtype implements a resource record type that dnsmsg has never heard of, and round-trips it through the wire codec.

It is the complete, compilable version of the worked example in docs/PLUGIN_GUIDE.md: a struct, the four dnsmsg.RData methods, a dnsmsg.DecodeFunc, a cloned dnsmsg.Registry, and the dnsmsg.UnpackOptions that carries the registry into the decoder. Nothing here reaches into the package's internals — every primitive it uses is exported precisely so that a record type can live outside dnsmsg.

It then demonstrates the three behaviours that matter more than the happy path:

  • Without the registry the same octets still decode, as dnsmsg.Unknown, and re-encode byte for byte. RFC 3597 passthrough means an unregistered type costs introspection, never data.
  • A decoder that runs off the end of its RDATA gets dnsmsg.ErrTruncated from the bound the message decoder installed, with no length checks of its own.
  • A decoder that leaves octets unread gets dnsmsg.ErrRDataLength. That is what stops a sloppy implementation from silently discarding a field it did not know about.

Run it with no arguments; it prints what it did and exits non-zero if any invariant fails.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL