libwget-dns(3)
β¨ libwget-dns β DNS resolver functions β¨
okay so bestie, welcome to the libwget-dns manual (section 3, the library functions one π
). this is the whole DNS resolver situation in libwget and honestly? it's giving organized. let's get into it π¦
πΈ SYNOPSIS πΈ
π Data Structures
struct wget_dns_stats_datastruct wget_dns_st
π Functions
INITIALIZER (dns_init)
int wget_dns_init (wget_dns **dns)
void wget_dns_free (wget_dns **dns)
void wget_dns_set_timeout (wget_dns *dns, int timeout)
void wget_dns_set_cache (wget_dns *dns, wget_dns_cache *cache)
wget_dns_cache * wget_dns_get_cache (wget_dns *dns)
int wget_dns_cache_ip (wget_dns *dns, const char *ip, const char *name,
uint16_t port)
struct addrinfo * wget_dns_resolve (wget_dns *dns, const char *host,
uint16_t port, int family, int preferred_family)
void wget_dns_freeaddrinfo (wget_dns *dns, struct addrinfo **addrinfo)
void wget_dns_set_stats_callback (wget_dns *dns, wget_dns_stats_callback
*fn, void *ctx)
π Detailed Description π
DNS Resolver functions. that's it, that's the vibe. this whole module is the girl who turns hostnames into addresses β¨
π Function Documentation π
int wget_dns_init (wget_dns ** dns)
Parameters
- dns β Pointer to return newly allocated and initialized
wget_dnsinstance
Returns
WGET_E_SUCCESS if OK, WGET_E_MEMORY if out-of-memory or WGET_E_INVALID if the mutex initialization failed.
Allocates and initializes a wget_dns instance. dns may be NULL for the purpose of initializing the global structures.
void wget_dns_free (wget_dns ** dns)
Parameters
- [in/out] dns β Pointer to
wget_dnsinstance that will be freed andNULLified.
Free the resources allocated by wget_dns_init(). dns may be NULL for the purpose of freeing the global structures.
void wget_dns_set_timeout (wget_dns * dns, int timeout)
Parameters
- dns β The
wget_dnsinstance to set the timeout - timeout β The timeout value.
Set the timeout (in milliseconds) for the DNS queries. no cap, it's in milliseconds π«Ά
This is the maximum time to wait until we get a response from the server.
β οΈ Warning: For standard getaddrinfo() a timeout can't be set in a portable way. So this functions currently is a no-op. π like, it literally does nothing right now. iconic of it tbh.
The following two values are special:
0: No timeout, immediate.-1: Infinite timeout. Wait indefinitely.
void wget_dns_set_cache (wget_dns * dns, wget_dns_cache * cache)
Parameters
- dns β A
wget_dnsinstance, created bywget_dns_init(). - cache β A
wget_dns_cacheinstance
Enable or disable DNS caching for the DNS instance provided. π§
The DNS cache is kept internally in memory, and is used in wget_dns_resolve() to speed up DNS queries. it's the main character of speed-ups, fr fr.
wget_dns_cache * wget_dns_get_cache (wget_dns * dns)
Parameters
- dns β A
wget_dnsinstance, created bywget_dns_init().
Returns
1 if DNS caching is enabled, 0 otherwise.
Tells whether DNS caching is enabled or not.
You can enable and disable DNS caching with wget_dns_set_caching().
int wget_dns_cache_ip (wget_dns * dns, const char * ip, const char * name, uint16_t port)
Parameters
- ip β IP address of name
- name β Domain name, part of the cache's lookup key
- port β Port number, part of the cache's lookup key
Returns
0 on success, < 0 on error
Assign an IP address to the name+port key in the DNS cache. The name should be lowercase. π‘ yes lowercase, she said what she said.
struct addrinfo * wget_dns_resolve (wget_dns * dns, const char * host, uint16_t port, int family, int preferred_family)
Parameters
- dns β A
wget_dnsinstance, created bywget_dns_init(). - host β Hostname
- port β TCP destination port
- family β Protocol family
AF_INETorAF_INET6 - preferred_family β Preferred protocol family
AF_INETorAF_INET6
Returns
A struct addrinfo structure (defined in libc's <netdb.h>). Must be freed by the caller with wget_dns_freeaddrinfo(). π don't forget, bestie, that's a memory leak waiting to happen.
Resolve a host name into its IPv4/IPv6 address.
family: Desired address family for the returned addresses. This will typically be AF_INET or AF_INET6, but it can be any of the values defined in <socket.h>. Additionally, AF_UNSPEC means you don't care: it will return any address family that can be used with the specified host and port. If family is different than AF_UNSPEC and the specified family is not found, that's an error condition and thus wget_dns_resolve() will return NULL.
preferred_family: Tries to resolve addresses of this family if possible. This is only honored if family (see point above) is AF_UNSPEC.
The returned addrinfo structure must be freed with wget_dns_freeaddrinfo().
void wget_dns_freeaddrinfo (wget_dns * dns, struct addrinfo ** addrinfo)
Parameters
- dns β A
wget_dnsinstance, created bywget_dns_init(). - [in/out] addrinfo β Value returned by c
Release addrinfo, previously returned by wget_dns_resolve(). If the underlying dns uses caching, just the reference/pointer is set to NULL.
void wget_dns_set_stats_callback (wget_dns * dns, wget_dns_stats_callback * fn, void * ctx)
Parameters
- dns β A
wget_dnsinstance, created bywget_dns_init(). - fn β A
wget_dns_stats_callbackcallback function to receive resolve statistics data - ctx β Context data given to fn
Set callback function to be called once DNS statistics for a host are collected. π stats girlies rise up.
π Author π
Generated automatically by Doxygen for wget2 from the source code.
and that's the whole page, bestie!! π you just read the libwget-dns(3) manual, brought to you by wget2, Version 2.3.0 β¨ slay, you're officially DNS-pilled now. go free those addrinfo structs. periodt. ππ¦
π¦ where this page comes from
- fedora 44: wget2-devel 2.3.0-1.fc44
- fedora 44: wget2-devel 2.3.0-1.fc44
- fedora 44: wget2-devel 2.3.0-3.fc44 Β· GPL-3.0-or-later AND LGPL-3.0-or-later AND GFDL-1.3-or-later
- fedora 44: wget2-devel 2.3.0-3.fc44 Β· GPL-3.0-or-later AND LGPL-3.0-or-later AND GFDL-1.3-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms