|
|
@@ -106,7 +106,7 @@ unconvert_listeners(Ls) when is_list(Ls) ->
|
|
|
{[Type, Name], Lis1} = maps_key_take([<<"type">>, <<"name">>], Lis),
|
|
|
_ = vaildate_listener_name(Name),
|
|
|
NLis1 = maps:without([<<"id">>, <<"running">>], Lis1),
|
|
|
- emqx_map_lib:deep_merge(Acc, #{Type => #{Name => NLis1}})
|
|
|
+ emqx_utils_maps:deep_merge(Acc, #{Type => #{Name => NLis1}})
|
|
|
end,
|
|
|
#{},
|
|
|
Ls
|
|
|
@@ -160,8 +160,8 @@ gateway(GwName0) ->
|
|
|
RawConf = emqx_config:fill_defaults(
|
|
|
emqx_config:get_root_raw(Path)
|
|
|
),
|
|
|
- Confs = emqx_map_lib:jsonable_map(
|
|
|
- emqx_map_lib:deep_get(Path, RawConf)
|
|
|
+ Confs = emqx_utils_maps:jsonable_map(
|
|
|
+ emqx_utils_maps:deep_get(Path, RawConf)
|
|
|
),
|
|
|
LsConf = maps:get(<<"listeners">>, Confs, #{}),
|
|
|
Confs#{<<"listeners">> => convert_listeners(GwName, LsConf)}.
|
|
|
@@ -198,8 +198,8 @@ listeners(GwName0) ->
|
|
|
RawConf = emqx_config:fill_defaults(
|
|
|
emqx_config:get_root_raw([<<"gateway">>])
|
|
|
),
|
|
|
- Listeners = emqx_map_lib:jsonable_map(
|
|
|
- emqx_map_lib:deep_get(
|
|
|
+ Listeners = emqx_utils_maps:jsonable_map(
|
|
|
+ emqx_utils_maps:deep_get(
|
|
|
[<<"gateway">>, GwName, <<"listeners">>], RawConf
|
|
|
)
|
|
|
),
|
|
|
@@ -213,12 +213,12 @@ listener(ListenerId) ->
|
|
|
),
|
|
|
try
|
|
|
Path = [<<"gateway">>, GwName, <<"listeners">>, Type, LName],
|
|
|
- LConf = emqx_map_lib:deep_get(Path, RootConf),
|
|
|
+ LConf = emqx_utils_maps:deep_get(Path, RootConf),
|
|
|
Running = emqx_gateway_utils:is_running(
|
|
|
binary_to_existing_atom(ListenerId), LConf
|
|
|
),
|
|
|
{ok,
|
|
|
- emqx_map_lib:jsonable_map(
|
|
|
+ emqx_utils_maps:jsonable_map(
|
|
|
LConf#{
|
|
|
id => ListenerId,
|
|
|
type => Type,
|
|
|
@@ -305,8 +305,8 @@ ret_ok_err({ok, _}) -> ok;
|
|
|
ret_ok_err(Err) -> Err.
|
|
|
|
|
|
ret_gw(GwName, {ok, #{raw_config := GwConf}}) ->
|
|
|
- GwConf1 = emqx_map_lib:deep_get([bin(GwName)], GwConf),
|
|
|
- LsConf = emqx_map_lib:deep_get(
|
|
|
+ GwConf1 = emqx_utils_maps:deep_get([bin(GwName)], GwConf),
|
|
|
+ LsConf = emqx_utils_maps:deep_get(
|
|
|
[bin(GwName), <<"listeners">>],
|
|
|
GwConf,
|
|
|
#{}
|
|
|
@@ -331,7 +331,7 @@ ret_gw(_GwName, Err) ->
|
|
|
Err.
|
|
|
|
|
|
ret_authn(GwName, {ok, #{raw_config := GwConf}}) ->
|
|
|
- Authn = emqx_map_lib:deep_get(
|
|
|
+ Authn = emqx_utils_maps:deep_get(
|
|
|
[bin(GwName), <<"authentication">>],
|
|
|
GwConf
|
|
|
),
|
|
|
@@ -340,7 +340,7 @@ ret_authn(_GwName, Err) ->
|
|
|
Err.
|
|
|
|
|
|
ret_authn(GwName, {LType, LName}, {ok, #{raw_config := GwConf}}) ->
|
|
|
- Authn = emqx_map_lib:deep_get(
|
|
|
+ Authn = emqx_utils_maps:deep_get(
|
|
|
[
|
|
|
bin(GwName),
|
|
|
<<"listeners">>,
|
|
|
@@ -355,7 +355,7 @@ ret_authn(_, _, Err) ->
|
|
|
Err.
|
|
|
|
|
|
ret_listener_or_err(GwName, {LType, LName}, {ok, #{raw_config := GwConf}}) ->
|
|
|
- LConf = emqx_map_lib:deep_get(
|
|
|
+ LConf = emqx_utils_maps:deep_get(
|
|
|
[bin(GwName), <<"listeners">>, bin(LType), bin(LName)],
|
|
|
GwConf
|
|
|
),
|
|
|
@@ -377,7 +377,7 @@ pre_config_update(_, {load_gateway, GwName, Conf}, RawConf) ->
|
|
|
case maps:get(GwName, RawConf, undefined) of
|
|
|
undefined ->
|
|
|
NConf = tune_gw_certs(fun convert_certs/2, GwName, Conf),
|
|
|
- {ok, emqx_map_lib:deep_put([GwName], RawConf, NConf)};
|
|
|
+ {ok, emqx_utils_maps:deep_put([GwName], RawConf, NConf)};
|
|
|
_ ->
|
|
|
badres_gateway(already_exist, GwName)
|
|
|
end;
|
|
|
@@ -389,7 +389,7 @@ pre_config_update(_, {update_gateway, GwName, Conf}, RawConf) ->
|
|
|
Conf1 = maps:without([<<"listeners">>, ?AUTHN_BIN], Conf),
|
|
|
NConf = tune_gw_certs(fun convert_certs/2, GwName, Conf1),
|
|
|
NConf1 = maps:merge(GwRawConf, NConf),
|
|
|
- {ok, emqx_map_lib:deep_put([GwName], RawConf, NConf1)}
|
|
|
+ {ok, emqx_utils_maps:deep_put([GwName], RawConf, NConf1)}
|
|
|
end;
|
|
|
pre_config_update(_, {unload_gateway, GwName}, RawConf) ->
|
|
|
_ = tune_gw_certs(
|
|
|
@@ -400,7 +400,7 @@ pre_config_update(_, {unload_gateway, GwName}, RawConf) ->
|
|
|
{ok, maps:remove(GwName, RawConf)};
|
|
|
pre_config_update(_, {add_listener, GwName, {LType, LName}, Conf}, RawConf) ->
|
|
|
case
|
|
|
- emqx_map_lib:deep_get(
|
|
|
+ emqx_utils_maps:deep_get(
|
|
|
[GwName, <<"listeners">>, LType, LName], RawConf, undefined
|
|
|
)
|
|
|
of
|
|
|
@@ -408,7 +408,7 @@ pre_config_update(_, {add_listener, GwName, {LType, LName}, Conf}, RawConf) ->
|
|
|
NConf = convert_certs(certs_dir(GwName), Conf),
|
|
|
NListener = #{LType => #{LName => NConf}},
|
|
|
{ok,
|
|
|
- emqx_map_lib:deep_merge(
|
|
|
+ emqx_utils_maps:deep_merge(
|
|
|
RawConf,
|
|
|
#{GwName => #{<<"listeners">> => NListener}}
|
|
|
)};
|
|
|
@@ -417,7 +417,7 @@ pre_config_update(_, {add_listener, GwName, {LType, LName}, Conf}, RawConf) ->
|
|
|
end;
|
|
|
pre_config_update(_, {update_listener, GwName, {LType, LName}, Conf}, RawConf) ->
|
|
|
case
|
|
|
- emqx_map_lib:deep_get(
|
|
|
+ emqx_utils_maps:deep_get(
|
|
|
[GwName, <<"listeners">>, LType, LName], RawConf, undefined
|
|
|
)
|
|
|
of
|
|
|
@@ -425,7 +425,7 @@ pre_config_update(_, {update_listener, GwName, {LType, LName}, Conf}, RawConf) -
|
|
|
badres_listener(not_found, GwName, LType, LName);
|
|
|
OldConf ->
|
|
|
NConf = convert_certs(certs_dir(GwName), Conf, OldConf),
|
|
|
- NRawConf = emqx_map_lib:deep_put(
|
|
|
+ NRawConf = emqx_utils_maps:deep_put(
|
|
|
[GwName, <<"listeners">>, LType, LName],
|
|
|
RawConf,
|
|
|
NConf
|
|
|
@@ -434,22 +434,22 @@ pre_config_update(_, {update_listener, GwName, {LType, LName}, Conf}, RawConf) -
|
|
|
end;
|
|
|
pre_config_update(_, {remove_listener, GwName, {LType, LName}}, RawConf) ->
|
|
|
Path = [GwName, <<"listeners">>, LType, LName],
|
|
|
- case emqx_map_lib:deep_get(Path, RawConf, undefined) of
|
|
|
+ case emqx_utils_maps:deep_get(Path, RawConf, undefined) of
|
|
|
undefined ->
|
|
|
{ok, RawConf};
|
|
|
OldConf ->
|
|
|
clear_certs(certs_dir(GwName), OldConf),
|
|
|
- {ok, emqx_map_lib:deep_remove(Path, RawConf)}
|
|
|
+ {ok, emqx_utils_maps:deep_remove(Path, RawConf)}
|
|
|
end;
|
|
|
pre_config_update(_, {add_authn, GwName, Conf}, RawConf) ->
|
|
|
case
|
|
|
- emqx_map_lib:deep_get(
|
|
|
+ emqx_utils_maps:deep_get(
|
|
|
[GwName, ?AUTHN_BIN], RawConf, undefined
|
|
|
)
|
|
|
of
|
|
|
undefined ->
|
|
|
{ok,
|
|
|
- emqx_map_lib:deep_merge(
|
|
|
+ emqx_utils_maps:deep_merge(
|
|
|
RawConf,
|
|
|
#{GwName => #{?AUTHN_BIN => Conf}}
|
|
|
)};
|
|
|
@@ -458,7 +458,7 @@ pre_config_update(_, {add_authn, GwName, Conf}, RawConf) ->
|
|
|
end;
|
|
|
pre_config_update(_, {add_authn, GwName, {LType, LName}, Conf}, RawConf) ->
|
|
|
case
|
|
|
- emqx_map_lib:deep_get(
|
|
|
+ emqx_utils_maps:deep_get(
|
|
|
[GwName, <<"listeners">>, LType, LName],
|
|
|
RawConf,
|
|
|
undefined
|
|
|
@@ -477,25 +477,25 @@ pre_config_update(_, {add_authn, GwName, {LType, LName}, Conf}, RawConf) ->
|
|
|
#{LType => #{LName => NListener}}
|
|
|
}
|
|
|
},
|
|
|
- {ok, emqx_map_lib:deep_merge(RawConf, NGateway)};
|
|
|
+ {ok, emqx_utils_maps:deep_merge(RawConf, NGateway)};
|
|
|
_ ->
|
|
|
badres_listener_authn(already_exist, GwName, LType, LName)
|
|
|
end
|
|
|
end;
|
|
|
pre_config_update(_, {update_authn, GwName, Conf}, RawConf) ->
|
|
|
case
|
|
|
- emqx_map_lib:deep_get(
|
|
|
+ emqx_utils_maps:deep_get(
|
|
|
[GwName, ?AUTHN_BIN], RawConf, undefined
|
|
|
)
|
|
|
of
|
|
|
undefined ->
|
|
|
badres_authn(not_found, GwName);
|
|
|
_Authn ->
|
|
|
- {ok, emqx_map_lib:deep_put([GwName, ?AUTHN_BIN], RawConf, Conf)}
|
|
|
+ {ok, emqx_utils_maps:deep_put([GwName, ?AUTHN_BIN], RawConf, Conf)}
|
|
|
end;
|
|
|
pre_config_update(_, {update_authn, GwName, {LType, LName}, Conf}, RawConf) ->
|
|
|
case
|
|
|
- emqx_map_lib:deep_get(
|
|
|
+ emqx_utils_maps:deep_get(
|
|
|
[GwName, <<"listeners">>, LType, LName],
|
|
|
RawConf,
|
|
|
undefined
|
|
|
@@ -514,7 +514,7 @@ pre_config_update(_, {update_authn, GwName, {LType, LName}, Conf}, RawConf) ->
|
|
|
Listener
|
|
|
),
|
|
|
{ok,
|
|
|
- emqx_map_lib:deep_put(
|
|
|
+ emqx_utils_maps:deep_put(
|
|
|
[GwName, <<"listeners">>, LType, LName],
|
|
|
RawConf,
|
|
|
NListener
|
|
|
@@ -523,12 +523,12 @@ pre_config_update(_, {update_authn, GwName, {LType, LName}, Conf}, RawConf) ->
|
|
|
end;
|
|
|
pre_config_update(_, {remove_authn, GwName}, RawConf) ->
|
|
|
{ok,
|
|
|
- emqx_map_lib:deep_remove(
|
|
|
+ emqx_utils_maps:deep_remove(
|
|
|
[GwName, ?AUTHN_BIN], RawConf
|
|
|
)};
|
|
|
pre_config_update(_, {remove_authn, GwName, {LType, LName}}, RawConf) ->
|
|
|
Path = [GwName, <<"listeners">>, LType, LName, ?AUTHN_BIN],
|
|
|
- {ok, emqx_map_lib:deep_remove(Path, RawConf)};
|
|
|
+ {ok, emqx_utils_maps:deep_remove(Path, RawConf)};
|
|
|
pre_config_update(_, UnknownReq, _RawConf) ->
|
|
|
logger:error("Unknown configuration update request: ~0p", [UnknownReq]),
|
|
|
{error, badreq}.
|