chore(gw): pass listener id into listener params
This commit is contained in:
parent
3e033b419c
commit
d8176f4378
|
@ -103,9 +103,15 @@ init(ConnInfo = #{peername := {PeerHost, _},
|
|||
#{ctx := Ctx} = Config) ->
|
||||
Peercert = maps:get(peercert, ConnInfo, undefined),
|
||||
Mountpoint = maps:get(mountpoint, Config, <<>>),
|
||||
ListenerId = case maps:get(listener, Config, undefined) of
|
||||
undefined -> undefined;
|
||||
{GwName, Type, LisName} ->
|
||||
emqx_gateway_utils:listener_id(GwName, Type, LisName)
|
||||
end,
|
||||
ClientInfo = set_peercert_infos(
|
||||
Peercert,
|
||||
#{ zone => default
|
||||
, listener => ListenerId
|
||||
, protocol => 'coap'
|
||||
, peerhost => PeerHost
|
||||
, sockport => SockPort
|
||||
|
|
|
@ -100,8 +100,8 @@ start_listener(GwName, Ctx, {Type, LisName, ListenOn, SocketOpts, Cfg}) ->
|
|||
|
||||
start_listener(GwName, Ctx, Type, LisName, ListenOn, SocketOpts, Cfg) ->
|
||||
Name = emqx_gateway_utils:listener_id(GwName, Type, LisName),
|
||||
NCfg = Cfg#{
|
||||
ctx => Ctx,
|
||||
NCfg = Cfg#{ctx => Ctx,
|
||||
listener => {GwName, Type, LisName},
|
||||
frame_mod => emqx_coap_frame,
|
||||
chann_mod => emqx_coap_channel
|
||||
},
|
||||
|
|
|
@ -29,8 +29,8 @@
|
|||
-type context() ::
|
||||
#{ %% Gateway Name
|
||||
gwname := gateway_name()
|
||||
%% Autenticator
|
||||
, auth := emqx_authentication:chain_name() | undefined
|
||||
%% Authentication chains
|
||||
, auth := [emqx_authentication:chain_name()] | undefined
|
||||
%% The ConnectionManager PID
|
||||
, cm := pid()
|
||||
}.
|
||||
|
|
|
@ -226,11 +226,7 @@ sock_opts(Name, Opts) ->
|
|||
%% Envs
|
||||
|
||||
active_n(Options) ->
|
||||
maps:get(
|
||||
active_n,
|
||||
maps:get(listener, Options, #{active_n => ?ACTIVE_N}),
|
||||
?ACTIVE_N
|
||||
).
|
||||
maps:get(active_n, Options, ?ACTIVE_N).
|
||||
|
||||
-spec idle_timeout(map()) -> pos_integer().
|
||||
idle_timeout(Options) ->
|
||||
|
|
|
@ -139,7 +139,12 @@ init(ConnInfo = #{socktype := Socktype,
|
|||
GRpcChann = maps:get(handler, Options),
|
||||
PoolName = maps:get(pool_name, Options),
|
||||
NConnInfo = default_conninfo(ConnInfo),
|
||||
ClientInfo = default_clientinfo(ConnInfo),
|
||||
ListenerId = case maps:get(listener, Options, undefined) of
|
||||
undefined -> undefined;
|
||||
{GwName, Type, LisName} ->
|
||||
emqx_gateway_utils:listener_id(GwName, Type, LisName)
|
||||
end,
|
||||
ClientInfo = maps:put(listener, ListenerId, default_clientinfo(ConnInfo)),
|
||||
Channel = #channel{
|
||||
ctx = Ctx,
|
||||
gcli = #{channel => GRpcChann, pool_name => PoolName},
|
||||
|
|
|
@ -156,6 +156,7 @@ start_listener(GwName, Ctx, Type, LisName, ListenOn, SocketOpts, Cfg) ->
|
|||
Name = emqx_gateway_utils:listener_id(GwName, Type, LisName),
|
||||
NCfg = Cfg#{
|
||||
ctx => Ctx,
|
||||
listener => {GwName, Type, LisName},
|
||||
frame_mod => emqx_exproto_frame,
|
||||
chann_mod => emqx_exproto_channel
|
||||
},
|
||||
|
|
|
@ -89,9 +89,15 @@ init(ConnInfo = #{peername := {PeerHost, _},
|
|||
#{ctx := Ctx} = Config) ->
|
||||
Peercert = maps:get(peercert, ConnInfo, undefined),
|
||||
Mountpoint = maps:get(mountpoint, Config, undefined),
|
||||
ListenerId = case maps:get(listener, Config, undefined) of
|
||||
undefined -> undefined;
|
||||
{GwName, Type, LisName} ->
|
||||
emqx_gateway_utils:listener_id(GwName, Type, LisName)
|
||||
end,
|
||||
ClientInfo = set_peercert_infos(
|
||||
Peercert,
|
||||
#{ zone => default
|
||||
, listener => ListenerId
|
||||
, protocol => lwm2m
|
||||
, peerhost => PeerHost
|
||||
, sockport => SockPort
|
||||
|
|
|
@ -102,6 +102,7 @@ start_listener(GwName, Ctx, {Type, LisName, ListenOn, SocketOpts, Cfg}) ->
|
|||
start_listener(GwName, Ctx, Type, LisName, ListenOn, SocketOpts, Cfg) ->
|
||||
Name = emqx_gateway_utils:listener_id(GwName, Type, LisName),
|
||||
NCfg = Cfg#{ ctx => Ctx
|
||||
, listener => {GwName, Type, LisName}
|
||||
, frame_mod => emqx_coap_frame
|
||||
, chann_mod => emqx_lwm2m_channel
|
||||
},
|
||||
|
|
|
@ -116,9 +116,15 @@ init(ConnInfo = #{peername := {PeerHost, _},
|
|||
Registry = maps:get(registry, Option),
|
||||
GwId = maps:get(gateway_id, Option),
|
||||
EnableQoS3 = maps:get(enable_qos3, Option, true),
|
||||
ListenerId = case maps:get(listener, Option, undefined) of
|
||||
undefined -> undefined;
|
||||
{GwName, Type, LisName} ->
|
||||
emqx_gateway_utils:listener_id(GwName, Type, LisName)
|
||||
end,
|
||||
ClientInfo = set_peercert_infos(
|
||||
Peercert,
|
||||
#{ zone => default
|
||||
, listener => ListenerId
|
||||
, protocol => 'mqtt-sn'
|
||||
, peerhost => PeerHost
|
||||
, sockport => SockPort
|
||||
|
|
|
@ -121,6 +121,7 @@ start_listener(GwName, Ctx, Type, LisName, ListenOn, SocketOpts, Cfg) ->
|
|||
Name = emqx_gateway_utils:listener_id(GwName, Type, LisName),
|
||||
NCfg = Cfg#{
|
||||
ctx => Ctx,
|
||||
listene => {GwName, Type, LisName},
|
||||
frame_mod => emqx_sn_frame,
|
||||
chann_mod => emqx_sn_channel
|
||||
},
|
||||
|
@ -138,13 +139,13 @@ merge_default(Options) ->
|
|||
end.
|
||||
|
||||
stop_listener(GwName, {Type, LisName, ListenOn, SocketOpts, Cfg}) ->
|
||||
StopRet = stop_listener(GwName, LisName, Type, ListenOn, SocketOpts, Cfg),
|
||||
StopRet = stop_listener(GwName, Type, LisName, ListenOn, SocketOpts, Cfg),
|
||||
ListenOnStr = emqx_gateway_utils:format_listenon(ListenOn),
|
||||
case StopRet of
|
||||
ok -> ?ULOG("Gateway ~s:~s:~s on ~s stopped.~n",
|
||||
[GwName, Type, LisName, ListenOnStr]);
|
||||
{error, Reason} ->
|
||||
?ELOG("Failed to stop gatewat ~s:~s:~s on ~s: ~0p~n",
|
||||
?ELOG("Failed to stop gateway ~s:~s:~s on ~s: ~0p~n",
|
||||
[GwName, Type, LisName, ListenOnStr, Reason])
|
||||
end,
|
||||
StopRet.
|
||||
|
|
|
@ -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