|
|
@@ -37,7 +37,6 @@
|
|
|
max_qos_allowed => emqx_types:qos(),
|
|
|
retain_available => boolean(),
|
|
|
wildcard_subscription => boolean(),
|
|
|
- subscription_identifiers => boolean(),
|
|
|
shared_subscription => boolean(),
|
|
|
exclusive_subscription => boolean()
|
|
|
}.
|
|
|
@@ -58,18 +57,17 @@
|
|
|
exclusive_subscription
|
|
|
]).
|
|
|
|
|
|
--define(DEFAULT_CAPS, #{
|
|
|
- max_packet_size => ?MAX_PACKET_SIZE,
|
|
|
- max_clientid_len => ?MAX_CLIENTID_LEN,
|
|
|
- max_topic_alias => ?MAX_TOPIC_AlIAS,
|
|
|
- max_topic_levels => ?MAX_TOPIC_LEVELS,
|
|
|
- max_qos_allowed => ?QOS_2,
|
|
|
- retain_available => true,
|
|
|
- wildcard_subscription => true,
|
|
|
- subscription_identifiers => true,
|
|
|
- shared_subscription => true,
|
|
|
- exclusive_subscription => false
|
|
|
-}).
|
|
|
+-define(DEFAULT_CAPS_KEYS, [
|
|
|
+ max_packet_size,
|
|
|
+ max_clientid_len,
|
|
|
+ max_topic_alias,
|
|
|
+ max_topic_levels,
|
|
|
+ max_qos_allowed,
|
|
|
+ retain_available,
|
|
|
+ wildcard_subscription,
|
|
|
+ shared_subscription,
|
|
|
+ exclusive_subscription
|
|
|
+]).
|
|
|
|
|
|
-spec check_pub(
|
|
|
emqx_types:zone(),
|
|
|
@@ -88,7 +86,7 @@ check_pub(Zone, Flags) when is_map(Flags) ->
|
|
|
error ->
|
|
|
Flags
|
|
|
end,
|
|
|
- maps:with(?PUBCAP_KEYS, get_caps(Zone))
|
|
|
+ get_caps(?PUBCAP_KEYS, Zone)
|
|
|
).
|
|
|
|
|
|
do_check_pub(#{topic_levels := Levels}, #{max_topic_levels := Limit}) when
|
|
|
@@ -111,7 +109,7 @@ do_check_pub(_Flags, _Caps) ->
|
|
|
) ->
|
|
|
ok_or_error(emqx_types:reason_code()).
|
|
|
check_sub(ClientInfo = #{zone := Zone}, Topic, SubOpts) ->
|
|
|
- Caps = maps:with(?SUBCAP_KEYS, get_caps(Zone)),
|
|
|
+ Caps = get_caps(?SUBCAP_KEYS, Zone),
|
|
|
Flags = lists:foldl(
|
|
|
fun
|
|
|
(max_topic_levels, Map) ->
|
|
|
@@ -152,10 +150,12 @@ do_check_sub(_Flags, _Caps, _, _) ->
|
|
|
ok.
|
|
|
|
|
|
get_caps(Zone) ->
|
|
|
- lists:foldl(
|
|
|
- fun({K, V}, Acc) ->
|
|
|
- Acc#{K => emqx_config:get_zone_conf(Zone, [mqtt, K], V)}
|
|
|
- end,
|
|
|
- #{},
|
|
|
- maps:to_list(?DEFAULT_CAPS)
|
|
|
+ get_caps(?DEFAULT_CAPS_KEYS, Zone).
|
|
|
+get_caps(Keys, Zone) ->
|
|
|
+ maps:with(
|
|
|
+ Keys,
|
|
|
+ maps:merge(
|
|
|
+ emqx_config:get([mqtt]),
|
|
|
+ emqx_config:get_zone_conf(Zone, [mqtt])
|
|
|
+ )
|
|
|
).
|