dsl

package
v0.0.0-...-259ffdc Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2015 License: GPL-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Simple DSL for pipebackend. Usage:

// Create new handle. You have to specify a default TTL here.
x := dsl.New()
root := regexp.QuoteMeta("example.com")

// most zones need SOA + NS records
x.SOA(root, func(c *dsl.Context) {
	c.Reply("ns1.example.com hostmaster.example.com 1 3600 1800 86400 3600")
})

// Zones need NS records too. All replies will be returned
x.NS(root, func(c *dsl.Context) {
	c.Reply("ns1.example.com")
	c.Reply("ns2.example.com")
	c.Reply("ns3.example.com")
})

// You don't have to use anonymous functions, of course
func answer(c *dsl.Context) {
	switch c.Query.QType {
		case "A"   : c.Reply("169.254.0.1")
		case "AAAA": c.Reply("fe80::1"    )
	}
}
x.A(root, answer)
x.AAAA(root, answer)

// Setting c.Error at any point will suppress *all* replies from being
// sent back. Instead, a FAIL response with the c.Error.Error() as the
// content is returned to powerdns
x.SSHFP(root, func(c *dsl.Context) {
	c.Reply("1 1 f1d2d2f924e986ac86fdf7b36c94bcdf32beec15")
	c.Error = errors.New("Don't use SSHFP on unsigned zones")
	c.Reply("1 2 e242ed3bffccdf271b7fbaf34ed72d089537b42f")
})

// You can do anything in a callback, but be aware that powerdns has a
// time limit on responses and there is no request concurrency within a
// single pipe connection. pdns achieves concurrency through multiple
// backend connections instead
c := make(chan string)
x.MX(root, func(c *dsl.Context) {
	c.Reply(<-c)
})

// If your regexp includes capture groups, they are quoted back to you.
// Here's a simple DNS echo server. Note the use of ReplyExtra to allow
// a non-default TTL to be set.
//
// Don't forget: DNS is supposed to be case-insensitive. Be careful.
c.TXT(`(.*)\.` + root, func(c *dsl.Context) {
	c.ReplyTTL(c.Query.QName, c.Matches[0], 0)
})

// Dispatch is up to you. It will probably look like this, but you
// might want to add logging around the request or something more
// complicated (different DSL instance depending on backend version?)
func doit(b *backend.Backend, q *backend.Query) ([]*backend.Response, error) {
	if q.QClass == "IN" {
		return x.Lookup(q)
	}
	return nil, errors.New("Only IN QClass is supported")
}

pipe := backend.New( r, w, "Example backend" )
err1 := pipe.Negotiate() // do check for errors
err2 := pipe.Run(doit)

AUTOGENERATED helper methods for IANA-registered RRTYPES. Do not edit. See generate_dsl_helpers.sh for details

Index

Constants

This section is empty.

Variables

View Source
var RRTypes = []string{
	"A",
	"AAAA",
	"AFSDB",
	"APL",
	"ATMA",
	"AXFR",
	"CAA",
	"CDNSKEY",
	"CDS",
	"CERT",
	"CNAME",
	"DHCID",
	"DLV",
	"DNAME",
	"DNSKEY",
	"DS",
	"EID",
	"GID",
	"GPOS",
	"HINFO",
	"HIP",
	"IPSECKEY",
	"ISDN",
	"IXFR",
	"KEY",
	"KX",
	"LOC",
	"LP",
	"MAILA",
	"MAILB",
	"MB",
	"MD",
	"MF",
	"MG",
	"MINFO",
	"MR",
	"MX",
	"NAPTR",
	"NID",
	"NIMLOC",
	"NINFO",
	"NS",
	"NSAP",
	"NSEC",
	"NULL",
	"NXT",
	"OPENPGPKEY",
	"OPT",
	"PTR",
	"PX",
	"RKEY",
	"RP",
	"RRSIG",
	"RT",
	"SIG",
	"SINK",
	"SOA",
	"SPF",
	"SRV",
	"SSHFP",
	"TA",
	"TALINK",
	"TKEY",
	"TLSA",
	"TSIG",
	"TXT",
	"TYPE",
	"UID",
	"UINFO",
	"UNSPEC",
	"URI",
	"WKS",
}

Functions

This section is empty.

Types

type Callback

type Callback func(c *Context)

Callbacks are registered against the DSL instance and run against incoming queries if the regexp they are registered with matches the QName of the query

type Context

type Context struct {
	// Replies that don't specify a TTL will be given this instead.
	DefaultTTL int

	// The query that triggered this callback run. Note that its QType
	// member may be "ANY"
	Query *backend.Query

	// QType this callback is being run as. Matches the qtype field given
	// with the callback at the time DSL.Register was called
	QType string

	// The callback is registered with a regexp; if that regexp contains
	// any match groups, then the matched text is placed here.
	Matches []string

	// Set this if an error has been encountered; no more callbacks will be
	// run, and the error text (only) will be reported to the backend.
	Error error

	// Answers to be sent to the backend are stored here. Context.Reply()
	// calls, etc, generate answers and put them here, for instance.
	// If multiple callbacks are being run, then later callbacks will be
	// able to see the answers earlier ones generated (for now)
	Answers []*backend.Response
}

Callbacks are run with a context instance, which allows them to accumulate answers while maintaining a short type signature. It will also make concurrent callbacks easier, when we handle that, but for now one context is maintained across all callbacks for a particular query

