dnsdb

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2021 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NA        = "n/a"
	Unlimited = "unlimited"
)

Variables

View Source
var (
	// ErrResultLimitExceeded is returned if a DNSDB v2 server reports that the query has exceeded
	// its row limit.
	ErrResultLimitExceeded = errors.New("result limit reached")

	// ErrBadRequest The URL is formatted incorrectly.
	ErrBadRequest = errors.New("bad request")
	// ErrUnauthorized The API key is not authorized (usually indicates the block quota is expired), or your API key
	// may not query this API version.
	ErrUnauthorized = errors.New("api key not authorized")
	// ErrForbidden If the X-API-Key header is not present, the provided API key is not valid, or the Client IP address not authorized for this API key.
	ErrForbidden = errors.New("invalid api key or ip not authorized")
	// ErrBadRange If the offset value is greater than the maximum allowed or if an offset value was provided when not permitted.
	ErrBadRange = errors.New("offset is greater than the maximum allowed")
	// ErrQuotaExceeded If you have exceeded your quota and no new requests will be accepted at this time.
	// - For time-based quotas: The API key's daily quota limit is exceeded. The quota will automatically replenish, usually at the start of the next day.
	// - For block-based quotas: The block quota is exhausted. You may need to purchase a larger quota.
	// - For burst rate secondary quotas: There were too many queries within the burst window. The window will automatically reopen at its end.
	ErrQuotaExceeded = errors.New("quota exceeded")
	// ErrConcurrencyLimit If the limit of number of concurrent connections is exceeded.
	ErrConcurrencyLimit = errors.New("concurrency limit exceeded")
)
View Source
var (
	ErrInvalidReset     = errors.New("invalid reset value")
	ErrInvalidLimit     = errors.New("invalid limit value")
	ErrInvalidRemaining = errors.New("invalid remaining value")
	ErrInvalidExpires   = errors.New("invalid expires value")
)
View Source
var (
	ErrInvalidRData = errors.New("rdata not []string or string")
)
View Source
var (
	Version = "(unknown)"
)

Functions

func HttpStatusError

func HttpStatusError(code int) error

Types

type Client

type Client interface {
	// LookupRRSet performs the rrset lookup query
	LookupRRSet(name string) Query
	// LookupRDataName performs the rdata name lookup query
	LookupRDataName(name string) Query
	// LookupRDataIP performs the rdata ip lookup query with a cidr. Use net.IPNet{IP: ip} for a
	// single IP.
	LookupRDataIP(ip net.IPNet) Query
	// LookupRDataIPRange performs the rdata ip lookup query with an ip range
	LookupRDataIPRange(lower, upper net.IP) Query
	// LookupRDataRaw performs the rdata raw lookup query
	LookupRDataRaw(raw []byte) Query
}

Client is an implementation of the DNSDB lookup API

type HttpResultFunc

type HttpResultFunc func(ctx context.Context, req *http.Request) Result

type PingClient

type PingClient interface {
	Ping() PingRequest
}

PingClient is an implementation of the DNSDB v2 Ping API

type PingRequest

type PingRequest interface {
	Do(context.Context) error
}

PingRequest is used to execute ping queries.

type PingResponse

type PingResponse struct {
	Ping string `json:"ping"`
}

PingResponse describes the output format of the DNSDB v2 API ping API

type Query

type Query interface {
	// WithRRType sets the rrtype for the query. The default value is ANY.
	WithRRType(rrtype string) Query

	// WithBailiwick sets the bailiwick for the query. This is only applicable to
	// RRSet-type queries.
	WithBailiwick(bailiwick string) Query

	// WithLimit sets the limit for the number of results returned.
	WithLimit(n int) Query
	// WithAggregation enables or disables grouping of identical rrsets across all time periods
	WithAggregation(aggr bool) Query

	// WithOffset sets how many rows to skip in the results. This is only applicable to Lookup queries
	// and the API server may return an error if it is set for a Summarize query.
	WithOffset(n int) Query

	// WithMaxCount is an option for Summarize query that instructs the api server to stop counting
	// and return an answer immediately once it has reached this value.
	WithMaxCount(n int) Query

	// WithTimeFirstBefore selects records with time_first that is before `when`.
	WithTimeFirstBefore(when time.Time) Query
	// WithTimeFirstAfter selects records with time_first that is after `when`.
	WithTimeFirstAfter(when time.Time) Query
	// WithTimeLastBefore selects records with time_last that is before `when`.
	WithTimeLastBefore(when time.Time) Query
	// WithTimeLastAfter selects records with time_last that is after `when`.
	WithTimeLastAfter(when time.Time) Query

	// WithRelativeTimeFirstBefore selects records with time_first that is before now - `since`. This will panic
	// if passed a negative Duration.
	WithRelativeTimeFirstBefore(since time.Duration) Query
	// WithRelativeTimeFirstAfter selects records with time_first that is after now - `since`. This will panic
	// if passed a negative Duration.
	WithRelativeTimeFirstAfter(since time.Duration) Query
	// WithRelativeTimeLastBefore selects records with time_last that is before now - `since`. This will panic
	// if passed a negative Duration.
	WithRelativeTimeLastBefore(since time.Duration) Query
	// WithRelativeTimeLastAfter selects records with time_last that is after now - `since`. This will panic
	// if passed a negative Duration.
	WithRelativeTimeLastAfter(since time.Duration) Query

	// Do executes the Query and returns a Result. Do is non-blocking. The caller must call `Result.Close()`.
	Do(ctx context.Context) Result
}

