CURLOPT_RESOLVE.3 3.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. .\" **************************************************************************
  2. .\" * _ _ ____ _
  3. .\" * Project ___| | | | _ \| |
  4. .\" * / __| | | | |_) | |
  5. .\" * | (__| |_| | _ <| |___
  6. .\" * \___|\___/|_| \_\_____|
  7. .\" *
  8. .\" * Copyright (C) 1998 - 2017, 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.haxx.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 "May 30, 2018" "libcurl 7.61.1" "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 single name resolve string should be written using the format
  38. HOST:PORT:ADDRESS[,ADDRESS]... where HOST is the name libcurl will try
  39. to resolve, PORT is the port number of the service where libcurl wants
  40. to connect to the HOST and ADDRESS is one or more numerical IP
  41. addresses. If you specify multiple ip addresses they need to be
  42. separated by comma. If libcurl is built to support IPv6, each of the
  43. ADDRESS entries can of course be either IPv4 or IPv6 style addressing.
  44. This option effectively pre-populates the DNS cache with entries for the
  45. host+port pair so redirects and everything that operations against the
  46. HOST+PORT will instead use your provided ADDRESS. Addresses set with
  47. \fICURLOPT_RESOLVE(3)\fP will not time-out from the DNS cache like ordinary
  48. entries.
  49. If the DNS cache already have an entry for the given host+port pair, then
  50. this entry will be removed and a new entry will be created. This is because
  51. old entry may have have different addresses or be ordinary entries with
  52. time-outs.
  53. The provided ADDRESS set by this option will be used even if
  54. \fICURLOPT_IPRESOLVE(3)\fP is set to make libcurl use another IP version.
  55. Remove names from the DNS cache again, to stop providing these fake resolves,
  56. by including a string in the linked list that uses the format
  57. \&"-HOST:PORT". The host name must be prefixed with a dash, and the host name
  58. and port number must exactly match what was already added previously.
  59. Support for providing the ADDRESS within [brackets] was added in 7.57.0.
  60. Support for providing multiple IP addresses per entry was added in 7.59.0.
  61. .SH DEFAULT
  62. NULL
  63. .SH PROTOCOLS
  64. All
  65. .SH EXAMPLE
  66. .nf
  67. CURL *curl;
  68. struct curl_slist *host = NULL;
  69. host = curl_slist_append(NULL, "example.com:80:127.0.0.1");
  70. curl = curl_easy_init();
  71. if(curl) {
  72. curl_easy_setopt(curl, CURLOPT_RESOLVE, host);
  73. curl_easy_setopt(curl, CURLOPT_URL, "http://example.com");
  74. curl_easy_perform(curl);
  75. /* always cleanup */
  76. curl_easy_cleanup(curl);
  77. }
  78. curl_slist_free_all(host);
  79. .fi
  80. .SH AVAILABILITY
  81. Added in 7.21.3. Removal support added in 7.42.0.
  82. .SH RETURN VALUE
  83. Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not.
  84. .SH "SEE ALSO"
  85. .BR CURLOPT_IPRESOLVE "(3), " CURLOPT_DNS_CACHE_TIMEOUT "(3), " CURLOPT_CONNECT_TO "(3), "