Просмотр исходного кода

feat(quic): compile and start quicer listener.

William Yang 4 лет назад
Родитель
Сommit
899ba579fc
4 измененных файлов с 324 добавлено и 1 удалено
  1. 306 0
      apps/emqx/etc/emqx.conf
  2. 16 1
      apps/emqx/src/emqx_listeners.erl
  3. 1 0
      rebar.config
  4. 1 0
      rebar.config.erl

Разница между файлами не показана из-за своего большого размера
+ 306 - 0
apps/emqx/etc/emqx.conf


+ 16 - 1
apps/emqx/src/emqx_listeners.erl

@@ -139,7 +139,22 @@ start_listener(Proto, ListenOn, Options) when Proto == http; Proto == ws ->
 %% Start MQTT/WSS listener
 start_listener(Proto, ListenOn, Options) when Proto == https; Proto == wss ->
     start_http_listener(fun cowboy:start_tls/3, 'mqtt:wss', ListenOn,
-                        ranch_opts(Options), ws_opts(Options)).
+                        ranch_opts(Options), ws_opts(Options));
+
+%% MQTT over QUIC
+start_listener(quic, ListenOn, Options) ->
+    SSLOpts = proplists:get_value(ssl_options, Options),
+    ListenOpts = [ {cert, proplists:get_value(certfile, SSLOpts)}
+                 , {key, proplists:get_value(keyfile, SSLOpts)}
+                 , {alpn, ["mqtt"]}
+                 , {conn_acceptors, 32}
+                 ],
+    ConnectionOpts = [ {conn_callback, quicer_server_conn_callback}
+                     , {idle_timeout_ms, 5000}
+                     , {peer_unidi_stream_count, 1}
+                     , {peer_bidi_stream_count, 10}],
+    StreamOpts = [{stream_callback, quicer_echo_server_stream_callback}],
+    quicer:start_listener('mqtt:quic', ListenOn, {ListenOpts, ConnectionOpts, StreamOpts}).
 
 replace(Opts, Key, Value) -> [{Key, Value} | proplists:delete(Key, Opts)].
 

+ 1 - 0
rebar.config

@@ -54,6 +54,7 @@
     , {snabbkaffe, {git, "https://github.com/kafka4beam/snabbkaffe.git", {tag, "0.13.0"}}}
     , {hocon, {git, "https://github.com/emqx/hocon.git", {tag, "0.5.1"}}}
     , {emqx_http_lib, {git, "https://github.com/emqx/emqx_http_lib.git", {tag, "0.2.1"}}}
+    , {quicer, {git, "https://github.com/qzhuyan/quic.git", {branch, "quicer_application"}}}
     ]}.
 
 {xref_ignores,

+ 1 - 0
rebar.config.erl

@@ -241,6 +241,7 @@ relx_apps(ReleaseType) ->
     , compiler
     , runtime_tools
     , cuttlefish
+    , quicer
     , emqx
     , {mnesia, load}
     , {ekka, load}