GNURLOPT_D..._ADDRESSES(3)

πŸ“¦ version 7.72.0, in nixos 26.05, nixpkgs unstable

πŸ’… GNURLOPT_D..._ADDRESSES(3) β€” CURLOPT_DNS_SHUFFLE_ADDRESSES πŸ’…

okay so bestie, this is a page from the curl_easy_setopt options corner of the gnurl manual, and it's genuinely one of the slayest little flags ever. like, it's short, it's chaotic, it's giving "shuffle button on your Spotify" but for IP addresses. iykyk. πŸŽ€


✨ NAME ✨

CURLOPT_DNS_SHUFFLE_ADDRESSES β€” Shuffle addresses when a hostname returns more than one 🌈


πŸ¦‹ SYNOPSIS πŸ¦‹

#include <gnurl/curl.h>

CURLcode curl_easy_setopt(CURL *handle, CURLOPT_DNS_SHUFFLE_ADDRESSES, long onoff);

πŸ’– DESCRIPTION πŸ’–

So here's the tea β˜•: when a name gets resolved and more than one IP address comes back, this option shuffles the order of all the returned addresses so they get used in a random order. literally just ✨randomized✨. This is similar to the ordering behavior of gethostbyname which is no longer used on most platforms (rip bozo πŸ’€).

Important vibe check: addresses will not be reshuffled if a name resolution is completed using the DNS cache. no cap. CURLOPT_DNS_CACHE_TIMEOUT(3) can be used together with this option to reduce the DNS cache timeout or disable caching entirely if frequent reshuffling is needed. (so if you want constant chaos, turn the cache down or off, bestie 🫢)

And since the addresses returned will be reordered randomly, their order will not be in accordance with RFC 3484 or any other deterministic order that may be generated by the system's name resolution implementation. 😭 This may have performance impacts and may cause IPv4 to be used before IPv6 or vice versa. so like, it's iconic but it's also a little unhinged, and the performance is lowkey affected. not me warning you twice πŸ’€


πŸŽ€ DEFAULT πŸŽ€

0 (disabled) β€” the shuffle is off until you say otherwise, queen πŸ‘‘


🌸 PROTOCOLS 🌸

All πŸ’―


πŸ”₯ EXAMPLE πŸ”₯

CURL *curl = curl_easy_init();
if(curl) {
  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
  curl_easy_setopt(curl, CURLOPT_DNS_SHUFFLE_ADDRESSES, 1L);

  curl_easy_perform(curl);

  /* always cleanup */
  curl_easy_cleanup(curl);
}

look at her go 🧚 she's shuffling! she's performing! she's cleaning up after herself because she's a responsible main character ✨


πŸ¦„ AVAILABILITY πŸ¦„

Added in 7.60.0 β€” so she's been serving looks since 2018, periodt πŸ’…


⭐ RETURN VALUE ⭐

CURLE_OK or an error such as CURLE_UNKNOWN_OPTION. πŸ’–

(so like, either it slays or it tells you the option was unknown. either way, no mystery.)


πŸ‘‘ SEE ALSO πŸ‘‘


okay that's the whole page, bestie!! now go forth and shuffle responsibly 🌸✨

libcurl 7.60.0 Β· 3 March 2018 πŸŽ€ mwah, love u, bye πŸ’œ

πŸ“¦ where this page comes from