diff --git a/etc/emqx.conf b/etc/emqx.conf index dc039c199..f302af423 100644 --- a/etc/emqx.conf +++ b/etc/emqx.conf @@ -525,20 +525,20 @@ zone.external.idle_timeout = 15s ## Publish limit for the external MQTT connections. ## -## Value: rate,burst -## Default: 10 messages per second, and 100 messages burst. -## zone.external.publish_limit = 10,100 - -## Enable ban check. -## -## Value: Flag -zone.external.enable_ban = on +## Value: Number,Duration +## Example: 10 messages per minute. +zone.external.publish_limit = 10,1m ## Enable ACL check. ## ## Value: Flag zone.external.enable_acl = on +## Enable ban check. +## +## Value: Flag +zone.external.enable_ban = on + ## Enable per connection statistics. ## ## Value: on | off @@ -766,7 +766,7 @@ listener.tcp.external.zone = external ## ## Value: rate,burst ## Unit: Bps -## listener.tcp.external.rate_limit = 1024,4096 +listener.tcp.external.rate_limit = 1024,4096 ## The access control rules for the MQTT/TCP listener. ## diff --git a/priv/emqx.schema b/priv/emqx.schema index c5afd9b43..2aa0a35a1 100644 --- a/priv/emqx.schema +++ b/priv/emqx.schema @@ -676,14 +676,14 @@ end}. {datatype, {enum, [allow, deny]}} ]}. -%% @doc Enable Ban. -{mapping, "zone.$name.enable_ban", "emqx.zones", [ +%% @doc Enable ACL check. +{mapping, "zone.$name.enable_acl", "emqx.zones", [ {default, off}, {datatype, flag} ]}. -%% @doc Enable ACL check. -{mapping, "zone.$name.enable_acl", "emqx.zones", [ +%% @doc Enable Ban. +{mapping, "zone.$name.enable_ban", "emqx.zones", [ {default, off}, {datatype, flag} ]}. @@ -696,7 +696,6 @@ end}. %% @doc Publish limit of the MQTT connections. {mapping, "zone.$name.publish_limit", "emqx.zones", [ - {default, undefined}, {datatype, string} ]}. @@ -850,6 +849,15 @@ end}. {mqtt_wildcard_subscription, Val}; ("shared_subscription", Val) -> {mqtt_shared_subscription, Val}; + ("publish_limit", Val) -> + [Limit, Duration] = string:tokens(Val, ", "), + PubLimit = case cuttlefish_duration:parse(Duration, s) of + Secs when is_integer(Secs) -> + {list_to_integer(Limit) / Secs, list_to_integer(Limit)}; + {error, Reason} -> + error(Reason) + end, + {publish_limit, PubLimit}; ("force_gc_policy", Val) -> [Count, Bytes] = string:tokens(Val, "| "), GcPolicy = case cuttlefish_bytesize:parse(Bytes) of @@ -862,12 +870,12 @@ end}. ("force_shutdown_policy", Val) -> [Len, Siz] = string:tokens(Val, "| "), ShutdownPolicy = case cuttlefish_bytesize:parse(Siz) of - {error, Reason} -> - error(Reason); - Siz1 -> - #{message_queue_len => list_to_integer(Len), - total_heap_size => Siz1} - end, + {error, Reason} -> + error(Reason); + Siz1 -> + #{message_queue_len => list_to_integer(Len), + total_heap_size => Siz1} + end, {force_shutdown_policy, ShutdownPolicy}; (Opt, Val) -> {list_to_atom(Opt), Val}