GNURLOPT_DOH_URL(3)

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

πŸ’– GNURLOPT_DOH_URL(3) β€” the DNS-over-HTTPS URL one πŸ’–

okay so bestie, this page is GNURLOPT_DOH_URL(3) from the curl_easy_setopt options manual family, and it's literally all about giving your DNS queries a ✨glow-up✨ by routing them through a DNS-over-HTTPS server. ngl, it's giving secure, it's giving private, it's giving main character energy for your resolver.


🌸 NAME 🌸

CURLOPT_DOH_URL β€” provide the DNS-over-HTTPS URL πŸ¦‹


✨ SYNOPSIS ✨

#include <gnurl/curl.h>

CURLcode curl_easy_setopt(CURL *handle, CURLOPT_DOH_URL, char *URL);

πŸ’… DESCRIPTION πŸ’…

so you pass in a pointer to a URL for the DOH server to use for name resolving, and that's the whole vibe. the parameter should be a char * to a null-terminated string, and it must be URL-encoded in literally this exact format: "https://host:port/path". like, it MUST specify a HTTPS URL β€” no exceptions, no shortcuts, periodt. πŸ”₯

here's the tea though: libcurl doesn't validate the syntax or even use this variable until the transfer is issued. so even if you set a crazy value here (and bestie, you could set the most unhinged string imaginable), curl_easy_setopt(3) will still return CURLE_OK. it's not being shady, it's just not checking yet. 😭

curl sends POST requests to the given DNS-over-HTTPS URL.

now, to find the DOH server itself β€” which might be specified using a name β€” libcurl will use the default name lookup function. you can bootstrap that by providing the address for the DOH server with CURLOPT_RESOLVE(3). iykyk, that's the little chicken-and-egg moment and this is how you solve it. 🐣

disable DOH use again by setting this option to NULL. bye bye, DOH era. πŸ‘‹


πŸŽ€ DEFAULT πŸŽ€

NULL β€” there is no default DOH URL. if this option isn't set, libcurl will use the default name resolver. no DOH, no drama, just the classic. πŸ’œ


🌈 PROTOCOLS 🌈

All 🫢


πŸ“ EXAMPLE πŸ“

CURL *curl = curl_easy_init();
if(curl) {
  curl_easy_setopt(curl, CURLOPT_URL, "http://example.com");
  curl_easy_setopt(curl, CURLOPT_DOH_URL, "https://dns.example.com");
  curl_easy_perform(curl);
}

look at that. iconic. CURLOPT_URL for the actual destination, CURLOPT_DOH_URL for the fancy DNS-over-HTTPS server, and then curl_easy_perform(curl) to make it all happen. chef's kiss. πŸ‘‘


⭐ AVAILABILITY ⭐

Added in 7.62.0 β€” she's not ancient, she's not brand new, she's just right. πŸ’«


πŸ’€ RETURN VALUE πŸ’€

Returns CURLE_OK on success, or CURLE_OUT_OF_MEMORY if there was insufficient heap space. like, your memory said "i simply cannot" and honestly? relatable. πŸ™ˆ

⚠️ also note (and this is lowkey important): curl_easy_setopt(3) won't actually parse the given string, so if you hand it a bad DOH URL, curl will not detect a problem until it tries to resolve a name with it. so the error shows up fashionably late. 😭

πŸ”₯ SEE ALSO πŸ”₯


and that's the whole page bestie, go forth and resolve responsibly πŸ’–βœ¨

sign-off tea: this beauty is from libcurl 7.62.0, dated 18 Jun 2018, and the page itself is GNURLOPT_DOH_URL(3). slay. πŸŽ€πŸ¦‹

πŸ“¦ where this page comes from