master
1#ifndef HEADER_CURL_HOSTIP_H
2#define HEADER_CURL_HOSTIP_H
3/***************************************************************************
4 * _ _ ____ _
5 * Project ___| | | | _ \| |
6 * / __| | | | |_) | |
7 * | (__| |_| | _ <| |___
8 * \___|\___/|_| \_\_____|
9 *
10 * Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
11 *
12 * This software is licensed as described in the file COPYING, which
13 * you should have received as part of this distribution. The terms
14 * are also available at https://curl.se/docs/copyright.html.
15 *
16 * You may opt to use, copy, modify, merge, publish, distribute and/or sell
17 * copies of the Software, and permit persons to whom the Software is
18 * furnished to do so, under the terms of the COPYING file.
19 *
20 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
21 * KIND, either express or implied.
22 *
23 * SPDX-License-Identifier: curl
24 *
25 ***************************************************************************/
26#include "curl_setup.h"
28#include "hash.h"
29#include "curlx/timeval.h" /* for curltime, timediff_t */
31/* Allocate enough memory to hold the full name information structs and
32 * everything. OSF1 is known to require at least 8872 bytes. The buffer
33 * required for storing all possible aliases and IP numbers is according to
34 * Stevens' Unix Network Programming 2nd edition, p. 304: 8192 bytes!
35 */
36#define CURL_HOSTENT_SIZE 9000
38#define CURL_TIMEOUT_RESOLVE_MS (300 * 1000)
40struct addrinfo;
41struct hostent;
42struct Curl_easy;
43struct connectdata;
44struct easy_pollset;
45struct Curl_https_rrinfo;
46struct Curl_multi;
47struct Curl_dns_entry;
48struct Curl_peer;
50/* DNS query types */
51#define CURL_DNSQ_A (1U << 0)
52#define CURL_DNSQ_AAAA (1U << 1)
53#define CURL_DNSQ_HTTPS (1U << 2)
55#define CURL_DNSQ_ADDR (uint8_t)(CURL_DNSQ_A | CURL_DNSQ_AAAA)
56#define CURL_DNSQ_IS_ADDR(x) (uint8_t)((x)&(CURL_DNSQ_ADDR))
58#ifdef CURLVERBOSE
59const char *Curl_resolv_query_str(uint8_t dns_queries);
60#endif
62/* Return CURL_DNSQ_* bits for the transfer and ip_version. */
63uint8_t Curl_resolv_dns_queries(struct Curl_easy *data, uint8_t ip_version);
65enum alpnid {
66 ALPN_none = 0,
67 ALPN_h1 = CURLALTSVC_H1,
68 ALPN_h2 = CURLALTSVC_H2,
69 ALPN_h3 = CURLALTSVC_H3
70};
72bool Curl_host_is_ipnum(const char *hostname);
74#ifdef USE_IPV6
75/* probe if it seems to work */
76CURLcode Curl_probeipv6(struct Curl_multi *multi);
77#else
78#define Curl_probeipv6(x) CURLE_OK
79#endif
81/* IPv4 thread-safe resolve function used for synch and asynch builds */
82struct Curl_addrinfo *Curl_ipv4_resolve_r(const char *hostname, uint16_t port);
84/*
85 * Curl_printable_address() returns a printable version of the 1st address
86 * given in the 'ai' argument. The result will be stored in the buf that is
87 * bufsize bytes big.
88 */
89void Curl_printable_address(const struct Curl_addrinfo *ai,
90 char *buf, size_t bufsize);
92/* Start DNS resolving for the given parameters. Returns
93 * - CURLE_OK: `*pdns` is the resolved DNS entry (needs to be unlinked).
94 * `*presolv_id` is 0.
95 * - CURLE_AGAIN: resolve is asynchronous and not finished yet.
96 * `presolv_id` is the identifier for querying results later.
97 * - other: the operation failed, `*pdns` is NULL, `*presolv_id` is 0.
98 */
99CURLcode Curl_resolv(struct Curl_easy *data,
100 struct Curl_peer *peer,
101 uint8_t dns_queries,
102 uint8_t transport,
103 bool for_proxy,
104 timediff_t timeout_ms,
105 uint32_t *presolv_id,
106 struct Curl_dns_entry **pdns);
108CURLcode Curl_resolv_blocking(struct Curl_easy *data,
109 uint8_t dns_queries,
110 const char *hostname,
111 uint16_t port,
112 uint8_t transport,
113 struct Curl_dns_entry **pdns);
115/* Announce start of a resolve operation to application callback,
116 * passing the resolver implementation (maybe NULL). */
117CURLcode Curl_resolv_announce_start(struct Curl_easy *data,
118 void *resolver);
120#ifdef USE_CURL_ASYNC
122CURLcode Curl_resolv_pollset(struct Curl_easy *data,
123 struct easy_pollset *ps);
125/* Get the `async` struct for the given `resolv_id`, if it exists. */
126struct Curl_resolv_async *Curl_async_get(struct Curl_easy *data,
127 uint32_t resolv_id);
129/* Shut down all resolves of the given easy handle. */
130void Curl_resolv_shutdown_all(struct Curl_easy *data);
132/* Destroy all resolve resources of the given easy handle. */
133void Curl_resolv_destroy_all(struct Curl_easy *data);
135CURLcode Curl_resolv_take_result(struct Curl_easy *data, uint32_t resolv_id,
136 struct Curl_dns_entry **pdns);
138void Curl_resolv_destroy(struct Curl_easy *data, uint32_t resolv_id);
140/* How much time has gone by since start of resolve.
141 * Returns CURL_TIMEOUT_RESOLVE_MS if `resolv_id` is no longer valid. */
142timediff_t Curl_resolv_elapsed_ms(struct Curl_easy *data,
143 uint32_t resolv_id,
144 const struct curltime *pnow);
146/* Return TRUE if `resolv_id` has answers (positive or negative) to
147 * all queries in `dns_queries`.
148 * Queries not requested are considered answered. */
149bool Curl_resolv_has_answers(struct Curl_easy *data,
150 uint32_t resolv_id, uint8_t dns_queries);
152const struct Curl_addrinfo *Curl_resolv_get_ai(struct Curl_easy *data,
153 uint32_t resolv_id,
154 int ai_family,
155 unsigned int index);
156#ifdef USE_HTTPSRR
158/* Start DNS resolving for HTTPS records. Returns
159 * - CURLE_OK: `*pdns` is the resolved DNS entry (needs to be unlinked).
160 * `*presolv_id` is 0.
161 * - CURLE_AGAIN: resolve is asynchronous and not finished yet.
162 * `presolv_id` is the identifier for querying results later.
163 * - other: the operation failed, `*pdns` is NULL, `*presolv_id` is 0.
164 */
165CURLcode Curl_resolv_https(struct Curl_easy *data,
166 struct Curl_peer *peer,
167 bool for_proxy,
168 timediff_t timeout_ms,
169 uint32_t *presolv_id,
170 struct Curl_dns_entry **pdns);
173const struct Curl_https_rrinfo *Curl_resolv_get_https(struct Curl_easy *data,
174 uint32_t resolv_id);
175bool Curl_resolv_knows_https(struct Curl_easy *data, uint32_t resolv_id);
176#endif /* USE_HTTPSRR */
178#else /* !USE_CURL_ASYNC */
179#define Curl_resolv_shutdown_all(x) Curl_nop_stmt
180#define Curl_resolv_destroy_all(x) Curl_nop_stmt
181#define Curl_resolv_take_result(x, y, z) CURLE_NOT_BUILT_IN
182#define Curl_resolv_elapsed_ms(x, y, z) CURL_TIMEOUT_RESOLVE_MS
183#define Curl_resolv_has_answers(x, y, z) TRUE
184#define Curl_resolv_get_ai(x, y, z, a) NULL
185#define Curl_resolv_get_https(x, y) NULL
186#define Curl_resolv_knows_https(x, y) TRUE
187#define Curl_resolv_pollset(x, y) CURLE_OK
188#define Curl_resolv_destroy(x, y) Curl_nop_stmt
189#endif /* USE_CURL_ASYNC */
191#ifdef CURLRES_SYNCH
192/*
193 * Curl_sync_getaddrinfo() is the non-async low-level name resolve API.
194 * There are several versions of this function - depending on IPV6
195 * support and platform.
196 */
197struct Curl_addrinfo *Curl_sync_getaddrinfo(struct Curl_easy *data,
198 uint8_t dns_queries,
199 const char *hostname,
200 uint16_t port,
201 uint8_t transport);
202#endif
204#endif /* HEADER_CURL_HOSTIP_H */
Diagnostics4 git calls · 571 ms
CallStatusSizeTime0571 ms
discover200152 B3 ms
git.upload-pack discover http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=ls-refs git.upstream.dur_ms=3 git.response.bytes=152 git.server.agent=gitty/1.0 git.server.object_format=sha1 git.server.caps=agent ls-refs fetch object-format git.server.fetch=shallow filter sideband-all git.protocol.version=2 git.pkt.frames=8 git.pkt.data=6 git.pkt.flush=2 git.pkt.delim=0 git.pkt.bytes=152 git.pkt.payload.max=34
ls-refs200149 B · hit3 ms
git.upload-pack ls-refs http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=ls-refs git.upstream.dur_ms=3 git.response.bytes=149 git.response.cache=HIT git.response.duration_ms=3 git.protocol.version=2 git.pkt.frames=3 git.pkt.data=2 git.pkt.flush=1 git.pkt.delim=0 git.pkt.bytes=149 git.pkt.payload.max=78 git.ls_refs.count=2 git.ls_refs.head=refs/heads/master
fetchblob:none · deepen 10200287 KiB · hit4 ms
git.upload-pack fetch http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=fetch git.upstream.dur_ms=3 git.response.bytes=293470 git.response.cache=HIT git.response.duration_ms=4 git.fetch.filter=blob:none git.fetch.filter.requested=tree:0 git.fetch.filter.fallback=blob:none git.fetch.filter.learned=false git.fetch.wants=31c911efe5652725e930f4d2e60c9060e5f6646d git.fetch.haves.count=0 git.fetch.deepen=10 git.fetch.thin_pack=false git.fetch.ofs_delta=true git.protocol.version=2 git.pkt.frames=10 git.pkt.data=8 git.pkt.flush=1 git.pkt.delim=1 git.pkt.bytes=293470 git.pkt.payload.max=65516 git.sideband.band1.bytes=293354 git.sideband.band2.bytes=0 git.sideband.band3.bytes=0 git.pack.objects=87 git.pack.bytes=293354 git.pack.ofs_delta=0 git.pack.ref_delta=1 git.pack.chain.max=1 git.pack.trailer=6a646bcda6740bab42e321b51998b52ea15146c0 git.pack.full=86Open pack map
fetch2002.4 KiB564 ms
git.upload-pack fetch http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=fetch git.upstream.dur_ms=564 git.response.bytes=2486 git.response.cache=MISS git.response.duration_ms=564 git.fetch.wants=43172101f2a0b863a106d18123d73438d8344ba8 git.fetch.haves.count=0 git.fetch.deepen=0 git.fetch.thin_pack=false git.fetch.ofs_delta=true git.protocol.version=2 git.pkt.frames=3 git.pkt.data=2 git.pkt.flush=1 git.pkt.delim=0 git.pkt.bytes=2486 git.pkt.payload.max=2465 git.sideband.band1.bytes=2464 git.sideband.band2.bytes=0 git.sideband.band3.bytes=0
Each row is one HTTP round trip ply made to the git server for this page, on one timeline. discover asks what the server speaks, ls-refs lists branch tips, fetch brings objects by id. A hit was served by Workers Cache. Tap a row for its wire details.
- Remote
- https://5ad2236b39de4c8bd8f6270ea63f3ea9.artifacts.cloudflare.net/git/public-v0/curl.git
- Ref
- refs/heads/master
- Commit
- 31c911efe5652725e930f4d2e60c9060e5f6646d
- cf-ray
- a5e9ef74ed300acb
- Request
- cc4d565d…
- Protocol
- v2 · sha1
- Agent
- gitty/1.0
- Filter
- advertised
- Fetch
- shallow filter sideband-all
- Capabilities
- agent ls-refs fetch object-format