From 23378136cbe0aaf67fba25d00a827f69b60dcc39 Mon Sep 17 00:00:00 2001 From: Gustaw Lippa Date: Thu, 22 Aug 2024 14:51:54 +0200 Subject: [PATCH] Rename `c2s_state_timeout` option to `state_timeout` Now, `c2s` is not doubled in the name, so `listen.c2s.c2s_state_timeout` has become `listen.c2s.state_timeout`. Note that for websockets, I decided to keep the prefix, so its `listen.http.handlers.mod_websockets.c2s_state_timeout`. --- doc/listeners/listen-c2s.md | 4 ++-- doc/listeners/listen-http.md | 4 ++-- doc/migrations/6.0.0_6.1.0.md | 2 +- doc/migrations/6.2.1_x.x.x.md | 4 ++++ src/c2s/mongoose_c2s.erl | 4 ++-- src/config/mongoose_config_spec.erl | 4 ++-- src/mod_bosh_socket.erl | 2 +- src/mod_websockets.erl | 2 +- test/common/config_parser_helper.erl | 2 +- 9 files changed, 16 insertions(+), 12 deletions(-) diff --git a/doc/listeners/listen-c2s.md b/doc/listeners/listen-c2s.md index fbfa6a21216..9467a87aea8 100644 --- a/doc/listeners/listen-c2s.md +++ b/doc/listeners/listen-c2s.md @@ -30,10 +30,10 @@ The value of the access rule needs to be either the shaper name or the string `" Maximum number of open connections. This is a *soft limit* according to the [Ranch](https://ninenines.eu/docs/en/ranch/2.1/manual/ranch) documentation. -### `listen.c2s.c2s_state_timeout` +### `listen.c2s.state_timeout` * **Syntax:** non-negative integer or the string `"infinity"` * **Default:** `5000` -* **Example:** `c2s_state_timeout = 10_000` +* **Example:** `state_timeout = 10_000` Timeout value (in milliseconds) used by the C2S state machine when waiting for the connecting client to respond during stream negotiation and SASL authentication. After the timeout the server responds with the `connection-timeout` stream error and closes the connection. diff --git a/doc/listeners/listen-http.md b/doc/listeners/listen-http.md index 96eb5a643ba..754b4b772dc 100644 --- a/doc/listeners/listen-http.md +++ b/doc/listeners/listen-http.md @@ -83,11 +83,11 @@ Maximum allowed incoming stanza size in bytes. ### `listen.http.handlers.mod_websockets.c2s_state_timeout` -Same as the [C2S option](listen-c2s.md#listenc2sc2s_state_timeout) +Same as the [C2S option](listen-c2s.md#listenc2sstate_timeout). ### `listen.http.handlers.mod_websockets.backwards_compatible_session` -Same as the [C2S option](listen-c2s.md#listenc2sbackwards_compatible_session) +Same as the [C2S option](listen-c2s.md#listenc2sbackwards_compatible_session). ## Handler types: GraphQL API - `mongoose_graphql_handler` diff --git a/doc/migrations/6.0.0_6.1.0.md b/doc/migrations/6.0.0_6.1.0.md index 9cf186e7aea..8723af2017f 100644 --- a/doc/migrations/6.0.0_6.1.0.md +++ b/doc/migrations/6.0.0_6.1.0.md @@ -6,7 +6,7 @@ With the new implementation of the client-to-server (C2S) state machine, `mongoo * Support for [`listen.http.handlers.mod_websockets.service`] has been removed, the component connection over WebSockets did not correspond to any XEP/RFC, and neither it was properly described anywhere in the MIM documentation. It was present in the default configuration file, and **you need to delete it** from your listener configuration unless you have already done so. * The `max_fsm_queue` option is no longer supported for C2S listeners. It is incompatible with the new `gen_statem` state machine, and if you need to limit incoming traffic, you should use [traffic shapers](../../configuration/shaper) instead. You need to remove this option from your C2S configuration if you are using it. * The default value of the [`backlog`](../configuration/listen.md#listenbacklog) option for all XMPP listeners has been increased from 100 to 1024 for performance reasons. -* You might be interested in the new C2S listener options: [`max_connections`](../listeners/listen-c2s.md#listenc2smax_connections), [`c2s_state_timeout`](../listeners/listen-c2s.md#listenc2sc2s_state_timeout), [`reuse_port`](../listeners/listen-c2s.md#listenc2sreuse_port) and [`backwards_compatible_session`](../listeners/listen-c2s.md#listenc2sbackwards_compatible_session). The first two options can be set for [websockets](../listeners/listen-http.md#handler-types-websockets-mod_websockets) as well. +* You might be interested in the new C2S listener options: [`max_connections`](../listeners/listen-c2s.md#listenc2smax_connections), [`c2s_state_timeout`](../listeners/listen-c2s.md#listenc2sstate_timeout), [`reuse_port`](../listeners/listen-c2s.md#listenc2sreuse_port) and [`backwards_compatible_session`](../listeners/listen-c2s.md#listenc2sbackwards_compatible_session). The first two options can be set for [websockets](../listeners/listen-http.md#handler-types-websockets-mod_websockets) as well. ## Module configuration diff --git a/doc/migrations/6.2.1_x.x.x.md b/doc/migrations/6.2.1_x.x.x.md index ef6676d49cb..2d838a94a27 100644 --- a/doc/migrations/6.2.1_x.x.x.md +++ b/doc/migrations/6.2.1_x.x.x.md @@ -2,3 +2,7 @@ Hook names have been unified by removing the `_hook` prefix from the few hooks which used it, e.g. `offline_message_hook` is now called `offline_message`. This change affects the hook metric names as well. + +## Listener configuration + +`listen.c2s.c2s_state_timeout` option has been renamed to [listen.c2s.state_timeout](../listeners/listen-c2s.md#listenc2sstate_timeout). diff --git a/src/c2s/mongoose_c2s.erl b/src/c2s/mongoose_c2s.erl index 1ba13d25da7..afc8fc76833 100644 --- a/src/c2s/mongoose_c2s.erl +++ b/src/c2s/mongoose_c2s.erl @@ -62,7 +62,7 @@ -type listener_opts() :: #{shaper := atom(), max_stanza_size := non_neg_integer(), backwards_compatible_session := boolean(), - c2s_state_timeout := non_neg_integer(), + state_timeout := non_neg_integer(), port := inet:port_number(), ip_tuple := inet:ip_address(), proto := tcp, @@ -1027,7 +1027,7 @@ send_xml(#c2s_data{socket = Socket}, XmlElements) when is_list(XmlElements) -> state_timeout(#c2s_data{listener_opts = LOpts}) -> state_timeout(LOpts); -state_timeout(#{c2s_state_timeout := Timeout}) -> +state_timeout(#{state_timeout := Timeout}) -> {state_timeout, Timeout, state_timeout_termination}. -spec replace_resource(data(), binary()) -> data(). diff --git a/src/config/mongoose_config_spec.erl b/src/config/mongoose_config_spec.erl index 24e2132dee9..19bff223378 100644 --- a/src/config/mongoose_config_spec.erl +++ b/src/config/mongoose_config_spec.erl @@ -301,7 +301,7 @@ xmpp_listener_extra(<<"c2s">>) -> validate = non_empty}, <<"max_connections">> => #option{type = int_or_infinity, validate = positive}, - <<"c2s_state_timeout">> => #option{type = int_or_infinity, + <<"state_timeout">> => #option{type = int_or_infinity, validate = non_negative}, <<"reuse_port">> => #option{type = boolean}, <<"backwards_compatible_session">> => #option{type = boolean}, @@ -313,7 +313,7 @@ xmpp_listener_extra(<<"c2s">>) -> defaults = #{<<"access">> => all, <<"shaper">> => none, <<"max_connections">> => infinity, - <<"c2s_state_timeout">> => 5000, + <<"state_timeout">> => 5000, <<"reuse_port">> => false, <<"backwards_compatible_session">> => true} }; diff --git a/src/mod_bosh_socket.erl b/src/mod_bosh_socket.erl index f7bbef6140b..7fead719fc9 100644 --- a/src/mod_bosh_socket.erl +++ b/src/mod_bosh_socket.erl @@ -202,7 +202,7 @@ init([{HostType, Sid, Peer, PeerCert, ListenerOpts}]) -> xml_socket => true, max_stanza_size => 0, hibernate_after => 0, - c2s_state_timeout => 5000, + state_timeout => 5000, backwards_compatible_session => true, proto => tcp}, {ok, C2SPid} = mongoose_c2s:start({?MODULE, BoshSocket, C2SOpts}, []), diff --git a/src/mod_websockets.erl b/src/mod_websockets.erl index 419659b9e30..77fe41e606d 100644 --- a/src/mod_websockets.erl +++ b/src/mod_websockets.erl @@ -211,7 +211,7 @@ maybe_start_fsm([#xmlel{ name = <<"open">> }], max_stanza_size => 0, xml_socket => true, hibernate_after => 0, - c2s_state_timeout => StateTimeout, + state_timeout => StateTimeout, backwards_compatible_session => BackwardsCompatible, port => Port, ip_tuple => IPTuple, proto => tcp}, do_start_fsm(Opts, State); diff --git a/test/common/config_parser_helper.erl b/test/common/config_parser_helper.erl index a3ba384f6d8..01af9ad6eca 100644 --- a/test/common/config_parser_helper.erl +++ b/test/common/config_parser_helper.erl @@ -1128,7 +1128,7 @@ default_config([listen, http, tls]) -> default_config([listen, c2s]) -> (common_xmpp_listener_config())#{module => mongoose_c2s_listener, max_connections => infinity, - c2s_state_timeout => 5000, + state_timeout => 5000, reuse_port => false, backwards_compatible_session => true, access => all,