summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2021-01-24 23:41:58 +0100
committerDaniel Stenberg <daniel@haxx.se>2021-01-24 23:41:58 +0100
commit8204826b2bdcbd25c6c16bad822045f0293021cc (patch)
treee07eaf58bced0cd81d55a3f27486c93ab8f60d48
parentecb13416e316fc1c781f865d2bb7e74462ef793b (diff)
downloadcurl-bagder/hostip-proxy-data-conn.tar.gz
hostip/proxy: remove conn->data usebagder/hostip-proxy-data-conn
-rw-r--r--lib/asyn-thread.c2
-rw-r--r--lib/ftp.c4
-rw-r--r--lib/hostip.c3
-rw-r--r--lib/hostip.h2
-rw-r--r--lib/http.c2
-rw-r--r--lib/http_proxy.c50
-rw-r--r--lib/http_proxy.h6
-rw-r--r--lib/multi.c4
-rw-r--r--lib/openldap.c6
-rw-r--r--lib/socks.c4
10 files changed, 43 insertions, 40 deletions
diff --git a/lib/asyn-thread.c b/lib/asyn-thread.c
index e79aa9127..3399b1a25 100644
--- a/lib/asyn-thread.c
+++ b/lib/asyn-thread.c
@@ -708,7 +708,7 @@ struct Curl_addrinfo *Curl_resolver_getaddrinfo(struct Curl_easy *data,
return NULL;
}
- failf(conn->data, "getaddrinfo() thread failed");
+ failf(data, "getaddrinfo() thread failed");
return NULL;
}
diff --git a/lib/ftp.c b/lib/ftp.c
index 6a1cf4df9..69b3f35df 100644
--- a/lib/ftp.c
+++ b/lib/ftp.c
@@ -3543,7 +3543,7 @@ static CURLcode ftp_do_more(struct Curl_easy *data, int *completep)
if(Curl_connect_ongoing(conn)) {
/* As we're in TUNNEL_CONNECT state now, we know the proxy name and port
aren't used so we blank their arguments. */
- result = Curl_proxyCONNECT(conn, SECONDARYSOCKET, NULL, 0);
+ result = Curl_proxyCONNECT(data, SECONDARYSOCKET, NULL, 0);
return result;
}
@@ -3565,7 +3565,7 @@ static CURLcode ftp_do_more(struct Curl_easy *data, int *completep)
}
#ifndef CURL_DISABLE_PROXY
- result = Curl_proxy_connect(conn, SECONDARYSOCKET);
+ result = Curl_proxy_connect(data, SECONDARYSOCKET);
if(result)
return result;
diff --git a/lib/hostip.c b/lib/hostip.c
index 9ca9bdbe7..46f641135 100644
--- a/lib/hostip.c
+++ b/lib/hostip.c
@@ -309,11 +309,10 @@ static struct Curl_dns_entry *fetch_addr(struct Curl_easy *data,
* use, or we'll leak memory!
*/
struct Curl_dns_entry *
-Curl_fetch_addr(struct connectdata *conn,
+Curl_fetch_addr(struct Curl_easy *data,
const char *hostname,
int port)
{
- struct Curl_easy *data = conn->data;
struct Curl_dns_entry *dns = NULL;
if(data->share)
diff --git a/lib/hostip.h b/lib/hostip.h
index 6deeb9f9c..c495c21e0 100644
--- a/lib/hostip.h
+++ b/lib/hostip.h
@@ -177,7 +177,7 @@ void Curl_printable_address(const struct Curl_addrinfo *ip,
* use, or we'll leak memory!
*/
struct Curl_dns_entry *
-Curl_fetch_addr(struct connectdata *conn,
+Curl_fetch_addr(struct Curl_easy *data,
const char *hostname,
int port);
diff --git a/lib/http.c b/lib/http.c
index 40773e6da..6f7f55d07 100644
--- a/lib/http.c
+++ b/lib/http.c
@@ -1433,7 +1433,7 @@ CURLcode Curl_http_connect(struct Curl_easy *data, bool *done)
#ifndef CURL_DISABLE_PROXY
/* the CONNECT procedure might not have been completed */
- result = Curl_proxy_connect(conn, FIRSTSOCKET);
+ result = Curl_proxy_connect(data, FIRSTSOCKET);
if(result)
return result;
diff --git a/lib/http_proxy.c b/lib/http_proxy.c
index 8bc86446f..46261184d 100644
--- a/lib/http_proxy.c
+++ b/lib/http_proxy.c
@@ -50,15 +50,16 @@
* proxy_ssl_connected connection bit when complete. Can be
* called multiple times.
*/
-static CURLcode https_proxy_connect(struct connectdata *conn, int sockindex)
+static CURLcode https_proxy_connect(struct Curl_easy *data, int sockindex)
{
#ifdef USE_SSL
+ struct connectdata *conn = data->conn;
CURLcode result = CURLE_OK;
DEBUGASSERT(conn->http_proxy.proxytype == CURLPROXY_HTTPS);
if(!conn->bits.proxy_ssl_connected[sockindex]) {
/* perform SSL initialization for this socket */
result =
- Curl_ssl_connect_nonblocking(conn->data, conn, sockindex,
+ Curl_ssl_connect_nonblocking(data, conn, sockindex,
&conn->bits.proxy_ssl_connected[sockindex]);
if(result)
/* a failed connection is marked for closure to prevent (bad) re-use or
@@ -67,17 +68,17 @@ static CURLcode https_proxy_connect(struct connectdata *conn, int sockindex)
}
return result;
#else
- (void) conn;
+ (void) data;
(void) sockindex;
return CURLE_NOT_BUILT_IN;
#endif
}
-CURLcode Curl_proxy_connect(struct connectdata *conn, int sockindex)
+CURLcode Curl_proxy_connect(struct Curl_easy *data, int sockindex)
{
- struct Curl_easy *data = conn->data;
+ struct connectdata *conn = data->conn;
if(conn->http_proxy.proxytype == CURLPROXY_HTTPS) {
- const CURLcode result = https_proxy_connect(conn, sockindex);
+ const CURLcode result = https_proxy_connect(data, sockindex);
if(result)
return result;
if(!conn->bits.proxy_ssl_connected[sockindex])
@@ -105,9 +106,9 @@ CURLcode Curl_proxy_connect(struct connectdata *conn, int sockindex)
* This function might be called several times in the multi interface case
* if the proxy's CONNECT response is not instant.
*/
- prot_save = conn->data->req.p.http;
+ prot_save = data->req.p.http;
memset(&http_proxy, 0, sizeof(http_proxy));
- conn->data->req.p.http = &http_proxy;
+ data->req.p.http = &http_proxy;
connkeep(conn, "HTTP proxy CONNECT");
/* for the secondary socket (FTP), use the "connect to host"
@@ -127,8 +128,8 @@ CURLcode Curl_proxy_connect(struct connectdata *conn, int sockindex)
remote_port = conn->conn_to_port;
else
remote_port = conn->remote_port;
- result = Curl_proxyCONNECT(conn, sockindex, hostname, remote_port);
- conn->data->req.p.http = prot_save;
+ result = Curl_proxyCONNECT(data, sockindex, hostname, remote_port);
+ data->req.p.http = prot_save;
if(CURLE_OK != result)
return result;
Curl_safefree(data->state.aptr.proxyuserpwd);
@@ -152,15 +153,16 @@ bool Curl_connect_ongoing(struct connectdata *conn)
(conn->connect_state->tunnel_state != TUNNEL_COMPLETE);
}
-static CURLcode connect_init(struct connectdata *conn, bool reinit)
+static CURLcode connect_init(struct Curl_easy *data, bool reinit)
{
struct http_connect_state *s;
+ struct connectdata *conn = data->conn;
if(!reinit) {
DEBUGASSERT(!conn->connect_state);
s = calloc(1, sizeof(struct http_connect_state));
if(!s)
return CURLE_OUT_OF_MEMORY;
- infof(conn->data, "allocate connect buffer!\n");
+ infof(data, "allocate connect buffer!\n");
conn->connect_state = s;
Curl_dyn_init(&s->rcvbuf, DYN_PROXY_CONNECT_HEADERS);
}
@@ -176,12 +178,13 @@ static CURLcode connect_init(struct connectdata *conn, bool reinit)
return CURLE_OK;
}
-static void connect_done(struct connectdata *conn)
+static void connect_done(struct Curl_easy *data)
{
+ struct connectdata *conn = data->conn;
struct http_connect_state *s = conn->connect_state;
s->tunnel_state = TUNNEL_COMPLETE;
Curl_dyn_free(&s->rcvbuf);
- infof(conn->data, "CONNECT phase completed!\n");
+ infof(data, "CONNECT phase completed!\n");
}
static CURLcode CONNECT_host(struct Curl_easy *data,
@@ -216,16 +219,16 @@ static CURLcode CONNECT_host(struct Curl_easy *data,
return CURLE_OK;
}
-static CURLcode CONNECT(struct connectdata *conn,
+static CURLcode CONNECT(struct Curl_easy *data,
int sockindex,
const char *hostname,
int remote_port)
#ifndef USE_HYPER
{
int subversion = 0;
- struct Curl_easy *data = conn->data;
struct SingleRequest *k = &data->req;
CURLcode result;
+ struct connectdata *conn = data->conn;
curl_socket_t tunnelsocket = conn->sock[sockindex];
struct http_connect_state *s = conn->connect_state;
char *linep;
@@ -592,7 +595,7 @@ static CURLcode CONNECT(struct connectdata *conn,
* means the HTTP authentication is still going on so if the tunnel
* is complete we start over in INIT state */
if(data->req.newurl && (TUNNEL_COMPLETE == s->tunnel_state)) {
- connect_init(conn, TRUE); /* reinit */
+ connect_init(data, TRUE); /* reinit */
}
} while(data->req.newurl);
@@ -601,7 +604,7 @@ static CURLcode CONNECT(struct connectdata *conn,
if(s->close_connection && data->req.newurl) {
conn->bits.proxy_connect_closed = TRUE;
infof(data, "Connect me again please\n");
- connect_done(conn);
+ connect_done(data);
}
else {
free(data->req.newurl);
@@ -646,7 +649,7 @@ static CURLcode CONNECT(struct connectdata *conn,
#else
/* The Hyper version of CONNECT */
{
- struct Curl_easy *data = conn->data;
+ struct connectdata *conn = data->conn;
struct hyptransfer *h = &data->hyp;
curl_socket_t tunnelsocket = conn->sock[sockindex];
struct http_connect_state *s = conn->connect_state;
@@ -879,21 +882,22 @@ void Curl_connect_free(struct Curl_easy *data)
* this proxy. After that, the socket can be used just as a normal socket.
*/
-CURLcode Curl_proxyCONNECT(struct connectdata *conn,
+CURLcode Curl_proxyCONNECT(struct Curl_easy *data,
int sockindex,
const char *hostname,
int remote_port)
{
CURLcode result;
+ struct connectdata *conn = data->conn;
if(!conn->connect_state) {
- result = connect_init(conn, FALSE);
+ result = connect_init(data, FALSE);
if(result)
return result;
}
- result = CONNECT(conn, sockindex, hostname, remote_port);
+ result = CONNECT(data, sockindex, hostname, remote_port);
if(result || Curl_connect_complete(conn))
- connect_done(conn);
+ connect_done(data);
return result;
}
diff --git a/lib/http_proxy.h b/lib/http_proxy.h
index a595e8b55..a78db0d04 100644
--- a/lib/http_proxy.h
+++ b/lib/http_proxy.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
* you should have received as part of this distribution. The terms
@@ -27,14 +27,14 @@
#if !defined(CURL_DISABLE_PROXY) && !defined(CURL_DISABLE_HTTP)
/* ftp can use this as well */
-CURLcode Curl_proxyCONNECT(struct connectdata *conn,
+CURLcode Curl_proxyCONNECT(struct Curl_easy *data,
int tunnelsocket,
const char *hostname, int remote_port);
/* Default proxy timeout in milliseconds */
#define PROXY_TIMEOUT (3600*1000)
-CURLcode Curl_proxy_connect(struct connectdata *conn, int sockindex);
+CURLcode Curl_proxy_connect(struct Curl_easy *data, int sockindex);
bool Curl_connect_complete(struct connectdata *conn);
bool Curl_connect_ongoing(struct connectdata *conn);
diff --git a/lib/multi.c b/lib/multi.c
index 0f9d79dc2..85707a1af 100644
--- a/lib/multi.c
+++ b/lib/multi.c
@@ -1499,7 +1499,7 @@ static CURLcode protocol_connect(struct Curl_easy *data,
if(!conn->bits.protoconnstart) {
#ifndef CURL_DISABLE_PROXY
- result = Curl_proxy_connect(conn, FIRSTSOCKET);
+ result = Curl_proxy_connect(data, FIRSTSOCKET);
if(result)
return result;
@@ -1729,7 +1729,7 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
hostname = conn->host.name;
/* check if we have the name resolved by now */
- dns = Curl_fetch_addr(conn, hostname, (int)conn->port);
+ dns = Curl_fetch_addr(data, hostname, (int)conn->port);
if(dns) {
#ifdef CURLRES_ASYNCH
diff --git a/lib/openldap.c b/lib/openldap.c
index bb6f785b5..4070bbf88 100644
--- a/lib/openldap.c
+++ b/lib/openldap.c
@@ -188,7 +188,7 @@ static CURLcode ldap_setup_connection(struct Curl_easy *data,
status = CURLE_OUT_OF_MEMORY;
msg = url_errs[rc];
}
- failf(conn->data, "LDAP local: %s", msg);
+ failf(data, "LDAP local: %s", msg);
return status;
}
proto = ldap_pvt_url_scheme2proto(lud->lud_scheme);
@@ -401,7 +401,7 @@ static CURLcode ldap_do(struct Curl_easy *data, bool *done)
status = CURLE_OUT_OF_MEMORY;
msg = url_errs[rc];
}
- failf(conn->data, "LDAP local: %s", msg);
+ failf(data, "LDAP local: %s", msg);
return status;
}
@@ -439,7 +439,7 @@ static CURLcode ldap_done(struct Curl_easy *data, CURLcode res,
ldap_abandon_ext(li->ld, lr->msgid, NULL, NULL);
lr->msgid = 0;
}
- conn->data->req.p.ldap = NULL;
+ data->req.p.ldap = NULL;
free(lr);
}
diff --git a/lib/socks.c b/lib/socks.c
index 165c5496f..d1c2a2ed1 100644
--- a/lib/socks.c
+++ b/lib/socks.c
@@ -257,7 +257,7 @@ CURLproxycode Curl_SOCKS4(const char *proxy_user,
case CONNECT_RESOLVING:
/* check if we have the name resolved by now */
- dns = Curl_fetch_addr(conn, hostname, (int)conn->port);
+ dns = Curl_fetch_addr(data, hostname, (int)conn->port);
if(dns) {
#ifdef CURLRES_ASYNCH
@@ -771,7 +771,7 @@ CURLproxycode Curl_SOCKS5(const char *proxy_user,
case CONNECT_RESOLVING:
/* check if we have the name resolved by now */
- dns = Curl_fetch_addr(conn, hostname, remote_port);
+ dns = Curl_fetch_addr(data, hostname, remote_port);
if(dns) {
#ifdef CURLRES_ASYNCH