master
1/***************************************************************************
2 * _ _ ____ _
3 * Project ___| | | | _ \| |
4 * / __| | | | |_) | |
5 * | (__| |_| | _ <| |___
6 * \___|\___/|_| \_\_____|
7 *
8 * Copyright (C) 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 * SPDX-License-Identifier: curl
22 *
23 ***************************************************************************/
24#include "unitcheck.h"
25#include "urldata.h"
26#include "strcase.h"
27#include "curl_addrinfo.h"
29static CURLcode t1607_setup(void)
30{
31 CURLcode result = CURLE_OK;
32 global_init(CURL_GLOBAL_ALL);
33 return result;
34}
36struct t1607_key {
37 uint8_t data[255 + 3];
38 size_t len;
39};
41static void t1607_create_key(struct t1607_key *key,
42 const char *hostname,
43 uint16_t port,
44 uint8_t type)
45{
46 size_t namelen = strlen(hostname);
47 if(namelen > (sizeof(key->data) - 3))
48 namelen = sizeof(key->data) - 3;
49 /* store and lower case the name */
50 key->data[0] = type;
51 key->data[1] = (uint8_t)((port >> 8) & 0xff);
52 key->data[2] = (uint8_t)(port & 0xff);
53 Curl_strntolower((char *)key->data + 3, hostname, namelen);
54 key->len = namelen + 3;
55}
57static CURLcode test_unit1607(const char *arg)
58{
59 /* In builds without IPv6 support CURLOPT_RESOLVE should skip over those
60 addresses, so we have to do that as well. */
61 static const char skip = 0;
62#ifdef USE_IPV6
63#define IPV6ONLY(x) x
64#else
65#define IPV6ONLY(x) &skip
66#endif
68 UNITTEST_BEGIN(t1607_setup())
70 struct testcase {
71 /* host:port:address[,address]... */
72 const char *optval;
74 /* lowercase host and port to retrieve the addresses from hostcache */
75 const char *host;
76 uint16_t port;
78 /* whether we expect a permanent or non-permanent cache entry */
79 bool permanent;
81 /* 0 to 9 addresses expected from hostcache */
82 const char *address[10];
83 };
85 /* CURLOPT_RESOLVE address parsing tests */
86 static const struct testcase tests[] = {
87 /* spaces are not allowed, for now */
88 { "test.com:80:127.0.0.1, 127.0.0.2",
89 "test.com", 80, TRUE, { NULL, }
90 },
91 { "TEST.com:80:,,127.0.0.1,,,127.0.0.2,,,,::1,,,",
92 "test.com", 80, TRUE, { "127.0.0.1", "127.0.0.2", IPV6ONLY("::1"), }
93 },
94 { "test.com:80:::1,127.0.0.1",
95 "test.com", 80, TRUE, { IPV6ONLY("::1"), "127.0.0.1", }
96 },
97 { "test.com:80:[::1],127.0.0.1",
98 "test.com", 80, TRUE, { IPV6ONLY("::1"), "127.0.0.1", }
99 },
100 { "test.com:80:::1",
101 "test.com", 80, TRUE, { IPV6ONLY("::1"), }
102 },
103 { "test.com:80:[::1]",
104 "test.com", 80, TRUE, { IPV6ONLY("::1"), }
105 },
106 { "test.com:80:127.0.0.1",
107 "test.com", 80, TRUE, { "127.0.0.1", }
108 },
109 { "test.com:80:,127.0.0.1",
110 "test.com", 80, TRUE, { "127.0.0.1", }
111 },
112 { "test.com:80:127.0.0.1,",
113 "test.com", 80, TRUE, { "127.0.0.1", }
114 },
115 { "test.com:0:127.0.0.1",
116 "test.com", 0, TRUE, { "127.0.0.1", }
117 },
118 { "+test.com:80:127.0.0.1,",
119 "test.com", 80, FALSE, { "127.0.0.1", }
120 },
121 };
123 size_t i;
124 struct Curl_multi *multi = NULL;
125 struct Curl_easy *easy = NULL;
126 struct curl_slist *list = NULL;
128 for(i = 0; i < CURL_ARRAYSIZE(tests); ++i) {
129 size_t j;
130 size_t addressnum = CURL_ARRAYSIZE(tests[i].address);
131 struct Curl_addrinfo *addr;
132 struct Curl_dns_entry *dns;
133 struct t1607_key entry_id;
134 bool problem = FALSE;
135 easy = curl_easy_init();
136 if(!easy)
137 goto error;
138 curl_easy_setopt(easy, CURLOPT_VERBOSE, 1L);
140 /* create a multi handle and add the easy handle to it so that the
141 hostcache is setup */
142 multi = curl_multi_init();
143 curl_multi_add_handle(multi, easy);
145 list = curl_slist_append(NULL, tests[i].optval);
146 if(!list)
147 goto error;
148 curl_easy_setopt(easy, CURLOPT_RESOLVE, list);
150 Curl_loadhostpairs(easy);
152 t1607_create_key(&entry_id, tests[i].host, tests[i].port, CURL_DNST_ADDR);
153 dns = Curl_hash_pick(&multi->dnscache.entries,
154 entry_id.data, entry_id.len);
156 addr = dns ? dns->addr : NULL;
158 for(j = 0; j < addressnum; ++j) {
159 uint16_t port = 0;
160 char ipaddress[MAX_IPADR_LEN] = { 0 };
162 if(!addr && !tests[i].address[j])
163 break;
165 if(tests[i].address[j] == &skip)
166 continue;
168 if(addr && sockaddr2string(addr->ai_addr, addr->ai_addrlen,
169 ipaddress, &port)) {
170 curl_mfprintf(stderr, "%s:%d tests[%zu] failed. "
171 "getaddressinfo failed.\n",
172 __FILE__, __LINE__, i);
173 problem = TRUE;
174 break;
175 }
177 if(addr && !tests[i].address[j]) {
178 curl_mfprintf(stderr, "%s:%d tests[%zu] failed. the retrieved addr "
179 "is %s but tests[%zu].address[%zu] is NULL.\n",
180 __FILE__, __LINE__, i, ipaddress, i, j);
181 problem = TRUE;
182 break;
183 }
185 if(!addr && tests[i].address[j]) {
186 curl_mfprintf(stderr, "%s:%d tests[%zu] failed. the retrieved addr "
187 "is NULL but tests[%zu].address[%zu] is %s.\n",
188 __FILE__, __LINE__, i, i, j, tests[i].address[j]);
189 problem = TRUE;
190 break;
191 }
193 if(!curl_strequal(ipaddress, tests[i].address[j])) {
194 curl_mfprintf(stderr, "%s:%d tests[%zu] failed. the retrieved addr "
195 "%s is not equal to tests[%zu].address[%zu] %s.\n",
196 __FILE__, __LINE__, i, ipaddress, i, j,
197 tests[i].address[j]);
198 problem = TRUE;
199 break;
200 }
202 if(port != tests[i].port) {
203 curl_mfprintf(stderr, "%s:%d tests[%zu] failed. the retrieved port "
204 "for tests[%zu].address[%zu] is %d "
205 "but tests[%zu].port is %d.\n",
206 __FILE__, __LINE__, i, i, j, port, i, tests[i].port);
207 problem = TRUE;
208 break;
209 }
211 if(!dns->permanent && tests[i].permanent) {
212 curl_mfprintf(stderr,
213 "%s:%d tests[%zu] failed. the permanent bit is not set "
214 "but tests[%zu].permanent is TRUE\n",
215 __FILE__, __LINE__, i, i);
216 problem = TRUE;
217 break;
218 }
220 if(dns->permanent && !tests[i].permanent) {
221 curl_mfprintf(stderr, "%s:%d tests[%zu] failed. the permanent bit "
222 "is set but tests[%zu].permanent is FALSE\n",
223 __FILE__, __LINE__, i, i);
224 problem = TRUE;
225 break;
226 }
228 if(!addr)
229 break;
231 addr = addr->ai_next;
232 }
234 curl_easy_cleanup(easy);
235 easy = NULL;
236 curl_multi_cleanup(multi);
237 multi = NULL;
238 curl_slist_free_all(list);
239 list = NULL;
241 if(problem) {
242 unitfail++;
243 continue;
244 }
245 }
246error:
247 curl_easy_cleanup(easy);
248 curl_multi_cleanup(multi);
249 curl_slist_free_all(list);
251 UNITTEST_END(curl_global_cleanup())
252}
Diagnostics4 git calls · 230 ms
CallStatusSizeTime0230 ms
discover200152 B2 ms
git.upload-pack discover http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=ls-refs git.upstream.dur_ms=2 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 · hit2 ms
git.upload-pack ls-refs http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=ls-refs git.upstream.dur_ms=2 git.response.bytes=149 git.response.cache=HIT git.response.duration_ms=2 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 · hit3 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=3 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 KiB225 ms
git.upload-pack fetch http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=fetch git.upstream.dur_ms=225 git.response.bytes=2451 git.response.cache=MISS git.response.duration_ms=225 git.fetch.wants=1d1fedcb1c7d78210bec85beaf58f2b12c5cbf49 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=2451 git.pkt.payload.max=2430 git.sideband.band1.bytes=2429 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
- a5e1fd3f1a6ca9c0
- Request
- f2a391c4…
- Protocol
- v2 · sha1
- Agent
- gitty/1.0
- Filter
- advertised
- Fetch
- shallow filter sideband-all
- Capabilities
- agent ls-refs fetch object-format