Merge pull request #11184 from sstrigler/EMQX-10270-e-5-1-0-missing-value-range-validation-for-the-max-packet-size-of-mqtt-settings
fix: limit mqtt max_packet_size to 256MB
This commit is contained in:
commit
9bcabe0a9e
|
@ -30,6 +30,7 @@
|
||||||
-include_lib("hocon/include/hoconsc.hrl").
|
-include_lib("hocon/include/hoconsc.hrl").
|
||||||
-include_lib("logger.hrl").
|
-include_lib("logger.hrl").
|
||||||
|
|
||||||
|
-define(MAX_INT_MQTT_PACKET_SIZE, 268435456).
|
||||||
-define(MAX_INT_TIMEOUT_MS, 4294967295).
|
-define(MAX_INT_TIMEOUT_MS, 4294967295).
|
||||||
%% floor(?MAX_INT_TIMEOUT_MS / 1000).
|
%% floor(?MAX_INT_TIMEOUT_MS / 1000).
|
||||||
-define(MAX_INT_TIMEOUT_S, 4294967).
|
-define(MAX_INT_TIMEOUT_S, 4294967).
|
||||||
|
@ -45,6 +46,7 @@
|
||||||
-type timeout_duration_s() :: 0..?MAX_INT_TIMEOUT_S.
|
-type timeout_duration_s() :: 0..?MAX_INT_TIMEOUT_S.
|
||||||
-type timeout_duration_ms() :: 0..?MAX_INT_TIMEOUT_MS.
|
-type timeout_duration_ms() :: 0..?MAX_INT_TIMEOUT_MS.
|
||||||
-type bytesize() :: integer().
|
-type bytesize() :: integer().
|
||||||
|
-type mqtt_max_packet_size() :: 1..?MAX_INT_MQTT_PACKET_SIZE.
|
||||||
-type wordsize() :: bytesize().
|
-type wordsize() :: bytesize().
|
||||||
-type percent() :: float().
|
-type percent() :: float().
|
||||||
-type file() :: string().
|
-type file() :: string().
|
||||||
|
@ -71,6 +73,7 @@
|
||||||
-typerefl_from_string({timeout_duration_s/0, emqx_schema, to_timeout_duration_s}).
|
-typerefl_from_string({timeout_duration_s/0, emqx_schema, to_timeout_duration_s}).
|
||||||
-typerefl_from_string({timeout_duration_ms/0, emqx_schema, to_timeout_duration_ms}).
|
-typerefl_from_string({timeout_duration_ms/0, emqx_schema, to_timeout_duration_ms}).
|
||||||
-typerefl_from_string({bytesize/0, emqx_schema, to_bytesize}).
|
-typerefl_from_string({bytesize/0, emqx_schema, to_bytesize}).
|
||||||
|
-typerefl_from_string({mqtt_max_packet_size/0, emqx_schema, to_bytesize}).
|
||||||
-typerefl_from_string({wordsize/0, emqx_schema, to_wordsize}).
|
-typerefl_from_string({wordsize/0, emqx_schema, to_wordsize}).
|
||||||
-typerefl_from_string({percent/0, emqx_schema, to_percent}).
|
-typerefl_from_string({percent/0, emqx_schema, to_percent}).
|
||||||
-typerefl_from_string({comma_separated_list/0, emqx_schema, to_comma_separated_list}).
|
-typerefl_from_string({comma_separated_list/0, emqx_schema, to_comma_separated_list}).
|
||||||
|
@ -151,6 +154,7 @@
|
||||||
timeout_duration_s/0,
|
timeout_duration_s/0,
|
||||||
timeout_duration_ms/0,
|
timeout_duration_ms/0,
|
||||||
bytesize/0,
|
bytesize/0,
|
||||||
|
mqtt_max_packet_size/0,
|
||||||
wordsize/0,
|
wordsize/0,
|
||||||
percent/0,
|
percent/0,
|
||||||
file/0,
|
file/0,
|
||||||
|
@ -3357,7 +3361,7 @@ mqtt_general() ->
|
||||||
)},
|
)},
|
||||||
{"max_packet_size",
|
{"max_packet_size",
|
||||||
sc(
|
sc(
|
||||||
bytesize(),
|
mqtt_max_packet_size(),
|
||||||
#{
|
#{
|
||||||
default => <<"1MB">>,
|
default => <<"1MB">>,
|
||||||
desc => ?DESC(mqtt_max_packet_size)
|
desc => ?DESC(mqtt_max_packet_size)
|
||||||
|
|
|
@ -852,6 +852,8 @@ typename_to_spec("timeout()", _Mod) ->
|
||||||
};
|
};
|
||||||
typename_to_spec("bytesize()", _Mod) ->
|
typename_to_spec("bytesize()", _Mod) ->
|
||||||
#{type => string, example => <<"32MB">>};
|
#{type => string, example => <<"32MB">>};
|
||||||
|
typename_to_spec("mqtt_max_packet_size()", _Mod) ->
|
||||||
|
#{type => string, example => <<"32MB">>};
|
||||||
typename_to_spec("wordsize()", _Mod) ->
|
typename_to_spec("wordsize()", _Mod) ->
|
||||||
#{type => string, example => <<"1024KB">>};
|
#{type => string, example => <<"1024KB">>};
|
||||||
typename_to_spec("map()", _Mod) ->
|
typename_to_spec("map()", _Mod) ->
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
Config value for `max_packet_size` has a max value of 256MB defined by protocol. This is now enforced and any configuration with a value greater than that will break.
|
Loading…
Reference in New Issue