func (*Context) Reply

func (c *Context) Reply(content string)

Add an answer, using default QName and TTL for the query

func (*Context) ReplyExtra

func (c *Context) ReplyExtra(qname, content string, ttl int)

Add an answer, specifying both QName and TTL.

func (*Context) ReplyTTL

func (c *Context) ReplyTTL(content string, ttl int)

Add an answer, using the default QName but specifying a particular TTL

type DSL

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

Instances of this struct are used to hold onto registered callbacks, etc.

func New

func New() *DSL

Get a new builder with a default TTL of one hour

func NewWithTTL

func NewWithTTL(ttl int) *DSL

Get a new builder, specifying a default TTL explicitly

func (*DSL) A

func (d *DSL) A(matcher string, f Callback)

Helper function to register a callback for A queries. The matcher is given as a string, which is compiled to a regular expression (using regexp.MustCompile) with the following rules:

* The regexp is anchored to the start of the match string("^" at start) * The case-insensitivity option is added "(?i)" * The regexp is anchored to the end of the match string ("$" at end)

If any of these options are unwelcome, you can use the DSL.Register and pass a regexp and the "A" string directly.

func (*DSL) AAAA

func (d *DSL) AAAA(matcher string, f Callback)

Helper function to register a callback for AAAA queries. The matcher is given as a string, which is compiled to a regular expression (using regexp.MustCompile) with the following rules:

* The regexp is anchored to the start of the match string("^" at start) * The case-insensitivity option is added "(?i)" * The regexp is anchored to the end of the match string ("$" at end)

If any of these options are unwelcome, you can use the DSL.Register and pass a regexp and the "AAAA" string directly.

func (*DSL) AFSDB

func (d *DSL) AFSDB(matcher string, f Callback)

Helper function to register a callback for AFSDB queries. The matcher is given as a string, which is compiled to a regular expression (using regexp.MustCompile) with the following rules:

* The regexp is anchored to the start of the match string("^" at start) * The case-insensitivity option is added "(?i)" * The regexp is anchored to the end of the match string ("$" at end)

If any of these options are unwelcome, you can use the DSL.Register and pass a regexp and the "AFSDB" string directly.

func (*DSL) APL

func (d *DSL) APL(matcher string, f Callback)

Helper function to register a callback for APL queries. The matcher is given as a string, which is compiled to a regular expression (using regexp.MustCompile) with the following rules:

* The regexp is anchored to the start of the match string("^" at start) * The case-insensitivity option is added "(?i)" * The regexp is anchored to the end of the match string ("$" at end)

If any of these options are unwelcome, you can use the DSL.Register and pass a regexp and the "APL" string directly.

func (*DSL) ATMA

func (d *DSL) ATMA(matcher string, f Callback)

Helper function to register a callback for ATMA queries. The matcher is given as a string, which is compiled to a regular expression (using regexp.MustCompile) with the following rules:

* The regexp is anchored to the start of the match string("^" at start) * The case-insensitivity option is added "(?i)" * The regexp is anchored to the end of the match string ("$" at end)

If any of these options are unwelcome, you can use the DSL.Register and pass a regexp and the "ATMA" string directly.

func (*DSL) AXFR

func (d *DSL) AXFR(matcher string, f Callback)

Helper function to register a callback for AXFR queries. The matcher is given as a string, which is compiled to a regular expression (using regexp.MustCompile) with the following rules:

* The regexp is anchored to the start of the match string("^" at start) * The case-insensitivity option is added "(?i)" * The regexp is anchored to the end of the match string ("$" at end)

If any of these options are unwelcome, you can use the DSL.Register and pass a regexp and the "AXFR" string directly.

func (*DSL) Before

func (d *DSL) Before(f Callback)

Register a callback to run before every request. Set c.Error to halt processing, or mutate the context however you like.

func (*DSL) CAA

func (d *DSL) CAA(matcher string, f Callback)

Helper function to register a callback for CAA queries. The matcher is given as a string, which is compiled to a regular expression (using regexp.MustCompile) with the following rules:

* The regexp is anchored to the start of the match string("^" at start) * The case-insensitivity option is added "(?i)" * The regexp is anchored to the end of the match string ("$" at end)

If any of these options are unwelcome, you can use the DSL.Register and pass a regexp and the "CAA" string directly.

func (*DSL) CDNSKEY

func (d *DSL) CDNSKEY(matcher string, f Callback)

Helper function to register a callback for CDNSKEY queries. The matcher is given as a string, which is compiled to a regular expression (using regexp.MustCompile) with the following rules:

* The regexp is anchored to the start of the match string("^" at start) * The case-insensitivity option is added "(?i)" * The regexp is anchored to the end of the match string ("$" at end)

If any of these options are unwelcome, you can use the DSL.Register and pass a regexp and the "CDNSKEY" string directly.

func (*DSL) CDS

func (d *DSL) CDS(matcher string, f Callback)

Helper function to register a callback for CDS queries. The matcher is given as a string, which is compiled to a regular expression (using regexp.MustCompile) with the following rules:

* The regexp is anchored to the start of the match string("^" at start) * The case-insensitivity option is added "(?i)" * The regexp is anchored to the end of the match string ("$" at end)

If any of these options are unwelcome, you can use the DSL.Register and pass a regexp and the "CDS" string directly.

func (*DSL) CERT

func (d *DSL) CERT(matcher string, f Callback)

