Add MQTT section in configuration file
This commit is contained in:
parent
d516b8c241
commit
d9004d4cfb
|
@ -440,10 +440,50 @@ enable_acl_cache = on
|
||||||
## Default: 5 minute
|
## Default: 5 minute
|
||||||
acl_cache_age = 5m
|
acl_cache_age = 5m
|
||||||
|
|
||||||
## The ACL cache size, 0 means no limit.
|
##--------------------------------------------------------------------
|
||||||
|
## MQTT
|
||||||
|
##--------------------------------------------------------------------
|
||||||
|
|
||||||
|
## Maximum MQTT packet size allowed.
|
||||||
##
|
##
|
||||||
## Value: Integer
|
## Value: Bytes
|
||||||
acl_cache_size = 0
|
## Default: 1MB
|
||||||
|
mqtt.max_packet_size = 1MB
|
||||||
|
|
||||||
|
## Maximum length of MQTT clientId allowed.
|
||||||
|
##
|
||||||
|
## Value: Number [23-65535]
|
||||||
|
mqtt.max_clientid_len = 65535
|
||||||
|
|
||||||
|
## Maximum topic levels allowed. 0 means no limit.
|
||||||
|
##
|
||||||
|
## Value: Number
|
||||||
|
mqtt.max_topic_levels = 0
|
||||||
|
|
||||||
|
## Maximum QoS allowed.
|
||||||
|
##
|
||||||
|
## Value: 0 | 1 | 2
|
||||||
|
mqtt.max_qos_allowed = 2
|
||||||
|
|
||||||
|
## Maximum Topic Alias, 0 means no limit.
|
||||||
|
##
|
||||||
|
## Value: 0-65535
|
||||||
|
mqtt.max_topic_alias = 0
|
||||||
|
|
||||||
|
## Whether the Server supports MQTT retained messages.
|
||||||
|
##
|
||||||
|
## Value: boolean
|
||||||
|
mqtt.retain_available = true
|
||||||
|
|
||||||
|
## Whether the Server supports MQTT Wildcard Subscriptions
|
||||||
|
##
|
||||||
|
## Value: boolean
|
||||||
|
mqtt.wildcard_subscription = true
|
||||||
|
|
||||||
|
## Whether the Server supports MQTT Shared Subscriptions
|
||||||
|
##
|
||||||
|
## Value: boolean
|
||||||
|
mqtt.shared_subscription = true
|
||||||
|
|
||||||
##--------------------------------------------------------------------
|
##--------------------------------------------------------------------
|
||||||
## Listeners
|
## Listeners
|
||||||
|
@ -1303,43 +1343,43 @@ zone.external.enable_stats = on
|
||||||
## Maximum MQTT packet size allowed.
|
## Maximum MQTT packet size allowed.
|
||||||
##
|
##
|
||||||
## Value: Bytes
|
## Value: Bytes
|
||||||
## Default: 64KB
|
## Default: 1MB
|
||||||
zone.external.max_packet_size = 1MB
|
## zone.external.max_packet_size = 64KB
|
||||||
|
|
||||||
## Maximum length of MQTT clientId allowed.
|
## Maximum length of MQTT clientId allowed.
|
||||||
##
|
##
|
||||||
## Value: Number [23-65535]
|
## Value: Number [23-65535]
|
||||||
zone.external.max_clientid_len = 65535
|
## zone.external.max_clientid_len = 1024
|
||||||
|
|
||||||
## Maximum topic levels allowed. 0 means no limit.
|
## Maximum topic levels allowed. 0 means no limit.
|
||||||
##
|
##
|
||||||
## Value: Number
|
## Value: Number
|
||||||
zone.external.max_topic_levels = 0
|
## zone.external.max_topic_levels = 7
|
||||||
|
|
||||||
## Maximum QoS allowed.
|
## Maximum QoS allowed.
|
||||||
##
|
##
|
||||||
## Value: 0 | 1 | 2
|
## Value: 0 | 1 | 2
|
||||||
zone.external.max_qos_allowed = 2
|
## zone.external.max_qos_allowed = 2
|
||||||
|
|
||||||
## Maximum Topic Alias, 0 means no limit.
|
## Maximum Topic Alias, 0 means no limit.
|
||||||
##
|
##
|
||||||
## Value: 0-65535
|
## Value: 0-65535
|
||||||
zone.external.max_topic_alias = 0
|
## zone.external.max_topic_alias = 0
|
||||||
|
|
||||||
## Whether the Server supports retained messages.
|
## Whether the Server supports retained messages.
|
||||||
##
|
##
|
||||||
## Value: boolean
|
## Value: boolean
|
||||||
zone.external.retain_available = true
|
## zone.external.retain_available = true
|
||||||
|
|
||||||
## Whether the Server supports Wildcard Subscriptions
|
## Whether the Server supports Wildcard Subscriptions
|
||||||
##
|
##
|
||||||
## Value: boolean
|
## Value: boolean
|
||||||
zone.external.wildcard_subscription = true
|
## zone.external.wildcard_subscription = false
|
||||||
|
|
||||||
## Whether the Server supports Shared Subscriptions
|
## Whether the Server supports Shared Subscriptions
|
||||||
##
|
##
|
||||||
## Value: boolean
|
## Value: boolean
|
||||||
zone.external.shared_subscription = true
|
## zone.external.shared_subscription = false
|
||||||
|
|
||||||
## The backoff for MQTT keepalive timeout. The broker will kick a connection out
|
## The backoff for MQTT keepalive timeout. The broker will kick a connection out
|
||||||
## until 'Keepalive * backoff * 2' timeout.
|
## until 'Keepalive * backoff * 2' timeout.
|
||||||
|
@ -1421,12 +1461,12 @@ zone.internal.enable_acl = off
|
||||||
## See zone.$name.wildcard_subscription.
|
## See zone.$name.wildcard_subscription.
|
||||||
##
|
##
|
||||||
## Value: boolean
|
## Value: boolean
|
||||||
zone.internal.wildcard_subscription = true
|
## zone.internal.wildcard_subscription = true
|
||||||
|
|
||||||
## See zone.$name.shared_subscription.
|
## See zone.$name.shared_subscription.
|
||||||
##
|
##
|
||||||
## Value: boolean
|
## Value: boolean
|
||||||
zone.internal.shared_subscription = true
|
## zone.internal.shared_subscription = true
|
||||||
|
|
||||||
## See zone.$name.max_subscriptions.
|
## See zone.$name.max_subscriptions.
|
||||||
##
|
##
|
||||||
|
|
|
@ -578,11 +578,64 @@ end}.
|
||||||
]}.
|
]}.
|
||||||
|
|
||||||
%% @doc ACL cache size.
|
%% @doc ACL cache size.
|
||||||
{mapping, "acl_cache_size", "emqx.acl_cache_size", [
|
%% {mapping, "acl_cache_size", "emqx.acl_cache_size", [
|
||||||
|
%% {default, 0},
|
||||||
|
%% {datatype, integer}
|
||||||
|
%% ]}.
|
||||||
|
|
||||||
|
%%--------------------------------------------------------------------
|
||||||
|
%% MQTT
|
||||||
|
%%--------------------------------------------------------------------
|
||||||
|
|
||||||
|
%% @doc Max Packet Size Allowed, 1MB by default.
|
||||||
|
{mapping, "mqtt.max_packet_size", "emqx.max_packet_size", [
|
||||||
|
{default, "1MB"},
|
||||||
|
{datatype, bytesize}
|
||||||
|
]}.
|
||||||
|
|
||||||
|
%% @doc Set the Max ClientId Length Allowed.
|
||||||
|
{mapping, "mqtt.max_clientid_len", "emqx.max_clientid_len", [
|
||||||
|
{default, 65535},
|
||||||
|
{datatype, integer}
|
||||||
|
]}.
|
||||||
|
|
||||||
|
%% @doc Set the Maximum topic levels.
|
||||||
|
{mapping, "mqtt.max_topic_levels", "emqx.max_topic_levels", [
|
||||||
{default, 0},
|
{default, 0},
|
||||||
{datatype, integer}
|
{datatype, integer}
|
||||||
]}.
|
]}.
|
||||||
|
|
||||||
|
%% @doc Set the Maximum QoS allowed.
|
||||||
|
{mapping, "mqtt.max_qos_allowed", "emqx.max_qos_allowed", [
|
||||||
|
{default, 2},
|
||||||
|
{datatype, integer},
|
||||||
|
{validators, ["range:0-2"]}
|
||||||
|
]}.
|
||||||
|
|
||||||
|
%% @doc Set the Maximum topic alias.
|
||||||
|
{mapping, "mqtt.max_topic_alias", "emqx.max_topic_alias", [
|
||||||
|
{default, 0},
|
||||||
|
{datatype, integer}
|
||||||
|
]}.
|
||||||
|
|
||||||
|
%% @doc Whether the server supports MQTT retained messages.
|
||||||
|
{mapping, "mqtt.retain_available", "emqx.mqtt_retain_available", [
|
||||||
|
{default, true},
|
||||||
|
{datatype, {enum, [true, false]}}
|
||||||
|
]}.
|
||||||
|
|
||||||
|
%% @doc Whether the Server supports MQTT Wildcard Subscriptions.
|
||||||
|
{mapping, "mqtt.wildcard_subscription", "emqx.mqtt_wildcard_subscription", [
|
||||||
|
{default, true},
|
||||||
|
{datatype, {enum, [true, false]}}
|
||||||
|
]}.
|
||||||
|
|
||||||
|
%% @doc Whether the Server supports MQTT Shared Subscriptions.
|
||||||
|
{mapping, "mqtt.shared_subscription", "emqx.mqtt_shared_subscription", [
|
||||||
|
{default, true},
|
||||||
|
{datatype, {enum, [true, false]}}
|
||||||
|
]}.
|
||||||
|
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
%% Listeners
|
%% Listeners
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
|
@ -1211,50 +1264,42 @@ end}.
|
||||||
|
|
||||||
%% @doc Max Packet Size Allowed, 64K by default.
|
%% @doc Max Packet Size Allowed, 64K by default.
|
||||||
{mapping, "zone.$name.max_packet_size", "emqx.zones", [
|
{mapping, "zone.$name.max_packet_size", "emqx.zones", [
|
||||||
{default, "64KB"},
|
|
||||||
{datatype, bytesize}
|
{datatype, bytesize}
|
||||||
]}.
|
]}.
|
||||||
|
|
||||||
%% @doc Set the Max ClientId Length Allowed.
|
%% @doc Set the Max ClientId Length Allowed.
|
||||||
{mapping, "zone.$name.max_clientid_len", "emqx.zones", [
|
{mapping, "zone.$name.max_clientid_len", "emqx.zones", [
|
||||||
{default, 65535},
|
|
||||||
{datatype, integer}
|
{datatype, integer}
|
||||||
]}.
|
]}.
|
||||||
|
|
||||||
%% @doc Set the Maximum topic levels.
|
%% @doc Set the Maximum topic levels.
|
||||||
{mapping, "zone.$name.max_topic_levels", "emqx.zones", [
|
{mapping, "zone.$name.max_topic_levels", "emqx.zones", [
|
||||||
{default, 0},
|
|
||||||
{datatype, integer}
|
{datatype, integer}
|
||||||
]}.
|
]}.
|
||||||
|
|
||||||
%% @doc Set the Maximum QoS allowed.
|
%% @doc Set the Maximum QoS allowed.
|
||||||
{mapping, "zone.$name.max_qos_allowed", "emqx.zones", [
|
{mapping, "zone.$name.max_qos_allowed", "emqx.zones", [
|
||||||
{default, 2},
|
|
||||||
{datatype, integer},
|
{datatype, integer},
|
||||||
{validators, ["range:0-2"]}
|
{validators, ["range:0-2"]}
|
||||||
]}.
|
]}.
|
||||||
|
|
||||||
%% @doc Set the Maximum topic alias.
|
%% @doc Set the Maximum topic alias.
|
||||||
{mapping, "zone.$name.max_topic_alias", "emqx.zones", [
|
{mapping, "zone.$name.max_topic_alias", "emqx.zones", [
|
||||||
{default, 0},
|
|
||||||
{datatype, integer}
|
{datatype, integer}
|
||||||
]}.
|
]}.
|
||||||
|
|
||||||
%% @doc Whether the server supports retained messages.
|
%% @doc Whether the server supports retained messages.
|
||||||
{mapping, "zone.$name.retain_available", "emqx.zones", [
|
{mapping, "zone.$name.retain_available", "emqx.zones", [
|
||||||
{default, true},
|
|
||||||
{datatype, {enum, [true, false]}}
|
{datatype, {enum, [true, false]}}
|
||||||
]}.
|
]}.
|
||||||
|
|
||||||
%% @doc Whether the Server supports Wildcard Subscriptions.
|
%% @doc Whether the Server supports Wildcard Subscriptions.
|
||||||
{mapping, "zone.$name.wildcard_subscription", "emqx.zones", [
|
{mapping, "zone.$name.wildcard_subscription", "emqx.zones", [
|
||||||
{default, true},
|
|
||||||
{datatype, {enum, [true, false]}}
|
{datatype, {enum, [true, false]}}
|
||||||
]}.
|
]}.
|
||||||
|
|
||||||
%% @doc Whether the Server supports Shared Subscriptions.
|
%% @doc Whether the Server supports Shared Subscriptions.
|
||||||
{mapping, "zone.$name.shared_subscription", "emqx.zones", [
|
{mapping, "zone.$name.shared_subscription", "emqx.zones", [
|
||||||
{default, true},
|
|
||||||
{datatype, {enum, [true, false]}}
|
{datatype, {enum, [true, false]}}
|
||||||
]}.
|
]}.
|
||||||
|
|
||||||
|
@ -1327,16 +1372,21 @@ end}.
|
||||||
]}.
|
]}.
|
||||||
|
|
||||||
{translation, "emqx.zones", fun(Conf) ->
|
{translation, "emqx.zones", fun(Conf) ->
|
||||||
|
Mapping = fun(retain_available, Val) ->
|
||||||
|
{mqtt_retain_available, Val};
|
||||||
|
(wildcard_subscription, Val) ->
|
||||||
|
{mqtt_wildcard_subscription, Val};
|
||||||
|
(shared_subscription, Val) ->
|
||||||
|
{mqtt_shared_subscription, Val};
|
||||||
|
(Opt, Val) -> {Opt, Val}
|
||||||
|
end,
|
||||||
maps:to_list(
|
maps:to_list(
|
||||||
lists:foldl(
|
lists:foldl(
|
||||||
fun({["zone", Name, Opt], Val}, Acc) ->
|
fun({["zone", Name, Opt], Val}, Zones) ->
|
||||||
ZName = list_to_atom(Name),
|
maps:update_with(list_to_atom(Name),
|
||||||
case maps:find(ZName, Acc) of
|
fun(Opts) ->
|
||||||
{ok, Opts} ->
|
[Mapping(list_to_atom(Opt), Val)|Opts]
|
||||||
maps:put(ZName, [{list_to_atom(Opt), Val} | Opts], Acc);
|
end, [], Zones)
|
||||||
error ->
|
|
||||||
maps:put(ZName, [{list_to_atom(Opt), Val}], Acc)
|
|
||||||
end
|
|
||||||
end, #{}, lists:usort(cuttlefish_variable:filter_by_prefix("zone.", Conf))))
|
end, #{}, lists:usort(cuttlefish_variable:filter_by_prefix("zone.", Conf))))
|
||||||
end}.
|
end}.
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue