CURLOPT_RESOLVE.3 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. .\" generated by cd2nroff 0.1 from CURLOPT_RESOLVE.md
  2. .TH CURLOPT_RESOLVE 3 "2025-01-17" libcurl
  3. .SH NAME
  4. CURLOPT_RESOLVE \- provide custom hostname to IP address resolves
  5. .SH SYNOPSIS
  6. .nf
  7. #include <curl/curl.h>
  8. CURLcode curl_easy_setopt(CURL *handle, CURLOPT_RESOLVE,
  9. struct curl_slist *hosts);
  10. .fi
  11. .SH DESCRIPTION
  12. Pass a pointer to a linked list of strings with hostname resolve information
  13. to use for requests with this handle. The linked list should be a fully valid
  14. list of \fBstruct curl_slist\fP structs properly filled in. Use
  15. \fIcurl_slist_append(3)\fP to create the list and \fIcurl_slist_free_all(3)\fP to clean up
  16. an entire list.
  17. Each resolve rule to add should be written using the format
  18. .nf
  19. [+]HOST:PORT:ADDRESS[,ADDRESS]
  20. .fi
  21. HOST is the name libcurl wants to resolve, PORT is the port number of the
  22. service where libcurl wants to connect to the HOST and ADDRESS is one or more
  23. numerical IP addresses. If you specify multiple IP addresses they need to be
  24. separated by comma. If libcurl is built to support IPv6, each of the ADDRESS
  25. entries can of course be either IPv4 or IPv6 style addressing.
  26. Specify the host as a single ampersand (\fI*\fP) to match all names. This wildcard
  27. is resolved last so any resolve with a specific host and port number is given
  28. priority.
  29. This option effectively populates the DNS cache with entries for the host+port
  30. pair so redirects and everything that operations against the HOST+PORT instead
  31. use your provided ADDRESS.
  32. The optional leading plus (\fI+\fP) specifies that the new entry should timeout.
  33. Entries added without the leading plus character never times out whereas
  34. entries added with \fI+HOST:...\fP times out just like ordinary DNS cache entries.
  35. If the DNS cache already has an entry for the given host+port pair, the new
  36. entry overrides the former one.
  37. An ADDRESS provided by this option is only used if not restricted by the
  38. setting of \fICURLOPT_IPRESOLVE(3)\fP to a different IP version.
  39. To remove names from the DNS cache again, to stop providing these fake
  40. resolves, include a string in the linked list that uses the format
  41. .nf
  42. -HOST:PORT
  43. .fi
  44. The entry to remove must be prefixed with a dash, and the hostname and port
  45. number must exactly match what was added previously.
  46. .SH DEFAULT
  47. NULL
  48. .SH PROTOCOLS
  49. This functionality affects all supported protocols
  50. .SH EXAMPLE
  51. .nf
  52. int main(void)
  53. {
  54. CURL *curl;
  55. struct curl_slist *host = NULL;
  56. host = curl_slist_append(NULL, "example.com:443:127.0.0.1");
  57. curl = curl_easy_init();
  58. if(curl) {
  59. curl_easy_setopt(curl, CURLOPT_RESOLVE, host);
  60. curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
  61. curl_easy_perform(curl);
  62. /* always cleanup */
  63. curl_easy_cleanup(curl);
  64. }
  65. curl_slist_free_all(host);
  66. }
  67. .fi
  68. .SH HISTORY
  69. Added in 7.21.3. Removal support added in 7.42.0.
  70. Support for providing the ADDRESS within [brackets] was added in 7.57.0.
  71. Support for providing multiple IP addresses per entry was added in 7.59.0.
  72. Support for adding non\-permanent entries by using the "+" prefix was added in
  73. 7.75.0.
  74. .SH AVAILABILITY
  75. Added in curl 7.21.3
  76. .SH RETURN VALUE
  77. Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not.
  78. .SH SEE ALSO
  79. .BR CURLOPT_CONNECT_TO (3),
  80. .BR CURLOPT_DNS_CACHE_TIMEOUT (3),
  81. .BR CURLOPT_IPRESOLVE (3)