Helper function to register a callback for CERT queries. The matcher is given as a string, which is compiled to a regular expression (using regexp.MustCompile) with the following rules:

* The regexp is anchored to the start of the match string("^" at start) * The case-insensitivity option is added "(?i)" * The regexp is anchored to the end of the match string ("$" at end)

If any of these options are unwelcome, you can use the DSL.Register and pass a regexp and the "CERT" string directly.

func (*DSL) CNAME

func (d *DSL) CNAME(matcher string, f Callback)

Helper function to register a callback for CNAME queries. The matcher is given as a string, which is compiled to a regular expression (using regexp.MustCompile) with the following rules:

* The regexp is anchored to the start of the match string("^" at start) * The case-insensitivity option is added "(?i)" * The regexp is anchored to the end of the match string ("$" at end)

If any of these options are unwelcome, you can use the DSL.Register and pass a regexp and the "CNAME" string directly.

func (*DSL) DHCID

func (d *DSL) DHCID(matcher string, f Callback)

Helper function to register a callback for DHCID queries. The matcher is given as a string, which is compiled to a regular expression (using regexp.MustCompile) with the following rules:

* The regexp is anchored to the start of the match string("^" at start) * The case-insensitivity option is added "(?i)" * The regexp is anchored to the end of the match string ("$" at end)

If any of these options are unwelcome, you can use the DSL.Register and pass a regexp and the "DHCID" string directly.

func (*DSL) DLV

func (d *DSL) DLV(matcher string, f Callback)

Helper function to register a callback for DLV queries. The matcher is given as a string, which is compiled to a regular expression (using regexp.MustCompile) with the following rules:

* The regexp is anchored to the start of the match string("^" at start) * The case-insensitivity option is added "(?i)" * The regexp is anchored to the end of the match string ("$" at end)

If any of these options are unwelcome, you can use the DSL.Register and pass a regexp and the "DLV" string directly.

func (*DSL) DNAME

func (d *DSL) DNAME(matcher string, f Callback)

Helper function to register a callback for DNAME queries. The matcher is given as a string, which is compiled to a regular expression (using regexp.MustCompile) with the following rules:

* The regexp is anchored to the start of the match string("^" at start) * The case-insensitivity option is added "(?i)" * The regexp is anchored to the end of the match string ("$" at end)

If any of these options are unwelcome, you can use the DSL.Register and pass a regexp and the "DNAME" string directly.

func (*DSL) DNSKEY

func (d *DSL) DNSKEY(matcher string, f Callback)

Helper function to register a callback for DNSKEY queries. The matcher is given as a string, which is compiled to a regular expression (using regexp.MustCompile) with the following rules:

* The regexp is anchored to the start of the match string("^" at start) * The case-insensitivity option is added "(?i)" * The regexp is anchored to the end of the match string ("$" at end)

If any of these options are unwelcome, you can use the DSL.Register and pass a regexp and the "DNSKEY" string directly.

func (*DSL) DS

func (d *DSL) DS(matcher string, f Callback)

Helper function to register a callback for DS queries. The matcher is given as a string, which is compiled to a regular expression (using regexp.MustCompile) with the following rules:

* The regexp is anchored to the start of the match string("^" at start) * The case-insensitivity option is added "(?i)" * The regexp is anchored to the end of the match string ("$" at end)

If any of these options are unwelcome, you can use the DSL.Register and pass a regexp and the "DS" string directly.

func (*DSL) EID

func (d *DSL) EID(matcher string, f Callback)

Helper function to register a callback for EID queries. The matcher is given as a string, which is compiled to a regular expression (using regexp.MustCompile) with the following rules:

* The regexp is anchored to the start of the match string("^" at start) * The case-insensitivity option is added "(?i)" * The regexp is anchored to the end of the match string ("$" at end)

If any of these options are unwelcome, you can use the DSL.Register and pass a regexp and the "EID" string directly.

func (*DSL) GID

func (d *DSL) GID(matcher string, f Callback)

Helper function to register a callback for GID queries. The matcher is given as a string, which is compiled to a regular expression (using regexp.MustCompile) with the following rules:

* The regexp is anchored to the start of the match string("^" at start) * The case-insensitivity option is added "(?i)" * The regexp is anchored to the end of the match string ("$" at end)

If any of these options are unwelcome, you can use the DSL.Register and pass a regexp and the "GID" string directly.

func (*DSL) GPOS

func (d *DSL) GPOS(matcher string, f Callback)

Helper function to register a callback for GPOS queries. The matcher is given as a string, which is compiled to a regular expression (using regexp.MustCompile) with the following rules:

* The regexp is anchored to the start of the match string("^" at start) * The case-insensitivity option is added "(?i)" * The regexp is anchored to the end of the match string ("$" at end)

If any of these options are unwelcome, you can use the DSL.Register and pass a regexp and the "GPOS" string directly.

func (*DSL) HINFO

func (d *DSL) HINFO(matcher string, f Callback)

Helper function to register a callback for HINFO queries. The matcher is given as a string, which is compiled to a regular expression (using regexp.MustCompile) with the following rules:

* The regexp is anchored to the start of the match string("^" at start) * The case-insensitivity option is added "(?i)" * The regexp is anchored to the end of the match string ("$" at end)

If any of these options are unwelcome, you can use the DSL.Register and pass a regexp and the "HINFO" string directly.

