Merge pull request #8908 from HJianBo/using-erlang-system-time
fix(time): replace os:system_time with erlang:system_time
This commit is contained in:
commit
5592b1503d
|
@ -16,6 +16,7 @@ File format:
|
|||
|
||||
- Fix rule-engine update behaviour which may initialize actions for disabled rules. [#8849](https://github.com/emqx/emqx/pull/8849)
|
||||
- Fix JWT plugin don't support non-integer timestamp claims. [#8862](https://github.com/emqx/emqx/pull/8862)
|
||||
- Fix delayed publish inaccurate caused by os time change. [#8908](https://github.com/emqx/emqx/pull/8908)
|
||||
- Fix a possible dead loop caused by shared subscriptions with `shared_dispatch_ack_enabled=true`. [#8918](https://github.com/emqx/emqx/pull/8918)
|
||||
- Fix dashboard binding IP address not working. [#8916](https://github.com/emqx/emqx/pull/8916)
|
||||
- Fix rule SQL topic matching to null values failed. [#8927](https://github.com/emqx/emqx/pull/8927)
|
||||
|
|
|
@ -200,7 +200,7 @@ do_verify(JwsCompacted, [Jwk|More]) ->
|
|||
end.
|
||||
|
||||
check_claims(Claims) ->
|
||||
Now = os:system_time(seconds),
|
||||
Now = erlang:system_time(seconds),
|
||||
Checker = [{<<"exp">>, with_num_value(
|
||||
fun(ExpireTime) -> Now < ExpireTime end)},
|
||||
{<<"iat">>, with_num_value(
|
||||
|
|
|
@ -74,7 +74,7 @@ t_check_auth(_Config) ->
|
|||
Plain = #{clientid => <<"client1">>, username => <<"plain">>, zone => external},
|
||||
Jwt = sign([{clientid, <<"client1">>},
|
||||
{username, <<"plain">>},
|
||||
{exp, os:system_time(seconds) + 2}], <<"HS256">>, <<"emqxsecret">>),
|
||||
{exp, erlang:system_time(seconds) + 2}], <<"HS256">>, <<"emqxsecret">>),
|
||||
ct:pal("Jwt: ~p~n", [Jwt]),
|
||||
|
||||
Result0 = emqx_access_control:authenticate(Plain#{password => Jwt}),
|
||||
|
@ -100,7 +100,7 @@ t_check_nbf(_Config) ->
|
|||
Plain = #{clientid => <<"client1">>, username => <<"plain">>, zone => external},
|
||||
Jwt = sign([{clientid, <<"client1">>},
|
||||
{username, <<"plain">>},
|
||||
{nbf, os:system_time(seconds) + 3}], <<"HS256">>, <<"emqxsecret">>),
|
||||
{nbf, erlang:system_time(seconds) + 3}], <<"HS256">>, <<"emqxsecret">>),
|
||||
ct:pal("Jwt: ~p~n", [Jwt]),
|
||||
|
||||
Result0 = emqx_access_control:authenticate(Plain#{password => Jwt}),
|
||||
|
@ -113,7 +113,7 @@ t_check_iat(_Config) ->
|
|||
Plain = #{clientid => <<"client1">>, username => <<"plain">>, zone => external},
|
||||
Jwt = sign([{clientid, <<"client1">>},
|
||||
{username, <<"plain">>},
|
||||
{iat, os:system_time(seconds) + 3}], <<"HS256">>, <<"emqxsecret">>),
|
||||
{iat, erlang:system_time(seconds) + 3}], <<"HS256">>, <<"emqxsecret">>),
|
||||
ct:pal("Jwt: ~p~n", [Jwt]),
|
||||
|
||||
Result0 = emqx_access_control:authenticate(Plain#{password => Jwt}),
|
||||
|
@ -146,7 +146,7 @@ t_check_auth_str_exp(init, _Config) ->
|
|||
application:unset_env(emqx_auth_jwt, verify_claims).
|
||||
t_check_auth_str_exp(_Config) ->
|
||||
Plain = #{clientid => <<"client1">>, username => <<"plain">>, zone => external},
|
||||
Exp = integer_to_binary(os:system_time(seconds) + 3),
|
||||
Exp = integer_to_binary(erlang:system_time(seconds) + 3),
|
||||
|
||||
Jwt0 = sign([{clientid, <<"client1">>},
|
||||
{username, <<"plain">>},
|
||||
|
@ -166,7 +166,7 @@ t_check_auth_str_exp(_Config) ->
|
|||
ct:pal("Auth result: ~p~n", [Result1]),
|
||||
?assertMatch({error, _}, Result1),
|
||||
|
||||
Exp2 = float_to_binary(os:system_time(seconds) + 3.5),
|
||||
Exp2 = float_to_binary(erlang:system_time(seconds) + 3.5),
|
||||
|
||||
Jwt2 = sign([{clientid, <<"client1">>},
|
||||
{username, <<"plain">>},
|
||||
|
@ -181,7 +181,7 @@ t_check_auth_float_exp(init, _Config) ->
|
|||
application:unset_env(emqx_auth_jwt, verify_claims).
|
||||
t_check_auth_float_exp(_Config) ->
|
||||
Plain = #{clientid => <<"client1">>, username => <<"plain">>, zone => external},
|
||||
Exp = os:system_time(seconds) + 3.5,
|
||||
Exp = erlang:system_time(seconds) + 3.5,
|
||||
|
||||
Jwt0 = sign([{clientid, <<"client1">>},
|
||||
{username, <<"plain">>},
|
||||
|
@ -208,7 +208,7 @@ t_check_claims(_Config) ->
|
|||
Jwt = sign([{client_id, <<"client1">>},
|
||||
{username, <<"plain">>},
|
||||
{sub, value},
|
||||
{exp, os:system_time(seconds) + 3}], <<"HS256">>, <<"emqxsecret">>),
|
||||
{exp, erlang:system_time(seconds) + 3}], <<"HS256">>, <<"emqxsecret">>),
|
||||
Result0 = emqx_access_control:authenticate(Plain#{password => Jwt}),
|
||||
ct:pal("Auth result: ~p~n", [Result0]),
|
||||
?assertMatch({ok, #{auth_result := success, jwt_claims := _}}, Result0),
|
||||
|
@ -224,7 +224,7 @@ t_check_claims_clientid(_Config) ->
|
|||
Plain = #{clientid => <<"client23">>, username => <<"plain">>, zone => external},
|
||||
Jwt = sign([{clientid, <<"client23">>},
|
||||
{username, <<"plain">>},
|
||||
{exp, os:system_time(seconds) + 3}], <<"HS256">>, <<"emqxsecret">>),
|
||||
{exp, erlang:system_time(seconds) + 3}], <<"HS256">>, <<"emqxsecret">>),
|
||||
Result0 = emqx_access_control:authenticate(Plain#{password => Jwt}),
|
||||
ct:pal("Auth result: ~p~n", [Result0]),
|
||||
?assertMatch({ok, #{auth_result := success, jwt_claims := _}}, Result0),
|
||||
|
@ -240,7 +240,7 @@ t_check_claims_username(_Config) ->
|
|||
Plain = #{clientid => <<"client23">>, username => <<"plain">>, zone => external},
|
||||
Jwt = sign([{client_id, <<"client23">>},
|
||||
{username, <<"plain">>},
|
||||
{exp, os:system_time(seconds) + 3}], <<"HS256">>, <<"emqxsecret">>),
|
||||
{exp, erlang:system_time(seconds) + 3}], <<"HS256">>, <<"emqxsecret">>),
|
||||
Result0 = emqx_access_control:authenticate(Plain#{password => Jwt}),
|
||||
ct:pal("Auth result: ~p~n", [Result0]),
|
||||
?assertMatch({ok, #{auth_result := success, jwt_claims := _}}, Result0),
|
||||
|
@ -256,7 +256,7 @@ t_check_claims_kid_in_header(_Config) ->
|
|||
Plain = #{clientid => <<"client23">>, username => <<"plain">>, zone => external},
|
||||
Jwt = sign([{clientid, <<"client23">>},
|
||||
{username, <<"plain">>},
|
||||
{exp, os:system_time(seconds) + 3}],
|
||||
{exp, erlang:system_time(seconds) + 3}],
|
||||
#{<<"alg">> => <<"HS256">>,
|
||||
<<"kid">> => <<"a_kid_str">>}, <<"emqxsecret">>),
|
||||
Result0 = emqx_access_control:authenticate(Plain#{password => Jwt}),
|
||||
|
@ -297,7 +297,7 @@ t_check_jwt_acl(_Config) ->
|
|||
{sub, value},
|
||||
{acl, [{sub, [<<"a/b">>]},
|
||||
{pub, [<<"c/d">>]}]},
|
||||
{exp, os:system_time(seconds) + 10}],
|
||||
{exp, erlang:system_time(seconds) + 10}],
|
||||
<<"HS256">>,
|
||||
<<"emqxsecret">>),
|
||||
|
||||
|
@ -337,7 +337,7 @@ t_check_jwt_acl_no_recs(_Config) ->
|
|||
{username, <<"plain">>},
|
||||
{sub, value},
|
||||
{acl, []},
|
||||
{exp, os:system_time(seconds) + 10}],
|
||||
{exp, erlang:system_time(seconds) + 10}],
|
||||
<<"HS256">>,
|
||||
<<"emqxsecret">>),
|
||||
|
||||
|
@ -360,7 +360,7 @@ t_check_jwt_acl_no_acl_claim(_Config) ->
|
|||
Jwt = sign([{client_id, <<"client1">>},
|
||||
{username, <<"plain">>},
|
||||
{sub, value},
|
||||
{exp, os:system_time(seconds) + 10}],
|
||||
{exp, erlang:system_time(seconds) + 10}],
|
||||
<<"HS256">>,
|
||||
<<"emqxsecret">>),
|
||||
|
||||
|
@ -384,7 +384,7 @@ t_check_jwt_acl_expire(_Config) ->
|
|||
{username, <<"plain">>},
|
||||
{sub, value},
|
||||
{acl, [{sub, [<<"a/b">>]}]},
|
||||
{exp, os:system_time(seconds) + 1}],
|
||||
{exp, erlang:system_time(seconds) + 1}],
|
||||
<<"HS256">>,
|
||||
<<"emqxsecret">>),
|
||||
|
||||
|
|
|
@ -160,7 +160,7 @@ handle_cast(Msg, State) ->
|
|||
|
||||
%% Do Publish...
|
||||
handle_info({timeout, TRef, do_publish}, State = #{timer := TRef}) ->
|
||||
DeletedKeys = do_publish(mnesia:dirty_first(?TAB), os:system_time(seconds)),
|
||||
DeletedKeys = do_publish(mnesia:dirty_first(?TAB), erlang:system_time(seconds)),
|
||||
lists:foreach(fun(Key) -> mnesia:dirty_delete(?TAB, Key) end, DeletedKeys),
|
||||
{noreply, ensure_publish_timer(State#{timer := undefined, publish_at := 0})};
|
||||
|
||||
|
@ -203,11 +203,11 @@ ensure_publish_timer(State) ->
|
|||
ensure_publish_timer('$end_of_table', State) ->
|
||||
State#{timer := undefined, publish_at := 0};
|
||||
ensure_publish_timer({Ts, _Id}, State = #{timer := undefined}) ->
|
||||
ensure_publish_timer(Ts, os:system_time(seconds), State);
|
||||
ensure_publish_timer(Ts, erlang:system_time(seconds), State);
|
||||
ensure_publish_timer({Ts, _Id}, State = #{timer := TRef, publish_at := PubAt})
|
||||
when Ts < PubAt ->
|
||||
ok = emqx_misc:cancel_timer(TRef),
|
||||
ensure_publish_timer(Ts, os:system_time(seconds), State);
|
||||
ensure_publish_timer(Ts, erlang:system_time(seconds), State);
|
||||
ensure_publish_timer(_Key, State) ->
|
||||
State.
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{application, emqx_modules,
|
||||
[{description, "EMQ X Module Management"},
|
||||
{vsn, "4.3.9"},
|
||||
{vsn, "4.3.10"},
|
||||
{modules, []},
|
||||
{applications, [kernel,stdlib]},
|
||||
{mod, {emqx_modules_app, []}},
|
||||
|
|
|
@ -1,10 +1,14 @@
|
|||
%% -*- mode: erlang -*-
|
||||
%% Unless you know what you are doing, DO NOT edit manually!!
|
||||
{VSN,
|
||||
[{"4.3.8",[{load_module,emqx_modules,brutal_purge,soft_purge,[]}]},
|
||||
[{"4.3.9",[{load_module,emqx_mod_delayed,brutal_purge,soft_purge,[]}]},
|
||||
{"4.3.8",
|
||||
[{load_module,emqx_modules,brutal_purge,soft_purge,[]},
|
||||
{load_module,emqx_mod_delayed,brutal_purge,soft_purge,[]}]},
|
||||
{<<"4\\.3\\.[5-7]">>,
|
||||
[{load_module,emqx_mod_rewrite,brutal_purge,soft_purge,[]},
|
||||
{load_module,emqx_modules,brutal_purge,soft_purge,[]}]},
|
||||
{load_module,emqx_modules,brutal_purge,soft_purge,[]},
|
||||
{load_module,emqx_mod_delayed,brutal_purge,soft_purge,[]}]},
|
||||
{"4.3.4",
|
||||
[{load_module,emqx_modules,brutal_purge,soft_purge,[]},
|
||||
{load_module,emqx_mod_subscription,brutal_purge,soft_purge,[]},
|
||||
|
@ -31,10 +35,14 @@
|
|||
{load_module,emqx_mod_api_topic_metrics,brutal_purge,soft_purge,[]},
|
||||
{load_module,emqx_mod_rewrite,brutal_purge,soft_purge,[]}]},
|
||||
{<<".*">>,[]}],
|
||||
[{"4.3.8",[{load_module,emqx_modules,brutal_purge,soft_purge,[]}]},
|
||||
[{"4.3.9",[{load_module,emqx_mod_delayed,brutal_purge,soft_purge,[]}]},
|
||||
{"4.3.8",
|
||||
[{load_module,emqx_modules,brutal_purge,soft_purge,[]},
|
||||
{load_module,emqx_mod_delayed,brutal_purge,soft_purge,[]}]},
|
||||
{<<"4\\.3\\.[5-7]">>,
|
||||
[{load_module,emqx_mod_rewrite,brutal_purge,soft_purge,[]},
|
||||
{load_module,emqx_modules,brutal_purge,soft_purge,[]}]},
|
||||
{load_module,emqx_modules,brutal_purge,soft_purge,[]},
|
||||
{load_module,emqx_mod_delayed,brutal_purge,soft_purge,[]}]},
|
||||
{"4.3.4",
|
||||
[{load_module,emqx_modules,brutal_purge,soft_purge,[]},
|
||||
{load_module,emqx_mod_subscription,brutal_purge,soft_purge,[]},
|
||||
|
|
Loading…
Reference in New Issue