Artifactspublic-v0

curl

master
ply4 git calls138 ms289 KiB2 cachedprotocol v2
179 lines5.5 KiBRaw
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 ***************************************************************************/
25/*
26 * Verify that the resolver-start callback (CURLOPT_RESOLVER_START_FUNCTION)
27 * is announced, and can veto the resolve, before the HTTPS RR side-query is
28 * sent out on the wire. This binds a UDP socket of its own, points the
29 * c-ares HTTPS RR channel at it via the CURL_DNS_SERVER debug hook, and
30 * makes the callback abort the moment it sees the HTTPS RR resolver state.
31 * If the query had already been dispatched, this local "DNS server" would
32 * have received it regardless of the callback's veto.
33 */
35#include "first.h"
37#ifdef HAVE_NETINET_IN_H
38#include <netinet/in.h>
39#endif
40#ifdef HAVE_ARPA_INET_H
41#include <arpa/inet.h>
42#endif
44static int t464_cb_count = 0;
45static int t464_https_seen = 0;
47static int t464_resolver_start_cb(void *resolver_state, void *reserved,
48 void *userdata)
50 (void)reserved;
51 (void)userdata;
52 t464_cb_count++;
53 if(resolver_state) {
54 /* This is the HTTPS RR side-channel announce: veto it. */
55 t464_https_seen = 1;
56 return 1;
57 }
58 /* This is the regular A/AAAA announce: let it proceed. */
59 return 0;
62#ifndef INADDR_LOOPBACK
63#define INADDR_LOOPBACK 0x7f000001
64#endif
66static CURLcode test_lib464(const char *URL)
68 CURL *curl = NULL;
69 CURLcode result = CURLE_OK;
70 curl_socket_t dnssock = CURL_SOCKET_BAD;
71 struct sockaddr_in sa;
72 curl_socklen_t salen = sizeof(sa);
73 char envbuf[64];
74 char inbuf[512];
75 fd_set fds;
76 struct timeval tv;
77 int port;
78 int gotpacket = 0;
79 bool global_inited = FALSE;
81 dnssock = CURL_SOCKET(AF_INET, SOCK_DGRAM, 0);
82 if(dnssock == CURL_SOCKET_BAD) {
83 curl_mfprintf(stderr, "socket creation error\n");
84 return TEST_ERR_MAJOR_BAD;
85 }
87 memset(&sa, 0, sizeof(sa));
88 sa.sin_family = AF_INET;
89 sa.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
90 sa.sin_port = 0;
92 if(bind(dnssock, (struct sockaddr *)&sa, sizeof(sa))) {
93 curl_mfprintf(stderr, "bind() failed\n");
94 result = TEST_ERR_MAJOR_BAD;
95 goto test_cleanup;
96 }
97 if(getsockname(dnssock, (struct sockaddr *)&sa, &salen)) {
98 curl_mfprintf(stderr, "getsockname() failed\n");
99 result = TEST_ERR_MAJOR_BAD;
100 goto test_cleanup;
101 }
102 port = ntohs(sa.sin_port);
103 curl_msnprintf(envbuf, sizeof(envbuf), "127.0.0.1:%d", port);
104#ifdef _WIN32
105 _putenv_s("CURL_DNS_SERVER", envbuf);
106#else
107 setenv("CURL_DNS_SERVER", envbuf, 1);
108#endif
110 if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
111 curl_mfprintf(stderr, "curl_global_init() failed\n");
112 result = TEST_ERR_MAJOR_BAD;
113 goto test_cleanup;
114 }
115 global_inited = TRUE;
116 curl = curl_easy_init();
117 if(!curl) {
118 curl_mfprintf(stderr, "curl_easy_init() failed\n");
119 result = TEST_ERR_MAJOR_BAD;
120 goto test_cleanup;
121 }
123 easy_setopt(curl, CURLOPT_URL, URL);
124 easy_setopt(curl, CURLOPT_VERBOSE, 1L);
125 easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L);
126 easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0L);
127 easy_setopt(curl, CURLOPT_RESOLVER_START_FUNCTION, t464_resolver_start_cb);
129 /* Vetoing the HTTPS RR side-query only drops that optional lookup, it
130 * does not fail the transfer: the plain A/AAAA resolve still succeeds
131 * and curl goes on to (fail to) connect, since nothing listens on the
132 * target port. */
133 result = curl_easy_perform(curl);
134 if(result != CURLE_COULDNT_CONNECT) {
135 curl_mfprintf(stderr, "curl_easy_perform should have returned "
136 "CURLE_COULDNT_CONNECT but instead returned error %d\n",
137 (int)result);
138 if(result == CURLE_OK)
139 result = TEST_ERR_FAILURE;
140 goto test_cleanup;
141 }
142 result = CURLE_OK;
144 if(!t464_https_seen) {
145 curl_mfprintf(stderr, "the HTTPS RR resolver-start announce never "
146 "happened, this test needs asyn-rr support\n");
147 result = TEST_ERR_FAILURE;
148 goto test_cleanup;
149 }
150 if(t464_cb_count != 2) {
151 curl_mfprintf(stderr, "Unexpected number of callbacks: %d\n",
152 t464_cb_count);
153 result = TEST_ERR_FAILURE;
154 goto test_cleanup;
155 }
157 FD_ZERO(&fds);
158 FD_SET(dnssock, &fds);
159 tv.tv_sec = 0;
160 tv.tv_usec = 200000;
161 if(select((int)dnssock + 1, &fds, NULL, NULL, &tv) > 0)
162 gotpacket = (recvfrom(dnssock, inbuf, sizeof(inbuf), 0, NULL, NULL) > 0);
164 if(gotpacket) {
165 curl_mfprintf(stderr, "the HTTPS RR query was sent on the wire before "
166 "the resolver-start callback could veto it\n");
167 result = TEST_ERR_FAILURE;
168 goto test_cleanup;
169 }
171test_cleanup:
172 curl_easy_cleanup(curl);
173 if(global_inited)
174 curl_global_cleanup();
175 if(dnssock != CURL_SOCKET_BAD)
176 sclose(dnssock);
178 return result;
Diagnostics4 git calls · 138 ms
CallStatusSizeTime0138 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=86
Open pack map
fetch2002.2 KiB133 ms
git.upload-pack fetch
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=fetch
git.upstream.dur_ms=133
git.response.bytes=2226
git.response.cache=MISS
git.response.duration_ms=133
git.fetch.wants=0bb5d3910c1c7f7dfb8a4f81668d62f08038e16a
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=2226
git.pkt.payload.max=2205
git.sideband.band1.bytes=2204
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
a5e316b87840cf5b
Request
3ae66386…
Protocol
v2 · sha1
Agent
gitty/1.0
Filter
advertised
Fetch
shallow filter sideband-all
Capabilities
agent ls-refs fetch object-format