func (*DSL) HIP

func (d *DSL) HIP(matcher string, f Callback)

Helper function to register a callback for HIP queries. The matcher is given as a string, which is compiled to a regular expression (using regexp.MustCompile) with the following rules:

* The regexp is anchored to the start of the match string("^" at start) * The case-insensitivity option is added "(?i)" * The regexp is anchored to the end of the match string ("$" at end)

If any of these options are unwelcome, you can use the DSL.Register and pass a regexp and the "HIP" string directly.

func (*DSL) IPSECKEY

func (d *DSL) IPSECKEY(matcher string, f Callback)

Helper function to register a callback for IPSECKEY queries. The matcher is given as a string, which is compiled to a regular expression (using regexp.MustCompile) with the following rules:

* The regexp is anchored to the start of the match string("^" at start) * The case-insensitivity option is added "(?i)" * The regexp is anchored to the end of the match string ("$" at end)

If any of these options are unwelcome, you can use the DSL.Register and pass a regexp and the "IPSECKEY" string directly.

func (*DSL) ISDN

func (d *DSL) ISDN(matcher string, f Callback)

Helper function to register a callback for ISDN queries. The matcher is given as a string, which is compiled to a regular expression (using regexp.MustCompile) with the following rules:

* The regexp is anchored to the start of the match string("^" at start) * The case-insensitivity option is added "(?i)" * The regexp is anchored to the end of the match string ("$" at end)

If any of these options are unwelcome, you can use the DSL.Register and pass a regexp and the "ISDN" string directly.

func (*DSL) IXFR

func (d *DSL) IXFR(matcher string, f Callback)

Helper function to register a callback for IXFR queries. The matcher is given as a string, which is compiled to a regular expression (using regexp.MustCompile) with the following rules:

* The regexp is anchored to the start of the match string("^" at start) * The case-insensitivity option is added "(?i)" * The regexp is anchored to the end of the match string ("$" at end)

If any of these options are unwelcome, you can use the DSL.Register and pass a regexp and the "IXFR" string directly.

func (*DSL) KEY

func (d *DSL) KEY(matcher string, f Callback)

Helper function to register a callback for KEY queries. The matcher is given as a string, which is compiled to a regular expression (using regexp.MustCompile) with the following rules:

* The regexp is anchored to the start of the match string("^" at start) * The case-insensitivity option is added "(?i)" * The regexp is anchored to the end of the match string ("$" at end)

If any of these options are unwelcome, you can use the DSL.Register and pass a regexp and the "KEY" string directly.

func (*DSL) KX

func (d *DSL) KX(matcher string, f Callback)

Helper function to register a callback for KX queries. The matcher is given as a string, which is compiled to a regular expression (using regexp.MustCompile) with the following rules:

* The regexp is anchored to the start of the match string("^" at start) * The case-insensitivity option is added "(?i)" * The regexp is anchored to the end of the match string ("$" at end)

If any of these options are unwelcome, you can use the DSL.Register and pass a regexp and the "KX" string directly.

func (*DSL) LOC

func (d *DSL) LOC(matcher string, f Callback)

Helper function to register a callback for LOC queries. The matcher is given as a string, which is compiled to a regular expression (using regexp.MustCompile) with the following rules:

* The regexp is anchored to the start of the match string("^" at start) * The case-insensitivity option is added "(?i)" * The regexp is anchored to the end of the match string ("$" at end)

If any of these options are unwelcome, you can use the DSL.Register and pass a regexp and the "LOC" string directly.

func (*DSL) LP

func (d *DSL) LP(matcher string, f Callback)

Helper function to register a callback for LP queries. The matcher is given as a string, which is compiled to a regular expression (using regexp.MustCompile) with the following rules:

* The regexp is anchored to the start of the match string("^" at start) * The case-insensitivity option is added "(?i)" * The regexp is anchored to the end of the match string ("$" at end)

If any of these options are unwelcome, you can use the DSL.Register and pass a regexp and the "LP" string directly.

func (*DSL) Lookup

func (d *DSL) Lookup(q *backend.Query) ([]*backend.Response, error)

Run all registered callbacks against the query. If any callbacks report an error, we halt and return the error only (partially constructed responses are discarded).

For now, callbacks are run sequentially, rather than in parallel. There could be a speedup to running each callback in its own goroutine. Currently, all callbacks share the same context instance; we'd have to change that if we ran them in parallel.

func (*DSL) MAILA

func (d *DSL) MAILA(matcher string, f Callback)

Helper function to register a callback for MAILA queries. The matcher is given as a string, which is compiled to a regular expression (using regexp.MustCompile) with the following rules:

* The regexp is anchored to the start of the match string("^" at start) * The case-insensitivity option is added "(?i)" * The regexp is anchored to the end of the match string ("$" at end)

If any of these options are unwelcome, you can use the DSL.Register and pass a regexp and the "MAILA" string directly.

func (*DSL) MAILB

func (d *DSL) MAILB(matcher string, f Callback)

Helper function to register a callback for MAILB queries. The matcher is given as a string, which is compiled to a regular expression (using regexp.MustCompile) with the following rules:

* The regexp is anchored to the start of the match string("^" at start) * The case-insensitivity option is added "(?i)" * The regexp is anchored to the end of the match string ("$" at end)

If any of these options are unwelcome, you can use the DSL.Register and pass a regexp and the "MAILB" string directly.

func (*DSL) MB