Query is used to build parameters for queries and to execute them

func NewHttpRDataIPQuery

func NewHttpRDataIPQuery(net net.IPNet, url *url.URL, headers http.Header, result HttpResultFunc) Query

func NewHttpRDataIPRangeQuery

func NewHttpRDataIPRangeQuery(lower, upper net.IP, url *url.URL, headers http.Header, result HttpResultFunc) Query

func NewHttpRDataNameQuery

func NewHttpRDataNameQuery(name string, url *url.URL, headers http.Header, result HttpResultFunc) Query

func NewHttpRDataRawQuery

func NewHttpRDataRawQuery(raw []byte, url *url.URL, headers http.Header, result HttpResultFunc) Query

func NewHttpRRSetQuery

func NewHttpRRSetQuery(name string, url *url.URL, headers http.Header, result HttpResultFunc) Query

type RRSet

type RRSet struct {
	// RRName is the owner name of the RRset in DNS presentation format.
	RRName string
	// RRType is esource record type of the RRset, either using the standard DNS type mnemonic, or an RFC 3597 generic
	// type, i.e. the string TYPE immediately followed by the decimal RRtype number.
	RRType string
	// RData is an array of one or more Rdata values. The Rdata values are converted to the standard presentation
	// format based on the rrtype value. If the encoder lacks a type-specific presentation format for the RRset's
	// rrtype, then the RFC 3597 generic Rdata encoding will be used.
	RData []string
	// RawRData is a byte array returned for rdata rows in flex search.
	RawRData  []byte
	Bailiwick string
	// Count is the number of times the RRset was observed via passive DNS replication.
	Count int
	// NumResults is the number of results (RRsets) that would be returned from a Lookup.
	NumResults int
	// TimeFirst is the first time that the record was observed via passive DNS replication.
	TimeFirst time.Time
	// TimeLast is the last time that the record was observed via passive DNS replication.
	TimeLast time.Time
	// ZoneTimeFirst is the first time that the record was observed via zone file import.
	ZoneTimeFirst time.Time
	// ZoneTimeLast is the last time that the record was observed via zone file import.
	ZoneTimeLast time.Time
}

func (RRSet) MarshalJSON

func (r RRSet) MarshalJSON() ([]byte, error)

func (*RRSet) UnmarshalJSON

func (r *RRSet) UnmarshalJSON(data []byte) error

type Rate

type Rate struct {
	Reset       *time.Time `json:"reset"`
	Limit       *int       `json:"limit"`
	Remaining   *int       `json:"remaining"`
	Expires     *time.Time `json:"expires"`
	ResultsMax  int        `json:"results_max"`
	OffsetMax   int        `json:"offset_max"`
	BurstSize   int        `json:"burst_size"`
	BurstWindow int        `json:"burst_window"`
}

func (*Rate) UnmarshalJSON

func (r *Rate) UnmarshalJSON(data []byte) error

type RateLimit

type RateLimit struct {
	Rate Rate `json:"rate"`
}

func NewRateLimitFromHeaders

func NewRateLimitFromHeaders(header http.Header) (*RateLimit, error)

type RateLimitClient

type RateLimitClient interface {
	RateLimit() RateLimitQuery
}

type RateLimitQuery

type RateLimitQuery interface {
	Do(ctx context.Context) (RateLimit, error)
}

type RateLimitResult

type RateLimitResult interface {
	// Rate is non-blocking and should not be called until Ch() has been closed.
	Rate() *RateLimit
}

type Result

type Result interface {
	// Close terminates the query and closes the channel returned by `Ch()`
	Close()
	// Ch returns a channel with the results of the query.
	Ch() <-chan RRSet
	// Err should be called after the channel has been closed to check if any errors have occurred.
	Err() error
}

Result returns the results of the query.

type SummarizeClient

type SummarizeClient interface {
	// SummarizeRRSet performs the rrset summarize query
	SummarizeRRSet(name string) Query
	// SummarizeRDataName performs the rdata name summarize query
	SummarizeRDataName(name string) Query
	// SummarizeRDataIP performs the rdata ip summarize query with a cidr. Use net.IPNet{IP: ip} for a
	// single IP.
	SummarizeRDataIP(ip net.IPNet) Query
	// SummarizeRDataIPRange performs the rdata ip summarize query with an ip range
	SummarizeRDataIPRange(lower, upper net.IP) Query
	// SummarizeRDataRaw performs the rdata raw summarize query
	SummarizeRDataRaw(raw []byte) Query
}

SummarizeClient is an implementation of the DNSDB summary API

Directories

Path Synopsis
v2
saf

Jump to

Keyboard shortcuts

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