CURLOPT_RESOLVE.3 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. .\" **************************************************************************
  2. .\" * _ _ ____ _
  3. .\" * Project ___| | | | _ \| |
  4. .\" * / __| | | | |_) | |
  5. .\" * | (__| |_| | _ <| |___
  6. .\" * \___|\___/|_| \_\_____|
  7. .\" *
  8. .\" * Copyright (C) 1998 - 2021, Daniel Stenberg, <daniel@haxx.se>, et al.
  9. .\" *
  10. .\" * This software is licensed as described in the file COPYING, which
  11. .\" * you should have received as part of this distribution. The terms
  12. .\" * are also available at https://curl.se/docs/copyright.html.
  13. .\" *
  14. .\" * You may opt to use, copy, modify, merge, publish, distribute and/or sell
  15. .\" * copies of the Software, and permit persons to whom the Software is
  16. .\" * furnished to do so, under the terms of the COPYING file.
  17. .\" *
  18. .\" * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
  19. .\" * KIND, either express or implied.
  20. .\" *
  21. .\" **************************************************************************
  22. .\"
  23. .TH CURLOPT_RESOLVE 3 "19 Jun 2014" "libcurl 7.37.0" "curl_easy_setopt options"
  24. .SH NAME
  25. CURLOPT_RESOLVE \- provide custom host name to IP address resolves
  26. .SH SYNOPSIS
  27. .nf
  28. #include <curl/curl.h>
  29. CURLcode curl_easy_setopt(CURL *handle, CURLOPT_RESOLVE,
  30. struct curl_slist *hosts);
  31. .SH DESCRIPTION
  32. Pass a pointer to a linked list of strings with host name resolve information
  33. to use for requests with this handle. The linked list should be a fully valid
  34. list of \fBstruct curl_slist\fP structs properly filled in. Use
  35. \fIcurl_slist_append(3)\fP to create the list and \fIcurl_slist_free_all(3)\fP
  36. to clean up an entire list.
  37. Each resolve rule to add should be written using the format
  38. .nf
  39. [+]HOST:PORT:ADDRESS[,ADDRESS]
  40. .fi
  41. \&... where HOST is the name libcurl will try to resolve, PORT is the port
  42. number of the service where libcurl wants to connect to the HOST and ADDRESS
  43. is one or more numerical IP addresses. If you specify multiple ip addresses
  44. they need to be separated by comma. If libcurl is built to support IPv6, each
  45. of the ADDRESS entries can of course be either IPv4 or IPv6 style addressing.
  46. This option effectively pre-populates the DNS cache with entries for the
  47. host+port pair so redirects and everything that operations against the
  48. HOST+PORT will instead use your provided ADDRESS.
  49. The optional leading "+" specifies that the new entry should time-out. Entries
  50. added without the leading plus character will never time-out whereas entries
  51. added with "+HOST:..." will time-out just like ordinary DNS cache entries.
  52. If the DNS cache already has an entry for the given host+port pair, the new
  53. entry will override the former one.
  54. An ADDRESS provided by this option will only be used if not restricted by the
  55. setting of \fICURLOPT_IPRESOLVE(3)\fP to a different IP version.
  56. To remove names from the DNS cache again, to stop providing these fake
  57. resolves, include a string in the linked list that uses the format
  58. .nf
  59. -HOST:PORT
  60. .fi
  61. The entry to remove must be prefixed with a dash, and the host name and port
  62. number must exactly match what was added previously.
  63. .SH DEFAULT
  64. NULL
  65. .SH PROTOCOLS
  66. All
  67. .SH EXAMPLE
  68. .nf
  69. CURL *curl;
  70. struct curl_slist *host = NULL;
  71. host = curl_slist_append(NULL, "example.com:443:127.0.0.1");
  72. curl = curl_easy_init();
  73. if(curl) {
  74. curl_easy_setopt(curl, CURLOPT_RESOLVE, host);
  75. curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
  76. curl_easy_perform(curl);
  77. /* always cleanup */
  78. curl_easy_cleanup(curl);
  79. }
  80. curl_slist_free_all(host);
  81. .fi
  82. .SH AVAILABILITY
  83. Added in 7.21.3. Removal support added in 7.42.0.
  84. Support for providing the ADDRESS within [brackets] was added in 7.57.0.
  85. Support for providing multiple IP addresses per entry was added in 7.59.0.
  86. Support for adding non-permanent entries by using the "+" prefix was added in
  87. 7.75.0.
  88. .SH RETURN VALUE
  89. Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not.
  90. .SH "SEE ALSO"
  91. .BR CURLOPT_IPRESOLVE "(3), " CURLOPT_DNS_CACHE_TIMEOUT "(3), "
  92. .BR CURLOPT_CONNECT_TO "(3), "