Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Tunnel ¶
type Tunnel struct { Messages chan string // contains filtered or unexported fields }
A Tunnel listens for DNS queries. Messages that are collected and decoded are outputted through the Messages channel.
func NewTunnel ¶
func NewTunnel(topDomain string, expiration time.Duration, deletionInterval time.Duration, maxMessageSize int) *Tunnel
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.