func (d *DSL) MB(matcher string, f Callback)

Helper function to register a callback for MB queries. The matcher is given as a string, which is compiled to a regular expression (using regexp.MustCompile) with the following rules:

* The regexp is anchored to the start of the match string("^" at start) * The case-insensitivity option is added "(?i)" * The regexp is anchored to the end of the match string ("$" at end)

If any of these options are unwelcome, you can use the DSL.Register and pass a regexp and the "MB" string directly.

func (*DSL) MD

func (d *DSL) MD(matcher string, f Callback)

Helper function to register a callback for MD queries. The matcher is given as a string, which is compiled to a regular expression (using regexp.MustCompile) with the following rules:

* The regexp is anchored to the start of the match string("^" at start) * The case-insensitivity option is added "(?i)" * The regexp is anchored to the end of the match string ("$" at end)

If any of these options are unwelcome, you can use the DSL.Register and pass a regexp and the "MD" string directly.

func (*DSL) MF

func (d *DSL) MF(matcher string, f Callback)

Helper function to register a callback for MF queries. The matcher is given as a string, which is compiled to a regular expression (using regexp.MustCompile) with the following rules:

* The regexp is anchored to the start of the match string("^" at start) * The case-insensitivity option is added "(?i)" * The regexp is anchored to the end of the match string ("$" at end)

If any of these options are unwelcome, you can use the DSL.Register and pass a regexp and the "MF" string directly.

func (*DSL) MG

func (d *DSL) MG(matcher string, f Callback)

Helper function to register a callback for MG queries. The matcher is given as a string, which is compiled to a regular expression (using regexp.MustCompile) with the following rules:

* The regexp is anchored to the start of the match string("^" at start) * The case-insensitivity option is added "(?i)" * The regexp is anchored to the end of the match string ("$" at end)

If any of these options are unwelcome, you can use the DSL.Register and pass a regexp and the "MG" string directly.

func (*DSL) MINFO

func (d *DSL) MINFO(matcher string, f Callback)

Helper function to register a callback for MINFO queries. The matcher is given as a string, which is compiled to a regular expression (using regexp.MustCompile) with the following rules:

* The regexp is anchored to the start of the match string("^" at start) * The case-insensitivity option is added "(?i)" * The regexp is anchored to the end of the match string ("$" at end)

If any of these options are unwelcome, you can use the DSL.Register and pass a regexp and the "MINFO" string directly.

func (*DSL) MR

func (d *DSL) MR(matcher string, f Callback)

Helper function to register a callback for MR queries. The matcher is given as a string, which is compiled to a regular expression (using regexp.MustCompile) with the following rules:

* The regexp is anchored to the start of the match string("^" at start) * The case-insensitivity option is added "(?i)" * The regexp is anchored to the end of the match string ("$" at end)

If any of these options are unwelcome, you can use the DSL.Register and pass a regexp and the "MR" string directly.

func (*DSL) MX

func (d *DSL) MX(matcher string, f Callback)

Helper function to register a callback for MX queries. The matcher is given as a string, which is compiled to a regular expression (using regexp.MustCompile) with the following rules:

* The regexp is anchored to the start of the match string("^" at start) * The case-insensitivity option is added "(?i)" * The regexp is anchored to the end of the match string ("$" at end)

If any of these options are unwelcome, you can use the DSL.Register and pass a regexp and the "MX" string directly.

func (*DSL) NAPTR

func (d *DSL) NAPTR(matcher string, f Callback)

Helper function to register a callback for NAPTR queries. The matcher is given as a string, which is compiled to a regular expression (using regexp.MustCompile) with the following rules:

* The regexp is anchored to the start of the match string("^" at start) * The case-insensitivity option is added "(?i)" * The regexp is anchored to the end of the match string ("$" at end)

If any of these options are unwelcome, you can use the DSL.Register and pass a regexp and the "NAPTR" string directly.

func (*DSL) NID

func (d *DSL) NID(matcher string, f Callback)

Helper function to register a callback for NID queries. The matcher is given as a string, which is compiled to a regular expression (using regexp.MustCompile) with the following rules:

* The regexp is anchored to the start of the match string("^" at start) * The case-insensitivity option is added "(?i)" * The regexp is anchored to the end of the match string ("$" at end)

If any of these options are unwelcome, you can use the DSL.Register and pass a regexp and the "NID" string directly.

func (*DSL) NIMLOC

func (d *DSL) NIMLOC(matcher string, f Callback)

Helper function to register a callback for NIMLOC queries. The matcher is given as a string, which is compiled to a regular expression (using regexp.MustCompile) with the following rules:

* The regexp is anchored to the start of the match string("^" at start) * The case-insensitivity option is added "(?i)" * The regexp is anchored to the end of the match string ("$" at end)

If any of these options are unwelcome, you can use the DSL.Register and pass a regexp and the "NIMLOC" string directly.

func (*DSL) NINFO

func (d *DSL) NINFO(matcher string, f Callback)

Helper function to register a callback for NINFO queries. The matcher is given as a string, which is compiled to a regular expression (using regexp.MustCompile) with the following rules:

* The regexp is anchored to the start of the match string("^" at start) * The case-insensitivity option is added "(?i)" * The regexp is anchored to the end of the match string ("$" at end)

If any of these options are unwelcome, you can use the DSL.Register and pass a regexp and the "NINFO" string directly.

func (*DSL) NS

