Преглед изворни кода

Add mqtt.strict_mode configuration (#3069)

Add mqtt.strict_mode configuration
turtleDeng пре 6 година
родитељ
комит
a540958846
3 измењених фајлова са 29 додато и 10 уклоњено
  1. 15 0
      etc/emqx.conf
  2. 13 9
      priv/emqx.schema
  3. 1 1
      src/emqx_zone.erl

+ 15 - 0
etc/emqx.conf

@@ -542,6 +542,11 @@ mqtt.shared_subscription = true
 ## Value: true | false
 mqtt.ignore_loop_deliver = false
 
+## Whether to parse the MQTT frame in strict mode
+##
+## Value: true | false
+mqtt.strict_mode = false
+
 ##--------------------------------------------------------------------
 ## Zones
 ##--------------------------------------------------------------------
@@ -751,6 +756,11 @@ zone.external.use_username_as_clientid = false
 ## Value: true | false
 zone.external.ignore_loop_deliver = false
 
+## Whether to parse the MQTT frame in strict mode
+##
+## Value: true | false
+zone.external.strict_mode = false
+
 ##--------------------------------------------------------------------
 ## Internal Zone
 
@@ -832,6 +842,11 @@ zone.internal.use_username_as_clientid = false
 ## Value: true | false
 zone.internal.ignore_loop_deliver = false
 
+## Whether to parse the MQTT frame in strict mode
+##
+## Value: true | false
+zone.internal.strict_mode = false
+
 ##--------------------------------------------------------------------
 ## Listeners
 ##--------------------------------------------------------------------

+ 13 - 9
priv/emqx.schema

@@ -715,6 +715,12 @@ end}.
   {datatype, {enum, [true, false]}}
 ]}.
 
+%% @doc Whether to parse the MQTT frame in strict mode
+{mapping, "mqtt.strict_mode", "emqx.strict_mode", [
+  {default, false},
+  {datatype, {enum, [true, false]}}
+]}.
+
 %%--------------------------------------------------------------------
 %% Zones
 %%--------------------------------------------------------------------
@@ -931,14 +937,14 @@ end}.
   {datatype, {enum, [true, false]}}
 ]}.
 
+%% @doc Whether to parse the MQTT frame in strict mode
+{mapping, "zone.$name.strict_mode", "emqx.zones", [
+  {default, false},
+  {datatype, {enum, [true, false]}}
+]}.
+
 {translation, "emqx.zones", fun(Conf) ->
-  Mapping = fun("retain_available", Val) ->
-                    {retain_available, Val};
-               ("wildcard_subscription", Val) ->
-                    {wildcard_subscription, Val};
-               ("shared_subscription", Val) ->
-                    {shared_subscription, Val};
-               ("publish_limit", Val) ->
+  Mapping = fun("publish_limit", Val) ->
                     [L, D] = string:tokens(Val, ", "),
                     Limit = list_to_integer(L),
                     Duration = case cuttlefish_duration:parse(D, s) of
@@ -1000,8 +1006,6 @@ end}.
                                         end, #{}, string:tokens(Val, ",")),
                             {mqueue_priorities, MqueuePriorities}
                     end;
-               ("mountpoint", Val) ->
-                    {mountpoint, iolist_to_binary(Val)};
                (Opt, Val) ->
                     {list_to_atom(Opt), Val}
             end,

+ 1 - 1
src/emqx_zone.erl

@@ -141,7 +141,7 @@ mqtt_frame_options(Zone) ->
 
 -spec(mqtt_strict_mode(zone()) -> boolean()).
 mqtt_strict_mode(Zone) ->
-    get_env(Zone, mqtt_strict_mode, false).
+    get_env(Zone, strict_mode, false).
 
 -spec(max_packet_size(zone()) -> integer()).
 max_packet_size(Zone) ->