mirror of
https://github.com/warmcat/libwebsockets.git
synced 2025-03-09 00:00:04 +01:00
defer changing to proxy uri until connected
Reported-by: shyswork Signed-off-by: Andy Green <andy.green@linaro.org>
This commit is contained in:
parent
6811457323
commit
36efd82da6
1 changed files with 17 additions and 15 deletions
|
@ -25,25 +25,16 @@ struct libwebsocket *__libwebsocket_client_connect_2(
|
|||
"\x0d\x0a",
|
||||
lws_hdr_simple_ptr(wsi, _WSI_TOKEN_CLIENT_PEER_ADDRESS),
|
||||
wsi->u.hdr.ah->c_port);
|
||||
|
||||
/* OK from now on we talk via the proxy, so connect to that */
|
||||
|
||||
/*
|
||||
* (will overwrite existing pointer,
|
||||
* leaving old string/frag there but unreferenced)
|
||||
*/
|
||||
if (lws_hdr_simple_create(wsi, _WSI_TOKEN_CLIENT_PEER_ADDRESS,
|
||||
context->http_proxy_address))
|
||||
goto oom4;
|
||||
wsi->u.hdr.ah->c_port = context->http_proxy_port;
|
||||
ads = context->http_proxy_address;
|
||||
server_addr.sin_port = htons(context->http_proxy_port);
|
||||
} else {
|
||||
ads = lws_hdr_simple_ptr(wsi, _WSI_TOKEN_CLIENT_PEER_ADDRESS);
|
||||
server_addr.sin_port = htons(wsi->u.hdr.ah->c_port);
|
||||
}
|
||||
|
||||
/*
|
||||
* prepare the actual connection (to the proxy, if any)
|
||||
*/
|
||||
|
||||
ads = lws_hdr_simple_ptr(wsi, _WSI_TOKEN_CLIENT_PEER_ADDRESS);
|
||||
|
||||
lwsl_client("__libwebsocket_client_connect_2: address %s\n", ads);
|
||||
|
||||
server_hostent = gethostbyname(ads);
|
||||
|
@ -77,8 +68,8 @@ struct libwebsocket *__libwebsocket_client_connect_2(
|
|||
}
|
||||
|
||||
server_addr.sin_family = AF_INET;
|
||||
server_addr.sin_port = htons(wsi->u.hdr.ah->c_port);
|
||||
server_addr.sin_addr = *((struct in_addr *)server_hostent->h_addr);
|
||||
|
||||
bzero(&server_addr.sin_zero, 8);
|
||||
|
||||
if (connect(wsi->sock, (struct sockaddr *)&server_addr,
|
||||
|
@ -112,6 +103,17 @@ struct libwebsocket *__libwebsocket_client_connect_2(
|
|||
|
||||
if (context->http_proxy_port) {
|
||||
|
||||
/* OK from now on we talk via the proxy, so connect to that */
|
||||
|
||||
/*
|
||||
* (will overwrite existing pointer,
|
||||
* leaving old string/frag there but unreferenced)
|
||||
*/
|
||||
if (lws_hdr_simple_create(wsi, _WSI_TOKEN_CLIENT_PEER_ADDRESS,
|
||||
context->http_proxy_address))
|
||||
goto failed;
|
||||
wsi->u.hdr.ah->c_port = context->http_proxy_port;
|
||||
|
||||
n = send(wsi->sock, context->service_buffer, plen, MSG_NOSIGNAL);
|
||||
if (n < 0) {
|
||||
lwsl_debug("ERROR writing to proxy socket\n");
|
||||
|
|
Loading…
Add table
Reference in a new issue