getdns_address(3)

πŸ“¦
version 1.7.3 Β· 2 versions
, in alpine 3.24, arch rolling, epel 10, epel 9, fedora 43, fedora 44, nixpkgs unstable, ubuntu resolute, ubuntu stonking

πŸ’– getdns_address β€” bestie, let's get you some IPs πŸ’–

okay so this is getdns_address(3), from the getdns manual, and it's literally the glow-up you need when you've got a hostname and you're begging the universe for an address. two functions, one job. let's go ✨


🌸 NAME 🌸

getdns_address, getdns_address_sync β€” get ip address(es) for a name

no cap, that's the whole vibe: you give it a name, it gives you addresses. πŸ’…


πŸŽ€ LIBRARY πŸŽ€

DNS Resolver library (libgetdns, -lgetdns)

link against it, queen. that's the -lgetdns right there. 🫢


✨ SYNOPSIS ✨

#include <getdns.h>

getdns_return_t
getdns_address (getdns_context *context,
   const char *name,
   getdns_dict *extensions,
   void *userarg,
   getdns_transaction_t *transaction_id,
   getdns_callback_t callbackfn)

getdns_return_t
getdns_address_sync (getdns_context *context,
   const char *name,
   getdns_dict *extensions,
   getdns_dict **response)

two flavors, bestie: the async one that takes a callbackfn, and the sync one that just hands you a response. pick your fighter. πŸ”₯


πŸ¦‹ DESCRIPTION πŸ¦‹

so getdns_address(3) and getdns_address_sync are the public entry points into the getdns API library, and what they do is retrieve the address given a host name. and the way that they always return both IPv4 AND IPv6 addresses? iconic. it's giving "why choose". 🌈

this function will use all of the namespaces from the context β€” and the whole reason is to better emulate getaddrinfo (3). periodt.

here's the tea on every single parameter, no skipping, i don't gatekeep:

  • context β€” a pointer to the previously created DNS context that's gonna be used with this DNS request. see getdns_context (3). πŸ’œ
  • name β€” the host name to resolve to an address. and heads up, bestie: note that an IP address is considered invalid here. it's a name field. respect the field. 😭
  • extensions β€” extensions for this request, NULL if there's no extensions. see libgetdns (3) for a detailed description of extensions.
  • userarg β€” returned to the callback function untouched. can be NULL. it's just vibes passing through. ✨
  • transaction_id β€” populated by the API and used to identify the callback (for example, to getdns_cancel_callback). can be NULL, and it's set to 0 if the function fails. πŸ’€
  • callbackfn β€” a non-NULL pointer to a callback function defined by the application, typically used to process the response. only the asynchronous signature accepts a callback function; the synchronous signature does not include a callback. see libgetdns (3) for a more detailed discussion of callback functions.
  • response β€” a getdns_dict type is returned in response, and it always contains at least three names: replies_full (a list containing the DNS response as binary data), replies_tree (a list containing the parsed DNS response data) and status (an int). the storage associated with this must be freed by a call to getdns_free_sync_request_memory (3).
🚨 bestie, do NOT forget that free. that memory is not gonna free itself and it's not your little meow meow. call getdns_free_sync_request_memory (3). i'm serious. 😭

πŸ’… RETURN VALUES πŸ’…

upon successful completion the functions return GETDNS_RETURN_GOOD, otherwise the following error values are returned. buckle up, there's a whole roster:

  • GETDNS_RETURN_BAD_CONTEXT β€” if the context pointer is invalid or the context has internal deficiencies. it's giving "not that girl". πŸ™ˆ
  • GETDNS_RETURN_BAD_DOMAIN_NAME β€” if the domain name passed to the function is invalid.
  • GETDNS_RETURN_EXTENSION_MISFORMAT β€” if the data type specified in one or more of the extensions does not match the specifications.
  • GETDNS_RETURN_GENERIC_ERROR β€” if some problem was encountered in the function not addressed by one of the more specific return codes. the catch-all, the main character of error codes. πŸ’€
  • GETDNS_RETURN_INVALID PARAMETER β€” if one or more parameters has an invalid value.
  • GETDNS_RETURN_MEMORY_ERROR β€” if unable to allocate the memory required.
  • GETDNS_RETURN_NO_SUCH_EXTENSION β€” if one or more of the strings specified in the extensions are not valid.

and the values of status included in the response parameter are:

  • GETDNS_RESPSTATUS_GOOD β€” if at least one response was returned. slay. ✨
  • GETDNS_RESPSTATUS_NO_NAME β€” if queries for the name yielded all negative responses.
  • GETDNS_RESPSTATUS_ALL_TIMEOUT β€” if all queries for the name timed out. πŸ’€
  • GETDNS_RESPSTATUS_NO_SECURE_ANSWERS β€” if only secure replies accepted (per context) and at least one response was received but no DNS responses were secure through DNSSEC.

for a more detailed explanation of the response object see libgetdns (3). πŸ‘‘


🌟 EXAMPLES 🌟

TBD

yeah bestie. TBD. the examples are coming, they're just running late, that's so on brand. πŸ˜­πŸŽ€


πŸ“ FILES πŸ“

  • /etc/hosts
  • /etc/resolv.conf

the classic duo. the OG besties. 🫢


πŸ’œ SEE ALSO πŸ’œ

libgetdns(3), getdns_context(3), getdns_free_sync_request_memory(3), getdns_general(3), getdns_general_sync(3), getdns_hostname(3), getdns_hostname_sync(3), getdns_service(3), getdns_service_sync(3)

go read the whole family, iykyk. πŸ“šβœ¨


and that's the page, bestie! this was getdns 1.7.3, dated December 2015 β€” yes she's vintage and she still ate. go resolve something cute. mwah. πŸ’–πŸŽ€πŸ¦‹πŸŒΈ