diff options
-rw-r--r-- | doc/src/manual/gun.asciidoc | 2 | ||||
-rw-r--r-- | doc/src/manual/gun.await_up.asciidoc | 2 | ||||
-rw-r--r-- | doc/src/manual/gun.open.asciidoc | 2 | ||||
-rw-r--r-- | doc/src/manual/gun.open_unix.asciidoc | 2 | ||||
-rw-r--r-- | doc/src/manual/gun_down.asciidoc | 2 | ||||
-rw-r--r-- | doc/src/manual/gun_error.asciidoc | 2 | ||||
-rw-r--r-- | doc/src/manual/gun_tunnel_up.asciidoc (renamed from doc/src/manual/gun_socks_up.asciidoc) | 14 | ||||
-rw-r--r-- | doc/src/manual/gun_up.asciidoc | 4 | ||||
-rw-r--r-- | src/gun.erl | 7 | ||||
-rw-r--r-- | src/gun_http.erl | 2 | ||||
-rw-r--r-- | src/gun_http2.erl | 2 | ||||
-rw-r--r-- | test/raw_SUITE.erl | 2 | ||||
-rw-r--r-- | test/socks_SUITE.erl | 6 |
13 files changed, 26 insertions, 23 deletions
diff --git a/doc/src/manual/gun.asciidoc b/doc/src/manual/gun.asciidoc index 2067d96..a2d51f6 100644 --- a/doc/src/manual/gun.asciidoc +++ b/doc/src/manual/gun.asciidoc @@ -64,7 +64,7 @@ by sending any of the following messages: Connection: * link:man:gun_up(3)[gun_up(3)] - The connection is up -* link:man:gun_socks_up(3)[gun_socks_up(3)] - The Socks connection is up +* link:man:gun_tunnel_up(3)[gun_tunnel_up(3)] - The tunnel is up * link:man:gun_down(3)[gun_down(3)] - The connection is down * link:man:gun_upgrade(3)[gun_upgrade(3)] - Successful protocol upgrade * link:man:gun_error(3)[gun_error(3)] - Stream or connection-wide error diff --git a/doc/src/manual/gun.await_up.asciidoc b/doc/src/manual/gun.await_up.asciidoc index d9934b5..ffe39fd 100644 --- a/doc/src/manual/gun.await_up.asciidoc +++ b/doc/src/manual/gun.await_up.asciidoc @@ -71,5 +71,5 @@ may also be returned when a timeout or an error occur. link:man:gun(3)[gun(3)], link:man:gun:open(3)[gun:open(3)], link:man:gun:open_unix(3)[gun:open_unix(3)], -link:man:gun_socks_up(3)[gun_socks_up(3)], +link:man:gun_tunnel_up(3)[gun_tunnel_up(3)], link:man:gun_up(3)[gun_up(3)] diff --git a/doc/src/manual/gun.open.asciidoc b/doc/src/manual/gun.open.asciidoc index 63bb3f8..57d4490 100644 --- a/doc/src/manual/gun.open.asciidoc +++ b/doc/src/manual/gun.open.asciidoc @@ -73,5 +73,5 @@ message will be sent for that. link:man:gun(3)[gun(3)], link:man:gun:open_unix(3)[gun:open_unix(3)], link:man:gun:await_up(3)[gun:await_up(3)], -link:man:gun_socks_up(3)[gun_socks_up(3)], +link:man:gun_tunnel_up(3)[gun_tunnel_up(3)], link:man:gun_up(3)[gun_up(3)] diff --git a/doc/src/manual/gun.open_unix.asciidoc b/doc/src/manual/gun.open_unix.asciidoc index 441bfa8..0063728 100644 --- a/doc/src/manual/gun.open_unix.asciidoc +++ b/doc/src/manual/gun.open_unix.asciidoc @@ -61,5 +61,5 @@ message will be sent for that. link:man:gun(3)[gun(3)], link:man:gun:open(3)[gun:open(3)], link:man:gun:await_up(3)[gun:await_up(3)], -link:man:gun_socks_up(3)[gun_socks_up(3)], +link:man:gun_tunnel_up(3)[gun_tunnel_up(3)], link:man:gun_up(3)[gun_up(3)] diff --git a/doc/src/manual/gun_down.asciidoc b/doc/src/manual/gun_down.asciidoc index 6785cb5..a9fabde 100644 --- a/doc/src/manual/gun_down.asciidoc +++ b/doc/src/manual/gun_down.asciidoc @@ -75,5 +75,5 @@ link:man:gun(3)[gun(3)], link:man:gun:open(3)[gun:open(3)], link:man:gun:open_unix(3)[gun:open_unix(3)], link:man:gun_up(3)[gun_up(3)], -link:man:gun_socks_up(3)[gun_socks_up(3)], +link:man:gun_tunnel_up(3)[gun_tunnel_up(3)], link:man:gun_error(3)[gun_error(3)] diff --git a/doc/src/manual/gun_error.asciidoc b/doc/src/manual/gun_error.asciidoc index ac278fd..800b49c 100644 --- a/doc/src/manual/gun_error.asciidoc +++ b/doc/src/manual/gun_error.asciidoc @@ -64,5 +64,5 @@ handle_info({gun_error, ConnPid, _StreamRef, _Reason}, link:man:gun(3)[gun(3)], link:man:gun_up(3)[gun_up(3)], -link:man:gun_socks_up(3)[gun_socks_up(3)], +link:man:gun_tunnel_up(3)[gun_tunnel_up(3)], link:man:gun_down(3)[gun_down(3)] diff --git a/doc/src/manual/gun_socks_up.asciidoc b/doc/src/manual/gun_tunnel_up.asciidoc index e65cbff..5fc753e 100644 --- a/doc/src/manual/gun_socks_up.asciidoc +++ b/doc/src/manual/gun_tunnel_up.asciidoc @@ -1,14 +1,16 @@ -= gun_socks_up(3) += gun_tunnel_up(3) == Name -gun_socks_up - The Socks connection is up +gun_tunnel_up - The tunnel is up + +// @todo Update with StreamRef == Description [source,erlang] ---- -{gun_socks_up, ConnPid, Protocol} +{gun_tunnel_up, ConnPid, Protocol} ConnPid :: pid() Protocol :: http | http2 | socks @@ -21,7 +23,7 @@ completed through the configured Socks proxy. If Gun is configured to connect to another Socks server, then the connection is not usable yet. One or more -link:man:gun_socks_up(3)[gun_socks_up(3)] messages will follow. +link:man:gun_tunnel_up(3)[gun_tunnel_up(3)] messages will follow. Otherwise, Gun will start processing the messages it received while waiting for the connection to be up. If this is a reconnection, @@ -46,10 +48,10 @@ to determine the capabilities of the server. == Examples -.Receive a gun_socks_up message in a gen_server +.Receive a gun_tunnel_up message in a gen_server [source,erlang] ---- -handle_info({gun_socks_up, ConnPid, _Protocol}, +handle_info({gun_tunnel_up, ConnPid, _Protocol}, State=#state{conn_pid=ConnPid}) -> %% Do something. {noreply, State}. diff --git a/doc/src/manual/gun_up.asciidoc b/doc/src/manual/gun_up.asciidoc index db09fca..3853afd 100644 --- a/doc/src/manual/gun_up.asciidoc +++ b/doc/src/manual/gun_up.asciidoc @@ -21,7 +21,7 @@ reconnection completed. If Gun is configured to connect to a Socks server, then the connection is not usable yet. One or more -link:man:gun_socks_up(3)[gun_socks_up(3)] messages will follow. +link:man:gun_tunnel_up(3)[gun_tunnel_up(3)] messages will follow. Otherwise, Gun will start processing the messages it received while waiting for the connection to be up. If this is a reconnection, @@ -61,6 +61,6 @@ link:man:gun(3)[gun(3)], link:man:gun:open(3)[gun:open(3)], link:man:gun:open_unix(3)[gun:open_unix(3)], link:man:gun:await_up(3)[gun:await_up(3)], -link:man:gun_socks_up(3)[gun_socks_up(3)], +link:man:gun_tunnel_up(3)[gun_tunnel_up(3)], link:man:gun_down(3)[gun_down(3)], link:man:gun_error(3)[gun_error(3)] diff --git a/src/gun.erl b/src/gun.erl index e83c709..2f92b95 100644 --- a/src/gun.erl +++ b/src/gun.erl @@ -808,8 +808,7 @@ await_up(ServerPid, Timeout, MRef) -> receive {gun_up, ServerPid, Protocol} -> {ok, Protocol}; - %% @todo Maybe name it gun_tunnel_up. And send it for HTTP/1.1 CONNECT and HTTP/2 CONNECT and SOCKS. - {gun_socks_up, ServerPid, Protocol} -> + {gun_tunnel_up, ServerPid, Protocol} -> {ok, Protocol}; {'DOWN', MRef, process, ServerPid, Reason} -> {error, {down, Reason}} @@ -1587,9 +1586,9 @@ commands([{switch_protocol, Protocol0, ReplyTo}], State0=#state{ Protocol1 = protocol_handler(P), {Protocol1, maps:get(Protocol1:opts_name(), Opts, #{})} end, - %% When we switch_protocol from socks we must send a gun_socks_up message. + %% When we switch_protocol from socks we must send a gun_tunnel_up message. _ = case CurrentProtocol of - gun_socks -> ReplyTo ! {gun_socks_up, self(), Protocol:name()}; + gun_socks -> ReplyTo ! {gun_tunnel_up, self(), Protocol:name()}; _ -> ok end, {StateName, ProtoState} = Protocol:init(ReplyTo, Socket, Transport, ProtoOpts), diff --git a/src/gun_http.erl b/src/gun_http.erl index 6b511a3..bced64d 100644 --- a/src/gun_http.erl +++ b/src/gun_http.erl @@ -340,12 +340,14 @@ handle_connect(Rest, State=#http_state{ timeout => maps:get(tls_handshake_timeout, Destination, infinity) }, Protocols = maps:get(protocols, Destination, [http2, http]), +%% @todo gun_tunnel_up when the protocol switch is complete {handle_ret([ {origin, <<"https">>, NewHost, NewPort, connect}, {tls_handshake, HandshakeEvent, Protocols, ReplyTo} ], State), EvHandlerState1}; _ -> [Protocol] = maps:get(protocols, Destination, [http]), +%% @todo gun_tunnel_up {handle_ret([ {origin, <<"http">>, NewHost, NewPort, connect}, {switch_protocol, Protocol, ReplyTo} diff --git a/src/gun_http2.erl b/src/gun_http2.erl index da6747b..5b8d229 100644 --- a/src/gun_http2.erl +++ b/src/gun_http2.erl @@ -366,7 +366,7 @@ tunnel_commands([{switch_protocol, Protocol0, ReplyTo}|Tail], Stream=#stream{ref %% @todo We need to allow other protocol opts in http2_opts too. {Protocol1, maps:get(Protocol1:opts_name(), Opts, #{})} end, - %% When we switch_protocol from socks we must send a gun_socks_up message. + %% When we switch_protocol from socks we must send a gun_tunnel_up message. _ = case CurrentProtocol of gun_socks -> ReplyTo ! {gun_tunnel_up, self(), stream_ref(State, StreamRef), Protocol:name()}; _ -> ok diff --git a/test/raw_SUITE.erl b/test/raw_SUITE.erl index 9875467..bd34ebb 100644 --- a/test/raw_SUITE.erl +++ b/test/raw_SUITE.erl @@ -85,7 +85,7 @@ do_socks5_raw(OriginTransport, ProxyTransport) -> protocols => [raw] }}] }), - %% We receive a gun_up and a gun_socks_up. + %% We receive a gun_up and a gun_tunnel_up. {ok, socks} = gun:await_up(ConnPid), {ok, raw} = gun:await_up(ConnPid), %% The proxy received two packets. diff --git a/test/socks_SUITE.erl b/test/socks_SUITE.erl index 5e15eac..436ea3f 100644 --- a/test/socks_SUITE.erl +++ b/test/socks_SUITE.erl @@ -222,7 +222,7 @@ do_socks5(OriginScheme, OriginTransport, OriginProtocol, ProxyTransport, SocksAu protocols => [OriginProtocol] }}] }), - %% We receive a gun_up and a gun_socks_up. + %% We receive a gun_up and a gun_tunnel_up. {ok, socks} = gun:await_up(ConnPid), {ok, OriginProtocol} = gun:await_up(ConnPid), %% The proxy received two packets. @@ -300,7 +300,7 @@ do_socks5_through_multiple_proxies(OriginScheme, OriginTransport, ProxyTransport }}] }}] }), - %% We receive a gun_up and two gun_socks_up. + %% We receive a gun_up and two gun_tunnel_up. {ok, socks} = gun:await_up(ConnPid), {ok, socks} = gun:await_up(ConnPid), {ok, http} = gun:await_up(ConnPid), @@ -382,7 +382,7 @@ do_socks5_through_connect_proxy(OriginScheme, OriginTransport, ProxyTransport) - }), {request, <<"CONNECT">>, Authority1, 'HTTP/1.1', _} = receive_from(Proxy1Pid), {response, fin, 200, _} = gun:await(ConnPid, StreamRef), - %% We receive a gun_socks_up afterwards. This is the origin HTTP server. + %% We receive a gun_tunnel_up afterwards. This is the origin HTTP server. {ok, http} = gun:await_up(ConnPid), %% The second proxy receives a Socks5 auth/connect request. {auth_methods, 1, [none]} = receive_from(Proxy2Pid), |