mirror of
https://github.com/curl/curl.git
synced 2025-09-19 02:22:47 +03:00
conn: add 'attach' to protocol handler, make libssh2 use it
The libssh2 backend has SSH session associated with the connection but the callback context is the easy handle, so when a connection gets attached to a transfer, the protocol handler now allows for a custom function to get used to set things up correctly. Reported-by: Michael O'Farrell Fixes #6898 Closes #7078
This commit is contained in:
parent
904b27d18d
commit
0c55fbab45
|
@ -79,6 +79,7 @@ const struct Curl_handler Curl_handler_rtmp = {
|
||||||
rtmp_disconnect, /* disconnect */
|
rtmp_disconnect, /* disconnect */
|
||||||
ZERO_NULL, /* readwrite */
|
ZERO_NULL, /* readwrite */
|
||||||
ZERO_NULL, /* connection_check */
|
ZERO_NULL, /* connection_check */
|
||||||
|
ZERO_NULL, /* attach connection */
|
||||||
PORT_RTMP, /* defport */
|
PORT_RTMP, /* defport */
|
||||||
CURLPROTO_RTMP, /* protocol */
|
CURLPROTO_RTMP, /* protocol */
|
||||||
CURLPROTO_RTMP, /* family */
|
CURLPROTO_RTMP, /* family */
|
||||||
|
@ -101,6 +102,7 @@ const struct Curl_handler Curl_handler_rtmpt = {
|
||||||
rtmp_disconnect, /* disconnect */
|
rtmp_disconnect, /* disconnect */
|
||||||
ZERO_NULL, /* readwrite */
|
ZERO_NULL, /* readwrite */
|
||||||
ZERO_NULL, /* connection_check */
|
ZERO_NULL, /* connection_check */
|
||||||
|
ZERO_NULL, /* attach connection */
|
||||||
PORT_RTMPT, /* defport */
|
PORT_RTMPT, /* defport */
|
||||||
CURLPROTO_RTMPT, /* protocol */
|
CURLPROTO_RTMPT, /* protocol */
|
||||||
CURLPROTO_RTMPT, /* family */
|
CURLPROTO_RTMPT, /* family */
|
||||||
|
@ -123,6 +125,7 @@ const struct Curl_handler Curl_handler_rtmpe = {
|
||||||
rtmp_disconnect, /* disconnect */
|
rtmp_disconnect, /* disconnect */
|
||||||
ZERO_NULL, /* readwrite */
|
ZERO_NULL, /* readwrite */
|
||||||
ZERO_NULL, /* connection_check */
|
ZERO_NULL, /* connection_check */
|
||||||
|
ZERO_NULL, /* attach connection */
|
||||||
PORT_RTMP, /* defport */
|
PORT_RTMP, /* defport */
|
||||||
CURLPROTO_RTMPE, /* protocol */
|
CURLPROTO_RTMPE, /* protocol */
|
||||||
CURLPROTO_RTMPE, /* family */
|
CURLPROTO_RTMPE, /* family */
|
||||||
|
@ -145,6 +148,7 @@ const struct Curl_handler Curl_handler_rtmpte = {
|
||||||
rtmp_disconnect, /* disconnect */
|
rtmp_disconnect, /* disconnect */
|
||||||
ZERO_NULL, /* readwrite */
|
ZERO_NULL, /* readwrite */
|
||||||
ZERO_NULL, /* connection_check */
|
ZERO_NULL, /* connection_check */
|
||||||
|
ZERO_NULL, /* attach connection */
|
||||||
PORT_RTMPT, /* defport */
|
PORT_RTMPT, /* defport */
|
||||||
CURLPROTO_RTMPTE, /* protocol */
|
CURLPROTO_RTMPTE, /* protocol */
|
||||||
CURLPROTO_RTMPTE, /* family */
|
CURLPROTO_RTMPTE, /* family */
|
||||||
|
@ -167,6 +171,7 @@ const struct Curl_handler Curl_handler_rtmps = {
|
||||||
rtmp_disconnect, /* disconnect */
|
rtmp_disconnect, /* disconnect */
|
||||||
ZERO_NULL, /* readwrite */
|
ZERO_NULL, /* readwrite */
|
||||||
ZERO_NULL, /* connection_check */
|
ZERO_NULL, /* connection_check */
|
||||||
|
ZERO_NULL, /* attach connection */
|
||||||
PORT_RTMPS, /* defport */
|
PORT_RTMPS, /* defport */
|
||||||
CURLPROTO_RTMPS, /* protocol */
|
CURLPROTO_RTMPS, /* protocol */
|
||||||
CURLPROTO_RTMP, /* family */
|
CURLPROTO_RTMP, /* family */
|
||||||
|
@ -189,6 +194,7 @@ const struct Curl_handler Curl_handler_rtmpts = {
|
||||||
rtmp_disconnect, /* disconnect */
|
rtmp_disconnect, /* disconnect */
|
||||||
ZERO_NULL, /* readwrite */
|
ZERO_NULL, /* readwrite */
|
||||||
ZERO_NULL, /* connection_check */
|
ZERO_NULL, /* connection_check */
|
||||||
|
ZERO_NULL, /* attach connection */
|
||||||
PORT_RTMPS, /* defport */
|
PORT_RTMPS, /* defport */
|
||||||
CURLPROTO_RTMPTS, /* protocol */
|
CURLPROTO_RTMPTS, /* protocol */
|
||||||
CURLPROTO_RTMPT, /* family */
|
CURLPROTO_RTMPT, /* family */
|
||||||
|
|
|
@ -89,6 +89,7 @@ const struct Curl_handler Curl_handler_dict = {
|
||||||
ZERO_NULL, /* disconnect */
|
ZERO_NULL, /* disconnect */
|
||||||
ZERO_NULL, /* readwrite */
|
ZERO_NULL, /* readwrite */
|
||||||
ZERO_NULL, /* connection_check */
|
ZERO_NULL, /* connection_check */
|
||||||
|
ZERO_NULL, /* attach connection */
|
||||||
PORT_DICT, /* defport */
|
PORT_DICT, /* defport */
|
||||||
CURLPROTO_DICT, /* protocol */
|
CURLPROTO_DICT, /* protocol */
|
||||||
CURLPROTO_DICT, /* family */
|
CURLPROTO_DICT, /* family */
|
||||||
|
|
|
@ -111,6 +111,7 @@ const struct Curl_handler Curl_handler_file = {
|
||||||
file_disconnect, /* disconnect */
|
file_disconnect, /* disconnect */
|
||||||
ZERO_NULL, /* readwrite */
|
ZERO_NULL, /* readwrite */
|
||||||
ZERO_NULL, /* connection_check */
|
ZERO_NULL, /* connection_check */
|
||||||
|
ZERO_NULL, /* attach connection */
|
||||||
0, /* defport */
|
0, /* defport */
|
||||||
CURLPROTO_FILE, /* protocol */
|
CURLPROTO_FILE, /* protocol */
|
||||||
CURLPROTO_FILE, /* family */
|
CURLPROTO_FILE, /* family */
|
||||||
|
|
|
@ -175,6 +175,7 @@ const struct Curl_handler Curl_handler_ftp = {
|
||||||
ftp_disconnect, /* disconnect */
|
ftp_disconnect, /* disconnect */
|
||||||
ZERO_NULL, /* readwrite */
|
ZERO_NULL, /* readwrite */
|
||||||
ZERO_NULL, /* connection_check */
|
ZERO_NULL, /* connection_check */
|
||||||
|
ZERO_NULL, /* attach connection */
|
||||||
PORT_FTP, /* defport */
|
PORT_FTP, /* defport */
|
||||||
CURLPROTO_FTP, /* protocol */
|
CURLPROTO_FTP, /* protocol */
|
||||||
CURLPROTO_FTP, /* family */
|
CURLPROTO_FTP, /* family */
|
||||||
|
@ -205,6 +206,7 @@ const struct Curl_handler Curl_handler_ftps = {
|
||||||
ftp_disconnect, /* disconnect */
|
ftp_disconnect, /* disconnect */
|
||||||
ZERO_NULL, /* readwrite */
|
ZERO_NULL, /* readwrite */
|
||||||
ZERO_NULL, /* connection_check */
|
ZERO_NULL, /* connection_check */
|
||||||
|
ZERO_NULL, /* attach connection */
|
||||||
PORT_FTPS, /* defport */
|
PORT_FTPS, /* defport */
|
||||||
CURLPROTO_FTPS, /* protocol */
|
CURLPROTO_FTPS, /* protocol */
|
||||||
CURLPROTO_FTP, /* family */
|
CURLPROTO_FTP, /* family */
|
||||||
|
|
|
@ -74,6 +74,7 @@ const struct Curl_handler Curl_handler_gopher = {
|
||||||
ZERO_NULL, /* disconnect */
|
ZERO_NULL, /* disconnect */
|
||||||
ZERO_NULL, /* readwrite */
|
ZERO_NULL, /* readwrite */
|
||||||
ZERO_NULL, /* connection_check */
|
ZERO_NULL, /* connection_check */
|
||||||
|
ZERO_NULL, /* attach connection */
|
||||||
PORT_GOPHER, /* defport */
|
PORT_GOPHER, /* defport */
|
||||||
CURLPROTO_GOPHER, /* protocol */
|
CURLPROTO_GOPHER, /* protocol */
|
||||||
CURLPROTO_GOPHER, /* family */
|
CURLPROTO_GOPHER, /* family */
|
||||||
|
@ -97,6 +98,7 @@ const struct Curl_handler Curl_handler_gophers = {
|
||||||
ZERO_NULL, /* disconnect */
|
ZERO_NULL, /* disconnect */
|
||||||
ZERO_NULL, /* readwrite */
|
ZERO_NULL, /* readwrite */
|
||||||
ZERO_NULL, /* connection_check */
|
ZERO_NULL, /* connection_check */
|
||||||
|
ZERO_NULL, /* attach connection */
|
||||||
PORT_GOPHER, /* defport */
|
PORT_GOPHER, /* defport */
|
||||||
CURLPROTO_GOPHERS, /* protocol */
|
CURLPROTO_GOPHERS, /* protocol */
|
||||||
CURLPROTO_GOPHER, /* family */
|
CURLPROTO_GOPHER, /* family */
|
||||||
|
|
|
@ -133,6 +133,7 @@ const struct Curl_handler Curl_handler_http = {
|
||||||
ZERO_NULL, /* disconnect */
|
ZERO_NULL, /* disconnect */
|
||||||
ZERO_NULL, /* readwrite */
|
ZERO_NULL, /* readwrite */
|
||||||
ZERO_NULL, /* connection_check */
|
ZERO_NULL, /* connection_check */
|
||||||
|
ZERO_NULL, /* attach connection */
|
||||||
PORT_HTTP, /* defport */
|
PORT_HTTP, /* defport */
|
||||||
CURLPROTO_HTTP, /* protocol */
|
CURLPROTO_HTTP, /* protocol */
|
||||||
CURLPROTO_HTTP, /* family */
|
CURLPROTO_HTTP, /* family */
|
||||||
|
@ -160,6 +161,7 @@ const struct Curl_handler Curl_handler_https = {
|
||||||
ZERO_NULL, /* disconnect */
|
ZERO_NULL, /* disconnect */
|
||||||
ZERO_NULL, /* readwrite */
|
ZERO_NULL, /* readwrite */
|
||||||
ZERO_NULL, /* connection_check */
|
ZERO_NULL, /* connection_check */
|
||||||
|
ZERO_NULL, /* attach connection */
|
||||||
PORT_HTTPS, /* defport */
|
PORT_HTTPS, /* defport */
|
||||||
CURLPROTO_HTTPS, /* protocol */
|
CURLPROTO_HTTPS, /* protocol */
|
||||||
CURLPROTO_HTTP, /* family */
|
CURLPROTO_HTTP, /* family */
|
||||||
|
|
|
@ -319,6 +319,7 @@ static const struct Curl_handler Curl_handler_http2 = {
|
||||||
http2_disconnect, /* disconnect */
|
http2_disconnect, /* disconnect */
|
||||||
ZERO_NULL, /* readwrite */
|
ZERO_NULL, /* readwrite */
|
||||||
http2_conncheck, /* connection_check */
|
http2_conncheck, /* connection_check */
|
||||||
|
ZERO_NULL, /* attach connection */
|
||||||
PORT_HTTP, /* defport */
|
PORT_HTTP, /* defport */
|
||||||
CURLPROTO_HTTP, /* protocol */
|
CURLPROTO_HTTP, /* protocol */
|
||||||
CURLPROTO_HTTP, /* family */
|
CURLPROTO_HTTP, /* family */
|
||||||
|
@ -341,6 +342,7 @@ static const struct Curl_handler Curl_handler_http2_ssl = {
|
||||||
http2_disconnect, /* disconnect */
|
http2_disconnect, /* disconnect */
|
||||||
ZERO_NULL, /* readwrite */
|
ZERO_NULL, /* readwrite */
|
||||||
http2_conncheck, /* connection_check */
|
http2_conncheck, /* connection_check */
|
||||||
|
ZERO_NULL, /* attach connection */
|
||||||
PORT_HTTP, /* defport */
|
PORT_HTTP, /* defport */
|
||||||
CURLPROTO_HTTPS, /* protocol */
|
CURLPROTO_HTTPS, /* protocol */
|
||||||
CURLPROTO_HTTP, /* family */
|
CURLPROTO_HTTP, /* family */
|
||||||
|
|
|
@ -136,6 +136,7 @@ const struct Curl_handler Curl_handler_imap = {
|
||||||
imap_disconnect, /* disconnect */
|
imap_disconnect, /* disconnect */
|
||||||
ZERO_NULL, /* readwrite */
|
ZERO_NULL, /* readwrite */
|
||||||
ZERO_NULL, /* connection_check */
|
ZERO_NULL, /* connection_check */
|
||||||
|
ZERO_NULL, /* attach connection */
|
||||||
PORT_IMAP, /* defport */
|
PORT_IMAP, /* defport */
|
||||||
CURLPROTO_IMAP, /* protocol */
|
CURLPROTO_IMAP, /* protocol */
|
||||||
CURLPROTO_IMAP, /* family */
|
CURLPROTO_IMAP, /* family */
|
||||||
|
@ -164,6 +165,7 @@ const struct Curl_handler Curl_handler_imaps = {
|
||||||
imap_disconnect, /* disconnect */
|
imap_disconnect, /* disconnect */
|
||||||
ZERO_NULL, /* readwrite */
|
ZERO_NULL, /* readwrite */
|
||||||
ZERO_NULL, /* connection_check */
|
ZERO_NULL, /* connection_check */
|
||||||
|
ZERO_NULL, /* attach connection */
|
||||||
PORT_IMAPS, /* defport */
|
PORT_IMAPS, /* defport */
|
||||||
CURLPROTO_IMAPS, /* protocol */
|
CURLPROTO_IMAPS, /* protocol */
|
||||||
CURLPROTO_IMAP, /* family */
|
CURLPROTO_IMAP, /* family */
|
||||||
|
|
|
@ -149,6 +149,7 @@ const struct Curl_handler Curl_handler_ldap = {
|
||||||
ZERO_NULL, /* disconnect */
|
ZERO_NULL, /* disconnect */
|
||||||
ZERO_NULL, /* readwrite */
|
ZERO_NULL, /* readwrite */
|
||||||
ZERO_NULL, /* connection_check */
|
ZERO_NULL, /* connection_check */
|
||||||
|
ZERO_NULL, /* attach connection */
|
||||||
PORT_LDAP, /* defport */
|
PORT_LDAP, /* defport */
|
||||||
CURLPROTO_LDAP, /* protocol */
|
CURLPROTO_LDAP, /* protocol */
|
||||||
CURLPROTO_LDAP, /* family */
|
CURLPROTO_LDAP, /* family */
|
||||||
|
@ -176,6 +177,7 @@ const struct Curl_handler Curl_handler_ldaps = {
|
||||||
ZERO_NULL, /* disconnect */
|
ZERO_NULL, /* disconnect */
|
||||||
ZERO_NULL, /* readwrite */
|
ZERO_NULL, /* readwrite */
|
||||||
ZERO_NULL, /* connection_check */
|
ZERO_NULL, /* connection_check */
|
||||||
|
ZERO_NULL, /* attach connection */
|
||||||
PORT_LDAPS, /* defport */
|
PORT_LDAPS, /* defport */
|
||||||
CURLPROTO_LDAPS, /* protocol */
|
CURLPROTO_LDAPS, /* protocol */
|
||||||
CURLPROTO_LDAP, /* family */
|
CURLPROTO_LDAP, /* family */
|
||||||
|
|
|
@ -86,6 +86,7 @@ const struct Curl_handler Curl_handler_mqtt = {
|
||||||
ZERO_NULL, /* disconnect */
|
ZERO_NULL, /* disconnect */
|
||||||
ZERO_NULL, /* readwrite */
|
ZERO_NULL, /* readwrite */
|
||||||
ZERO_NULL, /* connection_check */
|
ZERO_NULL, /* connection_check */
|
||||||
|
ZERO_NULL, /* attach connection */
|
||||||
PORT_MQTT, /* defport */
|
PORT_MQTT, /* defport */
|
||||||
CURLPROTO_MQTT, /* protocol */
|
CURLPROTO_MQTT, /* protocol */
|
||||||
CURLPROTO_MQTT, /* family */
|
CURLPROTO_MQTT, /* family */
|
||||||
|
|
|
@ -896,6 +896,8 @@ void Curl_attach_connnection(struct Curl_easy *data,
|
||||||
data->conn = conn;
|
data->conn = conn;
|
||||||
Curl_llist_insert_next(&conn->easyq, conn->easyq.tail, data,
|
Curl_llist_insert_next(&conn->easyq, conn->easyq.tail, data,
|
||||||
&data->conn_queue);
|
&data->conn_queue);
|
||||||
|
if(conn->handler->attach)
|
||||||
|
conn->handler->attach(data, conn);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int waitconnect_getsock(struct connectdata *conn,
|
static int waitconnect_getsock(struct connectdata *conn,
|
||||||
|
|
|
@ -107,6 +107,7 @@ const struct Curl_handler Curl_handler_ldap = {
|
||||||
oldap_disconnect, /* disconnect */
|
oldap_disconnect, /* disconnect */
|
||||||
ZERO_NULL, /* readwrite */
|
ZERO_NULL, /* readwrite */
|
||||||
ZERO_NULL, /* connection_check */
|
ZERO_NULL, /* connection_check */
|
||||||
|
ZERO_NULL, /* attach connection */
|
||||||
PORT_LDAP, /* defport */
|
PORT_LDAP, /* defport */
|
||||||
CURLPROTO_LDAP, /* protocol */
|
CURLPROTO_LDAP, /* protocol */
|
||||||
CURLPROTO_LDAP, /* family */
|
CURLPROTO_LDAP, /* family */
|
||||||
|
@ -134,6 +135,7 @@ const struct Curl_handler Curl_handler_ldaps = {
|
||||||
oldap_disconnect, /* disconnect */
|
oldap_disconnect, /* disconnect */
|
||||||
ZERO_NULL, /* readwrite */
|
ZERO_NULL, /* readwrite */
|
||||||
ZERO_NULL, /* connection_check */
|
ZERO_NULL, /* connection_check */
|
||||||
|
ZERO_NULL, /* attach connection */
|
||||||
PORT_LDAPS, /* defport */
|
PORT_LDAPS, /* defport */
|
||||||
CURLPROTO_LDAPS, /* protocol */
|
CURLPROTO_LDAPS, /* protocol */
|
||||||
CURLPROTO_LDAP, /* family */
|
CURLPROTO_LDAP, /* family */
|
||||||
|
|
|
@ -131,6 +131,7 @@ const struct Curl_handler Curl_handler_pop3 = {
|
||||||
pop3_disconnect, /* disconnect */
|
pop3_disconnect, /* disconnect */
|
||||||
ZERO_NULL, /* readwrite */
|
ZERO_NULL, /* readwrite */
|
||||||
ZERO_NULL, /* connection_check */
|
ZERO_NULL, /* connection_check */
|
||||||
|
ZERO_NULL, /* attach connection */
|
||||||
PORT_POP3, /* defport */
|
PORT_POP3, /* defport */
|
||||||
CURLPROTO_POP3, /* protocol */
|
CURLPROTO_POP3, /* protocol */
|
||||||
CURLPROTO_POP3, /* family */
|
CURLPROTO_POP3, /* family */
|
||||||
|
@ -159,6 +160,7 @@ const struct Curl_handler Curl_handler_pop3s = {
|
||||||
pop3_disconnect, /* disconnect */
|
pop3_disconnect, /* disconnect */
|
||||||
ZERO_NULL, /* readwrite */
|
ZERO_NULL, /* readwrite */
|
||||||
ZERO_NULL, /* connection_check */
|
ZERO_NULL, /* connection_check */
|
||||||
|
ZERO_NULL, /* attach connection */
|
||||||
PORT_POP3S, /* defport */
|
PORT_POP3S, /* defport */
|
||||||
CURLPROTO_POP3S, /* protocol */
|
CURLPROTO_POP3S, /* protocol */
|
||||||
CURLPROTO_POP3, /* family */
|
CURLPROTO_POP3, /* family */
|
||||||
|
|
|
@ -109,6 +109,7 @@ const struct Curl_handler Curl_handler_rtsp = {
|
||||||
rtsp_disconnect, /* disconnect */
|
rtsp_disconnect, /* disconnect */
|
||||||
rtsp_rtp_readwrite, /* readwrite */
|
rtsp_rtp_readwrite, /* readwrite */
|
||||||
rtsp_conncheck, /* connection_check */
|
rtsp_conncheck, /* connection_check */
|
||||||
|
ZERO_NULL, /* attach connection */
|
||||||
PORT_RTSP, /* defport */
|
PORT_RTSP, /* defport */
|
||||||
CURLPROTO_RTSP, /* protocol */
|
CURLPROTO_RTSP, /* protocol */
|
||||||
CURLPROTO_RTSP, /* family */
|
CURLPROTO_RTSP, /* family */
|
||||||
|
|
|
@ -88,6 +88,7 @@ const struct Curl_handler Curl_handler_smb = {
|
||||||
smb_disconnect, /* disconnect */
|
smb_disconnect, /* disconnect */
|
||||||
ZERO_NULL, /* readwrite */
|
ZERO_NULL, /* readwrite */
|
||||||
ZERO_NULL, /* connection_check */
|
ZERO_NULL, /* connection_check */
|
||||||
|
ZERO_NULL, /* attach connection */
|
||||||
PORT_SMB, /* defport */
|
PORT_SMB, /* defport */
|
||||||
CURLPROTO_SMB, /* protocol */
|
CURLPROTO_SMB, /* protocol */
|
||||||
CURLPROTO_SMB, /* family */
|
CURLPROTO_SMB, /* family */
|
||||||
|
@ -114,6 +115,7 @@ const struct Curl_handler Curl_handler_smbs = {
|
||||||
smb_disconnect, /* disconnect */
|
smb_disconnect, /* disconnect */
|
||||||
ZERO_NULL, /* readwrite */
|
ZERO_NULL, /* readwrite */
|
||||||
ZERO_NULL, /* connection_check */
|
ZERO_NULL, /* connection_check */
|
||||||
|
ZERO_NULL, /* attach connection */
|
||||||
PORT_SMBS, /* defport */
|
PORT_SMBS, /* defport */
|
||||||
CURLPROTO_SMBS, /* protocol */
|
CURLPROTO_SMBS, /* protocol */
|
||||||
CURLPROTO_SMB, /* family */
|
CURLPROTO_SMB, /* family */
|
||||||
|
|
|
@ -136,6 +136,7 @@ const struct Curl_handler Curl_handler_smtp = {
|
||||||
smtp_disconnect, /* disconnect */
|
smtp_disconnect, /* disconnect */
|
||||||
ZERO_NULL, /* readwrite */
|
ZERO_NULL, /* readwrite */
|
||||||
ZERO_NULL, /* connection_check */
|
ZERO_NULL, /* connection_check */
|
||||||
|
ZERO_NULL, /* attach connection */
|
||||||
PORT_SMTP, /* defport */
|
PORT_SMTP, /* defport */
|
||||||
CURLPROTO_SMTP, /* protocol */
|
CURLPROTO_SMTP, /* protocol */
|
||||||
CURLPROTO_SMTP, /* family */
|
CURLPROTO_SMTP, /* family */
|
||||||
|
@ -164,6 +165,7 @@ const struct Curl_handler Curl_handler_smtps = {
|
||||||
smtp_disconnect, /* disconnect */
|
smtp_disconnect, /* disconnect */
|
||||||
ZERO_NULL, /* readwrite */
|
ZERO_NULL, /* readwrite */
|
||||||
ZERO_NULL, /* connection_check */
|
ZERO_NULL, /* connection_check */
|
||||||
|
ZERO_NULL, /* attach connection */
|
||||||
PORT_SMTPS, /* defport */
|
PORT_SMTPS, /* defport */
|
||||||
CURLPROTO_SMTPS, /* protocol */
|
CURLPROTO_SMTPS, /* protocol */
|
||||||
CURLPROTO_SMTP, /* family */
|
CURLPROTO_SMTP, /* family */
|
||||||
|
|
|
@ -185,6 +185,7 @@ const struct Curl_handler Curl_handler_telnet = {
|
||||||
ZERO_NULL, /* disconnect */
|
ZERO_NULL, /* disconnect */
|
||||||
ZERO_NULL, /* readwrite */
|
ZERO_NULL, /* readwrite */
|
||||||
ZERO_NULL, /* connection_check */
|
ZERO_NULL, /* connection_check */
|
||||||
|
ZERO_NULL, /* attach connection */
|
||||||
PORT_TELNET, /* defport */
|
PORT_TELNET, /* defport */
|
||||||
CURLPROTO_TELNET, /* protocol */
|
CURLPROTO_TELNET, /* protocol */
|
||||||
CURLPROTO_TELNET, /* family */
|
CURLPROTO_TELNET, /* family */
|
||||||
|
|
|
@ -182,6 +182,7 @@ const struct Curl_handler Curl_handler_tftp = {
|
||||||
tftp_disconnect, /* disconnect */
|
tftp_disconnect, /* disconnect */
|
||||||
ZERO_NULL, /* readwrite */
|
ZERO_NULL, /* readwrite */
|
||||||
ZERO_NULL, /* connection_check */
|
ZERO_NULL, /* connection_check */
|
||||||
|
ZERO_NULL, /* attach connection */
|
||||||
PORT_TFTP, /* defport */
|
PORT_TFTP, /* defport */
|
||||||
CURLPROTO_TFTP, /* protocol */
|
CURLPROTO_TFTP, /* protocol */
|
||||||
CURLPROTO_TFTP, /* family */
|
CURLPROTO_TFTP, /* family */
|
||||||
|
|
|
@ -292,6 +292,7 @@ static const struct Curl_handler Curl_handler_dummy = {
|
||||||
ZERO_NULL, /* disconnect */
|
ZERO_NULL, /* disconnect */
|
||||||
ZERO_NULL, /* readwrite */
|
ZERO_NULL, /* readwrite */
|
||||||
ZERO_NULL, /* connection_check */
|
ZERO_NULL, /* connection_check */
|
||||||
|
ZERO_NULL, /* attach connection */
|
||||||
0, /* defport */
|
0, /* defport */
|
||||||
0, /* protocol */
|
0, /* protocol */
|
||||||
0, /* family */
|
0, /* family */
|
||||||
|
|
|
@ -794,12 +794,16 @@ struct Curl_handler {
|
||||||
struct connectdata *conn,
|
struct connectdata *conn,
|
||||||
unsigned int checks_to_perform);
|
unsigned int checks_to_perform);
|
||||||
|
|
||||||
|
/* attach() attaches this transfer to this connection */
|
||||||
|
void (*attach)(struct Curl_easy *data, struct connectdata *conn);
|
||||||
|
|
||||||
int defport; /* Default port. */
|
int defport; /* Default port. */
|
||||||
unsigned int protocol; /* See CURLPROTO_* - this needs to be the single
|
unsigned int protocol; /* See CURLPROTO_* - this needs to be the single
|
||||||
specific protocol bit */
|
specific protocol bit */
|
||||||
unsigned int family; /* single bit for protocol family; basically the
|
unsigned int family; /* single bit for protocol family; basically the
|
||||||
non-TLS name of the protocol this is */
|
non-TLS name of the protocol this is */
|
||||||
unsigned int flags; /* Extra particular characteristics, see PROTOPT_* */
|
unsigned int flags; /* Extra particular characteristics, see PROTOPT_* */
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#define PROTOPT_NONE 0 /* nothing extra */
|
#define PROTOPT_NONE 0 /* nothing extra */
|
||||||
|
|
|
@ -159,6 +159,7 @@ const struct Curl_handler Curl_handler_scp = {
|
||||||
scp_disconnect, /* disconnect */
|
scp_disconnect, /* disconnect */
|
||||||
ZERO_NULL, /* readwrite */
|
ZERO_NULL, /* readwrite */
|
||||||
ZERO_NULL, /* connection_check */
|
ZERO_NULL, /* connection_check */
|
||||||
|
ZERO_NULL, /* attach connection */
|
||||||
PORT_SSH, /* defport */
|
PORT_SSH, /* defport */
|
||||||
CURLPROTO_SCP, /* protocol */
|
CURLPROTO_SCP, /* protocol */
|
||||||
CURLPROTO_SCP, /* family */
|
CURLPROTO_SCP, /* family */
|
||||||
|
@ -185,6 +186,7 @@ const struct Curl_handler Curl_handler_sftp = {
|
||||||
sftp_disconnect, /* disconnect */
|
sftp_disconnect, /* disconnect */
|
||||||
ZERO_NULL, /* readwrite */
|
ZERO_NULL, /* readwrite */
|
||||||
ZERO_NULL, /* connection_check */
|
ZERO_NULL, /* connection_check */
|
||||||
|
ZERO_NULL, /* attach connection */
|
||||||
PORT_SSH, /* defport */
|
PORT_SSH, /* defport */
|
||||||
CURLPROTO_SFTP, /* protocol */
|
CURLPROTO_SFTP, /* protocol */
|
||||||
CURLPROTO_SFTP, /* family */
|
CURLPROTO_SFTP, /* family */
|
||||||
|
|
|
@ -121,6 +121,7 @@ static int ssh_getsock(struct Curl_easy *data, struct connectdata *conn,
|
||||||
curl_socket_t *sock);
|
curl_socket_t *sock);
|
||||||
static CURLcode ssh_setup_connection(struct Curl_easy *data,
|
static CURLcode ssh_setup_connection(struct Curl_easy *data,
|
||||||
struct connectdata *conn);
|
struct connectdata *conn);
|
||||||
|
static void ssh_attach(struct Curl_easy *data, struct connectdata *conn);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* SCP protocol handler.
|
* SCP protocol handler.
|
||||||
|
@ -142,6 +143,7 @@ const struct Curl_handler Curl_handler_scp = {
|
||||||
scp_disconnect, /* disconnect */
|
scp_disconnect, /* disconnect */
|
||||||
ZERO_NULL, /* readwrite */
|
ZERO_NULL, /* readwrite */
|
||||||
ZERO_NULL, /* connection_check */
|
ZERO_NULL, /* connection_check */
|
||||||
|
ssh_attach,
|
||||||
PORT_SSH, /* defport */
|
PORT_SSH, /* defport */
|
||||||
CURLPROTO_SCP, /* protocol */
|
CURLPROTO_SCP, /* protocol */
|
||||||
CURLPROTO_SCP, /* family */
|
CURLPROTO_SCP, /* family */
|
||||||
|
@ -170,6 +172,7 @@ const struct Curl_handler Curl_handler_sftp = {
|
||||||
sftp_disconnect, /* disconnect */
|
sftp_disconnect, /* disconnect */
|
||||||
ZERO_NULL, /* readwrite */
|
ZERO_NULL, /* readwrite */
|
||||||
ZERO_NULL, /* connection_check */
|
ZERO_NULL, /* connection_check */
|
||||||
|
ssh_attach,
|
||||||
PORT_SSH, /* defport */
|
PORT_SSH, /* defport */
|
||||||
CURLPROTO_SFTP, /* protocol */
|
CURLPROTO_SFTP, /* protocol */
|
||||||
CURLPROTO_SFTP, /* family */
|
CURLPROTO_SFTP, /* family */
|
||||||
|
@ -3604,4 +3607,21 @@ size_t Curl_ssh_version(char *buffer, size_t buflen)
|
||||||
return msnprintf(buffer, buflen, "libssh2/%s", LIBSSH2_VERSION);
|
return msnprintf(buffer, buflen, "libssh2/%s", LIBSSH2_VERSION);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* The SSH session is associated with the *CONNECTION* but the callback user
|
||||||
|
* pointer is an easy handle pointer. This function allows us to reassign the
|
||||||
|
* user pointer to the *CURRENT* (new) easy handle.
|
||||||
|
*/
|
||||||
|
static void ssh_attach(struct Curl_easy *data, struct connectdata *conn)
|
||||||
|
{
|
||||||
|
DEBUGASSERT(data);
|
||||||
|
DEBUGASSERT(conn);
|
||||||
|
if(conn->handler->protocol & PROTO_FAMILY_SSH) {
|
||||||
|
struct ssh_conn *sshc = &conn->proto.sshc;
|
||||||
|
if(sshc->ssh_session) {
|
||||||
|
/* only re-attach if the session already exists */
|
||||||
|
void **abstract = libssh2_session_abstract(sshc->ssh_session);
|
||||||
|
*abstract = data;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
#endif /* USE_LIBSSH2 */
|
#endif /* USE_LIBSSH2 */
|
||||||
|
|
|
@ -263,9 +263,12 @@ extern const struct Curl_handler Curl_handler_sftp;
|
||||||
CURLcode Curl_ssh_init(void);
|
CURLcode Curl_ssh_init(void);
|
||||||
void Curl_ssh_cleanup(void);
|
void Curl_ssh_cleanup(void);
|
||||||
size_t Curl_ssh_version(char *buffer, size_t buflen);
|
size_t Curl_ssh_version(char *buffer, size_t buflen);
|
||||||
|
void Curl_ssh_attach(struct Curl_easy *data,
|
||||||
|
struct connectdata *conn);
|
||||||
#else
|
#else
|
||||||
/* for non-SSH builds */
|
/* for non-SSH builds */
|
||||||
#define Curl_ssh_cleanup()
|
#define Curl_ssh_cleanup()
|
||||||
|
#define Curl_ssh_attach(x,y)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif /* HEADER_CURL_SSH_H */
|
#endif /* HEADER_CURL_SSH_H */
|
||||||
|
|
|
@ -91,6 +91,7 @@ const struct Curl_handler Curl_handler_scp = {
|
||||||
wscp_disconnect, /* disconnect */
|
wscp_disconnect, /* disconnect */
|
||||||
ZERO_NULL, /* readwrite */
|
ZERO_NULL, /* readwrite */
|
||||||
ZERO_NULL, /* connection_check */
|
ZERO_NULL, /* connection_check */
|
||||||
|
ZERO_NULL, /* attach connection */
|
||||||
PORT_SSH, /* defport */
|
PORT_SSH, /* defport */
|
||||||
CURLPROTO_SCP, /* protocol */
|
CURLPROTO_SCP, /* protocol */
|
||||||
PROTOPT_DIRLOCK | PROTOPT_CLOSEACTION
|
PROTOPT_DIRLOCK | PROTOPT_CLOSEACTION
|
||||||
|
@ -119,6 +120,7 @@ const struct Curl_handler Curl_handler_sftp = {
|
||||||
wsftp_disconnect, /* disconnect */
|
wsftp_disconnect, /* disconnect */
|
||||||
ZERO_NULL, /* readwrite */
|
ZERO_NULL, /* readwrite */
|
||||||
ZERO_NULL, /* connection_check */
|
ZERO_NULL, /* connection_check */
|
||||||
|
ZERO_NULL, /* attach connection */
|
||||||
PORT_SSH, /* defport */
|
PORT_SSH, /* defport */
|
||||||
CURLPROTO_SFTP, /* protocol */
|
CURLPROTO_SFTP, /* protocol */
|
||||||
CURLPROTO_SFTP, /* family */
|
CURLPROTO_SFTP, /* family */
|
||||||
|
|
Loading…
Reference in New Issue
Block a user