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 "curl_setup.h"
26#include "curl_gethostname.h"
27#include "curlx/strcopy.h"
29/*
30 * Curl_gethostname() is a wrapper around gethostname() which allows
31 * overriding the hostname that the function would normally return.
32 * This capability is used by the test suite to verify exact matching
33 * by the SMTP module when a hostname is not provided.
34 *
35 * For libcurl debug enabled builds hostname overriding takes place
36 * when environment variable CURL_GETHOSTNAME is set, using the value
37 * held by the variable to override returned hostname.
38 *
39 * Note: The function always returns the un-qualified hostname rather
40 * than being provider dependent.
41 */
43int Curl_gethostname(char * const name, GETHOSTNAME_TYPE_ARG2 namelen)
44{
45#ifndef HAVE_GETHOSTNAME
47 /* Allow compilation and return failure when unavailable */
48 (void)name;
49 (void)namelen;
50 return -1;
52#else
53 int err;
54 char *dot;
56#ifdef DEBUGBUILD
58 /* Override hostname when environment variable CURL_GETHOSTNAME is set */
59 const char *force_hostname = getenv("CURL_GETHOSTNAME");
60 if(force_hostname) {
61 if(strlen(force_hostname) < (size_t)namelen)
62 curlx_strcopy(name, namelen, force_hostname, strlen(force_hostname));
63 else
64 return 1; /* cannot do it */
65 err = 0;
66 }
67 else {
68 name[0] = '\0';
69 err = gethostname(name, namelen);
70 }
72#else /* DEBUGBUILD */
74 name[0] = '\0';
75#ifdef __AMIGA__
76 err = gethostname((unsigned char *)name, namelen);
77#else
78 err = gethostname(name, namelen);
79#endif
81#endif
83 name[namelen - 1] = '\0';
85 if(err)
86 return err;
88 /* Truncate domain, leave only machine name */
89 dot = strchr(name, '.');
90 if(dot)
91 *dot = '\0';
93 return 0;
94#endif
95}
Diagnostics4 git calls · 375 ms
CallStatusSizeTime0375 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=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 · hit3 ms
git.upload-pack fetch http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=fetch git.upstream.dur_ms=369 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
fetch2001.2 KiB369 ms
git.upload-pack fetch http.response.status_code=200 git.response.bytes=1264 git.response.cache=MISS git.response.duration_ms=369 git.fetch.wants=661d4b177b22cd9f58dc48dc28b9304c2e21e83f 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=1264 git.pkt.payload.max=1243 git.sideband.band1.bytes=1242 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
- a5e1b3307fec5b65
- Request
- 8375fb7c…
- Protocol
- v2 · sha1
- Agent
- gitty/1.0
- Filter
- advertised
- Fetch
- shallow filter sideband-all
- Capabilities
- agent ls-refs fetch object-format