dnsgrab

package module
v0.0.0-...-5c3e238 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2024 License: Apache-2.0 Imports: 10 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrUnsupportedQueryType = errors.New("unsupported query type")
)

Functions

This section is empty.

Types

type Cache

type Cache interface {
	NameByIP(ip []byte) (name string, found bool)

	IPByName(name string) (ip []byte, found bool)

	Add(name string, ip []byte)

	MarkFresh(name string, ip []byte)

	NextSequence() uint32
}

Cache defines the API for a cache of names to IPs and vice versa

func NewInMemoryCache

func NewInMemoryCache(size int) Cache

type Server

type Server interface {
	// LocalAddr() returns the address at which this server is listening
	LocalAddr() net.Addr

	// Serve() runs the server (blocks until server ends)
	Serve() error

	// Close closes the server's network listener.
	Close() error

	// ProcessQuery processes a DNS query and returns the response bytes, the number of answers in the response, and any error encountered while
	// processing the query.
	ProcessQuery(b []byte) ([]byte, int, error)

	// ReverseLookup resolves the given fake IP address into the original hostname. If the given IP is not a fake IP,
	// this simply returns the provided IP in string form. If the IP is not found, this returns false.
	ReverseLookup(ip net.IP) (string, bool)
}

Server is a dns server that resolves queries for A records into fake IP addresses within the Class-E address space and allows reverse resolution of those back into the originally queried hostname.

func Listen

func Listen(cacheSize int, listenAddr string, defaultDNSServer func() string) (Server, error)

Listen creates a new server listening at the given listenAddr and that forwards queries it can't handle to the given defaultDNSServer. It uses an in-memory cache constrained by cacheSize.

func ListenWithCache

func ListenWithCache(listenAddr string, defaultDNSServer func() string, cache Cache) (Server, error)

ListenWithCache is like Listen but taking any Cache implementation.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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