Artifactspublic-v0

curl

master
ply4 git calls28 ms290 KiB3 cachedprotocol v2
263 lines8.8 KiBRaw
1#ifndef HEADER_CURL_VSSH_SSH_H
2#define HEADER_CURL_VSSH_SSH_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"
27#include "urldata.h"
29extern const struct Curl_protocol Curl_protocol_sftp;
30extern const struct Curl_protocol Curl_protocol_scp;
32#ifdef USE_SSH
34#ifdef USE_LIBSSH2
35#include <libssh2.h>
36#include <libssh2_sftp.h>
37#elif defined(USE_LIBSSH)
38/* in 0.10.0 or later, ignore deprecated warnings */
39#define SSH_SUPPRESS_DEPRECATED
40#include <libssh/libssh.h>
41#include <libssh/sftp.h>
42#endif
44/* meta key for storing protocol meta at easy handle */
45#define CURL_META_SSH_EASY "meta:proto:ssh:easy"
46/* meta key for storing protocol meta at connection */
47#define CURL_META_SSH_CONN "meta:proto:ssh:conn"
49/****************************************************************************
50 * SSH unique setup
51 ***************************************************************************/
52typedef enum {
53 SSH_NO_STATE = -1, /* Used for "nextState" so say there is none */
54 SSH_STOP = 0, /* do nothing state, stops the state machine */
56 SSH_INIT, /* First state in SSH-CONNECT */
57 SSH_S_STARTUP, /* Session startup */
58 SSH_HOSTKEY, /* verify hostkey */
59 SSH_AUTHLIST,
60 SSH_AUTH_PKEY_INIT,
61 SSH_AUTH_PKEY,
62 SSH_AUTH_PKEY_AUTO, /* libssh: ssh-agent, then the default key files */
63 SSH_AUTH_PASS_INIT,
64 SSH_AUTH_PASS,
65 SSH_AUTH_AGENT_INIT, /* initialize then wait for connection to agent */
66 SSH_AUTH_AGENT_LIST, /* ask for list then wait for entire list to come */
67 SSH_AUTH_AGENT, /* attempt one key at a time */
68 SSH_AUTH_HOST_INIT,
69 SSH_AUTH_HOST,
70 SSH_AUTH_KEY_INIT,
71 SSH_AUTH_KEY,
72 SSH_AUTH_GSSAPI,
73 SSH_AUTH_DONE,
74 SSH_SFTP_INIT,
75 SSH_SFTP_REALPATH, /* Last state in SSH-CONNECT */
77 SSH_SFTP_QUOTE_INIT, /* First state in SFTP-DO */
78 SSH_SFTP_POSTQUOTE_INIT, /* (Possibly) First state in SFTP-DONE */
79 SSH_SFTP_QUOTE,
80 SSH_SFTP_NEXT_QUOTE,
81 SSH_SFTP_QUOTE_STAT,
82 SSH_SFTP_QUOTE_SETSTAT,
83 SSH_SFTP_QUOTE_SYMLINK,
84 SSH_SFTP_QUOTE_MKDIR,
85 SSH_SFTP_QUOTE_RENAME,
86 SSH_SFTP_QUOTE_RMDIR,
87 SSH_SFTP_QUOTE_UNLINK,
88 SSH_SFTP_QUOTE_STATVFS,
89 SSH_SFTP_GETINFO,
90 SSH_SFTP_FILETIME,
91 SSH_SFTP_TRANS_INIT,
92 SSH_SFTP_UPLOAD_INIT,
93 SSH_SFTP_CREATE_DIRS_INIT,
94 SSH_SFTP_CREATE_DIRS,
95 SSH_SFTP_CREATE_DIRS_MKDIR,
96 SSH_SFTP_READDIR_INIT,
97 SSH_SFTP_READDIR,
98 SSH_SFTP_READDIR_LINK,
99 SSH_SFTP_READDIR_BOTTOM,
100 SSH_SFTP_READDIR_DONE,
101 SSH_SFTP_DOWNLOAD_INIT,
102 SSH_SFTP_DOWNLOAD_STAT, /* Last state in SFTP-DO */
103 SSH_SFTP_CLOSE, /* Last state in SFTP-DONE */
104 SSH_SFTP_SHUTDOWN, /* First state in SFTP-DISCONNECT */
105 SSH_SCP_TRANS_INIT, /* First state in SCP-DO */
106 SSH_SCP_UPLOAD_INIT,
107 SSH_SCP_DOWNLOAD_INIT,
108 SSH_SCP_DOWNLOAD,
109 SSH_SCP_DONE,
110 SSH_SCP_SEND_EOF,
111 SSH_SCP_WAIT_EOF,
112 SSH_SCP_WAIT_CLOSE,
113 SSH_SCP_CHANNEL_FREE, /* Last state in SCP-DONE */
114 SSH_SESSION_DISCONNECT, /* First state in SCP-DISCONNECT */
115 SSH_SESSION_FREE, /* Last state in SCP/SFTP-DISCONNECT */
116 SSH_QUIT,
117 SSH_LAST /* never used */
118} sshstate;
120#define CURL_PATH_MAX 1024
122/* this struct is used in the HandleData struct which is part of the
123 Curl_easy, which means this is used on a per-easy handle basis.
124 Everything that is strictly related to a connection is banned from this
125 struct. */
126struct SSHPROTO {
127 char *path; /* the path we operate on, at least one byte long */
128#ifdef USE_LIBSSH2
129 struct dynbuf readdir_link;
130 struct dynbuf readdir;
131 char readdir_filename[CURL_PATH_MAX + 1];
132 char readdir_longentry[CURL_PATH_MAX + 1];
134 LIBSSH2_SFTP_ATTRIBUTES quote_attrs; /* used by the SFTP_QUOTE state */
136 /* Here's a set of struct members used by the SFTP_READDIR state */
137 LIBSSH2_SFTP_ATTRIBUTES readdir_attrs;
138#endif
139};
141/* ssh_conn is used for struct connection-oriented data in the connectdata
142 struct */
143struct ssh_conn {
144 const char *authlist; /* List of auth. methods, managed by libssh2 */
146 /* common */
147 char *passphrase; /* strdup'ed pass-phrase to use or NULL */
148 char *pub_key; /* strdup'ed public key file */
149 char *priv_key; /* strdup'ed private key file */
150 sshstate state; /* always use ssh.c:state() to change state! */
151 sshstate nextstate; /* the state to goto after stopping */
152 struct curl_slist *quote_item; /* for the quote option */
153 char *quote_path1; /* two generic pointers for the QUOTE stuff */
154 char *quote_path2;
156 char *homedir; /* when doing SFTP we figure out home directory
157 in the connect phase */
158 /* end of READDIR stuff */
160 int secondCreateDirs; /* counter use by the code to see if the
161 second attempt has been made to change
162 to/create a directory */
163 int waitfor; /* REQ_IO_RECV/REQ_IO_SEND bits overriding
164 pollset given flags */
165 char *slash_pos; /* used by the SFTP_CREATE_DIRS state */
167#ifdef USE_LIBSSH
168 CURLcode actualcode; /* the actual error code */
169 char *readdir_linkPath;
170 size_t readdir_len;
171 struct dynbuf readdir_buf;
172/* our variables */
173 unsigned kbd_state; /* 0 or 1 */
174 ssh_key privkey;
175 ssh_key pubkey;
176 unsigned int auth_methods;
177 ssh_session ssh_session;
178 ssh_scp scp_session;
179 sftp_session sftp_session;
180 sftp_file sftp_file;
181 sftp_dir sftp_dir;
183 unsigned sftp_recv_state; /* 0 or 1 */
184#if LIBSSH_VERSION_INT > SSH_VERSION_INT(0, 11, 0)
185 sftp_aio sftp_recv_aio;
187 sftp_aio sftp_send_aio;
188 unsigned sftp_send_state; /* 0 or 1 */
189#else
190 int sftp_file_index; /* for async read */
191#endif
192 sftp_attributes readdir_attrs; /* used by the SFTP readdir actions */
193 sftp_attributes readdir_link_attrs; /* used by the SFTP readdir actions */
194 sftp_attributes quote_attrs; /* used by the SFTP_QUOTE state */
196 const char *readdir_filename; /* points within readdir_attrs */
197 const char *readdir_longentry;
198 char *readdir_tmp;
199 BIT(initialized);
200#elif defined(USE_LIBSSH2)
201 LIBSSH2_SESSION *ssh_session; /* Secure Shell session */
202 LIBSSH2_CHANNEL *ssh_channel; /* Secure Shell channel handle */
203 LIBSSH2_SFTP *sftp_session; /* SFTP handle */
204 LIBSSH2_SFTP_HANDLE *sftp_handle;
206#ifndef CURL_DISABLE_PROXY
207 /* for HTTPS proxy storage */
208 Curl_recv *tls_recv;
209 Curl_send *tls_send;
210#endif
212 LIBSSH2_AGENT *ssh_agent; /* proxy to ssh-agent/pageant */
213 struct libssh2_agent_publickey *sshagent_identity;
214 struct libssh2_agent_publickey *sshagent_prev_identity;
215 LIBSSH2_KNOWNHOSTS *kh;
216#endif /* USE_LIBSSH */
217 BIT(authed); /* the connection has been authenticated fine */
218 BIT(acceptfail); /* used by the SFTP_QUOTE (continue if
219 quote command fails) */
220};
222#ifdef USE_LIBSSH
223#if LIBSSH_VERSION_INT < SSH_VERSION_INT(0, 9, 0)
224#error "SCP/SFTP protocols require libssh 0.9.0 or greater"
225#endif
226#endif
228#ifdef USE_LIBSSH2
230/* Feature detection based on version numbers to better work with
231 non-configure platforms */
233#if !defined(LIBSSH2_VERSION_NUM) || (LIBSSH2_VERSION_NUM < 0x010900)
234#error "SCP/SFTP protocols require libssh2 1.9.0 or greater"
235/* 1.9.0 was released on June 20 2019 */
236#endif
238#endif /* USE_LIBSSH2 */
240#ifdef CURLVERBOSE
241const char *Curl_ssh_statename(sshstate state);
242#else
243#define Curl_ssh_statename(x) ""
244#endif
245void Curl_ssh_set_state(struct Curl_easy *data,
246 struct ssh_conn *sshc,
247 sshstate nowstate);
249#define myssh_to(x, y, z) Curl_ssh_set_state(x, y, z)
251/* generic SSH backend functions */
252CURLcode Curl_ssh_init(void);
253void Curl_ssh_cleanup(void);
254void Curl_ssh_version(char *buffer, size_t buflen);
255void Curl_ssh_attach(struct Curl_easy *data,
256 struct connectdata *conn);
257#else /* !USE_SSH */
258#define Curl_ssh_cleanup()
259#define Curl_ssh_attach(x, y)
260#define Curl_ssh_init() 0
261#endif /* USE_SSH */
263#endif /* HEADER_CURL_SSH_H */
Diagnostics4 git calls · 28 ms
CallStatusSizeTime028 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 · hit5 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=5
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
fetch2003.3 KiB · hit20 ms
git.upload-pack fetch
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=fetch
git.upstream.dur_ms=20
git.response.bytes=3358
git.response.cache=HIT
git.response.duration_ms=20
git.fetch.wants=efce81393bef6b0809e90ecc8f0c8016ced8277d
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=3358
git.pkt.payload.max=3337
git.sideband.band1.bytes=3336
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
a5e216d48b65984a
Request
99fb15bc…
Protocol
v2 · sha1
Agent
gitty/1.0
Filter
advertised
Fetch
shallow filter sideband-all
Capabilities
agent ls-refs fetch object-format