diff options
author | thegeorg <[email protected]> | 2025-05-12 15:51:24 +0300 |
---|---|---|
committer | thegeorg <[email protected]> | 2025-05-12 16:06:27 +0300 |
commit | d629bb70c8773d2c0c43f5088ddbb5a86d8c37ea (patch) | |
tree | 4f678e0d65ad08c800db21c657d3b0f71fafed06 /contrib/restricted/aws/aws-c-http/source/proxy_connection.c | |
parent | 92c4b696d7a1c03d54e13aff7a7c20a078d90dd7 (diff) |
Update contrib/restricted/aws libraries to nixpkgs 24.05
commit_hash:f8083acb039e6005e820cdee77b84e0a6b6c6d6d
Diffstat (limited to 'contrib/restricted/aws/aws-c-http/source/proxy_connection.c')
-rw-r--r-- | contrib/restricted/aws/aws-c-http/source/proxy_connection.c | 55 |
1 files changed, 35 insertions, 20 deletions
diff --git a/contrib/restricted/aws/aws-c-http/source/proxy_connection.c b/contrib/restricted/aws/aws-c-http/source/proxy_connection.c index e6cdb8a2460..3706c2fd543 100644 --- a/contrib/restricted/aws/aws-c-http/source/proxy_connection.c +++ b/contrib/restricted/aws/aws-c-http/source/proxy_connection.c @@ -39,7 +39,7 @@ AWS_STATIC_STRING_FROM_LITERAL(s_proxy_no_verify_peer_env_var, "AWS_PROXY_NO_VER #endif static struct aws_http_proxy_system_vtable s_default_vtable = { - .setup_client_tls = &aws_channel_setup_client_tls, + .aws_channel_setup_client_tls = &aws_channel_setup_client_tls, }; static struct aws_http_proxy_system_vtable *s_vtable = &s_default_vtable; @@ -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 */ @@ -465,7 +466,7 @@ static struct aws_http_message *s_build_h1_proxy_connect_request(struct aws_http } char port_str[20] = "\0"; - snprintf(port_str, sizeof(port_str), "%d", (int)user_data->original_port); + snprintf(port_str, sizeof(port_str), "%u", user_data->original_port); struct aws_byte_cursor port_cursor = aws_byte_cursor_from_c_str(port_str); if (aws_byte_buf_append(&path_buffer, &port_cursor)) { goto on_error; @@ -771,7 +772,7 @@ static void s_aws_http_on_stream_complete_tunnel_proxy( last_slot = last_slot->adj_right; } - if (s_vtable->setup_client_tls(last_slot, context->original_tls_options)) { + if (s_vtable->aws_channel_setup_client_tls(last_slot, context->original_tls_options)) { AWS_LOGF_ERROR( AWS_LS_HTTP_CONNECTION, "(%p) Proxy connection failed to start TLS negotiation with error %d(%s)", @@ -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); @@ -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) { @@ -1137,6 +1140,23 @@ static enum aws_http_proxy_connection_type s_determine_proxy_connection_type( } } +static struct aws_string *s_get_proxy_environment_value( + struct aws_allocator *allocator, + const struct aws_string *env_name) { + struct aws_string *out_string = NULL; + if (aws_get_environment_value(allocator, env_name, &out_string) == AWS_OP_SUCCESS && out_string != NULL && + out_string->len > 0) { + AWS_LOGF_DEBUG( + AWS_LS_HTTP_CONNECTION, + "%s environment found, %s", + aws_string_c_str(env_name), + aws_string_c_str(out_string)); + return out_string; + } + aws_string_destroy(out_string); + return NULL; +} + static int s_proxy_uri_init_from_env_variable( struct aws_allocator *allocator, const struct aws_http_client_connection_options *options, @@ -1145,25 +1165,19 @@ static int s_proxy_uri_init_from_env_variable( struct aws_string *proxy_uri_string = NULL; *found = false; if (options->tls_options) { - if (aws_get_environment_value(allocator, s_https_proxy_env_var_low, &proxy_uri_string) == AWS_OP_SUCCESS && - proxy_uri_string != NULL) { - AWS_LOGF_DEBUG(AWS_LS_HTTP_CONNECTION, "https_proxy environment found"); - } else if ( - aws_get_environment_value(allocator, s_https_proxy_env_var, &proxy_uri_string) == AWS_OP_SUCCESS && - proxy_uri_string != NULL) { - AWS_LOGF_DEBUG(AWS_LS_HTTP_CONNECTION, "HTTPS_PROXY environment found"); - } else { + proxy_uri_string = s_get_proxy_environment_value(allocator, s_https_proxy_env_var_low); + if (proxy_uri_string == NULL) { + proxy_uri_string = s_get_proxy_environment_value(allocator, s_https_proxy_env_var); + } + if (proxy_uri_string == NULL) { return AWS_OP_SUCCESS; } } else { - if (aws_get_environment_value(allocator, s_http_proxy_env_var_low, &proxy_uri_string) == AWS_OP_SUCCESS && - proxy_uri_string != NULL) { - AWS_LOGF_DEBUG(AWS_LS_HTTP_CONNECTION, "http_proxy environment found"); - } else if ( - aws_get_environment_value(allocator, s_http_proxy_env_var, &proxy_uri_string) == AWS_OP_SUCCESS && - proxy_uri_string != NULL) { - AWS_LOGF_DEBUG(AWS_LS_HTTP_CONNECTION, "HTTP_PROXY environment found"); - } else { + proxy_uri_string = s_get_proxy_environment_value(allocator, s_http_proxy_env_var_low); + if (proxy_uri_string == NULL) { + proxy_uri_string = s_get_proxy_environment_value(allocator, s_http_proxy_env_var); + } + if (proxy_uri_string == NULL) { return AWS_OP_SUCCESS; } } @@ -1213,7 +1227,7 @@ static int s_setup_proxy_tls_env_variable( AWS_LS_HTTP_CONNECTION, "Failed making default TLS context because of BYO_CRYPTO, set up the tls_options for proxy_env_settings to " "make it work."); - return AWS_OP_ERR; + return aws_raise_error(AWS_ERROR_UNIMPLEMENTED); #else struct aws_tls_ctx *tls_ctx = NULL; struct aws_tls_ctx_options tls_ctx_options; @@ -1642,6 +1656,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)) { |