Skip to content

Commit

Permalink
Support for host resolution override per connection (#434)
Browse files Browse the repository at this point in the history
* Support for host resolution override per connection
  • Loading branch information
bretambrose authored Apr 11, 2023
1 parent 0600662 commit c735009
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 0 deletions.
6 changes: 6 additions & 0 deletions include/aws/http/connection.h
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,12 @@ struct aws_http_client_connection_options {
* event loop group associated with the client bootstrap.
*/
struct aws_event_loop *requested_event_loop;

/**
* Optional
* Host resolution override that allows the user to override DNS behavior for this particular connection.
*/
const struct aws_host_resolution_config *host_resolution_config;
};

/* Predefined settings identifiers (RFC-7540 6.5.2) */
Expand Down
2 changes: 2 additions & 0 deletions include/aws/http/private/proxy_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,8 @@ struct aws_http_proxy_user_data {
struct aws_http_proxy_config *proxy_config;

struct aws_event_loop *requested_event_loop;

const struct aws_host_resolution_config *host_resolution_config;
};

struct aws_http_proxy_system_vtable {
Expand Down
6 changes: 6 additions & 0 deletions include/aws/http/websocket.h
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,12 @@ struct aws_websocket_client_connection_options {
* a single thread.
*/
struct aws_event_loop *requested_event_loop;

/**
* Optional
* Host resolution override that allows the user to override DNS behavior for this particular connection.
*/
const struct aws_host_resolution_config *host_resolution_config;
};

/**
Expand Down
1 change: 1 addition & 0 deletions source/connection.c
Original file line number Diff line number Diff line change
Expand Up @@ -1100,6 +1100,7 @@ int aws_http_client_connect_internal(
.enable_read_back_pressure = options.manual_window_management,
.user_data = http_bootstrap,
.requested_event_loop = options.requested_event_loop,
.host_resolution_override_config = options.host_resolution_config,
};

err = s_system_vtable_ptr->new_socket_channel(&channel_options);
Expand Down
4 changes: 4 additions & 0 deletions source/proxy_connection.c
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ struct aws_http_proxy_user_data *aws_http_proxy_user_data_new(
user_data->original_channel_on_setup = on_channel_setup;
user_data->original_channel_on_shutdown = on_channel_shutdown;
user_data->requested_event_loop = options.requested_event_loop;
user_data->host_resolution_config = options.host_resolution_config;
user_data->prior_knowledge_http2 = options.prior_knowledge_http2;

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

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

int result = aws_http_client_connect(&connect_options);
if (result == AWS_OP_ERR) {
Expand Down Expand Up @@ -1642,6 +1645,7 @@ int aws_http_proxy_new_socket_channel(
http_connection_options.on_setup = NULL; /* use channel callbacks, not http callbacks */
http_connection_options.on_shutdown = NULL; /* use channel callbacks, not http callbacks */
http_connection_options.requested_event_loop = channel_options->requested_event_loop;
http_connection_options.host_resolution_config = channel_options->host_resolution_override_config;

if (s_aws_http_client_connect_via_tunneling_proxy(
&http_connection_options, s_http_proxied_socket_channel_setup, s_http_proxied_socket_channel_shutdown)) {
Expand Down
1 change: 1 addition & 0 deletions source/websocket_bootstrap.c
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ int aws_websocket_client_connect(const struct aws_websocket_client_connection_op
http_options.on_setup = s_ws_bootstrap_on_http_setup;
http_options.on_shutdown = s_ws_bootstrap_on_http_shutdown;
http_options.requested_event_loop = options->requested_event_loop;
http_options.host_resolution_config = options->host_resolution_config;

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

0 comments on commit c735009

Please sign in to comment.