func (d *DSL) NS(matcher string, f Callback)

Helper function to register a callback for NS queries. The matcher is given as a string, which is compiled to a regular expression (using regexp.MustCompile) with the following rules:

* The regexp is anchored to the start of the match string("^" at start) * The case-insensitivity option is added "(?i)" * The regexp is anchored to the end of the match string ("$" at end)

If any of these options are unwelcome, you can use the DSL.Register and pass a regexp and the "NS" string directly.

func (*DSL) NSAP

func (d *DSL) NSAP(matcher string, f Callback)

Helper function to register a callback for NSAP queries. The matcher is given as a string, which is compiled to a regular expression (using regexp.MustCompile) with the following rules:

* The regexp is anchored to the start of the match string("^" at start) * The case-insensitivity option is added "(?i)" * The regexp is anchored to the end of the match string ("$" at end)

If any of these options are unwelcome, you can use the DSL.Register and pass a regexp and the "NSAP" string directly.

func (*DSL) NSEC

func (d *DSL) NSEC(matcher string, f Callback)

Helper function to register a callback for NSEC queries. The matcher is given as a string, which is compiled to a regular expression (using regexp.MustCompile) with the following rules:

* The regexp is anchored to the start of the match string("^" at start) * The case-insensitivity option is added "(?i)" * The regexp is anchored to the end of the match string ("$" at end)

If any of these options are unwelcome, you can use the DSL.Register and pass a regexp and the "NSEC" string directly.

func (*DSL) NULL

func (d *DSL) NULL(matcher string, f Callback)

Helper function to register a callback for NULL queries. The matcher is given as a string, which is compiled to a regular expression (using regexp.MustCompile) with the following rules:

* The regexp is anchored to the start of the match string("^" at start) * The case-insensitivity option is added "(?i)" * The regexp is anchored to the end of the match string ("$" at end)

If any of these options are unwelcome, you can use the DSL.Register and pass a regexp and the "NULL" string directly.

func (*DSL) NXT

func (d *DSL) NXT(matcher string, f Callback)

Helper function to register a callback for NXT queries. The matcher is given as a string, which is compiled to a regular expression (using regexp.MustCompile) with the following rules:

* The regexp is anchored to the start of the match string("^" at start) * The case-insensitivity option is added "(?i)" * The regexp is anchored to the end of the match string ("$" at end)

If any of these options are unwelcome, you can use the DSL.Register and pass a regexp and the "NXT" string directly.

func (*DSL) OPENPGPKEY

func (d *DSL) OPENPGPKEY(matcher string, f Callback)

Helper function to register a callback for OPENPGPKEY queries. The matcher is given as a string, which is compiled to a regular expression (using regexp.MustCompile) with the following rules:

* The regexp is anchored to the start of the match string("^" at start) * The case-insensitivity option is added "(?i)" * The regexp is anchored to the end of the match string ("$" at end)

If any of these options are unwelcome, you can use the DSL.Register and pass a regexp and the "OPENPGPKEY" string directly.

func (*DSL) OPT

func (d *DSL) OPT(matcher string, f Callback)

Helper function to register a callback for OPT queries. The matcher is given as a string, which is compiled to a regular expression (using regexp.MustCompile) with the following rules:

* The regexp is anchored to the start of the match string("^" at start) * The case-insensitivity option is added "(?i)" * The regexp is anchored to the end of the match string ("$" at end)

If any of these options are unwelcome, you can use the DSL.Register and pass a regexp and the "OPT" string directly.

func (*DSL) PTR

func (d *DSL) PTR(matcher string, f Callback)

Helper function to register a callback for PTR queries. The matcher is given as a string, which is compiled to a regular expression (using regexp.MustCompile) with the following rules:

* The regexp is anchored to the start of the match string("^" at start) * The case-insensitivity option is added "(?i)" * The regexp is anchored to the end of the match string ("$" at end)

If any of these options are unwelcome, you can use the DSL.Register and pass a regexp and the "PTR" string directly.

func (*DSL) PX

func (d *DSL) PX(matcher string, f Callback)

Helper function to register a callback for PX queries. The matcher is given as a string, which is compiled to a regular expression (using regexp.MustCompile) with the following rules:

* The regexp is anchored to the start of the match string("^" at start) * The case-insensitivity option is added "(?i)" * The regexp is anchored to the end of the match string ("$" at end)

If any of these options are unwelcome, you can use the DSL.Register and pass a regexp and the "PX" string directly.

func (*DSL) RKEY

func (d *DSL) RKEY(matcher string, f Callback)

Helper function to register a callback for RKEY queries. The matcher is given as a string, which is compiled to a regular expression (using regexp.MustCompile) with the following rules:

* The regexp is anchored to the start of the match string("^" at start) * The case-insensitivity option is added "(?i)" * The regexp is anchored to the end of the match string ("$" at end)

If any of these options are unwelcome, you can use the DSL.Register and pass a regexp and the "RKEY" string directly.

func (*DSL) RP

func (d *DSL) RP(matcher string, f Callback)

Helper function to register a callback for RP queries. The matcher is given as a string, which is compiled to a regular expression (using regexp.MustCompile) with the following rules:

* The regexp is anchored to the start of the match string("^" at start) * The case-insensitivity option is added "(?i)" * The regexp is anchored to the end of the match string ("$" at end)

If any of these options are unwelcome, you can use the DSL.Register and pass a regexp and the "RP" string directly.

