mirror of
https://github.com/moparisthebest/curl
synced 2024-12-23 08:38:49 -05:00
parent
bbe3aa9f88
commit
a304051620
@ -463,7 +463,7 @@ CURLcode Curl_resolver_wait_resolv(struct connectdata *conn,
|
|||||||
if(result || conn->async.done)
|
if(result || conn->async.done)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if(Curl_pgrsUpdate(conn))
|
if(Curl_pgrsUpdate(data))
|
||||||
result = CURLE_ABORTED_BY_CALLBACK;
|
result = CURLE_ABORTED_BY_CALLBACK;
|
||||||
else {
|
else {
|
||||||
struct curltime now2 = Curl_now();
|
struct curltime now2 = Curl_now();
|
||||||
|
@ -144,7 +144,7 @@ static int hyper_each_header(void *userdata,
|
|||||||
|
|
||||||
Curl_debug(data, CURLINFO_HEADER_IN, headp, len);
|
Curl_debug(data, CURLINFO_HEADER_IN, headp, len);
|
||||||
|
|
||||||
result = Curl_client_write(data->conn, CLIENTWRITE_HEADER, headp, len);
|
result = Curl_client_write(data, CLIENTWRITE_HEADER, headp, len);
|
||||||
if(result) {
|
if(result) {
|
||||||
data->state.hresult = CURLE_ABORTED_BY_CALLBACK;
|
data->state.hresult = CURLE_ABORTED_BY_CALLBACK;
|
||||||
return HYPER_ITER_BREAK;
|
return HYPER_ITER_BREAK;
|
||||||
@ -175,7 +175,7 @@ static int hyper_body_chunk(void *userdata, const hyper_buf *chunk)
|
|||||||
if(k->ignorebody)
|
if(k->ignorebody)
|
||||||
return HYPER_ITER_CONTINUE;
|
return HYPER_ITER_CONTINUE;
|
||||||
Curl_debug(data, CURLINFO_DATA_IN, buf, len);
|
Curl_debug(data, CURLINFO_DATA_IN, buf, len);
|
||||||
result = Curl_client_write(data->conn, CLIENTWRITE_BODY, buf, len);
|
result = Curl_client_write(data, CLIENTWRITE_BODY, buf, len);
|
||||||
|
|
||||||
if(result) {
|
if(result) {
|
||||||
data->state.hresult = result;
|
data->state.hresult = result;
|
||||||
|
@ -179,12 +179,14 @@ size_t Curl_conncache_size(struct Curl_easy *data)
|
|||||||
connectdata struct is setup to use.
|
connectdata struct is setup to use.
|
||||||
|
|
||||||
**NOTE**: When it returns, it holds the connection cache lock! */
|
**NOTE**: When it returns, it holds the connection cache lock! */
|
||||||
struct connectbundle *Curl_conncache_find_bundle(struct connectdata *conn,
|
struct connectbundle *
|
||||||
|
Curl_conncache_find_bundle(struct Curl_easy *data,
|
||||||
|
struct connectdata *conn,
|
||||||
struct conncache *connc,
|
struct conncache *connc,
|
||||||
const char **hostp)
|
const char **hostp)
|
||||||
{
|
{
|
||||||
struct connectbundle *bundle = NULL;
|
struct connectbundle *bundle = NULL;
|
||||||
CONNCACHE_LOCK(conn->data);
|
CONNCACHE_LOCK(data);
|
||||||
if(connc) {
|
if(connc) {
|
||||||
char key[HASHKEY_SIZE];
|
char key[HASHKEY_SIZE];
|
||||||
hashkey(conn, key, sizeof(key), hostp);
|
hashkey(conn, key, sizeof(key), hostp);
|
||||||
@ -227,15 +229,17 @@ static void conncache_remove_bundle(struct conncache *connc,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CURLcode Curl_conncache_add_conn(struct conncache *connc,
|
CURLcode Curl_conncache_add_conn(struct Curl_easy *data)
|
||||||
struct connectdata *conn)
|
|
||||||
{
|
{
|
||||||
CURLcode result = CURLE_OK;
|
CURLcode result = CURLE_OK;
|
||||||
struct connectbundle *bundle = NULL;
|
struct connectbundle *bundle = NULL;
|
||||||
struct Curl_easy *data = conn->data;
|
struct connectdata *conn = data->conn;
|
||||||
|
struct conncache *connc = data->state.conn_cache;
|
||||||
|
DEBUGASSERT(conn);
|
||||||
|
|
||||||
/* *find_bundle() locks the connection cache */
|
/* *find_bundle() locks the connection cache */
|
||||||
bundle = Curl_conncache_find_bundle(conn, data->state.conn_cache, NULL);
|
bundle = Curl_conncache_find_bundle(data, conn, data->state.conn_cache,
|
||||||
|
NULL);
|
||||||
if(!bundle) {
|
if(!bundle) {
|
||||||
int rc;
|
int rc;
|
||||||
char key[HASHKEY_SIZE];
|
char key[HASHKEY_SIZE];
|
||||||
@ -259,7 +263,7 @@ CURLcode Curl_conncache_add_conn(struct conncache *connc,
|
|||||||
conn->connection_id = connc->next_connection_id++;
|
conn->connection_id = connc->next_connection_id++;
|
||||||
connc->num_conn++;
|
connc->num_conn++;
|
||||||
|
|
||||||
DEBUGF(infof(conn->data, "Added connection %ld. "
|
DEBUGF(infof(data, "Added connection %ld. "
|
||||||
"The cache now contains %zu members\n",
|
"The cache now contains %zu members\n",
|
||||||
conn->connection_id, connc->num_conn));
|
conn->connection_id, connc->num_conn));
|
||||||
|
|
||||||
@ -270,8 +274,8 @@ CURLcode Curl_conncache_add_conn(struct conncache *connc,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Removes the connectdata object from the connection cache, but does *not*
|
* Removes the connectdata object from the connection cache, but the transfer
|
||||||
* clear the conn->data association. The transfer still owns this connection.
|
* still owns this connection.
|
||||||
*
|
*
|
||||||
* Pass TRUE/FALSE in the 'lock' argument depending on if the parent function
|
* Pass TRUE/FALSE in the 'lock' argument depending on if the parent function
|
||||||
* already holds the lock or not.
|
* already holds the lock or not.
|
||||||
@ -445,7 +449,7 @@ Curl_conncache_extract_bundle(struct Curl_easy *data,
|
|||||||
while(curr) {
|
while(curr) {
|
||||||
conn = curr->ptr;
|
conn = curr->ptr;
|
||||||
|
|
||||||
if(!CONN_INUSE(conn) && !conn->data) {
|
if(!CONN_INUSE(conn)) {
|
||||||
/* Set higher score for the age passed since the connection was used */
|
/* Set higher score for the age passed since the connection was used */
|
||||||
score = Curl_timediff(now, conn->lastused);
|
score = Curl_timediff(now, conn->lastused);
|
||||||
|
|
||||||
@ -503,7 +507,7 @@ Curl_conncache_extract_oldest(struct Curl_easy *data)
|
|||||||
while(curr) {
|
while(curr) {
|
||||||
conn = curr->ptr;
|
conn = curr->ptr;
|
||||||
|
|
||||||
if(!CONN_INUSE(conn) && !conn->data && !conn->bits.close &&
|
if(!CONN_INUSE(conn) && !conn->bits.close &&
|
||||||
!conn->bits.connect_only) {
|
!conn->bits.connect_only) {
|
||||||
/* Set higher score for the age passed since the connection was used */
|
/* Set higher score for the age passed since the connection was used */
|
||||||
score = Curl_timediff(now, conn->lastused);
|
score = Curl_timediff(now, conn->lastused);
|
||||||
@ -544,12 +548,10 @@ void Curl_conncache_close_all_connections(struct conncache *connc)
|
|||||||
conn = conncache_find_first_connection(connc);
|
conn = conncache_find_first_connection(connc);
|
||||||
while(conn) {
|
while(conn) {
|
||||||
SIGPIPE_VARIABLE(pipe_st);
|
SIGPIPE_VARIABLE(pipe_st);
|
||||||
conn->data = connc->closure_handle;
|
sigpipe_ignore(connc->closure_handle, &pipe_st);
|
||||||
|
|
||||||
sigpipe_ignore(conn->data, &pipe_st);
|
|
||||||
/* This will remove the connection from the cache */
|
/* This will remove the connection from the cache */
|
||||||
connclose(conn, "kill all");
|
connclose(conn, "kill all");
|
||||||
Curl_conncache_remove_conn(conn->data, conn, TRUE);
|
Curl_conncache_remove_conn(connc->closure_handle, conn, TRUE);
|
||||||
(void)Curl_disconnect(connc->closure_handle, conn, FALSE);
|
(void)Curl_disconnect(connc->closure_handle, conn, FALSE);
|
||||||
sigpipe_restore(&pipe_st);
|
sigpipe_restore(&pipe_st);
|
||||||
|
|
||||||
|
@ -85,7 +85,8 @@ int Curl_conncache_init(struct conncache *, int size);
|
|||||||
void Curl_conncache_destroy(struct conncache *connc);
|
void Curl_conncache_destroy(struct conncache *connc);
|
||||||
|
|
||||||
/* return the correct bundle, to a host or a proxy */
|
/* return the correct bundle, to a host or a proxy */
|
||||||
struct connectbundle *Curl_conncache_find_bundle(struct connectdata *conn,
|
struct connectbundle *Curl_conncache_find_bundle(struct Curl_easy *data,
|
||||||
|
struct connectdata *conn,
|
||||||
struct conncache *connc,
|
struct conncache *connc,
|
||||||
const char **hostp);
|
const char **hostp);
|
||||||
/* returns number of connections currently held in the connection cache */
|
/* returns number of connections currently held in the connection cache */
|
||||||
@ -93,8 +94,7 @@ size_t Curl_conncache_size(struct Curl_easy *data);
|
|||||||
|
|
||||||
bool Curl_conncache_return_conn(struct Curl_easy *data,
|
bool Curl_conncache_return_conn(struct Curl_easy *data,
|
||||||
struct connectdata *conn);
|
struct connectdata *conn);
|
||||||
CURLcode Curl_conncache_add_conn(struct conncache *connc,
|
CURLcode Curl_conncache_add_conn(struct Curl_easy *data) WARN_UNUSED_RESULT;
|
||||||
struct connectdata *conn) WARN_UNUSED_RESULT;
|
|
||||||
void Curl_conncache_remove_conn(struct Curl_easy *data,
|
void Curl_conncache_remove_conn(struct Curl_easy *data,
|
||||||
struct connectdata *conn,
|
struct connectdata *conn,
|
||||||
bool lock);
|
bool lock);
|
||||||
|
@ -788,13 +788,13 @@ static CURLcode connect_SOCKS(struct Curl_easy *data, int sockindex,
|
|||||||
case CURLPROXY_SOCKS5:
|
case CURLPROXY_SOCKS5:
|
||||||
case CURLPROXY_SOCKS5_HOSTNAME:
|
case CURLPROXY_SOCKS5_HOSTNAME:
|
||||||
pxresult = Curl_SOCKS5(conn->socks_proxy.user, conn->socks_proxy.passwd,
|
pxresult = Curl_SOCKS5(conn->socks_proxy.user, conn->socks_proxy.passwd,
|
||||||
host, port, sockindex, conn, done);
|
host, port, sockindex, data, done);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CURLPROXY_SOCKS4:
|
case CURLPROXY_SOCKS4:
|
||||||
case CURLPROXY_SOCKS4A:
|
case CURLPROXY_SOCKS4A:
|
||||||
pxresult = Curl_SOCKS4(conn->socks_proxy.user, host, port, sockindex,
|
pxresult = Curl_SOCKS4(conn->socks_proxy.user, host, port, sockindex,
|
||||||
conn, done);
|
data, done);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
@ -338,12 +338,12 @@ static CURLcode file_upload(struct Curl_easy *data)
|
|||||||
|
|
||||||
Curl_pgrsSetUploadCounter(data, bytecount);
|
Curl_pgrsSetUploadCounter(data, bytecount);
|
||||||
|
|
||||||
if(Curl_pgrsUpdate(data->conn))
|
if(Curl_pgrsUpdate(data))
|
||||||
result = CURLE_ABORTED_BY_CALLBACK;
|
result = CURLE_ABORTED_BY_CALLBACK;
|
||||||
else
|
else
|
||||||
result = Curl_speedcheck(data, Curl_now());
|
result = Curl_speedcheck(data, Curl_now());
|
||||||
}
|
}
|
||||||
if(!result && Curl_pgrsUpdate(data->conn))
|
if(!result && Curl_pgrsUpdate(data))
|
||||||
result = CURLE_ABORTED_BY_CALLBACK;
|
result = CURLE_ABORTED_BY_CALLBACK;
|
||||||
|
|
||||||
close(fd);
|
close(fd);
|
||||||
@ -527,12 +527,12 @@ static CURLcode file_do(struct Curl_easy *data, bool *done)
|
|||||||
|
|
||||||
Curl_pgrsSetDownloadCounter(data, bytecount);
|
Curl_pgrsSetDownloadCounter(data, bytecount);
|
||||||
|
|
||||||
if(Curl_pgrsUpdate(conn))
|
if(Curl_pgrsUpdate(data))
|
||||||
result = CURLE_ABORTED_BY_CALLBACK;
|
result = CURLE_ABORTED_BY_CALLBACK;
|
||||||
else
|
else
|
||||||
result = Curl_speedcheck(data, Curl_now());
|
result = Curl_speedcheck(data, Curl_now());
|
||||||
}
|
}
|
||||||
if(Curl_pgrsUpdate(conn))
|
if(Curl_pgrsUpdate(data))
|
||||||
result = CURLE_ABORTED_BY_CALLBACK;
|
result = CURLE_ABORTED_BY_CALLBACK;
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
@ -678,7 +678,7 @@ CURLcode Curl_GetFTPResponse(struct Curl_easy *data,
|
|||||||
return CURLE_RECV_ERROR;
|
return CURLE_RECV_ERROR;
|
||||||
|
|
||||||
case 0: /* timeout */
|
case 0: /* timeout */
|
||||||
if(Curl_pgrsUpdate(conn))
|
if(Curl_pgrsUpdate(data))
|
||||||
return CURLE_ABORTED_BY_CALLBACK;
|
return CURLE_ABORTED_BY_CALLBACK;
|
||||||
continue; /* just continue in our loop for the timeout duration */
|
continue; /* just continue in our loop for the timeout duration */
|
||||||
|
|
||||||
@ -2656,7 +2656,7 @@ static CURLcode ftp_statemachine(struct Curl_easy *data,
|
|||||||
size_t nread = 0;
|
size_t nread = 0;
|
||||||
|
|
||||||
if(pp->sendleft)
|
if(pp->sendleft)
|
||||||
return Curl_pp_flushsend(pp);
|
return Curl_pp_flushsend(data, pp);
|
||||||
|
|
||||||
result = ftp_readresp(data, sock, pp, &ftpcode, &nread);
|
result = ftp_readresp(data, sock, pp, &ftpcode, &nread);
|
||||||
if(result)
|
if(result)
|
||||||
|
@ -690,7 +690,7 @@ output_auth_headers(struct Curl_easy *data,
|
|||||||
#ifdef USE_NTLM
|
#ifdef USE_NTLM
|
||||||
if(authstatus->picked == CURLAUTH_NTLM) {
|
if(authstatus->picked == CURLAUTH_NTLM) {
|
||||||
auth = "NTLM";
|
auth = "NTLM";
|
||||||
result = Curl_output_ntlm(conn, proxy);
|
result = Curl_output_ntlm(data, proxy);
|
||||||
if(result)
|
if(result)
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -966,7 +966,7 @@ CURLcode Curl_http_input_auth(struct Curl_easy *data, bool proxy,
|
|||||||
if(authp->picked == CURLAUTH_NTLM ||
|
if(authp->picked == CURLAUTH_NTLM ||
|
||||||
authp->picked == CURLAUTH_NTLM_WB) {
|
authp->picked == CURLAUTH_NTLM_WB) {
|
||||||
/* NTLM authentication is picked and activated */
|
/* NTLM authentication is picked and activated */
|
||||||
CURLcode result = Curl_input_ntlm(conn, proxy, auth);
|
CURLcode result = Curl_input_ntlm(data, proxy, auth);
|
||||||
if(!result) {
|
if(!result) {
|
||||||
data->state.authproblem = FALSE;
|
data->state.authproblem = FALSE;
|
||||||
#ifdef NTLM_WB_ENABLED
|
#ifdef NTLM_WB_ENABLED
|
||||||
@ -3184,7 +3184,7 @@ CURLcode Curl_http(struct Curl_easy *data, bool *done)
|
|||||||
/* if a request-body has been sent off, we make sure this progress is noted
|
/* if a request-body has been sent off, we make sure this progress is noted
|
||||||
properly */
|
properly */
|
||||||
Curl_pgrsSetUploadCounter(data, data->req.writebytecount);
|
Curl_pgrsSetUploadCounter(data, data->req.writebytecount);
|
||||||
if(Curl_pgrsUpdate(conn))
|
if(Curl_pgrsUpdate(data))
|
||||||
result = CURLE_ABORTED_BY_CALLBACK;
|
result = CURLE_ABORTED_BY_CALLBACK;
|
||||||
|
|
||||||
if(!http->postsize) {
|
if(!http->postsize) {
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
* | (__| |_| | _ <| |___
|
* | (__| |_| | _ <| |___
|
||||||
* \___|\___/|_| \_\_____|
|
* \___|\___/|_| \_\_____|
|
||||||
*
|
*
|
||||||
* Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
|
* Copyright (C) 1998 - 2021, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||||
*
|
*
|
||||||
* This software is licensed as described in the file COPYING, which
|
* This software is licensed as described in the file COPYING, which
|
||||||
* you should have received as part of this distribution. The terms
|
* you should have received as part of this distribution. The terms
|
||||||
@ -59,7 +59,7 @@
|
|||||||
# define DEBUG_OUT(x) Curl_nop_stmt
|
# define DEBUG_OUT(x) Curl_nop_stmt
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
CURLcode Curl_input_ntlm(struct connectdata *conn,
|
CURLcode Curl_input_ntlm(struct Curl_easy *data,
|
||||||
bool proxy, /* if proxy or not */
|
bool proxy, /* if proxy or not */
|
||||||
const char *header) /* rest of the www-authenticate:
|
const char *header) /* rest of the www-authenticate:
|
||||||
header */
|
header */
|
||||||
@ -68,6 +68,7 @@ CURLcode Curl_input_ntlm(struct connectdata *conn,
|
|||||||
struct ntlmdata *ntlm;
|
struct ntlmdata *ntlm;
|
||||||
curlntlm *state;
|
curlntlm *state;
|
||||||
CURLcode result = CURLE_OK;
|
CURLcode result = CURLE_OK;
|
||||||
|
struct connectdata *conn = data->conn;
|
||||||
|
|
||||||
ntlm = proxy ? &conn->proxyntlm : &conn->ntlm;
|
ntlm = proxy ? &conn->proxyntlm : &conn->ntlm;
|
||||||
state = proxy ? &conn->proxy_ntlm_state : &conn->http_ntlm_state;
|
state = proxy ? &conn->proxy_ntlm_state : &conn->http_ntlm_state;
|
||||||
@ -79,7 +80,7 @@ CURLcode Curl_input_ntlm(struct connectdata *conn,
|
|||||||
header++;
|
header++;
|
||||||
|
|
||||||
if(*header) {
|
if(*header) {
|
||||||
result = Curl_auth_decode_ntlm_type2_message(conn->data, header, ntlm);
|
result = Curl_auth_decode_ntlm_type2_message(data, header, ntlm);
|
||||||
if(result)
|
if(result)
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
@ -87,17 +88,17 @@ CURLcode Curl_input_ntlm(struct connectdata *conn,
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if(*state == NTLMSTATE_LAST) {
|
if(*state == NTLMSTATE_LAST) {
|
||||||
infof(conn->data, "NTLM auth restarted\n");
|
infof(data, "NTLM auth restarted\n");
|
||||||
Curl_http_auth_cleanup_ntlm(conn);
|
Curl_http_auth_cleanup_ntlm(conn);
|
||||||
}
|
}
|
||||||
else if(*state == NTLMSTATE_TYPE3) {
|
else if(*state == NTLMSTATE_TYPE3) {
|
||||||
infof(conn->data, "NTLM handshake rejected\n");
|
infof(data, "NTLM handshake rejected\n");
|
||||||
Curl_http_auth_cleanup_ntlm(conn);
|
Curl_http_auth_cleanup_ntlm(conn);
|
||||||
*state = NTLMSTATE_NONE;
|
*state = NTLMSTATE_NONE;
|
||||||
return CURLE_REMOTE_ACCESS_DENIED;
|
return CURLE_REMOTE_ACCESS_DENIED;
|
||||||
}
|
}
|
||||||
else if(*state >= NTLMSTATE_TYPE1) {
|
else if(*state >= NTLMSTATE_TYPE1) {
|
||||||
infof(conn->data, "NTLM handshake failure (internal error)\n");
|
infof(data, "NTLM handshake failure (internal error)\n");
|
||||||
return CURLE_REMOTE_ACCESS_DENIED;
|
return CURLE_REMOTE_ACCESS_DENIED;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -111,7 +112,7 @@ CURLcode Curl_input_ntlm(struct connectdata *conn,
|
|||||||
/*
|
/*
|
||||||
* This is for creating ntlm header output
|
* This is for creating ntlm header output
|
||||||
*/
|
*/
|
||||||
CURLcode Curl_output_ntlm(struct connectdata *conn, bool proxy)
|
CURLcode Curl_output_ntlm(struct Curl_easy *data, bool proxy)
|
||||||
{
|
{
|
||||||
char *base64 = NULL;
|
char *base64 = NULL;
|
||||||
size_t len = 0;
|
size_t len = 0;
|
||||||
@ -131,8 +132,7 @@ CURLcode Curl_output_ntlm(struct connectdata *conn, bool proxy)
|
|||||||
struct ntlmdata *ntlm;
|
struct ntlmdata *ntlm;
|
||||||
curlntlm *state;
|
curlntlm *state;
|
||||||
struct auth *authp;
|
struct auth *authp;
|
||||||
struct Curl_easy *data = conn->data;
|
struct connectdata *conn = data->conn;
|
||||||
|
|
||||||
|
|
||||||
DEBUGASSERT(conn);
|
DEBUGASSERT(conn);
|
||||||
DEBUGASSERT(data);
|
DEBUGASSERT(data);
|
||||||
@ -142,12 +142,12 @@ CURLcode Curl_output_ntlm(struct connectdata *conn, bool proxy)
|
|||||||
allocuserpwd = &data->state.aptr.proxyuserpwd;
|
allocuserpwd = &data->state.aptr.proxyuserpwd;
|
||||||
userp = conn->http_proxy.user;
|
userp = conn->http_proxy.user;
|
||||||
passwdp = conn->http_proxy.passwd;
|
passwdp = conn->http_proxy.passwd;
|
||||||
service = conn->data->set.str[STRING_PROXY_SERVICE_NAME] ?
|
service = data->set.str[STRING_PROXY_SERVICE_NAME] ?
|
||||||
conn->data->set.str[STRING_PROXY_SERVICE_NAME] : "HTTP";
|
data->set.str[STRING_PROXY_SERVICE_NAME] : "HTTP";
|
||||||
hostname = conn->http_proxy.host.name;
|
hostname = conn->http_proxy.host.name;
|
||||||
ntlm = &conn->proxyntlm;
|
ntlm = &conn->proxyntlm;
|
||||||
state = &conn->proxy_ntlm_state;
|
state = &conn->proxy_ntlm_state;
|
||||||
authp = &conn->data->state.authproxy;
|
authp = &data->state.authproxy;
|
||||||
#else
|
#else
|
||||||
return CURLE_NOT_BUILT_IN;
|
return CURLE_NOT_BUILT_IN;
|
||||||
#endif
|
#endif
|
||||||
@ -156,12 +156,12 @@ CURLcode Curl_output_ntlm(struct connectdata *conn, bool proxy)
|
|||||||
allocuserpwd = &data->state.aptr.userpwd;
|
allocuserpwd = &data->state.aptr.userpwd;
|
||||||
userp = conn->user;
|
userp = conn->user;
|
||||||
passwdp = conn->passwd;
|
passwdp = conn->passwd;
|
||||||
service = conn->data->set.str[STRING_SERVICE_NAME] ?
|
service = data->set.str[STRING_SERVICE_NAME] ?
|
||||||
conn->data->set.str[STRING_SERVICE_NAME] : "HTTP";
|
data->set.str[STRING_SERVICE_NAME] : "HTTP";
|
||||||
hostname = conn->host.name;
|
hostname = conn->host.name;
|
||||||
ntlm = &conn->ntlm;
|
ntlm = &conn->ntlm;
|
||||||
state = &conn->http_ntlm_state;
|
state = &conn->http_ntlm_state;
|
||||||
authp = &conn->data->state.authhost;
|
authp = &data->state.authhost;
|
||||||
}
|
}
|
||||||
authp->done = FALSE;
|
authp->done = FALSE;
|
||||||
|
|
||||||
@ -188,7 +188,7 @@ CURLcode Curl_output_ntlm(struct connectdata *conn, bool proxy)
|
|||||||
case NTLMSTATE_TYPE1:
|
case NTLMSTATE_TYPE1:
|
||||||
default: /* for the weird cases we (re)start here */
|
default: /* for the weird cases we (re)start here */
|
||||||
/* Create a type-1 message */
|
/* Create a type-1 message */
|
||||||
result = Curl_auth_create_ntlm_type1_message(conn->data, userp, passwdp,
|
result = Curl_auth_create_ntlm_type1_message(data, userp, passwdp,
|
||||||
service, hostname,
|
service, hostname,
|
||||||
ntlm, &base64,
|
ntlm, &base64,
|
||||||
&len);
|
&len);
|
||||||
@ -210,7 +210,7 @@ CURLcode Curl_output_ntlm(struct connectdata *conn, bool proxy)
|
|||||||
|
|
||||||
case NTLMSTATE_TYPE2:
|
case NTLMSTATE_TYPE2:
|
||||||
/* We already received the type-2 message, create a type-3 message */
|
/* We already received the type-2 message, create a type-3 message */
|
||||||
result = Curl_auth_create_ntlm_type3_message(conn->data, userp, passwdp,
|
result = Curl_auth_create_ntlm_type3_message(data, userp, passwdp,
|
||||||
ntlm, &base64, &len);
|
ntlm, &base64, &len);
|
||||||
if(result)
|
if(result)
|
||||||
return result;
|
return result;
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
* | (__| |_| | _ <| |___
|
* | (__| |_| | _ <| |___
|
||||||
* \___|\___/|_| \_\_____|
|
* \___|\___/|_| \_\_____|
|
||||||
*
|
*
|
||||||
* Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
|
* Copyright (C) 1998 - 2021, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||||
*
|
*
|
||||||
* This software is licensed as described in the file COPYING, which
|
* This software is licensed as described in the file COPYING, which
|
||||||
* you should have received as part of this distribution. The terms
|
* you should have received as part of this distribution. The terms
|
||||||
@ -27,11 +27,11 @@
|
|||||||
#if !defined(CURL_DISABLE_HTTP) && defined(USE_NTLM)
|
#if !defined(CURL_DISABLE_HTTP) && defined(USE_NTLM)
|
||||||
|
|
||||||
/* this is for ntlm header input */
|
/* this is for ntlm header input */
|
||||||
CURLcode Curl_input_ntlm(struct connectdata *conn, bool proxy,
|
CURLcode Curl_input_ntlm(struct Curl_easy *data, bool proxy,
|
||||||
const char *header);
|
const char *header);
|
||||||
|
|
||||||
/* this is for creating ntlm header output */
|
/* this is for creating ntlm header output */
|
||||||
CURLcode Curl_output_ntlm(struct connectdata *conn, bool proxy);
|
CURLcode Curl_output_ntlm(struct Curl_easy *data, bool proxy);
|
||||||
|
|
||||||
void Curl_http_auth_cleanup_ntlm(struct connectdata *conn);
|
void Curl_http_auth_cleanup_ntlm(struct connectdata *conn);
|
||||||
|
|
||||||
|
@ -347,7 +347,7 @@ static CURLcode CONNECT(struct connectdata *conn,
|
|||||||
/* socket buffer drained, return */
|
/* socket buffer drained, return */
|
||||||
return CURLE_OK;
|
return CURLE_OK;
|
||||||
|
|
||||||
if(Curl_pgrsUpdate(conn))
|
if(Curl_pgrsUpdate(data))
|
||||||
return CURLE_ABORTED_BY_CALLBACK;
|
return CURLE_ABORTED_BY_CALLBACK;
|
||||||
|
|
||||||
if(result) {
|
if(result) {
|
||||||
@ -560,7 +560,7 @@ static CURLcode CONNECT(struct connectdata *conn,
|
|||||||
Curl_dyn_reset(&s->rcvbuf);
|
Curl_dyn_reset(&s->rcvbuf);
|
||||||
} /* while there's buffer left and loop is requested */
|
} /* while there's buffer left and loop is requested */
|
||||||
|
|
||||||
if(Curl_pgrsUpdate(conn))
|
if(Curl_pgrsUpdate(data))
|
||||||
return CURLE_ABORTED_BY_CALLBACK;
|
return CURLE_ABORTED_BY_CALLBACK;
|
||||||
|
|
||||||
if(error)
|
if(error)
|
||||||
|
@ -1284,7 +1284,7 @@ static CURLcode imap_statemachine(struct Curl_easy *data,
|
|||||||
|
|
||||||
/* Flush any data that needs to be sent */
|
/* Flush any data that needs to be sent */
|
||||||
if(pp->sendleft)
|
if(pp->sendleft)
|
||||||
return Curl_pp_flushsend(pp);
|
return Curl_pp_flushsend(data, pp);
|
||||||
|
|
||||||
do {
|
do {
|
||||||
/* Read the response from the server */
|
/* Read the response from the server */
|
||||||
|
@ -593,7 +593,7 @@ static CURLcode multi_done(struct Curl_easy *data,
|
|||||||
if(CURLE_ABORTED_BY_CALLBACK != result) {
|
if(CURLE_ABORTED_BY_CALLBACK != result) {
|
||||||
/* avoid this if we already aborted by callback to avoid this calling
|
/* avoid this if we already aborted by callback to avoid this calling
|
||||||
another callback */
|
another callback */
|
||||||
CURLcode rc = Curl_pgrsDone(conn);
|
CURLcode rc = Curl_pgrsDone(data);
|
||||||
if(!result && rc)
|
if(!result && rc)
|
||||||
result = CURLE_ABORTED_BY_CALLBACK;
|
result = CURLE_ABORTED_BY_CALLBACK;
|
||||||
}
|
}
|
||||||
@ -2069,7 +2069,7 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
|
|||||||
case CURLM_STATE_TOOFAST: /* limit-rate exceeded in either direction */
|
case CURLM_STATE_TOOFAST: /* limit-rate exceeded in either direction */
|
||||||
DEBUGASSERT(data->conn);
|
DEBUGASSERT(data->conn);
|
||||||
/* if both rates are within spec, resume transfer */
|
/* if both rates are within spec, resume transfer */
|
||||||
if(Curl_pgrsUpdate(data->conn))
|
if(Curl_pgrsUpdate(data))
|
||||||
result = CURLE_ABORTED_BY_CALLBACK;
|
result = CURLE_ABORTED_BY_CALLBACK;
|
||||||
else
|
else
|
||||||
result = Curl_speedcheck(data, *nowp);
|
result = Curl_speedcheck(data, *nowp);
|
||||||
@ -2352,7 +2352,7 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
|
|||||||
rc = CURLM_CALL_MULTI_PERFORM;
|
rc = CURLM_CALL_MULTI_PERFORM;
|
||||||
}
|
}
|
||||||
/* if there's still a connection to use, call the progress function */
|
/* if there's still a connection to use, call the progress function */
|
||||||
else if(data->conn && Curl_pgrsUpdate(data->conn)) {
|
else if(data->conn && Curl_pgrsUpdate(data)) {
|
||||||
/* aborted due to progress callback return code must close the
|
/* aborted due to progress callback return code must close the
|
||||||
connection */
|
connection */
|
||||||
result = CURLE_ABORTED_BY_CALLBACK;
|
result = CURLE_ABORTED_BY_CALLBACK;
|
||||||
|
@ -117,7 +117,7 @@ CURLcode Curl_pp_statemach(struct Curl_easy *data,
|
|||||||
|
|
||||||
if(block) {
|
if(block) {
|
||||||
/* if we didn't wait, we don't have to spend time on this now */
|
/* if we didn't wait, we don't have to spend time on this now */
|
||||||
if(Curl_pgrsUpdate(conn))
|
if(Curl_pgrsUpdate(data))
|
||||||
result = CURLE_ABORTED_BY_CALLBACK;
|
result = CURLE_ABORTED_BY_CALLBACK;
|
||||||
else
|
else
|
||||||
result = Curl_speedcheck(data, Curl_now());
|
result = Curl_speedcheck(data, Curl_now());
|
||||||
@ -469,13 +469,14 @@ int Curl_pp_getsock(struct pingpong *pp, curl_socket_t *socks)
|
|||||||
return GETSOCK_READSOCK(0);
|
return GETSOCK_READSOCK(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
CURLcode Curl_pp_flushsend(struct pingpong *pp)
|
CURLcode Curl_pp_flushsend(struct Curl_easy *data,
|
||||||
|
struct pingpong *pp)
|
||||||
{
|
{
|
||||||
/* we have a piece of a command still left to send */
|
/* we have a piece of a command still left to send */
|
||||||
struct connectdata *conn = pp->conn;
|
struct connectdata *conn = pp->conn;
|
||||||
ssize_t written;
|
ssize_t written;
|
||||||
curl_socket_t sock = conn->sock[FIRSTSOCKET];
|
curl_socket_t sock = conn->sock[FIRSTSOCKET];
|
||||||
CURLcode result = Curl_write(conn->data, sock, pp->sendthis + pp->sendsize -
|
CURLcode result = Curl_write(data, sock, pp->sendthis + pp->sendsize -
|
||||||
pp->sendleft, pp->sendleft, &written);
|
pp->sendleft, pp->sendleft, &written);
|
||||||
if(result)
|
if(result)
|
||||||
return result;
|
return result;
|
||||||
|
@ -143,7 +143,8 @@ CURLcode Curl_pp_readresp(struct Curl_easy *data,
|
|||||||
size_t *size); /* size of the response */
|
size_t *size); /* size of the response */
|
||||||
|
|
||||||
|
|
||||||
CURLcode Curl_pp_flushsend(struct pingpong *pp);
|
CURLcode Curl_pp_flushsend(struct Curl_easy *data,
|
||||||
|
struct pingpong *pp);
|
||||||
|
|
||||||
/* call this when a pingpong connection is disconnected */
|
/* call this when a pingpong connection is disconnected */
|
||||||
CURLcode Curl_pp_disconnect(struct pingpong *pp);
|
CURLcode Curl_pp_disconnect(struct pingpong *pp);
|
||||||
|
@ -962,7 +962,7 @@ static CURLcode pop3_statemachine(struct Curl_easy *data,
|
|||||||
|
|
||||||
/* Flush any data that needs to be sent */
|
/* Flush any data that needs to be sent */
|
||||||
if(pp->sendleft)
|
if(pp->sendleft)
|
||||||
return Curl_pp_flushsend(pp);
|
return Curl_pp_flushsend(data, pp);
|
||||||
|
|
||||||
do {
|
do {
|
||||||
/* Read the response from the server */
|
/* Read the response from the server */
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
* | (__| |_| | _ <| |___
|
* | (__| |_| | _ <| |___
|
||||||
* \___|\___/|_| \_\_____|
|
* \___|\___/|_| \_\_____|
|
||||||
*
|
*
|
||||||
* Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
|
* Copyright (C) 1998 - 2021, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||||
*
|
*
|
||||||
* This software is licensed as described in the file COPYING, which
|
* This software is licensed as described in the file COPYING, which
|
||||||
* you should have received as part of this distribution. The terms
|
* you should have received as part of this distribution. The terms
|
||||||
@ -137,12 +137,11 @@ static char *max5data(curl_off_t bytes, char *max5)
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int Curl_pgrsDone(struct connectdata *conn)
|
int Curl_pgrsDone(struct Curl_easy *data)
|
||||||
{
|
{
|
||||||
int rc;
|
int rc;
|
||||||
struct Curl_easy *data = conn->data;
|
|
||||||
data->progress.lastshow = 0;
|
data->progress.lastshow = 0;
|
||||||
rc = Curl_pgrsUpdate(conn); /* the final (forced) update */
|
rc = Curl_pgrsUpdate(data); /* the final (forced) update */
|
||||||
if(rc)
|
if(rc)
|
||||||
return rc;
|
return rc;
|
||||||
|
|
||||||
@ -371,11 +370,10 @@ void Curl_pgrsSetUploadSize(struct Curl_easy *data, curl_off_t size)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* returns TRUE if it's time to show the progress meter */
|
/* returns TRUE if it's time to show the progress meter */
|
||||||
static bool progress_calc(struct connectdata *conn, struct curltime now)
|
static bool progress_calc(struct Curl_easy *data, struct curltime now)
|
||||||
{
|
{
|
||||||
curl_off_t timespent;
|
curl_off_t timespent;
|
||||||
curl_off_t timespent_ms; /* milliseconds */
|
curl_off_t timespent_ms; /* milliseconds */
|
||||||
struct Curl_easy *data = conn->data;
|
|
||||||
curl_off_t dl = data->progress.downloaded;
|
curl_off_t dl = data->progress.downloaded;
|
||||||
curl_off_t ul = data->progress.uploaded;
|
curl_off_t ul = data->progress.uploaded;
|
||||||
bool timetoshow = FALSE;
|
bool timetoshow = FALSE;
|
||||||
@ -465,9 +463,8 @@ static bool progress_calc(struct connectdata *conn, struct curltime now)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifndef CURL_DISABLE_PROGRESS_METER
|
#ifndef CURL_DISABLE_PROGRESS_METER
|
||||||
static void progress_meter(struct connectdata *conn)
|
static void progress_meter(struct Curl_easy *data)
|
||||||
{
|
{
|
||||||
struct Curl_easy *data = conn->data;
|
|
||||||
char max5[6][10];
|
char max5[6][10];
|
||||||
curl_off_t dlpercen = 0;
|
curl_off_t dlpercen = 0;
|
||||||
curl_off_t ulpercen = 0;
|
curl_off_t ulpercen = 0;
|
||||||
@ -581,11 +578,10 @@ static void progress_meter(struct connectdata *conn)
|
|||||||
* Curl_pgrsUpdate() returns 0 for success or the value returned by the
|
* Curl_pgrsUpdate() returns 0 for success or the value returned by the
|
||||||
* progress callback!
|
* progress callback!
|
||||||
*/
|
*/
|
||||||
int Curl_pgrsUpdate(struct connectdata *conn)
|
int Curl_pgrsUpdate(struct Curl_easy *data)
|
||||||
{
|
{
|
||||||
struct Curl_easy *data = conn->data;
|
|
||||||
struct curltime now = Curl_now(); /* what time is it */
|
struct curltime now = Curl_now(); /* what time is it */
|
||||||
bool showprogress = progress_calc(conn, now);
|
bool showprogress = progress_calc(data, now);
|
||||||
if(!(data->progress.flags & PGRS_HIDE)) {
|
if(!(data->progress.flags & PGRS_HIDE)) {
|
||||||
if(data->set.fxferinfo) {
|
if(data->set.fxferinfo) {
|
||||||
int result;
|
int result;
|
||||||
@ -621,7 +617,7 @@ int Curl_pgrsUpdate(struct connectdata *conn)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(showprogress)
|
if(showprogress)
|
||||||
progress_meter(conn);
|
progress_meter(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
* | (__| |_| | _ <| |___
|
* | (__| |_| | _ <| |___
|
||||||
* \___|\___/|_| \_\_____|
|
* \___|\___/|_| \_\_____|
|
||||||
*
|
*
|
||||||
* Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
|
* Copyright (C) 1998 - 2021, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||||
*
|
*
|
||||||
* This software is licensed as described in the file COPYING, which
|
* This software is licensed as described in the file COPYING, which
|
||||||
* you should have received as part of this distribution. The terms
|
* you should have received as part of this distribution. The terms
|
||||||
@ -40,14 +40,14 @@ typedef enum {
|
|||||||
TIMER_LAST /* must be last */
|
TIMER_LAST /* must be last */
|
||||||
} timerid;
|
} timerid;
|
||||||
|
|
||||||
int Curl_pgrsDone(struct connectdata *);
|
int Curl_pgrsDone(struct Curl_easy *data);
|
||||||
void Curl_pgrsStartNow(struct Curl_easy *data);
|
void Curl_pgrsStartNow(struct Curl_easy *data);
|
||||||
void Curl_pgrsSetDownloadSize(struct Curl_easy *data, curl_off_t size);
|
void Curl_pgrsSetDownloadSize(struct Curl_easy *data, curl_off_t size);
|
||||||
void Curl_pgrsSetUploadSize(struct Curl_easy *data, curl_off_t size);
|
void Curl_pgrsSetUploadSize(struct Curl_easy *data, curl_off_t size);
|
||||||
void Curl_pgrsSetDownloadCounter(struct Curl_easy *data, curl_off_t size);
|
void Curl_pgrsSetDownloadCounter(struct Curl_easy *data, curl_off_t size);
|
||||||
void Curl_pgrsSetUploadCounter(struct Curl_easy *data, curl_off_t size);
|
void Curl_pgrsSetUploadCounter(struct Curl_easy *data, curl_off_t size);
|
||||||
void Curl_ratelimit(struct Curl_easy *data, struct curltime now);
|
void Curl_ratelimit(struct Curl_easy *data, struct curltime now);
|
||||||
int Curl_pgrsUpdate(struct connectdata *);
|
int Curl_pgrsUpdate(struct Curl_easy *data);
|
||||||
void Curl_pgrsResetTransferSizes(struct Curl_easy *data);
|
void Curl_pgrsResetTransferSizes(struct Curl_easy *data);
|
||||||
struct curltime Curl_pgrsTime(struct Curl_easy *data, timerid timer);
|
struct curltime Curl_pgrsTime(struct Curl_easy *data, timerid timer);
|
||||||
timediff_t Curl_pgrsLimitWaitTime(curl_off_t cursize,
|
timediff_t Curl_pgrsLimitWaitTime(curl_off_t cursize,
|
||||||
|
@ -590,7 +590,7 @@ static CURLcode rtsp_do(struct Curl_easy *data, bool *done)
|
|||||||
/* if a request-body has been sent off, we make sure this progress is
|
/* if a request-body has been sent off, we make sure this progress is
|
||||||
noted properly */
|
noted properly */
|
||||||
Curl_pgrsSetUploadCounter(data, data->req.writebytecount);
|
Curl_pgrsSetUploadCounter(data, data->req.writebytecount);
|
||||||
if(Curl_pgrsUpdate(conn))
|
if(Curl_pgrsUpdate(data))
|
||||||
result = CURLE_ABORTED_BY_CALLBACK;
|
result = CURLE_ABORTED_BY_CALLBACK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1179,7 +1179,7 @@ static CURLcode smtp_statemachine(struct Curl_easy *data,
|
|||||||
|
|
||||||
/* Flush any data that needs to be sent */
|
/* Flush any data that needs to be sent */
|
||||||
if(pp->sendleft)
|
if(pp->sendleft)
|
||||||
return Curl_pp_flushsend(pp);
|
return Curl_pp_flushsend(data, pp);
|
||||||
|
|
||||||
do {
|
do {
|
||||||
/* Read the response from the server */
|
/* Read the response from the server */
|
||||||
|
75
lib/socks.c
75
lib/socks.c
@ -51,7 +51,7 @@
|
|||||||
*
|
*
|
||||||
* This is STUPID BLOCKING behavior. Only used by the SOCKS GSSAPI functions.
|
* This is STUPID BLOCKING behavior. Only used by the SOCKS GSSAPI functions.
|
||||||
*/
|
*/
|
||||||
int Curl_blockread_all(struct connectdata *conn, /* connection data */
|
int Curl_blockread_all(struct Curl_easy *data, /* transfer */
|
||||||
curl_socket_t sockfd, /* read from this socket */
|
curl_socket_t sockfd, /* read from this socket */
|
||||||
char *buf, /* store read data here */
|
char *buf, /* store read data here */
|
||||||
ssize_t buffersize, /* max amount to read */
|
ssize_t buffersize, /* max amount to read */
|
||||||
@ -62,7 +62,7 @@ int Curl_blockread_all(struct connectdata *conn, /* connection data */
|
|||||||
int result;
|
int result;
|
||||||
*n = 0;
|
*n = 0;
|
||||||
for(;;) {
|
for(;;) {
|
||||||
timediff_t timeout_ms = Curl_timeleft(conn->data, NULL, TRUE);
|
timediff_t timeout_ms = Curl_timeleft(data, NULL, TRUE);
|
||||||
if(timeout_ms < 0) {
|
if(timeout_ms < 0) {
|
||||||
/* we already got the timeout */
|
/* we already got the timeout */
|
||||||
result = CURLE_OPERATION_TIMEDOUT;
|
result = CURLE_OPERATION_TIMEDOUT;
|
||||||
@ -107,13 +107,14 @@ int Curl_blockread_all(struct connectdata *conn, /* connection data */
|
|||||||
|
|
||||||
|
|
||||||
/* always use this function to change state, to make debugging easier */
|
/* always use this function to change state, to make debugging easier */
|
||||||
static void socksstate(struct connectdata *conn,
|
static void socksstate(struct Curl_easy *data,
|
||||||
enum connect_t state
|
enum connect_t state
|
||||||
#ifdef DEBUGBUILD
|
#ifdef DEBUGBUILD
|
||||||
, int lineno
|
, int lineno
|
||||||
#endif
|
#endif
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
struct connectdata *conn = data->conn;
|
||||||
enum connect_t oldstate = conn->cnnct.state;
|
enum connect_t oldstate = conn->cnnct.state;
|
||||||
#if defined(DEBUGBUILD) && !defined(CURL_DISABLE_VERBOSE_STRINGS)
|
#if defined(DEBUGBUILD) && !defined(CURL_DISABLE_VERBOSE_STRINGS)
|
||||||
/* synced with the state list in urldata.h */
|
/* synced with the state list in urldata.h */
|
||||||
@ -146,7 +147,7 @@ static void socksstate(struct connectdata *conn,
|
|||||||
conn->cnnct.state = state;
|
conn->cnnct.state = state;
|
||||||
|
|
||||||
#if defined(DEBUGBUILD) && !defined(CURL_DISABLE_VERBOSE_STRINGS)
|
#if defined(DEBUGBUILD) && !defined(CURL_DISABLE_VERBOSE_STRINGS)
|
||||||
infof(conn->data,
|
infof(data,
|
||||||
"SXSTATE: %s => %s conn %p; line %d\n",
|
"SXSTATE: %s => %s conn %p; line %d\n",
|
||||||
statename[oldstate], statename[conn->cnnct.state], conn,
|
statename[oldstate], statename[conn->cnnct.state], conn,
|
||||||
lineno);
|
lineno);
|
||||||
@ -188,29 +189,29 @@ CURLproxycode Curl_SOCKS4(const char *proxy_user,
|
|||||||
const char *hostname,
|
const char *hostname,
|
||||||
int remote_port,
|
int remote_port,
|
||||||
int sockindex,
|
int sockindex,
|
||||||
struct connectdata *conn,
|
struct Curl_easy *data,
|
||||||
bool *done)
|
bool *done)
|
||||||
{
|
{
|
||||||
|
struct connectdata *conn = data->conn;
|
||||||
const bool protocol4a =
|
const bool protocol4a =
|
||||||
(conn->socks_proxy.proxytype == CURLPROXY_SOCKS4A) ? TRUE : FALSE;
|
(conn->socks_proxy.proxytype == CURLPROXY_SOCKS4A) ? TRUE : FALSE;
|
||||||
unsigned char *socksreq = &conn->cnnct.socksreq[0];
|
unsigned char *socksreq = &conn->cnnct.socksreq[0];
|
||||||
CURLcode result;
|
CURLcode result;
|
||||||
curl_socket_t sockfd = conn->sock[sockindex];
|
curl_socket_t sockfd = conn->sock[sockindex];
|
||||||
struct Curl_easy *data = conn->data;
|
|
||||||
struct connstate *sx = &conn->cnnct;
|
struct connstate *sx = &conn->cnnct;
|
||||||
struct Curl_dns_entry *dns = NULL;
|
struct Curl_dns_entry *dns = NULL;
|
||||||
ssize_t actualread;
|
ssize_t actualread;
|
||||||
ssize_t written;
|
ssize_t written;
|
||||||
|
|
||||||
if(!SOCKS_STATE(sx->state) && !*done)
|
if(!SOCKS_STATE(sx->state) && !*done)
|
||||||
sxstate(conn, CONNECT_SOCKS_INIT);
|
sxstate(data, CONNECT_SOCKS_INIT);
|
||||||
|
|
||||||
switch(sx->state) {
|
switch(sx->state) {
|
||||||
case CONNECT_SOCKS_INIT:
|
case CONNECT_SOCKS_INIT:
|
||||||
/* SOCKS4 can only do IPv4, insist! */
|
/* SOCKS4 can only do IPv4, insist! */
|
||||||
conn->ip_version = CURL_IPRESOLVE_V4;
|
conn->ip_version = CURL_IPRESOLVE_V4;
|
||||||
if(conn->bits.httpproxy)
|
if(conn->bits.httpproxy)
|
||||||
infof(conn->data, "SOCKS4%s: connecting to HTTP proxy %s port %d\n",
|
infof(data, "SOCKS4%s: connecting to HTTP proxy %s port %d\n",
|
||||||
protocol4a ? "a" : "", hostname, remote_port);
|
protocol4a ? "a" : "", hostname, remote_port);
|
||||||
|
|
||||||
infof(data, "SOCKS4 communication to %s:%d\n", hostname, remote_port);
|
infof(data, "SOCKS4 communication to %s:%d\n", hostname, remote_port);
|
||||||
@ -239,16 +240,16 @@ CURLproxycode Curl_SOCKS4(const char *proxy_user,
|
|||||||
if(rc == CURLRESOLV_ERROR)
|
if(rc == CURLRESOLV_ERROR)
|
||||||
return CURLPX_RESOLVE_HOST;
|
return CURLPX_RESOLVE_HOST;
|
||||||
else if(rc == CURLRESOLV_PENDING) {
|
else if(rc == CURLRESOLV_PENDING) {
|
||||||
sxstate(conn, CONNECT_RESOLVING);
|
sxstate(data, CONNECT_RESOLVING);
|
||||||
infof(data, "SOCKS4 non-blocking resolve of %s\n", hostname);
|
infof(data, "SOCKS4 non-blocking resolve of %s\n", hostname);
|
||||||
return CURLPX_OK;
|
return CURLPX_OK;
|
||||||
}
|
}
|
||||||
sxstate(conn, CONNECT_RESOLVED);
|
sxstate(data, CONNECT_RESOLVED);
|
||||||
goto CONNECT_RESOLVED;
|
goto CONNECT_RESOLVED;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* socks4a doesn't resolve anything locally */
|
/* socks4a doesn't resolve anything locally */
|
||||||
sxstate(conn, CONNECT_REQ_INIT);
|
sxstate(data, CONNECT_REQ_INIT);
|
||||||
goto CONNECT_REQ_INIT;
|
goto CONNECT_REQ_INIT;
|
||||||
|
|
||||||
case CONNECT_RESOLVING:
|
case CONNECT_RESOLVING:
|
||||||
@ -261,7 +262,7 @@ CURLproxycode Curl_SOCKS4(const char *proxy_user,
|
|||||||
conn->async.done = TRUE;
|
conn->async.done = TRUE;
|
||||||
#endif
|
#endif
|
||||||
infof(data, "Hostname '%s' was found\n", hostname);
|
infof(data, "Hostname '%s' was found\n", hostname);
|
||||||
sxstate(conn, CONNECT_RESOLVED);
|
sxstate(data, CONNECT_RESOLVED);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
result = Curl_resolv_check(data->conn, &dns);
|
result = Curl_resolv_check(data->conn, &dns);
|
||||||
@ -352,7 +353,7 @@ CURLproxycode Curl_SOCKS4(const char *proxy_user,
|
|||||||
}
|
}
|
||||||
sx->outp = socksreq;
|
sx->outp = socksreq;
|
||||||
sx->outstanding = packetsize;
|
sx->outstanding = packetsize;
|
||||||
sxstate(conn, CONNECT_REQ_SENDING);
|
sxstate(data, CONNECT_REQ_SENDING);
|
||||||
}
|
}
|
||||||
/* FALLTHROUGH */
|
/* FALLTHROUGH */
|
||||||
case CONNECT_REQ_SENDING:
|
case CONNECT_REQ_SENDING:
|
||||||
@ -373,7 +374,7 @@ CURLproxycode Curl_SOCKS4(const char *proxy_user,
|
|||||||
/* done sending! */
|
/* done sending! */
|
||||||
sx->outstanding = 8; /* receive data size */
|
sx->outstanding = 8; /* receive data size */
|
||||||
sx->outp = socksreq;
|
sx->outp = socksreq;
|
||||||
sxstate(conn, CONNECT_SOCKS_READ);
|
sxstate(data, CONNECT_SOCKS_READ);
|
||||||
|
|
||||||
/* FALLTHROUGH */
|
/* FALLTHROUGH */
|
||||||
case CONNECT_SOCKS_READ:
|
case CONNECT_SOCKS_READ:
|
||||||
@ -396,7 +397,7 @@ CURLproxycode Curl_SOCKS4(const char *proxy_user,
|
|||||||
sx->outp += actualread;
|
sx->outp += actualread;
|
||||||
return CURLPX_OK;
|
return CURLPX_OK;
|
||||||
}
|
}
|
||||||
sxstate(conn, CONNECT_DONE);
|
sxstate(data, CONNECT_DONE);
|
||||||
break;
|
break;
|
||||||
default: /* lots of unused states in SOCKS4 */
|
default: /* lots of unused states in SOCKS4 */
|
||||||
break;
|
break;
|
||||||
@ -486,7 +487,7 @@ CURLproxycode Curl_SOCKS5(const char *proxy_user,
|
|||||||
const char *hostname,
|
const char *hostname,
|
||||||
int remote_port,
|
int remote_port,
|
||||||
int sockindex,
|
int sockindex,
|
||||||
struct connectdata *conn,
|
struct Curl_easy *data,
|
||||||
bool *done)
|
bool *done)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
@ -505,6 +506,7 @@ CURLproxycode Curl_SOCKS5(const char *proxy_user,
|
|||||||
o REP Reply field:
|
o REP Reply field:
|
||||||
o X'00' succeeded
|
o X'00' succeeded
|
||||||
*/
|
*/
|
||||||
|
struct connectdata *conn = data->conn;
|
||||||
unsigned char *socksreq = &conn->cnnct.socksreq[0];
|
unsigned char *socksreq = &conn->cnnct.socksreq[0];
|
||||||
char dest[256] = "unknown"; /* printable hostname:port */
|
char dest[256] = "unknown"; /* printable hostname:port */
|
||||||
int idx;
|
int idx;
|
||||||
@ -512,7 +514,6 @@ CURLproxycode Curl_SOCKS5(const char *proxy_user,
|
|||||||
ssize_t written;
|
ssize_t written;
|
||||||
CURLcode result;
|
CURLcode result;
|
||||||
curl_socket_t sockfd = conn->sock[sockindex];
|
curl_socket_t sockfd = conn->sock[sockindex];
|
||||||
struct Curl_easy *data = conn->data;
|
|
||||||
bool socks5_resolve_local =
|
bool socks5_resolve_local =
|
||||||
(conn->socks_proxy.proxytype == CURLPROXY_SOCKS5) ? TRUE : FALSE;
|
(conn->socks_proxy.proxytype == CURLPROXY_SOCKS5) ? TRUE : FALSE;
|
||||||
const size_t hostname_len = strlen(hostname);
|
const size_t hostname_len = strlen(hostname);
|
||||||
@ -523,23 +524,23 @@ CURLproxycode Curl_SOCKS5(const char *proxy_user,
|
|||||||
struct Curl_dns_entry *dns = NULL;
|
struct Curl_dns_entry *dns = NULL;
|
||||||
|
|
||||||
if(!SOCKS_STATE(sx->state) && !*done)
|
if(!SOCKS_STATE(sx->state) && !*done)
|
||||||
sxstate(conn, CONNECT_SOCKS_INIT);
|
sxstate(data, CONNECT_SOCKS_INIT);
|
||||||
|
|
||||||
switch(sx->state) {
|
switch(sx->state) {
|
||||||
case CONNECT_SOCKS_INIT:
|
case CONNECT_SOCKS_INIT:
|
||||||
if(conn->bits.httpproxy)
|
if(conn->bits.httpproxy)
|
||||||
infof(conn->data, "SOCKS5: connecting to HTTP proxy %s port %d\n",
|
infof(data, "SOCKS5: connecting to HTTP proxy %s port %d\n",
|
||||||
hostname, remote_port);
|
hostname, remote_port);
|
||||||
|
|
||||||
/* RFC1928 chapter 5 specifies max 255 chars for domain name in packet */
|
/* RFC1928 chapter 5 specifies max 255 chars for domain name in packet */
|
||||||
if(!socks5_resolve_local && hostname_len > 255) {
|
if(!socks5_resolve_local && hostname_len > 255) {
|
||||||
infof(conn->data, "SOCKS5: server resolving disabled for hostnames of "
|
infof(data, "SOCKS5: server resolving disabled for hostnames of "
|
||||||
"length > 255 [actual len=%zu]\n", hostname_len);
|
"length > 255 [actual len=%zu]\n", hostname_len);
|
||||||
socks5_resolve_local = TRUE;
|
socks5_resolve_local = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(auth & ~(CURLAUTH_BASIC | CURLAUTH_GSSAPI))
|
if(auth & ~(CURLAUTH_BASIC | CURLAUTH_GSSAPI))
|
||||||
infof(conn->data,
|
infof(data,
|
||||||
"warning: unsupported value passed to CURLOPT_SOCKS5_AUTH: %lu\n",
|
"warning: unsupported value passed to CURLOPT_SOCKS5_AUTH: %lu\n",
|
||||||
auth);
|
auth);
|
||||||
if(!(auth & CURLAUTH_BASIC))
|
if(!(auth & CURLAUTH_BASIC))
|
||||||
@ -567,12 +568,12 @@ CURLproxycode Curl_SOCKS5(const char *proxy_user,
|
|||||||
return CURLPX_SEND_CONNECT;
|
return CURLPX_SEND_CONNECT;
|
||||||
}
|
}
|
||||||
if(written != idx) {
|
if(written != idx) {
|
||||||
sxstate(conn, CONNECT_SOCKS_SEND);
|
sxstate(data, CONNECT_SOCKS_SEND);
|
||||||
sx->outstanding = idx - written;
|
sx->outstanding = idx - written;
|
||||||
sx->outp = &socksreq[written];
|
sx->outp = &socksreq[written];
|
||||||
return CURLPX_OK;
|
return CURLPX_OK;
|
||||||
}
|
}
|
||||||
sxstate(conn, CONNECT_SOCKS_READ);
|
sxstate(data, CONNECT_SOCKS_READ);
|
||||||
goto CONNECT_SOCKS_READ_INIT;
|
goto CONNECT_SOCKS_READ_INIT;
|
||||||
case CONNECT_SOCKS_SEND:
|
case CONNECT_SOCKS_SEND:
|
||||||
result = Curl_write_plain(data, sockfd, (char *)sx->outp,
|
result = Curl_write_plain(data, sockfd, (char *)sx->outp,
|
||||||
@ -617,18 +618,18 @@ CURLproxycode Curl_SOCKS5(const char *proxy_user,
|
|||||||
}
|
}
|
||||||
else if(socksreq[1] == 0) {
|
else if(socksreq[1] == 0) {
|
||||||
/* DONE! No authentication needed. Send request. */
|
/* DONE! No authentication needed. Send request. */
|
||||||
sxstate(conn, CONNECT_REQ_INIT);
|
sxstate(data, CONNECT_REQ_INIT);
|
||||||
goto CONNECT_REQ_INIT;
|
goto CONNECT_REQ_INIT;
|
||||||
}
|
}
|
||||||
else if(socksreq[1] == 2) {
|
else if(socksreq[1] == 2) {
|
||||||
/* regular name + password authentication */
|
/* regular name + password authentication */
|
||||||
sxstate(conn, CONNECT_AUTH_INIT);
|
sxstate(data, CONNECT_AUTH_INIT);
|
||||||
goto CONNECT_AUTH_INIT;
|
goto CONNECT_AUTH_INIT;
|
||||||
}
|
}
|
||||||
#if defined(HAVE_GSSAPI) || defined(USE_WINDOWS_SSPI)
|
#if defined(HAVE_GSSAPI) || defined(USE_WINDOWS_SSPI)
|
||||||
else if(allow_gssapi && (socksreq[1] == 1)) {
|
else if(allow_gssapi && (socksreq[1] == 1)) {
|
||||||
sxstate(conn, CONNECT_GSSAPI_INIT);
|
sxstate(data, CONNECT_GSSAPI_INIT);
|
||||||
result = Curl_SOCKS5_gssapi_negotiate(sockindex, conn);
|
result = Curl_SOCKS5_gssapi_negotiate(sockindex, data);
|
||||||
if(result) {
|
if(result) {
|
||||||
failf(data, "Unable to negotiate SOCKS5 GSS-API context.");
|
failf(data, "Unable to negotiate SOCKS5 GSS-API context.");
|
||||||
return CURLPX_GSSAPI;
|
return CURLPX_GSSAPI;
|
||||||
@ -701,7 +702,7 @@ CURLproxycode Curl_SOCKS5(const char *proxy_user,
|
|||||||
memcpy(socksreq + len, proxy_password, proxy_password_len);
|
memcpy(socksreq + len, proxy_password, proxy_password_len);
|
||||||
}
|
}
|
||||||
len += proxy_password_len;
|
len += proxy_password_len;
|
||||||
sxstate(conn, CONNECT_AUTH_SEND);
|
sxstate(data, CONNECT_AUTH_SEND);
|
||||||
sx->outstanding = len;
|
sx->outstanding = len;
|
||||||
sx->outp = socksreq;
|
sx->outp = socksreq;
|
||||||
}
|
}
|
||||||
@ -721,7 +722,7 @@ CURLproxycode Curl_SOCKS5(const char *proxy_user,
|
|||||||
}
|
}
|
||||||
sx->outp = socksreq;
|
sx->outp = socksreq;
|
||||||
sx->outstanding = 2;
|
sx->outstanding = 2;
|
||||||
sxstate(conn, CONNECT_AUTH_READ);
|
sxstate(data, CONNECT_AUTH_READ);
|
||||||
/* FALLTHROUGH */
|
/* FALLTHROUGH */
|
||||||
case CONNECT_AUTH_READ:
|
case CONNECT_AUTH_READ:
|
||||||
result = Curl_read_plain(sockfd, (char *)sx->outp,
|
result = Curl_read_plain(sockfd, (char *)sx->outp,
|
||||||
@ -749,7 +750,7 @@ CURLproxycode Curl_SOCKS5(const char *proxy_user,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Everything is good so far, user was authenticated! */
|
/* Everything is good so far, user was authenticated! */
|
||||||
sxstate(conn, CONNECT_REQ_INIT);
|
sxstate(data, CONNECT_REQ_INIT);
|
||||||
/* FALLTHROUGH */
|
/* FALLTHROUGH */
|
||||||
CONNECT_REQ_INIT:
|
CONNECT_REQ_INIT:
|
||||||
case CONNECT_REQ_INIT:
|
case CONNECT_REQ_INIT:
|
||||||
@ -761,10 +762,10 @@ CURLproxycode Curl_SOCKS5(const char *proxy_user,
|
|||||||
return CURLPX_RESOLVE_HOST;
|
return CURLPX_RESOLVE_HOST;
|
||||||
|
|
||||||
if(rc == CURLRESOLV_PENDING) {
|
if(rc == CURLRESOLV_PENDING) {
|
||||||
sxstate(conn, CONNECT_RESOLVING);
|
sxstate(data, CONNECT_RESOLVING);
|
||||||
return CURLPX_OK;
|
return CURLPX_OK;
|
||||||
}
|
}
|
||||||
sxstate(conn, CONNECT_RESOLVED);
|
sxstate(data, CONNECT_RESOLVED);
|
||||||
goto CONNECT_RESOLVED;
|
goto CONNECT_RESOLVED;
|
||||||
}
|
}
|
||||||
goto CONNECT_RESOLVE_REMOTE;
|
goto CONNECT_RESOLVE_REMOTE;
|
||||||
@ -878,7 +879,7 @@ CURLproxycode Curl_SOCKS5(const char *proxy_user,
|
|||||||
#endif
|
#endif
|
||||||
sx->outp = socksreq;
|
sx->outp = socksreq;
|
||||||
sx->outstanding = len;
|
sx->outstanding = len;
|
||||||
sxstate(conn, CONNECT_REQ_SENDING);
|
sxstate(data, CONNECT_REQ_SENDING);
|
||||||
/* FALLTHROUGH */
|
/* FALLTHROUGH */
|
||||||
case CONNECT_REQ_SENDING:
|
case CONNECT_REQ_SENDING:
|
||||||
result = Curl_write_plain(data, sockfd, (char *)sx->outp,
|
result = Curl_write_plain(data, sockfd, (char *)sx->outp,
|
||||||
@ -901,7 +902,7 @@ CURLproxycode Curl_SOCKS5(const char *proxy_user,
|
|||||||
#endif
|
#endif
|
||||||
sx->outstanding = 10; /* minimum packet size is 10 */
|
sx->outstanding = 10; /* minimum packet size is 10 */
|
||||||
sx->outp = socksreq;
|
sx->outp = socksreq;
|
||||||
sxstate(conn, CONNECT_REQ_READ);
|
sxstate(data, CONNECT_REQ_READ);
|
||||||
/* FALLTHROUGH */
|
/* FALLTHROUGH */
|
||||||
case CONNECT_REQ_READ:
|
case CONNECT_REQ_READ:
|
||||||
result = Curl_read_plain(sockfd, (char *)sx->outp,
|
result = Curl_read_plain(sockfd, (char *)sx->outp,
|
||||||
@ -992,10 +993,10 @@ CURLproxycode Curl_SOCKS5(const char *proxy_user,
|
|||||||
if(len > 10) {
|
if(len > 10) {
|
||||||
sx->outstanding = len - 10; /* get the rest */
|
sx->outstanding = len - 10; /* get the rest */
|
||||||
sx->outp = &socksreq[10];
|
sx->outp = &socksreq[10];
|
||||||
sxstate(conn, CONNECT_REQ_READ_MORE);
|
sxstate(data, CONNECT_REQ_READ_MORE);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
sxstate(conn, CONNECT_DONE);
|
sxstate(data, CONNECT_DONE);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#if defined(HAVE_GSSAPI) || defined(USE_WINDOWS_SSPI)
|
#if defined(HAVE_GSSAPI) || defined(USE_WINDOWS_SSPI)
|
||||||
@ -1020,7 +1021,7 @@ CURLproxycode Curl_SOCKS5(const char *proxy_user,
|
|||||||
sx->outp += actualread;
|
sx->outp += actualread;
|
||||||
return CURLPX_OK;
|
return CURLPX_OK;
|
||||||
}
|
}
|
||||||
sxstate(conn, CONNECT_DONE);
|
sxstate(data, CONNECT_DONE);
|
||||||
}
|
}
|
||||||
infof(data, "SOCKS5 request granted.\n");
|
infof(data, "SOCKS5 request granted.\n");
|
||||||
|
|
||||||
|
10
lib/socks.h
10
lib/socks.h
@ -7,7 +7,7 @@
|
|||||||
* | (__| |_| | _ <| |___
|
* | (__| |_| | _ <| |___
|
||||||
* \___|\___/|_| \_\_____|
|
* \___|\___/|_| \_\_____|
|
||||||
*
|
*
|
||||||
* Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
|
* Copyright (C) 1998 - 2021, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||||
*
|
*
|
||||||
* This software is licensed as described in the file COPYING, which
|
* This software is licensed as described in the file COPYING, which
|
||||||
* you should have received as part of this distribution. The terms
|
* you should have received as part of this distribution. The terms
|
||||||
@ -35,7 +35,7 @@
|
|||||||
*
|
*
|
||||||
* This is STUPID BLOCKING behavior
|
* This is STUPID BLOCKING behavior
|
||||||
*/
|
*/
|
||||||
int Curl_blockread_all(struct connectdata *conn,
|
int Curl_blockread_all(struct Curl_easy *data,
|
||||||
curl_socket_t sockfd,
|
curl_socket_t sockfd,
|
||||||
char *buf,
|
char *buf,
|
||||||
ssize_t buffersize,
|
ssize_t buffersize,
|
||||||
@ -52,7 +52,7 @@ CURLproxycode Curl_SOCKS4(const char *proxy_name,
|
|||||||
const char *hostname,
|
const char *hostname,
|
||||||
int remote_port,
|
int remote_port,
|
||||||
int sockindex,
|
int sockindex,
|
||||||
struct connectdata *conn,
|
struct Curl_easy *data,
|
||||||
bool *done);
|
bool *done);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -64,7 +64,7 @@ CURLproxycode Curl_SOCKS5(const char *proxy_name,
|
|||||||
const char *hostname,
|
const char *hostname,
|
||||||
int remote_port,
|
int remote_port,
|
||||||
int sockindex,
|
int sockindex,
|
||||||
struct connectdata *conn,
|
struct Curl_easy *data,
|
||||||
bool *done);
|
bool *done);
|
||||||
|
|
||||||
#if defined(HAVE_GSSAPI) || defined(USE_WINDOWS_SSPI)
|
#if defined(HAVE_GSSAPI) || defined(USE_WINDOWS_SSPI)
|
||||||
@ -72,7 +72,7 @@ CURLproxycode Curl_SOCKS5(const char *proxy_name,
|
|||||||
* This function handles the SOCKS5 GSS-API negotiation and initialisation
|
* This function handles the SOCKS5 GSS-API negotiation and initialisation
|
||||||
*/
|
*/
|
||||||
CURLcode Curl_SOCKS5_gssapi_negotiate(int sockindex,
|
CURLcode Curl_SOCKS5_gssapi_negotiate(int sockindex,
|
||||||
struct connectdata *conn);
|
struct Curl_easy *data);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif /* CURL_DISABLE_PROXY */
|
#endif /* CURL_DISABLE_PROXY */
|
||||||
|
@ -100,9 +100,9 @@ static int check_gss_err(struct Curl_easy *data,
|
|||||||
}
|
}
|
||||||
|
|
||||||
CURLcode Curl_SOCKS5_gssapi_negotiate(int sockindex,
|
CURLcode Curl_SOCKS5_gssapi_negotiate(int sockindex,
|
||||||
struct connectdata *conn)
|
struct Curl_easy *data)
|
||||||
{
|
{
|
||||||
struct Curl_easy *data = conn->data;
|
struct connectdata *conn = data->conn;
|
||||||
curl_socket_t sock = conn->sock[sockindex];
|
curl_socket_t sock = conn->sock[sockindex];
|
||||||
CURLcode code;
|
CURLcode code;
|
||||||
ssize_t actualread;
|
ssize_t actualread;
|
||||||
@ -240,7 +240,7 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(int sockindex,
|
|||||||
* +----+------+-----+----------------+
|
* +----+------+-----+----------------+
|
||||||
*/
|
*/
|
||||||
|
|
||||||
result = Curl_blockread_all(conn, sock, (char *)socksreq, 4, &actualread);
|
result = Curl_blockread_all(data, sock, (char *)socksreq, 4, &actualread);
|
||||||
if(result || (actualread != 4)) {
|
if(result || (actualread != 4)) {
|
||||||
failf(data, "Failed to receive GSS-API authentication response.");
|
failf(data, "Failed to receive GSS-API authentication response.");
|
||||||
gss_release_name(&gss_status, &server);
|
gss_release_name(&gss_status, &server);
|
||||||
@ -279,7 +279,7 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(int sockindex,
|
|||||||
return CURLE_OUT_OF_MEMORY;
|
return CURLE_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
result = Curl_blockread_all(conn, sock, (char *)gss_recv_token.value,
|
result = Curl_blockread_all(data, sock, (char *)gss_recv_token.value,
|
||||||
gss_recv_token.length, &actualread);
|
gss_recv_token.length, &actualread);
|
||||||
|
|
||||||
if(result || (actualread != us_length)) {
|
if(result || (actualread != us_length)) {
|
||||||
@ -437,7 +437,7 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(int sockindex,
|
|||||||
gss_release_buffer(&gss_status, &gss_w_token);
|
gss_release_buffer(&gss_status, &gss_w_token);
|
||||||
}
|
}
|
||||||
|
|
||||||
result = Curl_blockread_all(conn, sock, (char *)socksreq, 4, &actualread);
|
result = Curl_blockread_all(data, sock, (char *)socksreq, 4, &actualread);
|
||||||
if(result || (actualread != 4)) {
|
if(result || (actualread != 4)) {
|
||||||
failf(data, "Failed to receive GSS-API encryption response.");
|
failf(data, "Failed to receive GSS-API encryption response.");
|
||||||
gss_delete_sec_context(&gss_status, &gss_context, NULL);
|
gss_delete_sec_context(&gss_status, &gss_context, NULL);
|
||||||
@ -468,7 +468,7 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(int sockindex,
|
|||||||
gss_delete_sec_context(&gss_status, &gss_context, NULL);
|
gss_delete_sec_context(&gss_status, &gss_context, NULL);
|
||||||
return CURLE_OUT_OF_MEMORY;
|
return CURLE_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
result = Curl_blockread_all(conn, sock, (char *)gss_recv_token.value,
|
result = Curl_blockread_all(data, sock, (char *)gss_recv_token.value,
|
||||||
gss_recv_token.length, &actualread);
|
gss_recv_token.length, &actualread);
|
||||||
|
|
||||||
if(result || (actualread != us_length)) {
|
if(result || (actualread != us_length)) {
|
||||||
|
@ -43,7 +43,7 @@
|
|||||||
/*
|
/*
|
||||||
* Helper sspi error functions.
|
* Helper sspi error functions.
|
||||||
*/
|
*/
|
||||||
static int check_sspi_err(struct connectdata *conn,
|
static int check_sspi_err(struct Curl_easy *data,
|
||||||
SECURITY_STATUS status,
|
SECURITY_STATUS status,
|
||||||
const char *function)
|
const char *function)
|
||||||
{
|
{
|
||||||
@ -52,7 +52,7 @@ static int check_sspi_err(struct connectdata *conn,
|
|||||||
status != SEC_I_COMPLETE_NEEDED &&
|
status != SEC_I_COMPLETE_NEEDED &&
|
||||||
status != SEC_I_CONTINUE_NEEDED) {
|
status != SEC_I_CONTINUE_NEEDED) {
|
||||||
char buffer[STRERROR_LEN];
|
char buffer[STRERROR_LEN];
|
||||||
failf(conn->data, "SSPI error: %s failed: %s", function,
|
failf(data, "SSPI error: %s failed: %s", function,
|
||||||
Curl_sspi_strerror(status, buffer, sizeof(buffer)));
|
Curl_sspi_strerror(status, buffer, sizeof(buffer)));
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -61,9 +61,9 @@ static int check_sspi_err(struct connectdata *conn,
|
|||||||
|
|
||||||
/* This is the SSPI-using version of this function */
|
/* This is the SSPI-using version of this function */
|
||||||
CURLcode Curl_SOCKS5_gssapi_negotiate(int sockindex,
|
CURLcode Curl_SOCKS5_gssapi_negotiate(int sockindex,
|
||||||
struct connectdata *conn)
|
struct Curl_easy *data)
|
||||||
{
|
{
|
||||||
struct Curl_easy *data = conn->data;
|
struct connectdata *conn = data->conn;
|
||||||
curl_socket_t sock = conn->sock[sockindex];
|
curl_socket_t sock = conn->sock[sockindex];
|
||||||
CURLcode code;
|
CURLcode code;
|
||||||
ssize_t actualread;
|
ssize_t actualread;
|
||||||
@ -146,7 +146,7 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(int sockindex,
|
|||||||
&cred_handle,
|
&cred_handle,
|
||||||
&expiry);
|
&expiry);
|
||||||
|
|
||||||
if(check_sspi_err(conn, status, "AcquireCredentialsHandle")) {
|
if(check_sspi_err(data, status, "AcquireCredentialsHandle")) {
|
||||||
failf(data, "Failed to acquire credentials.");
|
failf(data, "Failed to acquire credentials.");
|
||||||
free(service_name);
|
free(service_name);
|
||||||
s_pSecFn->FreeCredentialsHandle(&cred_handle);
|
s_pSecFn->FreeCredentialsHandle(&cred_handle);
|
||||||
@ -188,7 +188,7 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(int sockindex,
|
|||||||
sspi_recv_token.cbBuffer = 0;
|
sspi_recv_token.cbBuffer = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(check_sspi_err(conn, status, "InitializeSecurityContext")) {
|
if(check_sspi_err(data, status, "InitializeSecurityContext")) {
|
||||||
free(service_name);
|
free(service_name);
|
||||||
s_pSecFn->FreeCredentialsHandle(&cred_handle);
|
s_pSecFn->FreeCredentialsHandle(&cred_handle);
|
||||||
s_pSecFn->DeleteSecurityContext(&sspi_context);
|
s_pSecFn->DeleteSecurityContext(&sspi_context);
|
||||||
@ -258,7 +258,7 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(int sockindex,
|
|||||||
* +----+------+-----+----------------+
|
* +----+------+-----+----------------+
|
||||||
*/
|
*/
|
||||||
|
|
||||||
result = Curl_blockread_all(conn, sock, (char *)socksreq, 4, &actualread);
|
result = Curl_blockread_all(data, sock, (char *)socksreq, 4, &actualread);
|
||||||
if(result || (actualread != 4)) {
|
if(result || (actualread != 4)) {
|
||||||
failf(data, "Failed to receive SSPI authentication response.");
|
failf(data, "Failed to receive SSPI authentication response.");
|
||||||
free(service_name);
|
free(service_name);
|
||||||
@ -298,7 +298,7 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(int sockindex,
|
|||||||
s_pSecFn->DeleteSecurityContext(&sspi_context);
|
s_pSecFn->DeleteSecurityContext(&sspi_context);
|
||||||
return CURLE_OUT_OF_MEMORY;
|
return CURLE_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
result = Curl_blockread_all(conn, sock, (char *)sspi_recv_token.pvBuffer,
|
result = Curl_blockread_all(data, sock, (char *)sspi_recv_token.pvBuffer,
|
||||||
sspi_recv_token.cbBuffer, &actualread);
|
sspi_recv_token.cbBuffer, &actualread);
|
||||||
|
|
||||||
if(result || (actualread != us_length)) {
|
if(result || (actualread != us_length)) {
|
||||||
@ -321,7 +321,7 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(int sockindex,
|
|||||||
SECPKG_CRED_ATTR_NAMES,
|
SECPKG_CRED_ATTR_NAMES,
|
||||||
&names);
|
&names);
|
||||||
s_pSecFn->FreeCredentialsHandle(&cred_handle);
|
s_pSecFn->FreeCredentialsHandle(&cred_handle);
|
||||||
if(check_sspi_err(conn, status, "QueryCredentialAttributes")) {
|
if(check_sspi_err(data, status, "QueryCredentialAttributes")) {
|
||||||
s_pSecFn->DeleteSecurityContext(&sspi_context);
|
s_pSecFn->DeleteSecurityContext(&sspi_context);
|
||||||
s_pSecFn->FreeContextBuffer(names.sUserName);
|
s_pSecFn->FreeContextBuffer(names.sUserName);
|
||||||
failf(data, "Failed to determine user name.");
|
failf(data, "Failed to determine user name.");
|
||||||
@ -386,7 +386,7 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(int sockindex,
|
|||||||
status = s_pSecFn->QueryContextAttributes(&sspi_context,
|
status = s_pSecFn->QueryContextAttributes(&sspi_context,
|
||||||
SECPKG_ATTR_SIZES,
|
SECPKG_ATTR_SIZES,
|
||||||
&sspi_sizes);
|
&sspi_sizes);
|
||||||
if(check_sspi_err(conn, status, "QueryContextAttributes")) {
|
if(check_sspi_err(data, status, "QueryContextAttributes")) {
|
||||||
s_pSecFn->DeleteSecurityContext(&sspi_context);
|
s_pSecFn->DeleteSecurityContext(&sspi_context);
|
||||||
failf(data, "Failed to query security context attributes.");
|
failf(data, "Failed to query security context attributes.");
|
||||||
return CURLE_COULDNT_CONNECT;
|
return CURLE_COULDNT_CONNECT;
|
||||||
@ -423,7 +423,7 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(int sockindex,
|
|||||||
KERB_WRAP_NO_ENCRYPT,
|
KERB_WRAP_NO_ENCRYPT,
|
||||||
&wrap_desc,
|
&wrap_desc,
|
||||||
0);
|
0);
|
||||||
if(check_sspi_err(conn, status, "EncryptMessage")) {
|
if(check_sspi_err(data, status, "EncryptMessage")) {
|
||||||
s_pSecFn->FreeContextBuffer(sspi_w_token[0].pvBuffer);
|
s_pSecFn->FreeContextBuffer(sspi_w_token[0].pvBuffer);
|
||||||
s_pSecFn->FreeContextBuffer(sspi_w_token[1].pvBuffer);
|
s_pSecFn->FreeContextBuffer(sspi_w_token[1].pvBuffer);
|
||||||
s_pSecFn->FreeContextBuffer(sspi_w_token[2].pvBuffer);
|
s_pSecFn->FreeContextBuffer(sspi_w_token[2].pvBuffer);
|
||||||
@ -498,7 +498,7 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(int sockindex,
|
|||||||
s_pSecFn->FreeContextBuffer(sspi_send_token.pvBuffer);
|
s_pSecFn->FreeContextBuffer(sspi_send_token.pvBuffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
result = Curl_blockread_all(conn, sock, (char *)socksreq, 4, &actualread);
|
result = Curl_blockread_all(data, sock, (char *)socksreq, 4, &actualread);
|
||||||
if(result || (actualread != 4)) {
|
if(result || (actualread != 4)) {
|
||||||
failf(data, "Failed to receive SSPI encryption response.");
|
failf(data, "Failed to receive SSPI encryption response.");
|
||||||
s_pSecFn->DeleteSecurityContext(&sspi_context);
|
s_pSecFn->DeleteSecurityContext(&sspi_context);
|
||||||
@ -530,7 +530,7 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(int sockindex,
|
|||||||
return CURLE_OUT_OF_MEMORY;
|
return CURLE_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
result = Curl_blockread_all(conn, sock, (char *)sspi_w_token[0].pvBuffer,
|
result = Curl_blockread_all(data, sock, (char *)sspi_w_token[0].pvBuffer,
|
||||||
sspi_w_token[0].cbBuffer, &actualread);
|
sspi_w_token[0].cbBuffer, &actualread);
|
||||||
|
|
||||||
if(result || (actualread != us_length)) {
|
if(result || (actualread != us_length)) {
|
||||||
@ -553,7 +553,7 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(int sockindex,
|
|||||||
0,
|
0,
|
||||||
&qop);
|
&qop);
|
||||||
|
|
||||||
if(check_sspi_err(conn, status, "DecryptMessage")) {
|
if(check_sspi_err(data, status, "DecryptMessage")) {
|
||||||
if(sspi_w_token[0].pvBuffer)
|
if(sspi_w_token[0].pvBuffer)
|
||||||
s_pSecFn->FreeContextBuffer(sspi_w_token[0].pvBuffer);
|
s_pSecFn->FreeContextBuffer(sspi_w_token[0].pvBuffer);
|
||||||
if(sspi_w_token[1].pvBuffer)
|
if(sspi_w_token[1].pvBuffer)
|
||||||
|
147
lib/telnet.c
147
lib/telnet.c
@ -88,7 +88,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
static
|
static
|
||||||
CURLcode telrcv(struct connectdata *,
|
CURLcode telrcv(struct Curl_easy *data,
|
||||||
const unsigned char *inbuf, /* Data received from socket */
|
const unsigned char *inbuf, /* Data received from socket */
|
||||||
ssize_t count); /* Number of bytes received */
|
ssize_t count); /* Number of bytes received */
|
||||||
|
|
||||||
@ -98,18 +98,18 @@ static void printoption(struct Curl_easy *data,
|
|||||||
int cmd, int option);
|
int cmd, int option);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static void negotiate(struct connectdata *);
|
static void negotiate(struct Curl_easy *data);
|
||||||
static void send_negotiation(struct connectdata *, int cmd, int option);
|
static void send_negotiation(struct Curl_easy *data, int cmd, int option);
|
||||||
static void set_local_option(struct connectdata *conn,
|
static void set_local_option(struct Curl_easy *data,
|
||||||
int option, int newstate);
|
int option, int newstate);
|
||||||
static void set_remote_option(struct connectdata *conn,
|
static void set_remote_option(struct Curl_easy *data,
|
||||||
int option, int newstate);
|
int option, int newstate);
|
||||||
|
|
||||||
static void printsub(struct Curl_easy *data,
|
static void printsub(struct Curl_easy *data,
|
||||||
int direction, unsigned char *pointer,
|
int direction, unsigned char *pointer,
|
||||||
size_t length);
|
size_t length);
|
||||||
static void suboption(struct connectdata *);
|
static void suboption(struct Curl_easy *data);
|
||||||
static void sendsuboption(struct connectdata *conn, int option);
|
static void sendsuboption(struct Curl_easy *data, int option);
|
||||||
|
|
||||||
static CURLcode telnet_do(struct Curl_easy *data, bool *done);
|
static CURLcode telnet_do(struct Curl_easy *data, bool *done);
|
||||||
static CURLcode telnet_done(struct Curl_easy *data,
|
static CURLcode telnet_done(struct Curl_easy *data,
|
||||||
@ -194,7 +194,7 @@ const struct Curl_handler Curl_handler_telnet = {
|
|||||||
|
|
||||||
|
|
||||||
static
|
static
|
||||||
CURLcode init_telnet(struct connectdata *conn)
|
CURLcode init_telnet(struct Curl_easy *data)
|
||||||
{
|
{
|
||||||
struct TELNET *tn;
|
struct TELNET *tn;
|
||||||
|
|
||||||
@ -202,7 +202,7 @@ CURLcode init_telnet(struct connectdata *conn)
|
|||||||
if(!tn)
|
if(!tn)
|
||||||
return CURLE_OUT_OF_MEMORY;
|
return CURLE_OUT_OF_MEMORY;
|
||||||
|
|
||||||
conn->data->req.p.telnet = tn; /* make us known */
|
data->req.p.telnet = tn; /* make us known */
|
||||||
|
|
||||||
tn->telrcv_state = CURL_TS_DATA;
|
tn->telrcv_state = CURL_TS_DATA;
|
||||||
|
|
||||||
@ -244,20 +244,20 @@ CURLcode init_telnet(struct connectdata *conn)
|
|||||||
return CURLE_OK;
|
return CURLE_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void negotiate(struct connectdata *conn)
|
static void negotiate(struct Curl_easy *data)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
struct TELNET *tn = (struct TELNET *) conn->data->req.p.telnet;
|
struct TELNET *tn = data->req.p.telnet;
|
||||||
|
|
||||||
for(i = 0; i < CURL_NTELOPTS; i++) {
|
for(i = 0; i < CURL_NTELOPTS; i++) {
|
||||||
if(i == CURL_TELOPT_ECHO)
|
if(i == CURL_TELOPT_ECHO)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if(tn->us_preferred[i] == CURL_YES)
|
if(tn->us_preferred[i] == CURL_YES)
|
||||||
set_local_option(conn, i, CURL_YES);
|
set_local_option(data, i, CURL_YES);
|
||||||
|
|
||||||
if(tn->him_preferred[i] == CURL_YES)
|
if(tn->him_preferred[i] == CURL_YES)
|
||||||
set_remote_option(conn, i, CURL_YES);
|
set_remote_option(data, i, CURL_YES);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -298,11 +298,11 @@ static void printoption(struct Curl_easy *data,
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static void send_negotiation(struct connectdata *conn, int cmd, int option)
|
static void send_negotiation(struct Curl_easy *data, int cmd, int option)
|
||||||
{
|
{
|
||||||
unsigned char buf[3];
|
unsigned char buf[3];
|
||||||
ssize_t bytes_written;
|
ssize_t bytes_written;
|
||||||
struct Curl_easy *data = conn->data;
|
struct connectdata *conn = data->conn;
|
||||||
|
|
||||||
buf[0] = CURL_IAC;
|
buf[0] = CURL_IAC;
|
||||||
buf[1] = (unsigned char)cmd;
|
buf[1] = (unsigned char)cmd;
|
||||||
@ -314,18 +314,18 @@ static void send_negotiation(struct connectdata *conn, int cmd, int option)
|
|||||||
failf(data,"Sending data failed (%d)",err);
|
failf(data,"Sending data failed (%d)",err);
|
||||||
}
|
}
|
||||||
|
|
||||||
printoption(conn->data, "SENT", cmd, option);
|
printoption(data, "SENT", cmd, option);
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
static
|
||||||
void set_remote_option(struct connectdata *conn, int option, int newstate)
|
void set_remote_option(struct Curl_easy *data, int option, int newstate)
|
||||||
{
|
{
|
||||||
struct TELNET *tn = (struct TELNET *)conn->data->req.p.telnet;
|
struct TELNET *tn = data->req.p.telnet;
|
||||||
if(newstate == CURL_YES) {
|
if(newstate == CURL_YES) {
|
||||||
switch(tn->him[option]) {
|
switch(tn->him[option]) {
|
||||||
case CURL_NO:
|
case CURL_NO:
|
||||||
tn->him[option] = CURL_WANTYES;
|
tn->him[option] = CURL_WANTYES;
|
||||||
send_negotiation(conn, CURL_DO, option);
|
send_negotiation(data, CURL_DO, option);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CURL_YES:
|
case CURL_YES:
|
||||||
@ -364,7 +364,7 @@ void set_remote_option(struct connectdata *conn, int option, int newstate)
|
|||||||
|
|
||||||
case CURL_YES:
|
case CURL_YES:
|
||||||
tn->him[option] = CURL_WANTNO;
|
tn->him[option] = CURL_WANTNO;
|
||||||
send_negotiation(conn, CURL_DONT, option);
|
send_negotiation(data, CURL_DONT, option);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CURL_WANTNO:
|
case CURL_WANTNO:
|
||||||
@ -392,17 +392,17 @@ void set_remote_option(struct connectdata *conn, int option, int newstate)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static
|
static
|
||||||
void rec_will(struct connectdata *conn, int option)
|
void rec_will(struct Curl_easy *data, int option)
|
||||||
{
|
{
|
||||||
struct TELNET *tn = (struct TELNET *)conn->data->req.p.telnet;
|
struct TELNET *tn = data->req.p.telnet;
|
||||||
switch(tn->him[option]) {
|
switch(tn->him[option]) {
|
||||||
case CURL_NO:
|
case CURL_NO:
|
||||||
if(tn->him_preferred[option] == CURL_YES) {
|
if(tn->him_preferred[option] == CURL_YES) {
|
||||||
tn->him[option] = CURL_YES;
|
tn->him[option] = CURL_YES;
|
||||||
send_negotiation(conn, CURL_DO, option);
|
send_negotiation(data, CURL_DO, option);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
send_negotiation(conn, CURL_DONT, option);
|
send_negotiation(data, CURL_DONT, option);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -432,7 +432,7 @@ void rec_will(struct connectdata *conn, int option)
|
|||||||
case CURL_OPPOSITE:
|
case CURL_OPPOSITE:
|
||||||
tn->him[option] = CURL_WANTNO;
|
tn->him[option] = CURL_WANTNO;
|
||||||
tn->himq[option] = CURL_EMPTY;
|
tn->himq[option] = CURL_EMPTY;
|
||||||
send_negotiation(conn, CURL_DONT, option);
|
send_negotiation(data, CURL_DONT, option);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -440,9 +440,9 @@ void rec_will(struct connectdata *conn, int option)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static
|
static
|
||||||
void rec_wont(struct connectdata *conn, int option)
|
void rec_wont(struct Curl_easy *data, int option)
|
||||||
{
|
{
|
||||||
struct TELNET *tn = (struct TELNET *)conn->data->req.p.telnet;
|
struct TELNET *tn = data->req.p.telnet;
|
||||||
switch(tn->him[option]) {
|
switch(tn->him[option]) {
|
||||||
case CURL_NO:
|
case CURL_NO:
|
||||||
/* Already disabled */
|
/* Already disabled */
|
||||||
@ -450,7 +450,7 @@ void rec_wont(struct connectdata *conn, int option)
|
|||||||
|
|
||||||
case CURL_YES:
|
case CURL_YES:
|
||||||
tn->him[option] = CURL_NO;
|
tn->him[option] = CURL_NO;
|
||||||
send_negotiation(conn, CURL_DONT, option);
|
send_negotiation(data, CURL_DONT, option);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CURL_WANTNO:
|
case CURL_WANTNO:
|
||||||
@ -462,7 +462,7 @@ void rec_wont(struct connectdata *conn, int option)
|
|||||||
case CURL_OPPOSITE:
|
case CURL_OPPOSITE:
|
||||||
tn->him[option] = CURL_WANTYES;
|
tn->him[option] = CURL_WANTYES;
|
||||||
tn->himq[option] = CURL_EMPTY;
|
tn->himq[option] = CURL_EMPTY;
|
||||||
send_negotiation(conn, CURL_DO, option);
|
send_negotiation(data, CURL_DO, option);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -482,14 +482,14 @@ void rec_wont(struct connectdata *conn, int option)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
set_local_option(struct connectdata *conn, int option, int newstate)
|
set_local_option(struct Curl_easy *data, int option, int newstate)
|
||||||
{
|
{
|
||||||
struct TELNET *tn = (struct TELNET *)conn->data->req.p.telnet;
|
struct TELNET *tn = data->req.p.telnet;
|
||||||
if(newstate == CURL_YES) {
|
if(newstate == CURL_YES) {
|
||||||
switch(tn->us[option]) {
|
switch(tn->us[option]) {
|
||||||
case CURL_NO:
|
case CURL_NO:
|
||||||
tn->us[option] = CURL_WANTYES;
|
tn->us[option] = CURL_WANTYES;
|
||||||
send_negotiation(conn, CURL_WILL, option);
|
send_negotiation(data, CURL_WILL, option);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CURL_YES:
|
case CURL_YES:
|
||||||
@ -528,7 +528,7 @@ set_local_option(struct connectdata *conn, int option, int newstate)
|
|||||||
|
|
||||||
case CURL_YES:
|
case CURL_YES:
|
||||||
tn->us[option] = CURL_WANTNO;
|
tn->us[option] = CURL_WANTNO;
|
||||||
send_negotiation(conn, CURL_WONT, option);
|
send_negotiation(data, CURL_WONT, option);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CURL_WANTNO:
|
case CURL_WANTNO:
|
||||||
@ -556,26 +556,26 @@ set_local_option(struct connectdata *conn, int option, int newstate)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static
|
static
|
||||||
void rec_do(struct connectdata *conn, int option)
|
void rec_do(struct Curl_easy *data, int option)
|
||||||
{
|
{
|
||||||
struct TELNET *tn = (struct TELNET *)conn->data->req.p.telnet;
|
struct TELNET *tn = data->req.p.telnet;
|
||||||
switch(tn->us[option]) {
|
switch(tn->us[option]) {
|
||||||
case CURL_NO:
|
case CURL_NO:
|
||||||
if(tn->us_preferred[option] == CURL_YES) {
|
if(tn->us_preferred[option] == CURL_YES) {
|
||||||
tn->us[option] = CURL_YES;
|
tn->us[option] = CURL_YES;
|
||||||
send_negotiation(conn, CURL_WILL, option);
|
send_negotiation(data, CURL_WILL, option);
|
||||||
if(tn->subnegotiation[option] == CURL_YES)
|
if(tn->subnegotiation[option] == CURL_YES)
|
||||||
/* transmission of data option */
|
/* transmission of data option */
|
||||||
sendsuboption(conn, option);
|
sendsuboption(data, option);
|
||||||
}
|
}
|
||||||
else if(tn->subnegotiation[option] == CURL_YES) {
|
else if(tn->subnegotiation[option] == CURL_YES) {
|
||||||
/* send information to achieve this option*/
|
/* send information to achieve this option*/
|
||||||
tn->us[option] = CURL_YES;
|
tn->us[option] = CURL_YES;
|
||||||
send_negotiation(conn, CURL_WILL, option);
|
send_negotiation(data, CURL_WILL, option);
|
||||||
sendsuboption(conn, option);
|
sendsuboption(data, option);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
send_negotiation(conn, CURL_WONT, option);
|
send_negotiation(data, CURL_WONT, option);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CURL_YES:
|
case CURL_YES:
|
||||||
@ -602,13 +602,13 @@ void rec_do(struct connectdata *conn, int option)
|
|||||||
tn->us[option] = CURL_YES;
|
tn->us[option] = CURL_YES;
|
||||||
if(tn->subnegotiation[option] == CURL_YES) {
|
if(tn->subnegotiation[option] == CURL_YES) {
|
||||||
/* transmission of data option */
|
/* transmission of data option */
|
||||||
sendsuboption(conn, option);
|
sendsuboption(data, option);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case CURL_OPPOSITE:
|
case CURL_OPPOSITE:
|
||||||
tn->us[option] = CURL_WANTNO;
|
tn->us[option] = CURL_WANTNO;
|
||||||
tn->himq[option] = CURL_EMPTY;
|
tn->himq[option] = CURL_EMPTY;
|
||||||
send_negotiation(conn, CURL_WONT, option);
|
send_negotiation(data, CURL_WONT, option);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -616,9 +616,9 @@ void rec_do(struct connectdata *conn, int option)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static
|
static
|
||||||
void rec_dont(struct connectdata *conn, int option)
|
void rec_dont(struct Curl_easy *data, int option)
|
||||||
{
|
{
|
||||||
struct TELNET *tn = (struct TELNET *)conn->data->req.p.telnet;
|
struct TELNET *tn = data->req.p.telnet;
|
||||||
switch(tn->us[option]) {
|
switch(tn->us[option]) {
|
||||||
case CURL_NO:
|
case CURL_NO:
|
||||||
/* Already disabled */
|
/* Already disabled */
|
||||||
@ -626,7 +626,7 @@ void rec_dont(struct connectdata *conn, int option)
|
|||||||
|
|
||||||
case CURL_YES:
|
case CURL_YES:
|
||||||
tn->us[option] = CURL_NO;
|
tn->us[option] = CURL_NO;
|
||||||
send_negotiation(conn, CURL_WONT, option);
|
send_negotiation(data, CURL_WONT, option);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CURL_WANTNO:
|
case CURL_WANTNO:
|
||||||
@ -638,7 +638,7 @@ void rec_dont(struct connectdata *conn, int option)
|
|||||||
case CURL_OPPOSITE:
|
case CURL_OPPOSITE:
|
||||||
tn->us[option] = CURL_WANTYES;
|
tn->us[option] = CURL_WANTYES;
|
||||||
tn->usq[option] = CURL_EMPTY;
|
tn->usq[option] = CURL_EMPTY;
|
||||||
send_negotiation(conn, CURL_WILL, option);
|
send_negotiation(data, CURL_WILL, option);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -770,14 +770,14 @@ static void printsub(struct Curl_easy *data,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static CURLcode check_telnet_options(struct connectdata *conn)
|
static CURLcode check_telnet_options(struct Curl_easy *data)
|
||||||
{
|
{
|
||||||
struct curl_slist *head;
|
struct curl_slist *head;
|
||||||
struct curl_slist *beg;
|
struct curl_slist *beg;
|
||||||
char option_keyword[128] = "";
|
char option_keyword[128] = "";
|
||||||
char option_arg[256] = "";
|
char option_arg[256] = "";
|
||||||
struct Curl_easy *data = conn->data;
|
struct TELNET *tn = data->req.p.telnet;
|
||||||
struct TELNET *tn = (struct TELNET *)conn->data->req.p.telnet;
|
struct connectdata *conn = data->conn;
|
||||||
CURLcode result = CURLE_OK;
|
CURLcode result = CURLE_OK;
|
||||||
int binary_option;
|
int binary_option;
|
||||||
|
|
||||||
@ -874,7 +874,7 @@ static CURLcode check_telnet_options(struct connectdata *conn)
|
|||||||
* side.
|
* side.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static void suboption(struct connectdata *conn)
|
static void suboption(struct Curl_easy *data)
|
||||||
{
|
{
|
||||||
struct curl_slist *v;
|
struct curl_slist *v;
|
||||||
unsigned char temp[2048];
|
unsigned char temp[2048];
|
||||||
@ -883,8 +883,8 @@ static void suboption(struct connectdata *conn)
|
|||||||
int err;
|
int err;
|
||||||
char varname[128] = "";
|
char varname[128] = "";
|
||||||
char varval[128] = "";
|
char varval[128] = "";
|
||||||
struct Curl_easy *data = conn->data;
|
struct TELNET *tn = data->req.p.telnet;
|
||||||
struct TELNET *tn = (struct TELNET *)data->req.p.telnet;
|
struct connectdata *conn = data->conn;
|
||||||
|
|
||||||
printsub(data, '<', (unsigned char *)tn->subbuffer, CURL_SB_LEN(tn) + 2);
|
printsub(data, '<', (unsigned char *)tn->subbuffer, CURL_SB_LEN(tn) + 2);
|
||||||
switch(CURL_SB_GET(tn)) {
|
switch(CURL_SB_GET(tn)) {
|
||||||
@ -951,15 +951,14 @@ static void suboption(struct connectdata *conn)
|
|||||||
* Send suboption information to the server side.
|
* Send suboption information to the server side.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static void sendsuboption(struct connectdata *conn, int option)
|
static void sendsuboption(struct Curl_easy *data, int option)
|
||||||
{
|
{
|
||||||
ssize_t bytes_written;
|
ssize_t bytes_written;
|
||||||
int err;
|
int err;
|
||||||
unsigned short x, y;
|
unsigned short x, y;
|
||||||
unsigned char *uc1, *uc2;
|
unsigned char *uc1, *uc2;
|
||||||
|
struct TELNET *tn = data->req.p.telnet;
|
||||||
struct Curl_easy *data = conn->data;
|
struct connectdata *conn = data->conn;
|
||||||
struct TELNET *tn = (struct TELNET *)data->req.p.telnet;
|
|
||||||
|
|
||||||
switch(option) {
|
switch(option) {
|
||||||
case CURL_TELOPT_NAWS:
|
case CURL_TELOPT_NAWS:
|
||||||
@ -1008,7 +1007,7 @@ static void sendsuboption(struct connectdata *conn, int option)
|
|||||||
|
|
||||||
|
|
||||||
static
|
static
|
||||||
CURLcode telrcv(struct connectdata *conn,
|
CURLcode telrcv(struct Curl_easy *data,
|
||||||
const unsigned char *inbuf, /* Data received from socket */
|
const unsigned char *inbuf, /* Data received from socket */
|
||||||
ssize_t count) /* Number of bytes received */
|
ssize_t count) /* Number of bytes received */
|
||||||
{
|
{
|
||||||
@ -1016,8 +1015,7 @@ CURLcode telrcv(struct connectdata *conn,
|
|||||||
CURLcode result;
|
CURLcode result;
|
||||||
int in = 0;
|
int in = 0;
|
||||||
int startwrite = -1;
|
int startwrite = -1;
|
||||||
struct Curl_easy *data = conn->data;
|
struct TELNET *tn = data->req.p.telnet;
|
||||||
struct TELNET *tn = (struct TELNET *)data->req.p.telnet;
|
|
||||||
|
|
||||||
#define startskipping() \
|
#define startskipping() \
|
||||||
if(startwrite >= 0) { \
|
if(startwrite >= 0) { \
|
||||||
@ -1097,28 +1095,28 @@ CURLcode telrcv(struct connectdata *conn,
|
|||||||
case CURL_TS_WILL:
|
case CURL_TS_WILL:
|
||||||
printoption(data, "RCVD", CURL_WILL, c);
|
printoption(data, "RCVD", CURL_WILL, c);
|
||||||
tn->please_negotiate = 1;
|
tn->please_negotiate = 1;
|
||||||
rec_will(conn, c);
|
rec_will(data, c);
|
||||||
tn->telrcv_state = CURL_TS_DATA;
|
tn->telrcv_state = CURL_TS_DATA;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CURL_TS_WONT:
|
case CURL_TS_WONT:
|
||||||
printoption(data, "RCVD", CURL_WONT, c);
|
printoption(data, "RCVD", CURL_WONT, c);
|
||||||
tn->please_negotiate = 1;
|
tn->please_negotiate = 1;
|
||||||
rec_wont(conn, c);
|
rec_wont(data, c);
|
||||||
tn->telrcv_state = CURL_TS_DATA;
|
tn->telrcv_state = CURL_TS_DATA;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CURL_TS_DO:
|
case CURL_TS_DO:
|
||||||
printoption(data, "RCVD", CURL_DO, c);
|
printoption(data, "RCVD", CURL_DO, c);
|
||||||
tn->please_negotiate = 1;
|
tn->please_negotiate = 1;
|
||||||
rec_do(conn, c);
|
rec_do(data, c);
|
||||||
tn->telrcv_state = CURL_TS_DATA;
|
tn->telrcv_state = CURL_TS_DATA;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CURL_TS_DONT:
|
case CURL_TS_DONT:
|
||||||
printoption(data, "RCVD", CURL_DONT, c);
|
printoption(data, "RCVD", CURL_DONT, c);
|
||||||
tn->please_negotiate = 1;
|
tn->please_negotiate = 1;
|
||||||
rec_dont(conn, c);
|
rec_dont(data, c);
|
||||||
tn->telrcv_state = CURL_TS_DATA;
|
tn->telrcv_state = CURL_TS_DATA;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -1147,7 +1145,7 @@ CURLcode telrcv(struct connectdata *conn,
|
|||||||
CURL_SB_TERM(tn);
|
CURL_SB_TERM(tn);
|
||||||
|
|
||||||
printoption(data, "In SUBOPTION processing, RCVD", CURL_IAC, c);
|
printoption(data, "In SUBOPTION processing, RCVD", CURL_IAC, c);
|
||||||
suboption(conn); /* handle sub-option */
|
suboption(data); /* handle sub-option */
|
||||||
tn->telrcv_state = CURL_TS_IAC;
|
tn->telrcv_state = CURL_TS_IAC;
|
||||||
goto process_iac;
|
goto process_iac;
|
||||||
}
|
}
|
||||||
@ -1159,7 +1157,7 @@ CURLcode telrcv(struct connectdata *conn,
|
|||||||
CURL_SB_ACCUM(tn, CURL_SE);
|
CURL_SB_ACCUM(tn, CURL_SE);
|
||||||
tn->subpointer -= 2;
|
tn->subpointer -= 2;
|
||||||
CURL_SB_TERM(tn);
|
CURL_SB_TERM(tn);
|
||||||
suboption(conn); /* handle sub-option */
|
suboption(data); /* handle sub-option */
|
||||||
tn->telrcv_state = CURL_TS_DATA;
|
tn->telrcv_state = CURL_TS_DATA;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -1236,8 +1234,7 @@ static CURLcode send_telnet_data(struct Curl_easy *data,
|
|||||||
static CURLcode telnet_done(struct Curl_easy *data,
|
static CURLcode telnet_done(struct Curl_easy *data,
|
||||||
CURLcode status, bool premature)
|
CURLcode status, bool premature)
|
||||||
{
|
{
|
||||||
struct connectdata *conn = data->conn;
|
struct TELNET *tn = data->req.p.telnet;
|
||||||
struct TELNET *tn = (struct TELNET *)conn->data->req.p.telnet;
|
|
||||||
(void)status; /* unused */
|
(void)status; /* unused */
|
||||||
(void)premature; /* not used */
|
(void)premature; /* not used */
|
||||||
|
|
||||||
@ -1247,7 +1244,7 @@ static CURLcode telnet_done(struct Curl_easy *data,
|
|||||||
curl_slist_free_all(tn->telnet_vars);
|
curl_slist_free_all(tn->telnet_vars);
|
||||||
tn->telnet_vars = NULL;
|
tn->telnet_vars = NULL;
|
||||||
|
|
||||||
Curl_safefree(conn->data->req.p.telnet);
|
Curl_safefree(data->req.p.telnet);
|
||||||
|
|
||||||
return CURLE_OK;
|
return CURLE_OK;
|
||||||
}
|
}
|
||||||
@ -1281,13 +1278,13 @@ static CURLcode telnet_do(struct Curl_easy *data, bool *done)
|
|||||||
|
|
||||||
*done = TRUE; /* unconditionally */
|
*done = TRUE; /* unconditionally */
|
||||||
|
|
||||||
result = init_telnet(conn);
|
result = init_telnet(data);
|
||||||
if(result)
|
if(result)
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
tn = data->req.p.telnet;
|
tn = data->req.p.telnet;
|
||||||
|
|
||||||
result = check_telnet_options(conn);
|
result = check_telnet_options(data);
|
||||||
if(result)
|
if(result)
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
@ -1436,7 +1433,7 @@ static CURLcode telnet_do(struct Curl_easy *data, bool *done)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
result = telrcv(conn, (unsigned char *) buf, nread);
|
result = telrcv(data, (unsigned char *) buf, nread);
|
||||||
if(result) {
|
if(result) {
|
||||||
keepon = FALSE;
|
keepon = FALSE;
|
||||||
break;
|
break;
|
||||||
@ -1446,7 +1443,7 @@ static CURLcode telnet_do(struct Curl_easy *data, bool *done)
|
|||||||
otherwise don't. We don't want to speak telnet with
|
otherwise don't. We don't want to speak telnet with
|
||||||
non-telnet servers, like POP or SMTP. */
|
non-telnet servers, like POP or SMTP. */
|
||||||
if(tn->please_negotiate && !tn->already_negotiated) {
|
if(tn->please_negotiate && !tn->already_negotiated) {
|
||||||
negotiate(conn);
|
negotiate(data);
|
||||||
tn->already_negotiated = 1;
|
tn->already_negotiated = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1518,7 +1515,7 @@ static CURLcode telnet_do(struct Curl_easy *data, bool *done)
|
|||||||
|
|
||||||
total_dl += nread;
|
total_dl += nread;
|
||||||
Curl_pgrsSetDownloadCounter(data, total_dl);
|
Curl_pgrsSetDownloadCounter(data, total_dl);
|
||||||
result = telrcv(conn, (unsigned char *)buf, nread);
|
result = telrcv(data, (unsigned char *)buf, nread);
|
||||||
if(result) {
|
if(result) {
|
||||||
keepon = FALSE;
|
keepon = FALSE;
|
||||||
break;
|
break;
|
||||||
@ -1528,7 +1525,7 @@ static CURLcode telnet_do(struct Curl_easy *data, bool *done)
|
|||||||
otherwise don't. We don't want to speak telnet with
|
otherwise don't. We don't want to speak telnet with
|
||||||
non-telnet servers, like POP or SMTP. */
|
non-telnet servers, like POP or SMTP. */
|
||||||
if(tn->please_negotiate && !tn->already_negotiated) {
|
if(tn->please_negotiate && !tn->already_negotiated) {
|
||||||
negotiate(conn);
|
negotiate(data);
|
||||||
tn->already_negotiated = 1;
|
tn->already_negotiated = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1575,7 +1572,7 @@ static CURLcode telnet_do(struct Curl_easy *data, bool *done)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(Curl_pgrsUpdate(conn)) {
|
if(Curl_pgrsUpdate(data)) {
|
||||||
result = CURLE_ABORTED_BY_CALLBACK;
|
result = CURLE_ABORTED_BY_CALLBACK;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1093,7 +1093,7 @@ static CURLcode tftp_done(struct Curl_easy *data, CURLcode status,
|
|||||||
(void)status; /* unused */
|
(void)status; /* unused */
|
||||||
(void)premature; /* not used */
|
(void)premature; /* not used */
|
||||||
|
|
||||||
if(Curl_pgrsDone(conn))
|
if(Curl_pgrsDone(data))
|
||||||
return CURLE_ABORTED_BY_CALLBACK;
|
return CURLE_ABORTED_BY_CALLBACK;
|
||||||
|
|
||||||
/* If we have encountered an error */
|
/* If we have encountered an error */
|
||||||
@ -1201,7 +1201,7 @@ static CURLcode tftp_receive_packet(struct Curl_easy *data)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Update the progress meter */
|
/* Update the progress meter */
|
||||||
if(Curl_pgrsUpdate(conn)) {
|
if(Curl_pgrsUpdate(data)) {
|
||||||
tftp_state_machine(state, TFTP_EVENT_ERROR);
|
tftp_state_machine(state, TFTP_EVENT_ERROR);
|
||||||
return CURLE_ABORTED_BY_CALLBACK;
|
return CURLE_ABORTED_BY_CALLBACK;
|
||||||
}
|
}
|
||||||
@ -1323,7 +1323,7 @@ static CURLcode tftp_doing(struct Curl_easy *data, bool *dophase_done)
|
|||||||
/* The multi code doesn't have this logic for the DOING state so we
|
/* The multi code doesn't have this logic for the DOING state so we
|
||||||
provide it for TFTP since it may do the entire transfer in this
|
provide it for TFTP since it may do the entire transfer in this
|
||||||
state. */
|
state. */
|
||||||
if(Curl_pgrsUpdate(data->conn))
|
if(Curl_pgrsUpdate(data))
|
||||||
result = CURLE_ABORTED_BY_CALLBACK;
|
result = CURLE_ABORTED_BY_CALLBACK;
|
||||||
else
|
else
|
||||||
result = Curl_speedcheck(data, Curl_now());
|
result = Curl_speedcheck(data, Curl_now());
|
||||||
|
@ -1259,7 +1259,7 @@ CURLcode Curl_readwrite(struct connectdata *conn,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(Curl_pgrsUpdate(conn))
|
if(Curl_pgrsUpdate(data))
|
||||||
result = CURLE_ABORTED_BY_CALLBACK;
|
result = CURLE_ABORTED_BY_CALLBACK;
|
||||||
else
|
else
|
||||||
result = Curl_speedcheck(data, k->now);
|
result = Curl_speedcheck(data, k->now);
|
||||||
@ -1318,7 +1318,7 @@ CURLcode Curl_readwrite(struct connectdata *conn,
|
|||||||
failf(data, "transfer closed with outstanding read data remaining");
|
failf(data, "transfer closed with outstanding read data remaining");
|
||||||
return CURLE_PARTIAL_FILE;
|
return CURLE_PARTIAL_FILE;
|
||||||
}
|
}
|
||||||
if(Curl_pgrsUpdate(conn))
|
if(Curl_pgrsUpdate(data))
|
||||||
return CURLE_ABORTED_BY_CALLBACK;
|
return CURLE_ABORTED_BY_CALLBACK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
29
lib/url.c
29
lib/url.c
@ -829,26 +829,23 @@ CURLcode Curl_disconnect(struct Curl_easy *data,
|
|||||||
/* Cleanup NEGOTIATE connection-related data */
|
/* Cleanup NEGOTIATE connection-related data */
|
||||||
Curl_http_auth_cleanup_negotiate(conn);
|
Curl_http_auth_cleanup_negotiate(conn);
|
||||||
|
|
||||||
/* the protocol specific disconnect handler and conn_shutdown need a transfer
|
|
||||||
for the connection! */
|
|
||||||
conn->data = data;
|
|
||||||
|
|
||||||
if(conn->bits.connect_only)
|
if(conn->bits.connect_only)
|
||||||
/* treat the connection as dead in CONNECT_ONLY situations */
|
/* treat the connection as dead in CONNECT_ONLY situations */
|
||||||
dead_connection = TRUE;
|
dead_connection = TRUE;
|
||||||
|
|
||||||
if(conn->handler->disconnect) {
|
/* temporarily attach the connection to this transfer handle for the
|
||||||
/* During disconnect, the connection and the transfer is already
|
disonnect and shutdown */
|
||||||
disassociated, but the SSH backends (and more?) still need the
|
Curl_attach_connnection(data, conn);
|
||||||
transfer's connection pointer to identify the used connection */
|
|
||||||
data->conn = conn;
|
|
||||||
|
|
||||||
|
if(conn->handler->disconnect)
|
||||||
/* This is set if protocol-specific cleanups should be made */
|
/* This is set if protocol-specific cleanups should be made */
|
||||||
conn->handler->disconnect(data, conn, dead_connection);
|
conn->handler->disconnect(data, conn, dead_connection);
|
||||||
data->conn = NULL; /* forget it again */
|
|
||||||
}
|
|
||||||
|
|
||||||
conn_shutdown(data, conn);
|
conn_shutdown(data, conn);
|
||||||
|
|
||||||
|
/* detach it again */
|
||||||
|
Curl_detach_connnection(data);
|
||||||
|
|
||||||
conn_free(conn);
|
conn_free(conn);
|
||||||
return CURLE_OK;
|
return CURLE_OK;
|
||||||
}
|
}
|
||||||
@ -1111,7 +1108,7 @@ ConnectionExists(struct Curl_easy *data,
|
|||||||
|
|
||||||
/* Look up the bundle with all the connections to this particular host.
|
/* Look up the bundle with all the connections to this particular host.
|
||||||
Locks the connection cache, beware of early returns! */
|
Locks the connection cache, beware of early returns! */
|
||||||
bundle = Curl_conncache_find_bundle(needle, data->state.conn_cache,
|
bundle = Curl_conncache_find_bundle(data, needle, data->state.conn_cache,
|
||||||
&hostbundle);
|
&hostbundle);
|
||||||
if(bundle) {
|
if(bundle) {
|
||||||
/* Max pipe length is zero (unlimited) for multiplexed connections */
|
/* Max pipe length is zero (unlimited) for multiplexed connections */
|
||||||
@ -3650,7 +3647,7 @@ static CURLcode create_conn(struct Curl_easy *data,
|
|||||||
conn->bits.tcpconnect[FIRSTSOCKET] = TRUE; /* we are "connected */
|
conn->bits.tcpconnect[FIRSTSOCKET] = TRUE; /* we are "connected */
|
||||||
|
|
||||||
Curl_attach_connnection(data, conn);
|
Curl_attach_connnection(data, conn);
|
||||||
result = Curl_conncache_add_conn(data->state.conn_cache, conn);
|
result = Curl_conncache_add_conn(data);
|
||||||
if(result)
|
if(result)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
@ -3820,7 +3817,8 @@ static CURLcode create_conn(struct Curl_easy *data,
|
|||||||
/* this gets a lock on the conncache */
|
/* this gets a lock on the conncache */
|
||||||
const char *bundlehost;
|
const char *bundlehost;
|
||||||
struct connectbundle *bundle =
|
struct connectbundle *bundle =
|
||||||
Curl_conncache_find_bundle(conn, data->state.conn_cache, &bundlehost);
|
Curl_conncache_find_bundle(data, conn, data->state.conn_cache,
|
||||||
|
&bundlehost);
|
||||||
|
|
||||||
if(max_host_connections > 0 && bundle &&
|
if(max_host_connections > 0 && bundle &&
|
||||||
(bundle->num_connections >= max_host_connections)) {
|
(bundle->num_connections >= max_host_connections)) {
|
||||||
@ -3873,8 +3871,7 @@ static CURLcode create_conn(struct Curl_easy *data,
|
|||||||
* cache of ours!
|
* cache of ours!
|
||||||
*/
|
*/
|
||||||
Curl_attach_connnection(data, conn);
|
Curl_attach_connnection(data, conn);
|
||||||
|
result = Curl_conncache_add_conn(data);
|
||||||
result = Curl_conncache_add_conn(data->state.conn_cache, conn);
|
|
||||||
if(result)
|
if(result)
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user