99#include <aws/http/http.h>
1010
1111#include <aws/http/connection.h>
12+ #include <aws/http/proxy.h>
13+ #include <aws/http/status_code.h>
14+ #include <aws/io/socket.h>
1215
16+ struct aws_http_connection_manager_options ;
1317struct aws_http_message ;
1418struct aws_channel_slot ;
1519struct aws_string ;
1620struct aws_tls_connection_options ;
21+ struct aws_http_proxy_negotiator ;
22+ struct aws_http_proxy_strategy ;
23+ struct aws_http_proxy_strategy_tunneling_sequence_options ;
24+ struct aws_http_proxy_strategy_tunneling_kerberos_options ;
25+ struct aws_http_proxy_strategy_tunneling_ntlm_options ;
1726
1827/*
1928 * (Successful) State transitions for proxy connections
@@ -37,17 +46,15 @@ struct aws_http_proxy_config {
3746
3847 struct aws_allocator * allocator ;
3948
49+ enum aws_http_proxy_connection_type connection_type ;
50+
4051 struct aws_byte_buf host ;
4152
4253 uint16_t port ;
4354
4455 struct aws_tls_connection_options * tls_options ;
4556
46- enum aws_http_proxy_authentication_type auth_type ;
47-
48- struct aws_byte_buf auth_username ;
49-
50- struct aws_byte_buf auth_password ;
57+ struct aws_http_proxy_strategy * proxy_strategy ;
5158};
5259
5360/*
@@ -61,19 +68,31 @@ struct aws_http_proxy_config {
6168struct aws_http_proxy_user_data {
6269 struct aws_allocator * allocator ;
6370
71+ /*
72+ * dynamic proxy connection resolution state
73+ */
6474 enum aws_proxy_bootstrap_state state ;
6575 int error_code ;
76+ enum aws_http_status_code connect_status_code ;
6677 struct aws_http_connection * connection ;
6778 struct aws_http_message * connect_request ;
6879 struct aws_http_stream * connect_stream ;
80+ struct aws_http_proxy_negotiator * proxy_negotiator ;
6981
82+ /*
83+ * Cached original connect options
84+ */
7085 struct aws_string * original_host ;
7186 uint16_t original_port ;
7287 aws_http_on_client_connection_setup_fn * original_on_setup ;
7388 aws_http_on_client_connection_shutdown_fn * original_on_shutdown ;
7489 void * original_user_data ;
7590
7691 struct aws_tls_connection_options * tls_options ;
92+ struct aws_client_bootstrap * bootstrap ;
93+ struct aws_socket_options socket_options ;
94+ bool manual_window_management ;
95+ size_t initial_window_size ;
7796
7897 struct aws_http_proxy_config * proxy_config ;
7998};
@@ -103,18 +122,81 @@ int aws_http_rewrite_uri_for_proxy_request(
103122AWS_HTTP_API
104123void aws_http_proxy_system_set_vtable (struct aws_http_proxy_system_vtable * vtable );
105124
125+ /**
126+ * Checks if tunneling proxy negotiation should continue to try and connect
127+ * @param proxy_negotiator negotiator to query
128+ * @return true if another connect request should be attempted, false otherwise
129+ */
130+ AWS_HTTP_API
131+ enum aws_http_proxy_negotiation_retry_directive aws_http_proxy_negotiator_get_retry_directive (
132+ struct aws_http_proxy_negotiator * proxy_negotiator );
133+
134+ /**
135+ * Constructor for a tunnel-only proxy strategy that applies no changes to outbound CONNECT requests. Intended to be
136+ * the first link in an adaptive sequence for a tunneling proxy: first try a basic CONNECT, then based on the response,
137+ * later links are allowed to make attempts.
138+ *
139+ * @param allocator memory allocator to use
140+ * @return a new proxy strategy if successfully constructed, otherwise NULL
141+ */
142+ AWS_HTTP_API
143+ struct aws_http_proxy_strategy * aws_http_proxy_strategy_new_tunneling_one_time_identity (
144+ struct aws_allocator * allocator );
145+
146+ /**
147+ * Constructor for a forwarding-only proxy strategy that does nothing. Exists so that all proxy logic uses a
148+ * strategy.
149+ *
150+ * @param allocator memory allocator to use
151+ * @return a new proxy strategy if successfully constructed, otherwise NULL
152+ */
153+ AWS_HTTP_API
154+ struct aws_http_proxy_strategy * aws_http_proxy_strategy_new_forwarding_identity (struct aws_allocator * allocator );
155+
156+ /**
157+ * Constructor for a tunneling proxy strategy that contains a set of sub-strategies which are tried
158+ * sequentially in order. Each strategy has the choice to either proceed on a fresh connection or
159+ * reuse the current one.
160+ *
161+ * @param allocator memory allocator to use
162+ * @param config sequence configuration options
163+ * @return a new proxy strategy if successfully constructed, otherwise NULL
164+ */
106165AWS_HTTP_API
107- struct aws_http_proxy_config * aws_http_proxy_config_new (
166+ struct aws_http_proxy_strategy * aws_http_proxy_strategy_new_tunneling_sequence (
108167 struct aws_allocator * allocator ,
109- const struct aws_http_proxy_options * options );
168+ struct aws_http_proxy_strategy_tunneling_sequence_options * config );
110169
170+ /**
171+ * A constructor for a proxy strategy that performs kerberos authentication by adding the appropriate
172+ * header and header value to CONNECT requests.
173+ *
174+ * Currently only supports synchronous fetch of kerberos token values.
175+ *
176+ * @param allocator memory allocator to use
177+ * @param config kerberos authentication configuration info
178+ * @return a new proxy strategy if successfully constructed, otherwise NULL
179+ */
111180AWS_HTTP_API
112- void aws_http_proxy_config_destroy (struct aws_http_proxy_config * config );
181+ struct aws_http_proxy_strategy * aws_http_proxy_strategy_new_tunneling_kerberos (
182+ struct aws_allocator * allocator ,
183+ struct aws_http_proxy_strategy_tunneling_kerberos_options * config );
113184
185+ /**
186+ * Constructor for an NTLM proxy strategy. Because ntlm is a challenge-response authentication protocol, this
187+ * strategy will only succeed in a chain in a non-leading position. The strategy extracts the challenge from the
188+ * proxy's response to a previous CONNECT request in the chain.
189+ *
190+ * Currently only supports synchronous fetch of token values.
191+ *
192+ * @param allocator memory allocator to use
193+ * @param config configuration options for the strategy
194+ * @return a new proxy strategy if successfully constructed, otherwise NULL
195+ */
114196AWS_HTTP_API
115- void aws_http_proxy_options_init_from_config (
116- struct aws_http_proxy_options * options ,
117- const struct aws_http_proxy_config * config );
197+ struct aws_http_proxy_strategy * aws_http_proxy_strategy_new_tunneling_ntlm (
198+ struct aws_allocator * allocator ,
199+ struct aws_http_proxy_strategy_tunneling_ntlm_options * config );
118200
119201AWS_EXTERN_C_END
120202
0 commit comments