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/*
25 * IDN conversions
26 */
27#include "curl_setup.h"
29#ifdef HAVE_NETINET_IN_H
30#include <netinet/in.h>
31#endif
32#ifdef HAVE_NETDB_H
33#include <netdb.h>
34#endif
35#ifdef HAVE_ARPA_INET_H
36#include <arpa/inet.h>
37#endif
38#ifdef HAVE_NET_IF_H
39#include <net/if.h>
40#endif
41#ifdef HAVE_IPHLPAPI_H
42#include <Iphlpapi.h>
43#endif
44#ifdef HAVE_SYS_IOCTL_H
45#include <sys/ioctl.h>
46#endif
47#ifdef HAVE_SYS_PARAM_H
48#include <sys/param.h>
49#endif
51#ifdef __VMS
52#include <in.h>
53#include <inet.h>
54#endif
56#ifdef HAVE_SYS_UN_H
57#include <sys/un.h>
58#endif
60#if defined(HAVE_IF_NAMETOINDEX) && defined(USE_WINSOCK)
61#if defined(__MINGW32__) && (__MINGW64_VERSION_MAJOR <= 5)
62#include <wincrypt.h> /* workaround for old mingw-w64 missing to include it */
63#endif
64#include <iphlpapi.h>
65#endif
67#include "curl_addrinfo.h"
68#include "curl_trc.h"
69#include "protocol.h"
70#include "http_proxy.h"
71#include "idn.h"
72#include "curlx/strdup.h"
73#include "curlx/strparse.h"
74#include "peer.h"
75#include "urldata.h"
76#include "url.h"
77#include "urlapi-int.h"
78#include "vtls/vtls.h"
80struct peer_parse {
81 const struct Curl_scheme *scheme;
82 struct Curl_str host_user;
83 struct Curl_str host;
84 struct Curl_str zoneid;
85 char *tmp_host_user;
86 char *tmp_host;
87 char *tmp_zoneid;
88 uint32_t scopeid;
89 uint16_t port;
90 bool ipv6;
91 bool unix_socket;
92 bool abstract_uds;
93};
95static void peer_parse_clear(struct peer_parse *pp)
96{
97 curlx_free(pp->tmp_host_user);
98 curlx_free(pp->tmp_host);
99 curlx_free(pp->tmp_zoneid);
100 memset(pp, 0, sizeof(*pp));
101}
103static CURLcode peer_create(struct peer_parse *pp,
104 struct Curl_peer **ppeer)
105{
106 struct Curl_peer *peer = NULL;
107 CURLcode result = CURLE_OK;
108 size_t zone_alen = 0, host_alen = 0;
110 if(!pp || !pp->scheme)
111 return CURLE_FAILED_INIT;
112 if(!pp->host.len && !(pp->scheme->flags & PROTOPT_NONETWORK))
113 return CURLE_FAILED_INIT;
115 if((pp->host.str != pp->host_user.str) ||
116 (pp->host.len != pp->host_user.len)) {
117 host_alen = pp->host.len + 1;
118 }
119 zone_alen = pp->zoneid.len ? (pp->zoneid.len + 1) : 0;
121 /* null-terminator already part of struct */
122 peer = curlx_calloc(1, sizeof(*peer) +
123 pp->host_user.len + host_alen + zone_alen);
124 if(!peer) {
125 result = CURLE_OUT_OF_MEMORY;
126 goto out;
127 }
129 peer->refcount = 1;
130 peer->scheme = pp->scheme;
131 peer->hostname = peer->user_hostname;
132 peer->port = pp->port;
133 peer->scopeid = pp->scopeid;
134 peer->ipv6 = pp->ipv6;
135 peer->unix_socket = pp->unix_socket;
136 peer->abstract_uds = pp->abstract_uds;
138 if(pp->host_user.len)
139 memcpy(peer->user_hostname, pp->host_user.str, pp->host_user.len);
141 if(host_alen) {
142 peer->hostname = peer->user_hostname + pp->host_user.len + 1;
143 memcpy(peer->hostname, pp->host.str, pp->host.len);
144 }
146 if(zone_alen) {
147 peer->zoneid = peer->user_hostname + pp->host_user.len + 1 + host_alen;
148 memcpy(peer->zoneid, pp->zoneid.str, pp->zoneid.len);
149#ifdef USE_IPV6
150 /* Determine scope_id if not already provided */
151 if(!peer->scopeid) {
152 const char *p = peer->zoneid;
153 curl_off_t scope;
154 if(!curlx_str_number(&p, &scope, UINT_MAX) && !*p) {
155 /* A plain number, use it directly as a scope id. */
156 peer->scopeid = (uint32_t)scope;
157 }
158#ifdef HAVE_IF_NAMETOINDEX
159 else {
160 /* Zone identifier is not fully numeric */
161 unsigned int idx = 0;
162 idx = if_nametoindex(peer->zoneid);
163 if(idx) {
164 peer->scopeid = (uint32_t)idx;
165 }
166 else {
167 /* Do we want to return an error here? */
168 }
169 }
170#endif /* HAVE_IF_NAMETOINDEX */
171 }
172#endif /* USE_IPV6 */
173 }
175out:
176 if(!result)
177 *ppeer = peer;
178 else
179 Curl_peer_unlink(&peer);
180 return result;
181}
183static CURLcode peer_parse_host(struct Curl_easy *data,
184 struct peer_parse *pp,
185 bool scan_for_ipv6)
186{
187 if(!pp || !pp->host_user.str || !pp->host_user.len)
188 return CURLE_FAILED_INIT;
190 if(pp->host_user.str[0] == '[') {
191 const char *s = pp->host_user.str + 1;
192 struct Curl_str tmp;
193 if(curlx_str_until(&s, &tmp, pp->host_user.len - 1, ']'))
194 return CURLE_URL_MALFORMAT;
196 if(!Curl_looks_like_ipv6(tmp.str, tmp.len, TRUE,
197 &pp->host, &pp->zoneid)) {
198 failf(data, "Invalid IPv6 address format in '%.*s'",
199 (int)pp->host_user.len, pp->host_user.str);
200 return CURLE_URL_MALFORMAT;
201 }
202 pp->ipv6 = TRUE;
203 }
204 else {
205#ifdef USE_IDN
206 if(!Curl_is_ASCII_str(&pp->host_user)) {
207 CURLcode result;
208 if(!pp->tmp_host_user) {
209 /* need a null-terminated string for IDN */
210 pp->tmp_host_user = curlx_memdup0(pp->host_user.str,
211 pp->host_user.len);
212 if(!pp->tmp_host_user)
213 return CURLE_OUT_OF_MEMORY;
214 }
215 result = Curl_idn_decode(pp->tmp_host_user, &pp->tmp_host);
216 if(!result &&
217 Curl_hostname_check(pp->tmp_host, strlen(pp->tmp_host))) {
218 failf(data, "Illegal hostname: %s", pp->tmp_host);
219 result = CURLE_URL_MALFORMAT;
220 }
221 if(result)
222 return result;
223 pp->host.str = pp->tmp_host;
224 pp->host.len = strlen(pp->host.str);
225 }
226 else
227#endif
228 if(scan_for_ipv6 &&
229 Curl_looks_like_ipv6(pp->host_user.str, pp->host_user.len, TRUE,
230 &pp->host, &pp->zoneid)) {
231 if(pp->host_user.len < MAX_IPADR_LEN) {
232 char tmp[MAX_IPADR_LEN];
233 memcpy(tmp, pp->host_user.str, pp->host_user.len);
234 tmp[pp->host_user.len] = 0;
235 pp->ipv6 = !Curl_is_ipv4addr(tmp);
236 }
237 else
238 pp->ipv6 = TRUE;
239 }
240 else
241 pp->host = pp->host_user;
242 }
243 return CURLE_OK;
244}
246CURLcode Curl_peer_create(struct Curl_easy *data,
247 const struct Curl_scheme *scheme,
248 const char *hostname,
249 uint16_t port,
250 struct Curl_peer **ppeer)
251{
252 struct peer_parse pp;
253 CURLcode result;
255 Curl_peer_unlink(ppeer);
256 memset(&pp, 0, sizeof(pp));
257 pp.scheme = scheme;
258 pp.host_user.str = hostname;
259 pp.host_user.len = strlen(hostname);
260 pp.port = port;
262 result = peer_parse_host(data, &pp, TRUE);
263 if(!result)
264 result = peer_create(&pp, ppeer);
266 peer_parse_clear(&pp);
267 return result;
268}
270#ifdef USE_UNIX_SOCKETS
271CURLcode Curl_peer_uds_create(const struct Curl_scheme *scheme,
272 const char *path,
273 bool abstract_unix_socket,
274 struct Curl_peer **ppeer)
275{
276 struct peer_parse pp;
277 size_t pathlen = path ? strlen(path) : 0;
278 CURLcode result = CURLE_OK;
280 Curl_peer_unlink(ppeer);
281 memset(&pp, 0, sizeof(pp));
282 if(!scheme)
283 return CURLE_FAILED_INIT;
284 if(!pathlen)
285 return CURLE_FAILED_INIT;
287 pp.scheme = scheme;
288 pp.host_user.str = pp.host.str = path;
289 pp.host_user.len = pp.host.len = pathlen;
290 pp.unix_socket = TRUE;
291 pp.abstract_uds = abstract_unix_socket;
293 result = peer_create(&pp, ppeer);
294 peer_parse_clear(&pp);
295 return result;
296}
297#endif /* USE_UNIX_SOCKETS */
299void Curl_peer_link(struct Curl_peer **pdest, struct Curl_peer *src)
300{
301 if(*pdest != src) {
302 Curl_peer_unlink(pdest);
303 *pdest = src;
304 if(src) {
305 DEBUGASSERT(src->refcount < UINT32_MAX);
306 src->refcount++;
307 }
308 }
309}
311void Curl_peer_unlink(struct Curl_peer **ppeer)
312{
313 if(*ppeer) {
314 struct Curl_peer *peer = *ppeer;
316 DEBUGASSERT(peer->refcount);
317 *ppeer = NULL;
318 if(peer->refcount)
319 peer->refcount--;
320 if(!peer->refcount) {
321 curlx_free(peer);
322 }
323 }
324}
326bool Curl_peer_equal(struct Curl_peer *p1, struct Curl_peer *p2)
327{
328 return (p1 == p2) ||
329 (p1 && p2 &&
330 (p1->scheme == p2->scheme) &&
331 Curl_peer_same_destination(p1, p2));
332}
334static bool peer_same_hostname(struct Curl_peer *p1, struct Curl_peer *p2)
335{
336 /* UNIX domain socket paths must be compared case-sensitive,
337 * as many filesystem are like that. */
338 return (p1->unix_socket == p2->unix_socket) &&
339 (p1->abstract_uds == p2->abstract_uds) &&
340 (p1->ipv6 == p2->ipv6) &&
341 /* unix_socket paths are case-sensitive, hostnames are not.
342 * Do strcmp() first on both, since we do a lot of matches
343 * on the same names and platform strcmp is way faster. */
344 (!strcmp(p1->hostname, p2->hostname) ||
345 (!p1->unix_socket &&
346 curl_strequal(p1->hostname, p2->hostname)));
347}
349static bool peer_same_zoneid(const char *z1, const char *z2)
350{
351 return (z1 == z2) ||
352 (z1 && z2 && !strcmp(z1, z2));
353}
355bool Curl_peer_same_destination(struct Curl_peer *p1, struct Curl_peer *p2)
356{
357 return (p1 == p2) ||
358 (p1 && p2 &&
359 (p1->port == p2->port) &&
360 peer_same_hostname(p1, p2) &&
361 (p1->scopeid == p2->scopeid) &&
362 (p1->scopeid || peer_same_zoneid(p1->zoneid, p2->zoneid)));
363}
365CURLcode Curl_peer_from_url(CURLU *uh, struct Curl_easy *data,
366 uint16_t port_override,
367 uint32_t scopeid_override,
368 struct Curl_peer **ppeer)
369{
370 struct peer_parse pp;
371 char *zoneid = NULL, *scheme = NULL, *hostname = NULL;
372 CURLUcode uc;
373 CURLcode result;
375 Curl_peer_unlink(ppeer);
376 memset(&pp, 0, sizeof(pp));
378 uc = curl_url_get(uh, CURLUPART_SCHEME, &scheme, 0);
379 if(uc)
380 return Curl_uc_to_curlcode(uc);
381 pp.scheme = Curl_get_scheme(scheme);
382 if(!pp.scheme) {
383 failf(data, "Protocol \"%s\" not supported%s", scheme,
384 data->state.this_is_a_follow ? " (in redirect)" : "");
385 result = CURLE_UNSUPPORTED_PROTOCOL;
386 goto out;
387 }
389 uc = curl_url_get(uh, CURLUPART_HOST, &hostname, 0);
390 if(uc) {
391 if((uc == CURLUE_NO_HOST) && (pp.scheme->flags & PROTOPT_NONETWORK))
392 ; /* acceptable */
393 else {
394 result = CURLE_OUT_OF_MEMORY;
395 goto out;
396 }
397 }
398 else if(strlen(hostname) > MAX_URL_LEN) {
399 failf(data, "Too long hostname (maximum is %d)", MAX_URL_LEN);
400 result = CURLE_URL_MALFORMAT;
401 goto out;
402 }
404 pp.host_user.str = hostname ? hostname : "";
405 pp.host_user.len = strlen(pp.host_user.str);
406 if(pp.host_user.len) {
407 result = peer_parse_host(data, &pp, FALSE);
408 if(result)
409 goto out;
410 }
411 else
412 pp.host = pp.host_user;
414 if(port_override) {
415 /* if set, we use this instead of the port possibly given in the URL */
416 char portbuf[16];
417 curl_msnprintf(portbuf, sizeof(portbuf), "%d", port_override);
418 uc = curl_url_set(uh, CURLUPART_PORT, portbuf, 0);
419 if(uc) {
420 result = CURLE_OUT_OF_MEMORY;
421 goto out;
422 }
423 else
424 pp.port = port_override;
425 }
426 else {
427 uc = Curl_url_get_port(uh, &pp.port);
428 if(uc) {
429 if(uc == CURLUE_OUT_OF_MEMORY) {
430 result = CURLE_OUT_OF_MEMORY;
431 goto out;
432 }
433 else if(!(pp.scheme->flags & PROTOPT_NONETWORK)) {
434 result = CURLE_URL_MALFORMAT;
435 goto out;
436 }
437 /* no port ok when not a network scheme */
438 }
439 }
441 if(scopeid_override)
442 /* Override any scope id from an URL zone. */
443 pp.scopeid = scopeid_override;
444 else {
445 if(curl_url_get(uh, CURLUPART_ZONEID, &zoneid, 0) ==
446 CURLUE_OUT_OF_MEMORY) {
447 result = CURLE_OUT_OF_MEMORY;
448 goto out;
449 }
450 if(zoneid) {
451 pp.zoneid.str = zoneid;
452 pp.zoneid.len = strlen(zoneid);
453 }
454 }
456 result = peer_create(&pp, ppeer);
457 if(result)
458 failf(data, "Error %d creating peer for %s:%u",
459 (int)result, pp.host_user.str, pp.port);
461out:
462 peer_parse_clear(&pp);
463 curlx_free(scheme);
464 curlx_free(hostname);
465 curlx_free(zoneid);
466 return result;
467}
469/* Parse a "host:port" string to connect to into a peer.
470 * IPv6 addresses might appear in brackets or without them. */
471CURLcode Curl_peer_from_connect_to(struct Curl_easy *data,
472 const struct Curl_peer *dest,
473 const char *connect_to,
474 struct Curl_peer **ppeer)
475{
476 struct peer_parse pp;
477 const char *portstr = NULL;
478 bool port_switch = FALSE;
479 CURLcode result;
481 Curl_peer_unlink(ppeer);
482 memset(&pp, 0, sizeof(pp));
483 if(!connect_to || !*connect_to)
484 return CURLE_FAILED_INIT;
486 pp.scheme = dest->scheme;
488 /* detect and extract RFC6874-style IPv6-addresses */
489 if(connect_to[0] == '[') {
490 const char *s = strchr(connect_to + 1, ']');
491 if(!s) {
492 failf(data, "Invalid IPv6 address format in '%s'", connect_to);
493 result = CURLE_SETOPT_OPTION_SYNTAX;
494 goto out;
495 }
496 portstr = strchr(s, ':');
497 pp.host_user.str = connect_to;
498 pp.host_user.len = s - pp.host_user.str + 1;
499 pp.ipv6 = TRUE;
500 }
501 else {
502 portstr = strchr(connect_to, ':');
503 pp.host_user.str = connect_to;
504 pp.host_user.len = portstr ?
505 (size_t)(portstr - connect_to) : strlen(connect_to);
506 }
508 if(!pp.host_user.len) { /* no hostname found, only port switch */
509 port_switch = TRUE;
510 pp.host_user.str = dest->user_hostname;
511 pp.host_user.len = strlen(dest->user_hostname);
512 }
514 result = peer_parse_host(data, &pp, FALSE);
515 if(result)
516 goto out;
517 /* On a port switch, ipv6 must stay the same */
518 DEBUGASSERT(!port_switch || ((bool)pp.ipv6 == (bool)dest->ipv6));
520 if(portstr && portstr[1]) {
521 const char *p = portstr + 1;
522 curl_off_t portparse;
523 if(curlx_str_number(&p, &portparse, 0xffff)) {
524 failf(data, "No valid port number in '%s'", connect_to);
525 result = CURLE_SETOPT_OPTION_SYNTAX;
526 goto out;
527 }
528 pp.port = (uint16_t)portparse; /* we know it will fit */
529 }
530 else
531 pp.port = dest->port;
533#ifndef USE_IPV6
534 if(pp.ipv6) {
535 failf(data, "Use of IPv6 in *_CONNECT_TO without IPv6 support built-in");
536 result = CURLE_NOT_BUILT_IN;
537 goto out;
538 }
539#endif
540 if(pp.ipv6 && port_switch) {
541 if(dest->zoneid) {
542 pp.zoneid.str = dest->zoneid;
543 pp.zoneid.len = strlen(dest->zoneid);
544 }
545 pp.scopeid = dest->scopeid;
546 }
548 result = peer_create(&pp, ppeer);
549 CURL_TRC_M(data, "connect-to peer_create2 -> %d", (int)result);
551out:
552 CURL_TRC_M(data, "parse connect_to peer: %s -> %d", connect_to, (int)result);
553 peer_parse_clear(&pp);
554 return result;
555}
557#ifndef CURL_DISABLE_PROXY
559#ifdef USE_UNIX_SOCKETS
560#define UNIX_SOCKET_PREFIX "localhost"
561#endif
563CURLcode Curl_scheme_to_proxytype(struct Curl_easy *data,
564 const char *scheme,
565 uint8_t *proxytype, const char *url)
566{
567 if(!scheme)
568 return CURLE_OK;
570 if(curl_strequal("https", scheme)) {
571 if(*proxytype != CURLPROXY_HTTPS2 && *proxytype != CURLPROXY_HTTPS3)
572 *proxytype = CURLPROXY_HTTPS;
573 }
574 else if(curl_strequal("socks5h", scheme))
575 *proxytype = CURLPROXY_SOCKS5_HOSTNAME;
576 else if(curl_strequal("socks5", scheme))
577 *proxytype = CURLPROXY_SOCKS5;
578 else if(curl_strequal("socks4a", scheme))
579 *proxytype = CURLPROXY_SOCKS4A;
580 else if(curl_strequal("socks4", scheme) || curl_strequal("socks", scheme))
581 *proxytype = CURLPROXY_SOCKS4;
582 else if(curl_strequal("http", scheme)) {
583 if(*proxytype != CURLPROXY_HTTP_1_0)
584 *proxytype = CURLPROXY_HTTP;
585 }
586 else {
587 /* Any other xxx:// reject! */
588 failf(data, "Unsupported proxy scheme for \'%s\'", url);
589 return CURLE_COULDNT_CONNECT;
590 }
591 return CURLE_OK;
592}
594CURLcode Curl_peer_from_proxy_url(CURLU *uh,
595 struct Curl_easy *data,
596 const char *url,
597 uint8_t proxytype,
598 struct Curl_peer **ppeer,
599 uint8_t *pproxytype)
600{
601 struct peer_parse pp;
602 char *scheme = NULL;
603 char *portptr = NULL;
604#ifdef USE_UNIX_SOCKETS
605 bool is_socks = FALSE;
606#endif
607 CURLUcode uc;
608 CURLcode result = CURLE_OK;
610 Curl_peer_unlink(ppeer);
611 memset(&pp, 0, sizeof(pp));
612 pp.port = CURL_DEFAULT_PROXY_PORT;
613 uc = curl_url_get(uh, CURLUPART_SCHEME, &scheme,
614 CURLU_NON_SUPPORT_SCHEME | CURLU_NO_GUESS_SCHEME);
615 if(uc) {
616 if(uc == CURLUE_OUT_OF_MEMORY) {
617 result = CURLE_OUT_OF_MEMORY;
618 goto out;
619 }
620 /* URL came without scheme, the passed `proxytype` determines it */
621 switch(proxytype) {
622 case CURLPROXY_HTTP:
623 case CURLPROXY_HTTP_1_0:
624 pp.scheme = &Curl_scheme_http;
625 break;
626 case CURLPROXY_HTTPS:
627 case CURLPROXY_HTTPS2:
628 case CURLPROXY_HTTPS3:
629 pp.scheme = &Curl_scheme_https;
630 break;
631 case CURLPROXY_SOCKS4:
632 pp.scheme = &Curl_scheme_socks4;
633 break;
634 case CURLPROXY_SOCKS4A:
635 pp.scheme = &Curl_scheme_socks4a;
636 break;
637 case CURLPROXY_SOCKS5:
638 pp.scheme = &Curl_scheme_socks5;
639 break;
640 case CURLPROXY_SOCKS5_HOSTNAME:
641 pp.scheme = &Curl_scheme_socks5h;
642 break;
643 default:
644 failf(data, "Unsupported proxy type %u for \'%s\'", proxytype, url);
645 result = CURLE_COULDNT_RESOLVE_PROXY;
646 goto out;
647 }
648 }
649 else {
650 pp.scheme = Curl_get_scheme(scheme);
651 result = Curl_scheme_to_proxytype(data, scheme, &proxytype, url);
652 if(result)
653 goto out;
654 }
655 DEBUGASSERT(pp.scheme);
657 if(CURL_PROXY_IS_HTTPS(proxytype) &&
658 !Curl_ssl_supports(data, SSLSUPP_HTTPS_PROXY)) {
659 failf(data, "Unsupported proxy \'%s\', libcurl is built without the "
660 "HTTPS-proxy support.", url);
661 result = CURLE_NOT_BUILT_IN;
662 goto out;
663 }
665 switch(pp.scheme->family) {
666 case CURLPROTO_SOCKS:
667#ifdef USE_UNIX_SOCKETS
668 is_socks = TRUE;
669#endif
670 break;
671 case CURLPROTO_HTTP:
672 break;
673 default:
674 failf(data, "Unsupported proxy protocol for \'%s\'", url);
675 result = CURLE_COULDNT_CONNECT;
676 goto out;
677 }
679 uc = curl_url_get(uh, CURLUPART_PORT, &portptr, 0);
680 if(uc == CURLUE_OUT_OF_MEMORY) {
681 result = CURLE_OUT_OF_MEMORY;
682 goto out;
683 }
684 if(portptr) {
685 curl_off_t num;
686 const char *p = portptr;
687 if(!curlx_str_number(&p, &num, UINT16_MAX))
688 pp.port = (uint16_t)num;
689 /* Should we not error out when the port number is invalid? */
690 curlx_free(portptr);
691 }
692 else {
693 /* No port in URL, take the set one or the proxy default */
694 if(data->set.proxyport)
695 pp.port = data->set.proxyport;
696 else if(CURL_PROXY_IS_HTTPS(proxytype))
697 pp.port = CURL_DEFAULT_HTTPS_PROXY_PORT;
698 else
699 pp.port = CURL_DEFAULT_PROXY_PORT;
700 }
702 /* now, clone the proxy hostname */
703 uc = curl_url_get(uh, CURLUPART_HOST, &pp.tmp_host_user, CURLU_URLDECODE);
704 if(uc) {
705 result = CURLE_OUT_OF_MEMORY;
706 goto out;
707 }
708 pp.host_user.str = pp.tmp_host_user;
709 pp.host_user.len = strlen(pp.tmp_host_user);
711#ifdef USE_UNIX_SOCKETS
712 if(is_socks && curl_strequal(UNIX_SOCKET_PREFIX, pp.tmp_host_user)) {
713 uc = curl_url_get(uh, CURLUPART_PATH, &pp.tmp_host, CURLU_URLDECODE);
714 if(uc) {
715 result = CURLE_OUT_OF_MEMORY;
716 goto out;
717 }
718 /* path will be "/", if no path was found */
719 if(strcmp("/", pp.tmp_host)) {
720 pp.host.str = pp.tmp_host;
721 pp.host.len = strlen(pp.tmp_host);
722 pp.unix_socket = TRUE;
723 }
724 else {
725 pp.host = pp.host_user;
726 }
727 }
728#endif /* USE_UNIX_SOCKETS */
730 if(!pp.host.len) {
731 result = peer_parse_host(data, &pp, FALSE);
732 if(result)
733 goto out;
734 }
736 uc = curl_url_get(uh, CURLUPART_ZONEID, &pp.tmp_zoneid, 0);
737 if(uc == CURLUE_OUT_OF_MEMORY) {
738 result = CURLE_OUT_OF_MEMORY;
739 goto out;
740 }
741 if(pp.tmp_zoneid) {
742 pp.zoneid.str = pp.tmp_zoneid;
743 pp.zoneid.len = strlen(pp.tmp_zoneid);
744 }
746 *pproxytype = proxytype;
747 result = peer_create(&pp, ppeer);
749out:
750 peer_parse_clear(&pp);
751 curlx_free(scheme);
752#ifdef DEBUGBUILD
753 if(!result)
754 DEBUGASSERT(*ppeer);
755#endif
756 return result;
757}
759#endif /* !CURL_DISABLE_PROXY */
Diagnostics4 git calls · 567 ms
CallStatusSizeTime0567 ms
discover200152 B3 ms
git.upload-pack discover http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=fetch 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 · 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 · hit2 ms
git.upload-pack fetch http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=fetch git.upstream.dur_ms=562 git.response.bytes=293470 git.response.cache=HIT git.response.duration_ms=2 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
fetch2005.4 KiB562 ms
git.upload-pack fetch http.response.status_code=200 git.response.bytes=5552 git.response.cache=MISS git.response.duration_ms=562 git.fetch.wants=5218091d879f353a07ac8d27aae3b66ccf2127fe 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=5552 git.pkt.payload.max=5531 git.sideband.band1.bytes=5530 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
- a5e272ce2fa8d806
- Request
- d7ec6395…
- Protocol
- v2 · sha1
- Agent
- gitty/1.0
- Filter
- advertised
- Fetch
- shallow filter sideband-all
- Capabilities
- agent ls-refs fetch object-format