func (*DSL) RRSIG

func (d *DSL) RRSIG(matcher string, f Callback)

Helper function to register a callback for RRSIG queries. The matcher is given as a string, which is compiled to a regular expression (using regexp.MustCompile) with the following rules:

* The regexp is anchored to the start of the match string("^" at start) * The case-insensitivity option is added "(?i)" * The regexp is anchored to the end of the match string ("$" at end)

If any of these options are unwelcome, you can use the DSL.Register and pass a regexp and the "RRSIG" string directly.

func (*DSL) RT

func (d *DSL) RT(matcher string, f Callback)

Helper function to register a callback for RT queries. The matcher is given as a string, which is compiled to a regular expression (using regexp.MustCompile) with the following rules:

* The regexp is anchored to the start of the match string("^" at start) * The case-insensitivity option is added "(?i)" * The regexp is anchored to the end of the match string ("$" at end)

If any of these options are unwelcome, you can use the DSL.Register and pass a regexp and the "RT" string directly.

func (*DSL) Register

func (d *DSL) Register(qtype string, re *regexp.Regexp, f Callback)

Register a callback to be run whenever a query with a QName matching the regular expression comes in. The regex is provided as a string (matcher) to keep ordinary invocations short; it's compiled immediately with regexp.MustCompile. Don't forget to anchor your regexes!

If match groups are included in the regex, then any matched text is placed in the Context the callback receives.

Callbacks are run with slightly obtuse ordering: all callbacks of a qtype are run in the order they were registered. We iterate the list of qtypes in the order that a callback with a matching qtype was *first* registered. If your pdns server has the "noshuffle" configuration directive, the order will be reflected in the responses returned by it; future concurrent DSL should maintain this ordering.

func (*DSL) SIG

func (d *DSL) SIG(matcher string, f Callback)

Helper function to register a callback for SIG queries. The matcher is given as a string, which is compiled to a regular expression (using regexp.MustCompile) with the following rules:

* The regexp is anchored to the start of the match string("^" at start) * The case-insensitivity option is added "(?i)" * The regexp is anchored to the end of the match string ("$" at end)

If any of these options are unwelcome, you can use the DSL.Register and pass a regexp and the "SIG" string directly.

func (*DSL) SINK

func (d *DSL) SINK(matcher string, f Callback)

Helper function to register a callback for SINK queries. The matcher is given as a string, which is compiled to a regular expression (using regexp.MustCompile) with the following rules:

* The regexp is anchored to the start of the match string("^" at start) * The case-insensitivity option is added "(?i)" * The regexp is anchored to the end of the match string ("$" at end)

If any of these options are unwelcome, you can use the DSL.Register and pass a regexp and the "SINK" string directly.

func (*DSL) SOA

func (d *DSL) SOA(matcher string, f Callback)

Helper function to register a callback for SOA queries. The matcher is given as a string, which is compiled to a regular expression (using regexp.MustCompile) with the following rules:

* The regexp is anchored to the start of the match string("^" at start) * The case-insensitivity option is added "(?i)" * The regexp is anchored to the end of the match string ("$" at end)

If any of these options are unwelcome, you can use the DSL.Register and pass a regexp and the "SOA" string directly.

func (*DSL) SPF

func (d *DSL) SPF(matcher string, f Callback)

Helper function to register a callback for SPF queries. The matcher is given as a string, which is compiled to a regular expression (using regexp.MustCompile) with the following rules:

* The regexp is anchored to the start of the match string("^" at start) * The case-insensitivity option is added "(?i)" * The regexp is anchored to the end of the match string ("$" at end)

If any of these options are unwelcome, you can use the DSL.Register and pass a regexp and the "SPF" string directly.

func (*DSL) SRV

func (d *DSL) SRV(matcher string, f Callback)

Helper function to register a callback for SRV queries. The matcher is given as a string, which is compiled to a regular expression (using regexp.MustCompile) with the following rules:

* The regexp is anchored to the start of the match string("^" at start) * The case-insensitivity option is added "(?i)" * The regexp is anchored to the end of the match string ("$" at end)

If any of these options are unwelcome, you can use the DSL.Register and pass a regexp and the "SRV" string directly.

func (*DSL) SSHFP

func (d *DSL) SSHFP(matcher string, f Callback)

Helper function to register a callback for SSHFP queries. The matcher is given as a string, which is compiled to a regular expression (using regexp.MustCompile) with the following rules:

* The regexp is anchored to the start of the match string("^" at start) * The case-insensitivity option is added "(?i)" * The regexp is anchored to the end of the match string ("$" at end)

If any of these options are unwelcome, you can use the DSL.Register and pass a regexp and the "SSHFP" string directly.

func (*DSL) String

func (d *DSL) String() string

Reports the registered callbacks, in order. Handy for testing or status.

func (*DSL) TA

func (d *DSL) TA(matcher string, f Callback)

Helper function to register a callback for TA queries. The matcher is given as a string, which is compiled to a regular expression (using regexp.MustCompile) with the following rules:

* The regexp is anchored to the start of the match string("^" at start) * The case-insensitivity option is added "(?i)" * The regexp is anchored to the end of the match string ("$" at end)

If any of these options are unwelcome, you can use the DSL.Register and pass a regexp and the "TA" string directly.

func (d *DSL) TALINK(matcher string, f Callback)

