fix(license): don't do not lose watermark fields.
This commit is contained in:
parent
7853eb75df
commit
001b209811
|
@ -94,7 +94,6 @@ check(_ConnInfo, AckProps) ->
|
||||||
pre_config_update(_, Cmd, Conf) ->
|
pre_config_update(_, Cmd, Conf) ->
|
||||||
{ok, do_update(Cmd, Conf)}.
|
{ok, do_update(Cmd, Conf)}.
|
||||||
|
|
||||||
post_config_update(_Path, _Cmd, ignore, _Old, _AppEnvs) -> ok;
|
|
||||||
post_config_update(_Path, _Cmd, NewConf, _Old, _AppEnvs) ->
|
post_config_update(_Path, _Cmd, NewConf, _Old, _AppEnvs) ->
|
||||||
case read_license(NewConf) of
|
case read_license(NewConf) of
|
||||||
{ok, License} ->
|
{ok, License} ->
|
||||||
|
@ -113,12 +112,12 @@ del_license_hook() ->
|
||||||
_ = emqx_hooks:del('client.connect', {?MODULE, check, []}),
|
_ = emqx_hooks:del('client.connect', {?MODULE, check, []}),
|
||||||
ok.
|
ok.
|
||||||
|
|
||||||
do_update({file, Filename}, _Conf) ->
|
do_update({file, Filename}, Conf) ->
|
||||||
case file:read_file(Filename) of
|
case file:read_file(Filename) of
|
||||||
{ok, Content} ->
|
{ok, Content} ->
|
||||||
case emqx_license_parser:parse(Content) of
|
case emqx_license_parser:parse(Content) of
|
||||||
{ok, _License} ->
|
{ok, _License} ->
|
||||||
#{<<"file">> => Filename};
|
maps:remove(<<"key">>, Conf#{<<"file">> => Filename});
|
||||||
{error, Reason} ->
|
{error, Reason} ->
|
||||||
erlang:throw(Reason)
|
erlang:throw(Reason)
|
||||||
end;
|
end;
|
||||||
|
@ -126,16 +125,16 @@ do_update({file, Filename}, _Conf) ->
|
||||||
erlang:throw({invalid_license_file, Reason})
|
erlang:throw({invalid_license_file, Reason})
|
||||||
end;
|
end;
|
||||||
|
|
||||||
do_update({key, Content}, _Conf) when is_binary(Content); is_list(Content) ->
|
do_update({key, Content}, Conf) when is_binary(Content); is_list(Content) ->
|
||||||
case emqx_license_parser:parse(Content) of
|
case emqx_license_parser:parse(Content) of
|
||||||
{ok, _License} ->
|
{ok, _License} ->
|
||||||
#{<<"key">> => Content};
|
maps:remove(<<"file">>, Conf#{<<"key">> => Content});
|
||||||
{error, Reason} ->
|
{error, Reason} ->
|
||||||
erlang:throw(Reason)
|
erlang:throw(Reason)
|
||||||
end;
|
end;
|
||||||
%% We don't do extra action when update license's watermark.
|
%% We don't do extra action when update license's watermark.
|
||||||
do_update(_Other, _Conf) ->
|
do_update(_Other, Conf) ->
|
||||||
{ok, ignore}.
|
Conf.
|
||||||
|
|
||||||
check_max_clients_exceeded(MaxClients) ->
|
check_max_clients_exceeded(MaxClients) ->
|
||||||
emqx_license_resources:connection_count() > MaxClients * 1.1.
|
emqx_license_resources:connection_count() > MaxClients * 1.1.
|
||||||
|
|
Loading…
Reference in New Issue