Skip to content

Commit c735009

Browse files
authored
Support for host resolution override per connection (#434)
* Support for host resolution override per connection
1 parent 0600662 commit c735009

File tree

6 files changed

+20
-0
lines changed

6 files changed

+20
-0
lines changed

include/aws/http/connection.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,12 @@ struct aws_http_client_connection_options {
398398
* event loop group associated with the client bootstrap.
399399
*/
400400
struct aws_event_loop *requested_event_loop;
401+
402+
/**
403+
* Optional
404+
* Host resolution override that allows the user to override DNS behavior for this particular connection.
405+
*/
406+
const struct aws_host_resolution_config *host_resolution_config;
401407
};
402408

403409
/* Predefined settings identifiers (RFC-7540 6.5.2) */

include/aws/http/private/proxy_impl.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,8 @@ struct aws_http_proxy_user_data {
126126
struct aws_http_proxy_config *proxy_config;
127127

128128
struct aws_event_loop *requested_event_loop;
129+
130+
const struct aws_host_resolution_config *host_resolution_config;
129131
};
130132

131133
struct aws_http_proxy_system_vtable {

include/aws/http/websocket.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,12 @@ struct aws_websocket_client_connection_options {
280280
* a single thread.
281281
*/
282282
struct aws_event_loop *requested_event_loop;
283+
284+
/**
285+
* Optional
286+
* Host resolution override that allows the user to override DNS behavior for this particular connection.
287+
*/
288+
const struct aws_host_resolution_config *host_resolution_config;
283289
};
284290

285291
/**

source/connection.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1100,6 +1100,7 @@ int aws_http_client_connect_internal(
11001100
.enable_read_back_pressure = options.manual_window_management,
11011101
.user_data = http_bootstrap,
11021102
.requested_event_loop = options.requested_event_loop,
1103+
.host_resolution_override_config = options.host_resolution_config,
11031104
};
11041105

11051106
err = s_system_vtable_ptr->new_socket_channel(&channel_options);

source/proxy_connection.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ struct aws_http_proxy_user_data *aws_http_proxy_user_data_new(
162162
user_data->original_channel_on_setup = on_channel_setup;
163163
user_data->original_channel_on_shutdown = on_channel_shutdown;
164164
user_data->requested_event_loop = options.requested_event_loop;
165+
user_data->host_resolution_config = options.host_resolution_config;
165166
user_data->prior_knowledge_http2 = options.prior_knowledge_http2;
166167

167168
/* one and only one setup callback must be valid */
@@ -1048,6 +1049,7 @@ static int s_aws_http_client_connect_via_forwarding_proxy(const struct aws_http_
10481049
options_copy.on_shutdown = s_aws_http_on_client_connection_http_proxy_shutdown_fn;
10491050
options_copy.tls_options = options->proxy_options->tls_options;
10501051
options_copy.requested_event_loop = options->requested_event_loop;
1052+
options_copy.host_resolution_config = options->host_resolution_config;
10511053
options_copy.prior_knowledge_http2 = false; /* ToDo, expose the protocol specific config for proxy connection. */
10521054

10531055
int result = aws_http_client_connect_internal(&options_copy, s_proxy_http_request_transform);
@@ -1084,6 +1086,7 @@ static int s_create_tunneling_connection(struct aws_http_proxy_user_data *user_d
10841086
connect_options.http1_options = NULL; /* ToDo, expose the protocol specific config for proxy connection. */
10851087
connect_options.http2_options = NULL; /* ToDo */
10861088
connect_options.requested_event_loop = user_data->requested_event_loop;
1089+
connect_options.host_resolution_config = user_data->host_resolution_config;
10871090

10881091
int result = aws_http_client_connect(&connect_options);
10891092
if (result == AWS_OP_ERR) {
@@ -1642,6 +1645,7 @@ int aws_http_proxy_new_socket_channel(
16421645
http_connection_options.on_setup = NULL; /* use channel callbacks, not http callbacks */
16431646
http_connection_options.on_shutdown = NULL; /* use channel callbacks, not http callbacks */
16441647
http_connection_options.requested_event_loop = channel_options->requested_event_loop;
1648+
http_connection_options.host_resolution_config = channel_options->host_resolution_override_config;
16451649

16461650
if (s_aws_http_client_connect_via_tunneling_proxy(
16471651
&http_connection_options, s_http_proxied_socket_channel_setup, s_http_proxied_socket_channel_shutdown)) {

source/websocket_bootstrap.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,7 @@ int aws_websocket_client_connect(const struct aws_websocket_client_connection_op
215215
http_options.on_setup = s_ws_bootstrap_on_http_setup;
216216
http_options.on_shutdown = s_ws_bootstrap_on_http_shutdown;
217217
http_options.requested_event_loop = options->requested_event_loop;
218+
http_options.host_resolution_config = options->host_resolution_config;
218219

219220
/* Infer port, if not explicitly specified in URI */
220221
http_options.port = options->port;

0 commit comments

Comments
 (0)