Helper function to register a callback for TALINK queries. The matcher is given as a string, which is compiled to a regular expression (using regexp.MustCompile) with the following rules:

* The regexp is anchored to the start of the match string("^" at start) * The case-insensitivity option is added "(?i)" * The regexp is anchored to the end of the match string ("$" at end)

If any of these options are unwelcome, you can use the DSL.Register and pass a regexp and the "TALINK" string directly.

func (*DSL) TKEY

func (d *DSL) TKEY(matcher string, f Callback)

Helper function to register a callback for TKEY queries. The matcher is given as a string, which is compiled to a regular expression (using regexp.MustCompile) with the following rules:

* The regexp is anchored to the start of the match string("^" at start) * The case-insensitivity option is added "(?i)" * The regexp is anchored to the end of the match string ("$" at end)

If any of these options are unwelcome, you can use the DSL.Register and pass a regexp and the "TKEY" string directly.

func (*DSL) TLSA

func (d *DSL) TLSA(matcher string, f Callback)

Helper function to register a callback for TLSA queries. The matcher is given as a string, which is compiled to a regular expression (using regexp.MustCompile) with the following rules:

* The regexp is anchored to the start of the match string("^" at start) * The case-insensitivity option is added "(?i)" * The regexp is anchored to the end of the match string ("$" at end)

If any of these options are unwelcome, you can use the DSL.Register and pass a regexp and the "TLSA" string directly.

func (*DSL) TSIG

func (d *DSL) TSIG(matcher string, f Callback)

Helper function to register a callback for TSIG queries. The matcher is given as a string, which is compiled to a regular expression (using regexp.MustCompile) with the following rules:

* The regexp is anchored to the start of the match string("^" at start) * The case-insensitivity option is added "(?i)" * The regexp is anchored to the end of the match string ("$" at end)

If any of these options are unwelcome, you can use the DSL.Register and pass a regexp and the "TSIG" string directly.

func (*DSL) TXT

func (d *DSL) TXT(matcher string, f Callback)

Helper function to register a callback for TXT queries. The matcher is given as a string, which is compiled to a regular expression (using regexp.MustCompile) with the following rules:

* The regexp is anchored to the start of the match string("^" at start) * The case-insensitivity option is added "(?i)" * The regexp is anchored to the end of the match string ("$" at end)

If any of these options are unwelcome, you can use the DSL.Register and pass a regexp and the "TXT" string directly.

func (*DSL) TYPE

func (d *DSL) TYPE(matcher string, f Callback)

Helper function to register a callback for TYPE queries. The matcher is given as a string, which is compiled to a regular expression (using regexp.MustCompile) with the following rules:

* The regexp is anchored to the start of the match string("^" at start) * The case-insensitivity option is added "(?i)" * The regexp is anchored to the end of the match string ("$" at end)

If any of these options are unwelcome, you can use the DSL.Register and pass a regexp and the "TYPE" string directly.

func (*DSL) UID

func (d *DSL) UID(matcher string, f Callback)

Helper function to register a callback for UID queries. The matcher is given as a string, which is compiled to a regular expression (using regexp.MustCompile) with the following rules:

* The regexp is anchored to the start of the match string("^" at start) * The case-insensitivity option is added "(?i)" * The regexp is anchored to the end of the match string ("$" at end)

If any of these options are unwelcome, you can use the DSL.Register and pass a regexp and the "UID" string directly.

func (*DSL) UINFO

func (d *DSL) UINFO(matcher string, f Callback)

Helper function to register a callback for UINFO queries. The matcher is given as a string, which is compiled to a regular expression (using regexp.MustCompile) with the following rules:

* The regexp is anchored to the start of the match string("^" at start) * The case-insensitivity option is added "(?i)" * The regexp is anchored to the end of the match string ("$" at end)

If any of these options are unwelcome, you can use the DSL.Register and pass a regexp and the "UINFO" string directly.

func (*DSL) UNSPEC

func (d *DSL) UNSPEC(matcher string, f Callback)

Helper function to register a callback for UNSPEC queries. The matcher is given as a string, which is compiled to a regular expression (using regexp.MustCompile) with the following rules:

* The regexp is anchored to the start of the match string("^" at start) * The case-insensitivity option is added "(?i)" * The regexp is anchored to the end of the match string ("$" at end)

If any of these options are unwelcome, you can use the DSL.Register and pass a regexp and the "UNSPEC" string directly.

func (*DSL) URI

func (d *DSL) URI(matcher string, f Callback)

Helper function to register a callback for URI queries. The matcher is given as a string, which is compiled to a regular expression (using regexp.MustCompile) with the following rules:

* The regexp is anchored to the start of the match string("^" at start) * The case-insensitivity option is added "(?i)" * The regexp is anchored to the end of the match string ("$" at end)

If any of these options are unwelcome, you can use the DSL.Register and pass a regexp and the "URI" string directly.

func (*DSL) WKS

func (d *DSL) WKS(matcher string, f Callback)

Helper function to register a callback for WKS queries. The matcher is given as a string, which is compiled to a regular expression (using regexp.MustCompile) with the following rules:

* The regexp is anchored to the start of the match string("^" at start) * The case-insensitivity option is added "(?i)" * The regexp is anchored to the end of the match string ("$" at end)

If any of these options are unwelcome, you can use the DSL.Register and pass a regexp and the "WKS" string directly.

Jump to

Keyboard shortcuts

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