Age | Commit message (Collapse) | Author |
|
|
|
The test suite is 216 tests with a tunnel created via two
proxies leading to one origin server. The tests are for
example socks5_h2_https where socks5 identifies the first
SOCKS5 proxy, h2 the second HTTP/2 CONNECT proxy and https
the secure HTTP/1.1 origin server.
The test not only sets up the tunnel and does a request
(or sends/receives data in the case of raw origin servers)
but also confirms that the stream_info and info data is
correct.
|
|
|
|
|
|
|
|
Also fixes all the tests. Lots of work remain around protocols
(how best to pass the base stream_ref to them? maybe the current
solution, maybe a new argument to Protocol:init) and strengthen
the concept of stream_ref, at least with its own type.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Also rework the different handle_head scenarios in separate
functions.
|
|
|
|
The reply_to option is also propagated when we switch protocols.
|
|
The auto-ping will at regular interval send a ping frame.
The silence_pings option defaults to true. It can be set
to false when the user needs to receive ping/pong frames.
|
|
Gun can now be used to send or receive arbitrary data in the
following scenarios:
* Directly after connecting to a server (this is not terribly
useful but it works nevertheless due to the Gun architecture)
* After connecting through one or more Socks and/or HTTP proxies.
This allows using Gun's proxy capabilities to access servers
located beyond firewalls.
* After performing an HTTP/1.1 Upgrade. This allows using Gun
to implement custom protocols that require upgrading from
an HTTP/1.1 connection.
As there is still no support for HTTP/2 CONNECT for the time
being, there are no relevant streams attached to those use
cases and therefore the raw protocol currently expects users
to use 'undefined' as the StreamRef value. This is not a
final decision and will most likely produce a Dialyzer
warning at this time.
|
|
|
|
The version is still kept in the state even if it's an option
because it's useful to have there and it's just a tiny atom.
|
|
Also correct various Socks related types. This commit also
adds a new gun:protocols/0 type as a simpler way of describing
preferred protocols. The protocol/opts tuple is also documented.
This commit also fixes an issue with the default value for the
preferred protocols when using CONNECT over TLS. It was
mistakenly not enabling http2 by default.
|
|
We now properly support TCP across two TLS proxies, and
TLS across two TCP/TLS proxies.
|
|
When doing a CONNECT from http to http or from socks to socks
we may want to use different configuration options. Switching
the protocol explicitly helps us achieve that. It will also
signal through events that a protocol switch occurred.
|
|
|
|
|
|
This commit also reworks the switch_protocol command.
The `P | {P, Opts}` type is used here as well. This
allows us to remove the code specific to Websocket.
In addition a few new protocol functions allow us
to declare what's the name of the options key for
the protocol and what the capabilities are with
regard to keepalive.
|
|
|
|
There's now an initial_tls_handshake state for the initial
connection with handshake, and tls_handshake state for any
subsequent TLS handshakes.
The Socks5 code will be able to reuse this tls_handshake
state to perform its own transport switches.
|
|
The graceful shutdown is implemented through a new 'closing'
state. This state is entered under different circumstances
depending on the protocol.
The gun:shutdown/1 function is now implemented and documented.
It allows shutting down the connection gracefully regardless
of the current state of the connection and for all protocols.
The behavior is entirely dependent on the protocol.
For HTTP/1.1 the connection stays up only until after the
current stream is complete; other streams are immediately
canceled.
For HTTP/2 a GOAWAY frame is sent and existing streams
continue to be processed. The connection is closed after
all streams are processed and the server's GOAWAY frame
is received.
For Websocket a close frame is sent. The connection is
closed when receiving the server's close frame.
In all cases the closing_timeout option defines how long
we wait, as a maximum, before closing the connection after
the graceful shutdown was started.
The graceful shutdown is also initiated when the owner
process goes away; when sending an HTTP/1.1 request
with the connection: close header; when receiving an
HTTP/1.1 response with the connection: close header;
when receiving an HTTP/1.0 response without a connection
header; when the server sends a GOAWAY HTTP/2 frame;
or when we send or receive a Websocket close frame.
Along with these changes, the gun:ws_send/2 function
now accepts a list of frames as argument. Those frames
may include a close frame that initiates the graceful
shutdown.
|
|
Flow control is disabled by default. The initial flow value
must be set to enable it (either for the entire connection
or on a per-request basis). Flow applies to all HTTP streams
as well as Websocket. HTTP/2 pushed streams receive the same
value as their originating stream.
|
|
|
|
|
|
|
|
|
|
|
|
And ensure that Websocket triggers all the request/response
events.
|
|
|
|
Thought it needed cow_http2_machine changes but everything
was available. For HTTP/1.1 it is triggered when receiving
data while expecting headers. For HTTP/2 it is triggered
after we have received a HEADERS frame for streams in idle
state.
|
|
This covers many scenarios but more need to be added.
|
|
|
|
|
|
|
|
Still need to add ALPN support and to wait before trying to send
data on a proxied TLS connection that didn't complete its handshake.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|