Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,22 @@ jobs:
if: ${{ !cancelled() }}
uses: ninenines/ci.erlang.mk/.github/workflows/ci.yaml@master

dialyzer-no-quicer:
name: Check / Dialyzer (without COWBOY_QUICER)
runs-on: ubuntu-latest
steps:

- name: Checkout repository
uses: actions/checkout@v4

- name: Install latest Erlang/OTP
uses: erlef/setup-beam@v1
with:
otp-version: '> 0'

- name: Run Dialyzer (without COWBOY_QUICER)
run: make dialyze COWBOY_QUICER=0

examples:
name: Check examples
runs-on: ubuntu-latest
Expand Down
15 changes: 11 additions & 4 deletions src/cowboy.erl
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,21 @@

-export([start_clear/3]).
-export([start_tls/3]).
-export([start_quic/3]).
-export([stop_listener/1]).
-export([get_env/2]).
-export([get_env/3]).
-export([set_env/3]).

%% Internal.
-export([log/2]).
-export([log/4]).
-ifdef(COWBOY_QUICER).
-export([start_quic/3]).

%% Don't warn about the bad quicer specs.
-dialyzer([{nowarn_function, start_quic/3}]).
-endif.

%% Internal.
-export([log/2]).
-export([log/4]).

-type opts() :: cowboy_http:opts() | cowboy_http2:opts().
-export_type([opts/0]).
Expand Down Expand Up @@ -73,6 +76,8 @@ start_tls(Ref, TransOpts0, ProtoOpts0) ->
},
ranch:start_listener(Ref, ranch_ssl, TransOpts, cowboy_tls, ProtoOpts).

-ifdef(COWBOY_QUICER).

%% @todo Experimental function to start a barebone QUIC listener.
%% This will need to be reworked to be closer to Ranch
%% listeners and provide equivalent features.
Expand Down Expand Up @@ -151,6 +156,8 @@ port_0() ->
end,
Port.

-endif.

ensure_alpn(TransOpts) ->
SocketOpts = maps:get(socket_opts, TransOpts, []),
TransOpts#{socket_opts => [
Expand Down
4 changes: 4 additions & 0 deletions src/cowboy_http3.erl
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@

-module(cowboy_http3).

-ifdef(COWBOY_QUICER).

-export([init/4]).

%% Temporary callback to do sendfile over QUIC.
Expand Down Expand Up @@ -1303,3 +1305,5 @@ stream_linger(State=#state{lingering_streams=Lingering0}, StreamID) ->

is_lingering_stream(#state{lingering_streams=Lingering}, StreamID) ->
lists:member(StreamID, Lingering).

-endif.
51 changes: 2 additions & 49 deletions src/cowboy_quicer.erl
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

-module(cowboy_quicer).

-ifdef(COWBOY_QUICER).

%% Connection.
-export([peername/1]).
-export([sockname/1]).
Expand All @@ -35,55 +37,6 @@
%% Messages.
-export([handle/1]).

-ifndef(COWBOY_QUICER).

-spec peername(_) -> no_return().
peername(_) -> no_quicer().

-spec sockname(_) -> no_return().
sockname(_) -> no_quicer().

-spec peercert(_) -> no_return().
peercert(_) -> no_quicer().

-spec shutdown(_, _) -> no_return().
shutdown(_, _) -> no_quicer().

-spec start_bidi_stream(_, _) -> no_return().
start_bidi_stream(_, _) -> no_quicer().

-spec start_unidi_stream(_, _) -> no_return().
start_unidi_stream(_, _) -> no_quicer().

-spec setopt(_, _, _, _) -> no_return().
setopt(_, _, _, _) -> no_quicer().

-spec send(_, _, _) -> no_return().
send(_, _, _) -> no_quicer().

-spec send(_, _, _, _) -> no_return().
send(_, _, _, _) -> no_quicer().

-spec send_datagram(_, _) -> no_return().
send_datagram(_, _) -> no_quicer().

-spec shutdown_stream(_, _) -> no_return().
shutdown_stream(_, _) -> no_quicer().

-spec shutdown_stream(_, _, _, _) -> no_return().
shutdown_stream(_, _, _, _) -> no_quicer().

-spec handle(_) -> no_return().
handle(_) -> no_quicer().

no_quicer() ->
error({no_quicer,
"Cowboy must be compiled with environment variable COWBOY_QUICER=1 "
"or with compilation flag -D COWBOY_QUICER=1 in order to enable "
"QUIC support using the emqx/quic NIF"}).

-else.

%% @todo Make quicer export these types.
-type quicer_connection_handle() :: reference().
-export_type([quicer_connection_handle/0]).
Expand Down
Loading