Skip to content

io.systemd.Resolve.Hook

Generic interface for implementing a domain name resolution hook.

Property Value
Go package github.com/rossedman/sdvarlink/systemd/latest/resolvehook
Available since systemd v260
Methods · types · errors 2 · 4 · 0

Methods

QueryFilter

streaming optional

Returns filter parameters for this hook. A hook service can implement this to reduce lookup requests, by enabling itself only for certain domains or certain numbers of labels in the name. It's recommended to implement this to reduce the number of redundant calls to each hook. Note that this is advisory only, and implementing services must be able to gracefully handle lookup requests that do not match this filter. This call is usually made with the 'more' flag set, in which case the connection is left open after the first reply, and the implementing hook services can send updates to the filter at any time. Whenever a further reply is sent the filter configured therein fully replaces any previously communicated filter.

func (c *Client) QueryFilter(ctx context.Context) (*QueryFilterOut, error)
func (c *Client) QueryFilterMore(ctx context.Context) iter.Seq2[*QueryFilterOut, error]

Reply

Field Type Description
filterDomains ?[]string A list of domains this hook is interested in. Lookups for domains not listed here will not be passed to the Hook via ResolveRecord(). If this field is not set, requests for all domains will be passed to the hook. Note that this applies recursively, i.e. a domain of a lookup is considered matching the listed domains both if it exactly matches it, and in case only a suffix of it matches it. If this is set to an empty array the hook is disabled.
filterLabelsMin ?int Require the specified number of labels or more in a domain for the hook to be considered.
filterLabelsMax ?int Require the specified number of labels or less in a domain for the hook to be considered.

ResolveRecord

Sent whenever a resolution request is made. This typically takes the filter parameters returned by QueryFilter() into account, but this is not guaranteed.

func (c *Client) ResolveRecord(ctx context.Context, in ResolveRecordIn) (*ResolveRecordOut, error)

Parameters

Field Type Description
question []Question The question being looked up, i.e. a combination of resource record keys. Note that unlike DNS queries on the wire these lookups can carry multiple key requests, albeit closely related ones. Specifically, lookups for A+AAAA for the the same hostname are submitted as one question, as are lookups for TXT+SRV when doing DNS-SD resolution. Moreover, when looking up resources with non-ASCII characters, they are placed together in a single question, once with labels encoded in UTF-8, and once in IDNA. Hook implementations must be able to deal with these and other similar combinations of resource key requests, and reply with all matching answers at once, or fail them as one. Partial success/failure combinations are not supported.

Reply

Field Type Description
rcode ?int A DNS response code. If a hook sets this return parameter further processing of the lookup via regular protocols such as DNS, LLMNR, mDNS is skipped, and the return code returned immediately. In other words, if a hook intends to let the request pass to normal resolution, it should not set this return parameter.
answer ?[]Answer An answer for a lookup, i.e. a combination of resource records, matching the request. This should only be set when the 'rcode' parameter is returned as 0 (SUCCESS).

Types

Answer

Encapsulates a positive lookup answer

Field Type Description
rr ?ResourceRecord A resource record that shall be looked up. Note that this field is (currently) mostly decoration, useful for debugging, and may be omitted. The data actually used is encoded in the 'raw' field.
raw string A resource record encoded in DNS wire format, in turn encoded in Base64. This is the actual data returned to the application, and should carry the same information as the 'rr' field, just in a different encoding.

Question

Encapsulates a lookup question

Field Type Description
key ResourceKey A resource record key that shall be looked up.

ResourceKey

Encapsulates the class/type/name part of a DNS resource record.

Field Type Description
class ?int The RR class, almost always IN, i.e 0x01. If unspecified defaults to IN.
type int The RR types, one of A, AAAA, PTR, …
name string The domain name.

ResourceRecord

Encapsulates a DNS resource record.

Field Type Description
key ResourceKey
priority ?int
weight ?int
port ?int
name ?string
cpu ?string
os ?string
items ?[]string
address ?[]int
mname ?string
rname ?string
serial ?int
refresh ?int
expire ?int
minimum ?int
exchange ?string
version ?int
size ?int
horiz_pre ?int
vert_pre ?int
latitude ?int
longitude ?int
altitude ?int
keyTag ?int
algorithm ?int
digestType ?int
digest ?string
fptype ?int
fingerprint ?string
flags ?int
protocol ?int
dnskey ?string
signer ?string
typeCovered ?int
labels ?int
originalTtl ?int
expiration ?int
inception ?int
signature ?string
nextDomain ?string
types ?[]int
iterations ?int
salt ?string
hash ?string
certUsage ?int
selector ?int
matchingType ?int
data ?string
tag ?string
value ?string
target ?string
svcparams ?object
order ?int
preference ?int
naptrFlags ?string
services ?string
regexp ?string
replacement ?string