browsertunnel: github.com/veggiedefender/browsertunnel/tunnel Index | Files

package tunnel

import "github.com/veggiedefender/browsertunnel/tunnel"

Index

Package Files

tunnel.go

type Tunnel Uses

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 Uses

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 Uses

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 Uses

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.

Package tunnel imports 8 packages (graph) and is imported by 1 packages. Updated 2020-07-24. Refresh now. Tools for package owners.