chore(gw): fix gatway enable/1 not working
This commit is contained in:
parent
d8176f4378
commit
a9e32ac106
|
@ -100,11 +100,17 @@ init([Gateway, Ctx, _GwDscrptr]) ->
|
|||
status = stopped,
|
||||
created_at = erlang:system_time(millisecond)
|
||||
},
|
||||
case maps:get(enable, Config, true) of
|
||||
false ->
|
||||
?LOG(info, "Skipp to start ~s gateway due to disabled", [GwName]),
|
||||
{ok, State};
|
||||
true ->
|
||||
case cb_gateway_load(State) of
|
||||
{error, Reason} ->
|
||||
{stop, {load_gateway_failure, Reason}};
|
||||
{ok, NState} ->
|
||||
{ok, NState}
|
||||
end
|
||||
end.
|
||||
|
||||
handle_call(info, _From, State) ->
|
||||
|
@ -235,10 +241,12 @@ do_init_authn([], Names) ->
|
|||
Names;
|
||||
do_init_authn([{_ChainName, _AuthConf = #{enable := false}}|More], Names) ->
|
||||
do_init_authn(More, Names);
|
||||
do_init_authn([{ChainName, AuthConf}|More], Names) ->
|
||||
do_init_authn([{ChainName, AuthConf}|More], Names) when is_map(AuthConf) ->
|
||||
_ = application:ensure_all_started(emqx_authn),
|
||||
do_create_authn_chain(ChainName, AuthConf),
|
||||
do_init_authn(More, [ChainName|Names]).
|
||||
do_init_authn(More, [ChainName|Names]);
|
||||
do_init_authn([_BadConf|More], Names) ->
|
||||
do_init_authn(More, Names).
|
||||
|
||||
authns(GwName, Config) ->
|
||||
Listeners = maps:to_list(maps:get(listeners, Config, #{})),
|
||||
|
@ -358,11 +366,6 @@ cb_gateway_load(State = #state{name = GwName,
|
|||
ctx = Ctx}) ->
|
||||
|
||||
Gateway = detailed_gateway_info(State),
|
||||
|
||||
case maps:get(enable, Config, true) of
|
||||
false ->
|
||||
?LOG(info, "Skipp to start ~s gateway due to disabled", [GwName]);
|
||||
true ->
|
||||
try
|
||||
AuthnNames = init_authn(GwName, Config),
|
||||
NCtx = Ctx#{auth => AuthnNames},
|
||||
|
@ -390,7 +393,6 @@ cb_gateway_load(State = #state{name = GwName,
|
|||
[GwName, Gateway, Ctx,
|
||||
Class, Reason1, Stk]),
|
||||
{error, {Class, Reason1, Stk}}
|
||||
end
|
||||
end.
|
||||
|
||||
cb_gateway_update(Config,
|
||||
|
|
|
@ -33,12 +33,11 @@ gateway.coap {
|
|||
subscribe_qos = qos1
|
||||
publish_qos = qos1
|
||||
authentication = undefined
|
||||
|
||||
listeners.udp.default {
|
||||
bind = 5683
|
||||
}
|
||||
}
|
||||
">>).
|
||||
}
|
||||
">>).
|
||||
|
||||
-define(HOST, "127.0.0.1").
|
||||
-define(PORT, 5683).
|
||||
|
|
|
@ -33,7 +33,7 @@ gateway.lwm2m {
|
|||
xml_dir = \"../../lib/emqx_gateway/src/lwm2m/lwm2m_xml\"
|
||||
lifetime_min = 1s
|
||||
lifetime_max = 86400s
|
||||
qmode_time_windonw = 22
|
||||
qmode_time_window = 22
|
||||
auto_observe = false
|
||||
mountpoint = \"lwm2m/%u\"
|
||||
update_msg_publish_condition = contains_object_list
|
||||
|
|
Loading…
Reference in New Issue