Merge pull request #8092 from qzhuyan/dev/william/bump-quicer
feat: new quicer 0.0.11
This commit is contained in:
commit
3c7dd5d6c4
|
@ -31,7 +31,7 @@ listeners.wss.default {
|
||||||
}
|
}
|
||||||
|
|
||||||
# listeners.quic.default {
|
# listeners.quic.default {
|
||||||
# enabled = false
|
# enabled = true
|
||||||
# bind = "0.0.0.0:14567"
|
# bind = "0.0.0.0:14567"
|
||||||
# max_connections = 1024000
|
# max_connections = 1024000
|
||||||
# keyfile = "{{ platform_etc_dir }}/certs/key.pem"
|
# keyfile = "{{ platform_etc_dir }}/certs/key.pem"
|
||||||
|
|
|
@ -43,7 +43,7 @@
|
||||||
{meck, "0.9.2"},
|
{meck, "0.9.2"},
|
||||||
{proper, "1.4.0"},
|
{proper, "1.4.0"},
|
||||||
{bbmustache, "1.10.0"},
|
{bbmustache, "1.10.0"},
|
||||||
{emqtt, {git, "https://github.com/emqx/emqtt", {tag, "1.5.0"}}}
|
{emqtt, {git, "https://github.com/emqx/emqtt", {tag, "1.6.0"}}}
|
||||||
]},
|
]},
|
||||||
{extra_src_dirs, [{"test", [recursive]}]}
|
{extra_src_dirs, [{"test", [recursive]}]}
|
||||||
]}
|
]}
|
||||||
|
|
|
@ -1,37 +1,46 @@
|
||||||
%% -*- mode: erlang -*-
|
%% -*- mode: erlang -*-
|
||||||
IsCentos6 = fun() ->
|
IsCentos6 = fun() ->
|
||||||
case file:read_file("/etc/centos-release") of
|
case file:read_file("/etc/centos-release") of
|
||||||
{ok, <<"CentOS release 6", _/binary >>} ->
|
{ok, <<"CentOS release 6", _/binary>>} ->
|
||||||
true;
|
true;
|
||||||
_ ->
|
_ ->
|
||||||
false
|
false
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
|
|
||||||
IsWin32 = fun() ->
|
IsWin32 = fun() ->
|
||||||
win32 =:= element(1, os:type())
|
win32 =:= element(1, os:type())
|
||||||
end,
|
end,
|
||||||
|
|
||||||
IsMacOS = fun() ->
|
IsMacOS = fun() ->
|
||||||
{unix, darwin} =:= os:type()
|
{unix, darwin} =:= os:type()
|
||||||
end,
|
end,
|
||||||
|
|
||||||
IsQuicSupp = fun() ->
|
IsQuicSupp = fun() ->
|
||||||
not (IsCentos6() orelse IsWin32()
|
not (IsCentos6() orelse IsWin32() orelse
|
||||||
orelse IsMacOS() orelse
|
IsMacOS() orelse
|
||||||
false =/= os:getenv("BUILD_WITHOUT_QUIC")
|
false =/= os:getenv("BUILD_WITHOUT_QUIC")) orelse
|
||||||
)
|
"1" == os:getenv("BUILD_WITH_QUIC")
|
||||||
orelse "1" == os:getenv("BUILD_WITH_QUIC")
|
end,
|
||||||
end,
|
|
||||||
|
|
||||||
Bcrypt = {bcrypt, {git, "https://github.com/emqx/erlang-bcrypt.git", {tag, "0.6.0"}}},
|
Bcrypt = {bcrypt, {git, "https://github.com/emqx/erlang-bcrypt.git", {tag, "0.6.0"}}},
|
||||||
Quicer = {quicer, {git, "https://github.com/emqx/quic.git", {tag, "0.0.9"}}},
|
Quicer = {quicer, {git, "https://github.com/emqx/quic.git", {tag, "0.0.11"}}}.
|
||||||
|
|
||||||
ExtraDeps = fun(C) ->
|
ExtraDeps = fun(C) ->
|
||||||
{deps, Deps0} = lists:keyfind(deps, 1, C),
|
{deps, Deps0} = lists:keyfind(deps, 1, C),
|
||||||
Deps = Deps0 ++ [Bcrypt || not IsWin32()] ++
|
{erl_opts, ErlOpts0} = lists:keyfind(erl_opts, 1, C),
|
||||||
[ Quicer || IsQuicSupp()],
|
IsQuic = IsQuicSupp(),
|
||||||
lists:keystore(deps, 1, C, {deps, Deps})
|
New = [
|
||||||
|
{deps, Deps0 ++ [Bcrypt || not IsWin32()] ++ [Quicer || IsQuic]},
|
||||||
|
{erl_opts, ErlOpts0 ++ [{d, 'BUILD_WITHOUT_QUIC'} || not IsQuic]}
|
||||||
|
],
|
||||||
|
lists:foldl(
|
||||||
|
fun({Key, _Val} = KV, Acc) ->
|
||||||
|
lists:keystore(Key, 1, Acc, KV)
|
||||||
end,
|
end,
|
||||||
|
C,
|
||||||
|
New
|
||||||
|
)
|
||||||
|
end,
|
||||||
|
|
||||||
ExtraDeps(CONFIG).
|
ExtraDeps(CONFIG).
|
||||||
|
|
|
@ -113,7 +113,7 @@ is_quicer_app_present() ->
|
||||||
end.
|
end.
|
||||||
|
|
||||||
is_quic_listener_configured() ->
|
is_quic_listener_configured() ->
|
||||||
emqx_listeners:has_enabled_listener_conf_by_type(quic).
|
maps:is_key(quic, emqx:get_config([listeners])).
|
||||||
|
|
||||||
get_description() -> emqx_release:description().
|
get_description() -> emqx_release:description().
|
||||||
|
|
||||||
|
|
|
@ -143,9 +143,13 @@ is_running(Type, ListenerId, _Conf) when Type =:= ws; Type =:= wss ->
|
||||||
_:_ ->
|
_:_ ->
|
||||||
false
|
false
|
||||||
end;
|
end;
|
||||||
is_running(quic, _ListenerId, _Conf) ->
|
is_running(quic, ListenerId, _Conf) ->
|
||||||
%% TODO: quic support
|
case quicer:listener(ListenerId) of
|
||||||
false.
|
{ok, Pid} when is_pid(Pid) ->
|
||||||
|
true;
|
||||||
|
_ ->
|
||||||
|
false
|
||||||
|
end.
|
||||||
|
|
||||||
current_conns(ID, ListenOn) ->
|
current_conns(ID, ListenOn) ->
|
||||||
{ok, #{type := Type, name := Name}} = parse_listener_id(ID),
|
{ok, #{type := Type, name := Name}} = parse_listener_id(ID),
|
||||||
|
@ -325,15 +329,18 @@ do_start_listener(quic, ListenerName, #{bind := ListenOn} = Opts) ->
|
||||||
case [A || {quicer, _, _} = A <- application:which_applications()] of
|
case [A || {quicer, _, _} = A <- application:which_applications()] of
|
||||||
[_] ->
|
[_] ->
|
||||||
DefAcceptors = erlang:system_info(schedulers_online) * 8,
|
DefAcceptors = erlang:system_info(schedulers_online) * 8,
|
||||||
|
IdleTimeout = timer:seconds(maps:get(idle_timeout, Opts)),
|
||||||
ListenOpts = [
|
ListenOpts = [
|
||||||
{cert, maps:get(certfile, Opts)},
|
{cert, maps:get(certfile, Opts)},
|
||||||
{key, maps:get(keyfile, Opts)},
|
{key, maps:get(keyfile, Opts)},
|
||||||
{alpn, ["mqtt"]},
|
{alpn, ["mqtt"]},
|
||||||
{conn_acceptors, lists:max([DefAcceptors, maps:get(acceptors, Opts, 0)])},
|
{conn_acceptors, lists:max([DefAcceptors, maps:get(acceptors, Opts, 0)])},
|
||||||
|
{keep_alive_interval_ms, ceil(IdleTimeout / 3)},
|
||||||
|
{server_resumption_level, 2},
|
||||||
{idle_timeout_ms,
|
{idle_timeout_ms,
|
||||||
lists:max([
|
lists:max([
|
||||||
emqx_config:get_zone_conf(zone(Opts), [mqtt, idle_timeout]) * 3,
|
emqx_config:get_zone_conf(zone(Opts), [mqtt, idle_timeout]) * 3,
|
||||||
timer:seconds(maps:get(idle_timeout, Opts))
|
IdleTimeout
|
||||||
])}
|
])}
|
||||||
],
|
],
|
||||||
ConnectionOpts = #{
|
ConnectionOpts = #{
|
||||||
|
|
|
@ -16,6 +16,12 @@
|
||||||
|
|
||||||
-module(emqx_quic_connection).
|
-module(emqx_quic_connection).
|
||||||
|
|
||||||
|
-ifndef(BUILD_WITHOUT_QUIC).
|
||||||
|
-include_lib("quicer/include/quicer.hrl").
|
||||||
|
-else.
|
||||||
|
-define(QUIC_CONNECTION_SHUTDOWN_FLAG_NONE, 0).
|
||||||
|
-endif.
|
||||||
|
|
||||||
%% Callbacks
|
%% Callbacks
|
||||||
-export([
|
-export([
|
||||||
init/1,
|
init/1,
|
||||||
|
@ -59,5 +65,5 @@ connected(_Conn, S) ->
|
||||||
|
|
||||||
-spec shutdown(quicer:connection_handler(), cb_state()) -> {ok, cb_state()} | {error, any()}.
|
-spec shutdown(quicer:connection_handler(), cb_state()) -> {ok, cb_state()} | {error, any()}.
|
||||||
shutdown(Conn, S) ->
|
shutdown(Conn, S) ->
|
||||||
quicer:async_close_connection(Conn),
|
quicer:async_shutdown_connection(Conn, ?QUIC_CONNECTION_SHUTDOWN_FLAG_NONE, 0),
|
||||||
{ok, S}.
|
{ok, S}.
|
||||||
|
|
|
@ -38,7 +38,7 @@ wait({ConnOwner, Conn}) ->
|
||||||
receive
|
receive
|
||||||
%% from msquic
|
%% from msquic
|
||||||
{quic, new_stream, Stream} ->
|
{quic, new_stream, Stream} ->
|
||||||
{ok, Stream};
|
{ok, {quic, Conn, Stream}};
|
||||||
{'EXIT', ConnOwner, _Reason} ->
|
{'EXIT', ConnOwner, _Reason} ->
|
||||||
{error, enotconn}
|
{error, enotconn}
|
||||||
end.
|
end.
|
||||||
|
@ -46,18 +46,18 @@ wait({ConnOwner, Conn}) ->
|
||||||
type(_) ->
|
type(_) ->
|
||||||
quic.
|
quic.
|
||||||
|
|
||||||
peername(S) ->
|
peername({quic, Conn, _Stream}) ->
|
||||||
quicer:peername(S).
|
quicer:peername(Conn).
|
||||||
|
|
||||||
sockname(S) ->
|
sockname({quic, Conn, _Stream}) ->
|
||||||
quicer:sockname(S).
|
quicer:sockname(Conn).
|
||||||
|
|
||||||
peercert(_S) ->
|
peercert(_S) ->
|
||||||
%% @todo but unsupported by msquic
|
%% @todo but unsupported by msquic
|
||||||
nossl.
|
nossl.
|
||||||
|
|
||||||
getstat(Socket, Stats) ->
|
getstat({quic, Conn, _Stream}, Stats) ->
|
||||||
case quicer:getstat(Socket, Stats) of
|
case quicer:getstat(Conn, Stats) of
|
||||||
{error, _} -> {error, closed};
|
{error, _} -> {error, closed};
|
||||||
Res -> Res
|
Res -> Res
|
||||||
end.
|
end.
|
||||||
|
@ -84,9 +84,9 @@ getopts(_Socket, _Opts) ->
|
||||||
{buffer, 80000}
|
{buffer, 80000}
|
||||||
]}.
|
]}.
|
||||||
|
|
||||||
fast_close(Stream) ->
|
fast_close({quic, _Conn, Stream}) ->
|
||||||
%% Stream might be closed already.
|
%% Flush send buffer, gracefully shutdown
|
||||||
_ = quicer:async_close_stream(Stream),
|
quicer:async_shutdown_stream(Stream),
|
||||||
ok.
|
ok.
|
||||||
|
|
||||||
-spec ensure_ok_or_exit(atom(), list(term())) -> term().
|
-spec ensure_ok_or_exit(atom(), list(term())) -> term().
|
||||||
|
@ -102,9 +102,7 @@ ensure_ok_or_exit(Fun, Args = [Sock | _]) when is_atom(Fun), is_list(Args) ->
|
||||||
Result
|
Result
|
||||||
end.
|
end.
|
||||||
|
|
||||||
async_send(Stream, Data, Options) when is_list(Data) ->
|
async_send({quic, _Conn, Stream}, Data, _Options) ->
|
||||||
async_send(Stream, iolist_to_binary(Data), Options);
|
|
||||||
async_send(Stream, Data, _Options) when is_binary(Data) ->
|
|
||||||
case quicer:send(Stream, Data) of
|
case quicer:send(Stream, Data) of
|
||||||
{ok, _Len} -> ok;
|
{ok, _Len} -> ok;
|
||||||
Other -> Other
|
Other -> Other
|
||||||
|
|
|
@ -472,7 +472,6 @@ ensure_dashboard_listeners_started(_App) ->
|
||||||
-spec ensure_quic_listener(Name :: atom(), UdpPort :: inet:port_number()) -> ok.
|
-spec ensure_quic_listener(Name :: atom(), UdpPort :: inet:port_number()) -> ok.
|
||||||
ensure_quic_listener(Name, UdpPort) ->
|
ensure_quic_listener(Name, UdpPort) ->
|
||||||
application:ensure_all_started(quicer),
|
application:ensure_all_started(quicer),
|
||||||
emqx_config:put([listeners, quic, Name, mountpoint], <<>>),
|
|
||||||
Conf = #{
|
Conf = #{
|
||||||
acceptors => 16,
|
acceptors => 16,
|
||||||
bind => {{0, 0, 0, 0}, UdpPort},
|
bind => {{0, 0, 0, 0}, UdpPort},
|
||||||
|
@ -491,6 +490,7 @@ ensure_quic_listener(Name, UdpPort) ->
|
||||||
mountpoint => <<>>,
|
mountpoint => <<>>,
|
||||||
zone => default
|
zone => default
|
||||||
},
|
},
|
||||||
|
emqx_config:put([listeners, quic, Name], Conf),
|
||||||
case emqx_listeners:start_listener(quic, Name, Conf) of
|
case emqx_listeners:start_listener(quic, Name, Conf) of
|
||||||
ok -> ok;
|
ok -> ok;
|
||||||
{error, {already_started, _Pid}} -> ok
|
{error, {already_started, _Pid}} -> ok
|
||||||
|
|
|
@ -252,7 +252,8 @@ t_connect_will_message(Config) ->
|
||||||
{ok, _, [2]} = emqtt:subscribe(Client4, Topic, qos2),
|
{ok, _, [2]} = emqtt:subscribe(Client4, Topic, qos2),
|
||||||
ok = emqtt:disconnect(Client3),
|
ok = emqtt:disconnect(Client3),
|
||||||
%% [MQTT-3.1.2-10]
|
%% [MQTT-3.1.2-10]
|
||||||
?assertEqual(0, length(receive_messages(1))),
|
MsgRecv = receive_messages(1),
|
||||||
|
?assertEqual([], MsgRecv),
|
||||||
ok = emqtt:disconnect(Client4).
|
ok = emqtt:disconnect(Client4).
|
||||||
|
|
||||||
t_batch_subscribe(init, Config) ->
|
t_batch_subscribe(init, Config) ->
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
%% eredis_cluster's dependency getting resolved earlier.
|
%% eredis_cluster's dependency getting resolved earlier.
|
||||||
%% Here we pin 1.5.2 to avoid surprises in the future.
|
%% Here we pin 1.5.2 to avoid surprises in the future.
|
||||||
{poolboy, {git, "https://github.com/emqx/poolboy.git", {tag, "1.5.2"}}},
|
{poolboy, {git, "https://github.com/emqx/poolboy.git", {tag, "1.5.2"}}},
|
||||||
{emqtt, {git, "https://github.com/emqx/emqtt", {tag, "1.5.1"}}}
|
{emqtt, {git, "https://github.com/emqx/emqtt", {tag, "1.6.0"}}}
|
||||||
]}.
|
]}.
|
||||||
|
|
||||||
{shell, [
|
{shell, [
|
||||||
|
|
4
mix.exs
4
mix.exs
|
@ -58,7 +58,7 @@ defmodule EMQXUmbrella.MixProject do
|
||||||
{:ecpool, github: "emqx/ecpool", tag: "0.5.2"},
|
{:ecpool, github: "emqx/ecpool", tag: "0.5.2"},
|
||||||
{:replayq, "0.3.4", override: true},
|
{:replayq, "0.3.4", override: true},
|
||||||
{:pbkdf2, github: "emqx/erlang-pbkdf2", tag: "2.0.4", override: true},
|
{:pbkdf2, github: "emqx/erlang-pbkdf2", tag: "2.0.4", override: true},
|
||||||
{:emqtt, github: "emqx/emqtt", tag: "1.5.1", override: true},
|
{:emqtt, github: "emqx/emqtt", tag: "1.6.0", override: true},
|
||||||
{:rulesql, github: "emqx/rulesql", tag: "0.1.4"},
|
{:rulesql, github: "emqx/rulesql", tag: "0.1.4"},
|
||||||
{:observer_cli, "1.7.1"},
|
{:observer_cli, "1.7.1"},
|
||||||
{:system_monitor, github: "ieQu1/system_monitor", tag: "3.0.3"},
|
{:system_monitor, github: "ieQu1/system_monitor", tag: "3.0.3"},
|
||||||
|
@ -591,7 +591,7 @@ defmodule EMQXUmbrella.MixProject do
|
||||||
defp quicer_dep() do
|
defp quicer_dep() do
|
||||||
if enable_quicer?(),
|
if enable_quicer?(),
|
||||||
# in conflict with emqx and emqtt
|
# in conflict with emqx and emqtt
|
||||||
do: [{:quicer, github: "emqx/quic", tag: "0.0.9", override: true}],
|
do: [{:quicer, github: "emqx/quic", tag: "0.0.11", override: true}],
|
||||||
else: []
|
else: []
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -60,7 +60,7 @@
|
||||||
, {ecpool, {git, "https://github.com/emqx/ecpool", {tag, "0.5.2"}}}
|
, {ecpool, {git, "https://github.com/emqx/ecpool", {tag, "0.5.2"}}}
|
||||||
, {replayq, "0.3.4"}
|
, {replayq, "0.3.4"}
|
||||||
, {pbkdf2, {git, "https://github.com/emqx/erlang-pbkdf2.git", {tag, "2.0.4"}}}
|
, {pbkdf2, {git, "https://github.com/emqx/erlang-pbkdf2.git", {tag, "2.0.4"}}}
|
||||||
, {emqtt, {git, "https://github.com/emqx/emqtt", {tag, "1.5.1"}}}
|
, {emqtt, {git, "https://github.com/emqx/emqtt", {tag, "1.6.0"}}}
|
||||||
, {rulesql, {git, "https://github.com/emqx/rulesql", {tag, "0.1.4"}}}
|
, {rulesql, {git, "https://github.com/emqx/rulesql", {tag, "0.1.4"}}}
|
||||||
, {observer_cli, "1.7.1"} % NOTE: depends on recon 2.5.x
|
, {observer_cli, "1.7.1"} % NOTE: depends on recon 2.5.x
|
||||||
, {system_monitor, {git, "https://github.com/ieQu1/system_monitor", {tag, "3.0.3"}}}
|
, {system_monitor, {git, "https://github.com/ieQu1/system_monitor", {tag, "3.0.3"}}}
|
||||||
|
|
|
@ -38,7 +38,7 @@ bcrypt() ->
|
||||||
{bcrypt, {git, "https://github.com/emqx/erlang-bcrypt.git", {tag, "0.6.0"}}}.
|
{bcrypt, {git, "https://github.com/emqx/erlang-bcrypt.git", {tag, "0.6.0"}}}.
|
||||||
|
|
||||||
quicer() ->
|
quicer() ->
|
||||||
{quicer, {git, "https://github.com/emqx/quic.git", {tag, "0.0.9"}}}.
|
{quicer, {git, "https://github.com/emqx/quic.git", {tag, "0.0.11"}}}.
|
||||||
|
|
||||||
jq() ->
|
jq() ->
|
||||||
{jq, {git, "https://github.com/emqx/jq", {tag, "v0.3.4"}}}.
|
{jq, {git, "https://github.com/emqx/jq", {tag, "v0.3.4"}}}.
|
||||||
|
@ -138,7 +138,8 @@ common_compile_opts(Edition, Vsn) ->
|
||||||
{compile_info, [{emqx_vsn, Vsn}]},
|
{compile_info, [{emqx_vsn, Vsn}]},
|
||||||
{d, 'EMQX_RELEASE_EDITION', Edition}
|
{d, 'EMQX_RELEASE_EDITION', Edition}
|
||||||
] ++
|
] ++
|
||||||
[{d, 'EMQX_BENCHMARK'} || os:getenv("EMQX_BENCHMARK") =:= "1"].
|
[{d, 'EMQX_BENCHMARK'} || os:getenv("EMQX_BENCHMARK") =:= "1"] ++
|
||||||
|
[{d, 'BUILD_WITHOUT_QUIC'} || not is_quicer_supported()].
|
||||||
|
|
||||||
prod_compile_opts(Edition, Vsn) ->
|
prod_compile_opts(Edition, Vsn) ->
|
||||||
[
|
[
|
||||||
|
|
Loading…
Reference in New Issue