Version: v0.0.0-...-c97b8ff Latest Latest

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

Go to latest
Published: Jul 19, 2020 License: MIT Imports: 8 Imported by: 0




This section is empty.


This section is empty.


This section is empty.


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.

func (*Tunnel) Close

func (tun *Tunnel) Close()

Close cleans up and stops the goroutines created by the tunnel. Calling Close() more than once will panic.

func (*Tunnel) ServeDNS

func (tun *Tunnel) ServeDNS(w dns.ResponseWriter, r *dns.Msg)

ServeDNS handles DNS queries, records them, and replies with a CNAME to blackhole-1.iana.org.

Source Files

Jump to

Keyboard shortcuts

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