massdns

package
v2.0.0-...-eb6a9d5 Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2024 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Overview

Package massdns provides a Resolver object used to invoke the massdns binary file.

The package contains a LineReader struct that implements the io.Reader interface. It is used to read strings line by line from an io.Reader while throttling the results according to a rate-limit specified. The LineReader is passed to the stdin of massdns, allowing it to approximately respect the number of DNS queries per second wanted.

Index

Constants

This section is empty.

Variables

View Source
var ErrNotStarted = errors.New("not started")

ErrNotStarted is an error happening when the LineReader hasn't been started.

Functions

This section is empty.

Types

type Callback

type Callback interface {
	Callback(line string) error
	Close()
}

Callback is a callback function that receives lines from the massdns output.

type DefaultWriteCallback

type DefaultWriteCallback struct {
	// contains filtered or unexported fields
}

DefaultWriteCallback is a callback that can save massdns results to files. It can save the valid domains found and the massdns results that gave valid domains.

func NewDefaultWriteCallback

func NewDefaultWriteCallback(massdnsFilename string, domainFilename string) (*DefaultWriteCallback, error)

NewDefaultWriteCallback creates a new DefaultWriteCallback. The file names can be empty to disable saving to a file.

func (*DefaultWriteCallback) Callback

func (c *DefaultWriteCallback) Callback(line string) error

Callback reads a line from the massdns stdout handler, parses the output and saves the relevant data.

func (*DefaultWriteCallback) Close

func (c *DefaultWriteCallback) Close()

Close closes the writers.

type JSONRecord

type JSONRecord struct {
	TTL   int    `json:"ttl"`
	Type  string `json:"type"`
	Class string `json:"class"`
	Name  string `json:"name"`
	Data  string `json:"data"`
}

JSONRecord contains a record from a massdns output file.

type JSONResponse

type JSONResponse struct {
	Name     string           `json:"name"`
	Type     string           `json:"type"`
	Class    string           `json:"class"`
	Status   string           `json:"status"`
	Data     JSONResponseData `json:"data"`
	Resolver string           `json:"resolver"`
}

JSONResponse contains the response from a massdns output file.

type JSONResponseData

type JSONResponseData struct {
	Answers     []JSONRecord `json:"answers"`
	Authorities []JSONRecord `json:"authorities"`
	Additionals []JSONRecord `json:"additionals"`
}

JSONResponseData contains the response data from a massdns output file.

type LineReader

type LineReader struct {
	// contains filtered or unexported fields
}

LineReader is a line reader that limits the number of line per second read.

func NewLineReader

func NewLineReader(r io.Reader, rate int) *LineReader

NewLineReader creates a new RateLimitLineReader.

func (*LineReader) Count

func (r *LineReader) Count() int

Count returns the number of lines read.

func (*LineReader) Read

func (r *LineReader) Read(p []byte) (n int, err error)

Read reads from the reader, counting the number of lines read and applying rate limiting.

type Resolver

type Resolver struct {
	// contains filtered or unexported fields
}

Resolver uses massdns to resolve a batch of domain names.

func NewResolver

func NewResolver(binPath string) *Resolver

NewResolver creates a new Resolver.

func (*Resolver) Current

func (r *Resolver) Current() int

Current returns the index of the last domain processed.

func (*Resolver) Resolve

func (r *Resolver) Resolve(reader io.Reader, output string, resolversFile string, qps int) error

Resolve reads domain names from the reader and saves the answers to a file. It uses the resolvers and queries per second limit specified.

type Runner

type Runner interface {
	Run(reader io.Reader, output string, resolversFile string, qps int) error
}

Runner is an interface that runs the commands required to execute the massdns binary.

type StdoutHandler

type StdoutHandler struct {
	// contains filtered or unexported fields
}

StdoutHandler read complete lines from the massdns output and sends them one by one to the callback function.

func NewStdoutHandler

func NewStdoutHandler(callback Callback) *StdoutHandler

NewStdoutHandler returns a new OutputHandler that can be used to receive massdns' stdout.

func (*StdoutHandler) Close

func (w *StdoutHandler) Close()

Close closes the callback interface.

func (*StdoutHandler) Write

func (w *StdoutHandler) Write(p []byte) (n int, err error)

Write detects strings terminated by a \n character in the specified buffer and sends them to the callback function.

Jump to

Keyboard shortcuts

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