A Tunnel listens for DNS queries. Messages that are collected and decoded are outputted through the Messages channel.
NewTunnel creates a new tunnel and starts goroutines to manage messages.
The expiration argument decides how long (at a minimum) a partial message is kept in memory before being deleted. Updating a message resets its expiration timer.
A goroutine running in the background periodically loops through each partial message in memory and removes messages that are expired. The deletionInterval argument controls how often this loop runs. Checking for expiration requires a full lock on the internal map of messages; therefore, values of deletionInterval that are too frequent may hurt performance.
The maxMessageSize argument configures the maximum size of an encoded message that the tunnel will accept. Messages that declare a size greater than maxMessageSize will be discarded.
Close cleans up and stops the goroutines created by the tunnel. Calling Close() more than once will panic.
ServeDNS handles DNS queries, records them, and replies with a CNAME to blackhole-1.iana.org.