getdns_context_set(3)
π getdns_context_set β bestie edition π
okay so this is the getdns manual page for getdns_context_set(3) β yes, the section-3 one, that's the library functions page, iykyk β¨
πΈ NAME πΈ
Bestie, this page is a whole girl group, not a solo act. Meet the lineup:
getdns_context_set_append_namegetdns_context_set_context_update_callbackgetdns_context_set_dns_root_serversgetdns_context_set_dns_transportgetdns_context_set_dnssec_trust_anchorsgetdns_context_set_dnssec_allowed_skewgetdns_context_set_follow_redirectsgetdns_context_set_limit_outstanding_queriesgetdns_context_set_namespacesgetdns_context_set_resolution_typegetdns_context_set_suffixgetdns_context_set_timeout
β¦and collectively they are the getdns context manipulation routines π periodt.
π LIBRARY π
DNS Resolver library β that's libgetdns, and you link it with -lgetdns π«Ά
β¨ SYNOPSIS β¨
First things first, include the header or nothing works, bestie:
#include <getdns.h>
Then here's the whole squad, exactly as they're declared:
getdns_return_t
getdns_context_set_append_name (getdns_context_t context,
getdns_append_name_t when_to_append)
getdns_return_t
getdns_context_set_context_update_callback (getdns_context_t context,
(*callback)(struct getdns_context *context, uint16_t changed_item))
getdns_return_t
getdns_context_set_dns_root_servers (getdns_context_t context,
getdns_list *root_addresses)
getdns_return_t
getdns_context_set_dns_transport (getdns_context_t context,
uint16_t transport)
getdns_return_t
getdns_contet_set_dnssec_allowed_skew (getdns_context *context,
uint32_t skew_seconds)
getdns_return_t
getdns_contet_set_dnssec_trust_anchors (getdns_context *context,
getdns_list *trust_anchors)
getdns_return_t
getdns_context_set_follow_redirects (getdns_context_t context,
getdns_redirects_t followredir)
getdns_return_t
getdns_context_set_limit_outstanding_queries (getdns_context_t context,
uint16_t limit)
getdns_return_t
getdns_context_set_namespaces (getdns_context_t context,
size_t namespace_count,
uint16_t *namespaces)
getdns_return_t
getdns_context_set_resolution_type (getdns_context_t context,
uint16_t restype)
getdns_return_t
getdns_context_set_suffix (getdns_context *context,
getdns_list *suffixes)
getdns_return_t
getdns_context_set_timeout (getdns_context_t context,
uint16_t timeout)
ngl, notice that two of these are spelledgetdns_contet_...in the synopsis (getdns_contet_set_dnssec_allowed_skewandgetdns_contet_set_dnssec_trust_anchors) while the NAME section saysgetdns_context_set_dnssec_allowed_skewandgetdns_context_set_dnssec_trust_anchors. I am not touching that. Copy-paste responsibly π
π¦ DESCRIPTION π¦
So these functions are how you mess with an already-allocated-and-initialized context. Like, the context has to exist first. Go read getdns_context (3) for the tea on how to allocate, initialize and destroy contexts, and for the full deep-dive on what a getdns_context even is. π§
Here's the rundown on each one, no cap:
getdns_context_set_append_name β tells the API whether to slap a suffix onto the query string before it starts resolving a name. The suffix comes from getdns_context_set_suffix (3). π
getdns_context_set_context_update_callback β sets a function that gets called when there are changes to the system files (for example /etc/resolv.conf and /etc/hosts). π
getdns_context_set_dns_transport β picks the transport used for DNS lookups. The default? UDP, and it falls back to TCP as needed. main character energy π₯
getdns_context_set_dnssec_trust_anchors β lets you, the caller, specify trust anchors as alternatives to the default trust anchors. π
getdns_context_set_dnssec_allowed_skew β sets how many seconds of skew are allowed in either direction when checking an RRSIG's expiration and inception fields. Default is 0. β
getdns_context_set_limit_outstanding_queries β the maximum number of outstanding DNS queries. Over that limit? The API queues your queries until current ones get answered, then it automatically fires off the queued ones. slay π¦
getdns_context_set_dns_root_servers β hands over an alternate set of addresses to use for looking up the top level domains. Don't call it and you get the default: the list of IANA root servers (think of this as the root hints). π
getdns_context_set_follow_redirects β whether DNS queries follow redirects (CNAME and DNAME). Default behavior is to follow redirects and return the eventual target. π
getdns_context_set_namespaces β sets the namespaces the resolver uses. Default is DNS and then local files. Future implementations will support netbios, mdns, and nis. π
getdns_context_set_resolution_type β specifies whether DNS queries get performed with non-recursive lookups or as a stub resolver. β¨
getdns_context_set_suffix β appends suffixes to domain names prior to executing the lookup, based on getdns_context_set_append_name. π
getdns_context_set_timeout β the number of milliseconds the API will wait for a response. π (yes, milliseconds, not seconds, don't do that to yourself)
π the parameters, one by one π
contextβ a previously allocated and initializedgetdns_context. Like I said. Allocate first. π«Άcallbackβ a callback function that will be called when changes are made to the system files (/etc/resolv.confand/etc/hosts) for contexts created withset_from_os=1. When this function is called, thechanged_itemparameter indicates which item in the context has changed. πΈroot_addressesβ a list ofgetdns_dicttypes, each identifying a single root server to use to look up top level domains. Every dictionary includes two names:address_type, a bindata containing the string"IPv4"or"IPv6", andaddress_data, a bindata containing the IP address. πtransportβ may be one of:GETDNS_CONTEXT_UDP_FIRST_AND_FALL_BACK_TO_TCPGETDNS_CONTEXT_UDP_ONLYGETDNS_CONTEXT_TCP_ONLYGETDNS_CONTEXT_TCP_ONLY_KEEP_CONNECTIONS_OPEN
If you need more information on what each of these means, reread the mnemonic and take a guess ;) β that's a direct quote from the source, and honestly? iconic.
followredirβ set it toGETDNS_REDIRECTS_FOLLOW(the default) and the eventual target of the redirect is returned. Set it toGETDNS_REDIRECTS_DO_NOT_FOLLOWand you get the CNAME or DNAME returned, and NOT the eventual target. π¦limitβ the maximum number of concurrent outstanding (unanswered) DNS queries. If exceeded, the API queues queries and issues them as the number of outstanding queries drops. A value of0indicates that there is no limit. β¨namespacesβ the namespaces array holds an ordered list of namespaces that will be queried.
Important: this context setting is ignored for thegetdns_generalandgetdns_general_syncfunctions; it is used for the other functions.
The values are GETDNS_CONTEXT_NAMESPACE_DNS, GETDNS_CONTEXT_NAMESPACE_LOCALNAMES, GETDNS_CONTEXT_NAMESPACE_NETBIOS, GETDNS_CONTEXT_NAMESPACE_MDNS, and GETDNS_CONTEXT_NAMESPACE_NIS.
When a normal lookup is done, the API does the lookups in the order given and stops when it gets the first result; a different method with the same result would be to run the queries in parallel and return when it gets the first result. Because lookups might be done over different mechanisms because of the different namespaces, there can be information leakage that is similar to that seen with getaddrinfo(). The default is determined by the OS. π
restypeβ can be set to eitherGETDNS_CONTEXT_RECURSIVE(the default) orGETDNS_CONTEXT_STUB(requires that forwarders be specified by the caller). πseconds_skewβ the number of seconds skew allowed in either direction when checking an RRSIGs expiration and inception fields. βsuffixesβ a list of bindatas that are strings that are to be appended based ongetdns_context_set_append_name. The values here follow the rules in section 2.1 of RFC 4343 to allow non-ASCII octets and special characters in labels. π§timeoutβ the number of milliseconds the API will wait for a response, after which the callback will be invoked (or the synchronous function will return) with a timeout error. β°trust_anchorsβ list of bindatas that are the DNSSEC trust anchors expressed as RDATA from the DNSKEY resource records. The default are supplied by the IANA root. πwhen_to_appendβ the value is:GETDNS_APPEND_NAME_ALWAYS,GETDNS_APPEND_NAME_ONLY_TO_SINGLE_LABEL_AFTER_FAILURE,GETDNS_APPEND_NAME_ONLY_TO_MULTIPLE_LABEL_NAME_AFTER_FAILURE, orGETDNS_APPEND_NAME_NEVER.
π₯ RETURN VALUES π₯
Upon successful completion the functions return GETDNS_RETURN_GOOD. Otherwise, the following error values are returned:
GETDNS_RETURN_BAD_CONTEXTβ if the context pointer is invalid. πGETDNS_RETURN_CONTEXT_UPDATE_FAILβ if there was a problem updating the context. π
π EXAMPLES π
TBD
(the source really does just say TBD, bestie. we wait. π )
π FILES π
/etc/hosts/etc/resolv.conf
π SEE ALSO π
libgetdns(3), getdns_address(3), getdns_address_sync(3), getdns_context(3), getdns_general(3), getdns_general_sync(3), getdns_hostname(3), getdns_hostname_sync(3), getdns_service(3), getdns_service_sync(3).
and that's the whole page, bestie π«Ά go forth and set your context. this was getdns 1.7.3, dated December 2015 β yes, december 2015, she's vintage, she's still serving, and she's still in your man pages. πβ¨
π¦ where this page comes from
- alpine 3.24: getdns-doc 1.7.3-r0 Β· BSD-3-Clause
- arch rolling: getdns 1.7.3-2 Β· BSD
- epel 10: getdns-devel 1.7.3-9.el10_2 Β· BSD-3-Clause
- epel 9: getdns-devel 1.7.3-1.el9 Β· BSD-3-Clause
- fedora 43: getdns-devel 1.7.3-9.fc43 Β· BSD-3-Clause
- fedora 43: getdns-devel 1.7.3-9.fc43 Β· BSD-3-Clause
- fedora 44: getdns-devel 1.7.3-10.fc44 Β· BSD-3-Clause
- fedora 44: getdns-devel 1.7.3-10.fc44 Β· BSD-3-Clause
- nixpkgs unstable: getdns 1.7.3
- ubuntu resolute: libgetdns-dev 1.7.3-3 Β· BSD-3-Clause
- ubuntu stonking: libgetdns-dev 1.7.3-5build1 Β· BSD-3-Clause
- Copyright (c) 2013, NLNet Labs, Verisign, Inc
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms