Skip to content

Commit

Permalink
feat(api): quicer:negotiated_protocol/1
Browse files Browse the repository at this point in the history
  • Loading branch information
qzhuyan committed Jul 2, 2023
1 parent 236f427 commit a33ee7c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/quicer.erl
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
, setopt/4
, get_stream_id/1
, getstat/2
, negotiated_protocol/1
, peername/1
, listeners/0
, listener/1
Expand Down Expand Up @@ -817,6 +818,11 @@ getstat(Conn, Cnts) ->
{ok, CntRes}
end.

%% @doc Returns the protocol negotiated through ALPN or NPN extensions.
-spec negotiated_protocol(Conn::connection_handle()) -> {ok, Protocol::binary()} | {error, Reason::any()}.
negotiated_protocol(Conn) ->
quicer:getopt(Conn, param_tls_negotiated_alpn, quic_tls).

%% @doc Peer name
%% mimic {@link ssl:peername/1}
-spec peername(connection_handle() | stream_handle()) ->
Expand Down
1 change: 1 addition & 0 deletions test/quicer_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -1844,6 +1844,7 @@ tc_alpn(Config) ->
{ok, Conn} = quicer:connect("localhost", Port, default_conn_opts(), 5000),
{ok, {_, _}} = quicer:sockname(Conn),
{ok, <<"sample">>} = quicer:getopt(Conn, param_tls_negotiated_alpn, quic_tls),
{ok, <<"sample">>} = quicer:negotiated_protocol(Conn),
ok = quicer:close_connection(Conn),
SPid ! done
after 1000 ->
Expand Down

0 comments on commit a33ee7c

Please sign in to comment.