diff --git a/.github/workflows/build_slim_packages.yaml b/.github/workflows/build_slim_packages.yaml index 5614b774c..bcd88054a 100644 --- a/.github/workflows/build_slim_packages.yaml +++ b/.github/workflows/build_slim_packages.yaml @@ -218,7 +218,7 @@ jobs: - emqx - emqx-enterprise runs-on: ubuntu-20.04 - container: "ghcr.io/iequ1/emqx-schema-validate:0.3.0" + container: "ghcr.io/iequ1/emqx-schema-validate:0.3.1" steps: - uses: actions/download-artifact@v2 name: Download schema dump diff --git a/apps/emqx/etc/emqx.conf b/apps/emqx/etc/emqx.conf index 0962e4be3..8f54ae41f 100644 --- a/apps/emqx/etc/emqx.conf +++ b/apps/emqx/etc/emqx.conf @@ -897,7 +897,7 @@ conn_congestion { ## get "congested", because there's too many packets to sent. ## The socket tries to buffer the packets until the buffer is ## full. If more packets come after that, the packets will be - ## "pending" in a queue and we consider the connection is + ## "pending" in a queue, and we consider the connection is ## "congested". ## ## Enable this to send an alarm when there's any bytes pending in diff --git a/apps/emqx/src/emqx_schema.erl b/apps/emqx/src/emqx_schema.erl index b8bdded8a..a4a1c8598 100644 --- a/apps/emqx/src/emqx_schema.erl +++ b/apps/emqx/src/emqx_schema.erl @@ -123,12 +123,12 @@ roots(high) -> {"zones", sc( map("name", ref("zone")), - #{} + #{desc => ?DESC(zones)} )}, {"mqtt", sc( ref("mqtt"), - #{ desc => ?DESC(mqtt)} + #{desc => ?DESC(mqtt)} )}, {?EMQX_AUTHENTICATION_CONFIG_ROOT_NAME, authentication( @@ -1242,7 +1242,7 @@ fields("sys_topics") -> {"sys_event_messages", sc( ref("event_names"), - #{ desc => ?DESC(sys_event_messages) } + #{desc => ?DESC(sys_event_messages)} )} ]; fields("event_names") -> @@ -1708,7 +1708,7 @@ desc("conn_congestion") -> "get \"congested\", because there are too many packets to be sent.\n" "The socket tries to buffer the packets until the buffer is\n" "full. If more packets arrive after that, the packets will be\n" - "\"pending\" in the queue and we consider the connection\n" + "\"pending\" in the queue, and we consider the connection\n" "congested.\n\n" "Note: `sndbuf` can be set to larger value if the\n" "alarm is triggered too often.\n" diff --git a/apps/emqx/src/emqx_tls_lib.erl b/apps/emqx/src/emqx_tls_lib.erl index ffa13194f..9f0c80be2 100644 --- a/apps/emqx/src/emqx_tls_lib.erl +++ b/apps/emqx/src/emqx_tls_lib.erl @@ -322,7 +322,8 @@ delete_old_file(_New, Old) -> case is_generated_file(Old) andalso filelib:is_regular(Old) andalso file:delete(Old) of ok -> ok; - false -> %% the file is not generated by us, or it is already deleted + %% the file is not generated by us, or it is already deleted + false -> ok; {error, Reason} -> ?SLOG(error, #{msg => "failed_to_delete_ssl_file", file_path => Old, reason => Reason}) @@ -412,16 +413,21 @@ pem_dir(Dir) -> filename:join([emqx:mutable_certs_dir(), Dir]). is_hex_str(HexStr) -> - try is_hex_str2(ensure_str(HexStr)) - catch throw: not_hex -> false + try + is_hex_str2(ensure_str(HexStr)) + catch + throw:not_hex -> false end. is_hex_str2(HexStr) -> - _ = [case S of + _ = [ + case S of S when S >= $0, S =< $9 -> S; S when S >= $a, S =< $f -> S; _ -> throw(not_hex) - end || S <- HexStr], + end + || S <- HexStr + ], true. hex_str(Bin) -> @@ -457,8 +463,7 @@ do_drop_invalid_certs([Key | Keys], SSL) -> PemOrPath -> case is_pem(PemOrPath) orelse is_valid_pem_file(PemOrPath) of true -> do_drop_invalid_certs(Keys, SSL); - {error, _} -> - do_drop_invalid_certs(Keys, maps:without([Key], SSL)) + {error, _} -> do_drop_invalid_certs(Keys, maps:without([Key], SSL)) end end. diff --git a/apps/emqx_modules/i18n/emqx_modules_schema_i18n.conf b/apps/emqx_modules/i18n/emqx_modules_schema_i18n.conf index ce187b92f..248f85341 100644 --- a/apps/emqx_modules/i18n/emqx_modules_schema_i18n.conf +++ b/apps/emqx_modules/i18n/emqx_modules_schema_i18n.conf @@ -4,11 +4,11 @@ emqx_modules_schema { desc { en: """The topic rewriting function of EMQX supports rewriting topic A to topic B when the client subscribes to topics, publishes messages, and cancels subscriptions according to user-configured rules. Each rewrite rule consists of three parts: subject filter, regular expression, and target expression. -Under the premise that the subject rewriting function is enabled, when EMQX receives a subject-based MQTT message such as a PUBLISH message, +Under the premise that the subject rewriting function is enabled, when EMQX receives a subject-based MQTT message such as a `PUBLISH` message, it will use the subject of the message to sequentially match the subject filter part of the rule in the configuration file. If the match is successful, the regular expression is used to extract the information in the subject, and then replaced with the target expression to form a new subject. -Variables in the format of $N can be used in the target expression to match the elements extracted from the regular expression. -The value of $N is the Nth element extracted from the regular expression. For example, $1 is the regular expression. The first element extracted by the expression. +Variables in the format of `$N` can be used in the target expression to match the elements extracted from the regular expression. +The value of `$N` is the Nth element extracted from the regular expression. For example, `$1` is the regular expression. The first element extracted by the expression. It should be noted that EMQX uses reverse order to read the rewrite rules in the configuration file. When a topic can match the topic filter of multiple topic rewrite rules at the same time, EMQX will only use the first rule it matches. Rewrite. If the regular expression in this rule does not match the subject of the MQTT message, the rewriting will fail, and no other rules will be attempted for rewriting. @@ -17,7 +17,7 @@ Therefore, users need to carefully design MQTT message topics and topic rewritin 重写规则分为 Pub 规则和 Sub 规则,Pub 规则匹配 PUSHLISH 报文携带的主题,Sub 规则匹配 SUBSCRIBE、UNSUBSCRIBE 报文携带的主题。 每条重写规则都由主题过滤器、正则表达式、目标表达式三部分组成。 在主题重写功能开启的前提下,EMQX 在收到诸如 PUBLISH 报文等带有主题的 MQTT 报文时,将使用报文中的主题去依次匹配配置文件中规则的主题过滤器部分,一旦成功匹配,则使用正则表达式提取主题中的信息,然后替换至目标表达式以构成新的主题。 -目标表达式中可以使用 $N 这种格式的变量匹配正则表达中提取出来的元素,$N 的值为正则表达式中提取出来的第 N 个元素,比如 $1 即为正则表达式提取的第一个元素。 +目标表达式中可以使用 `$N` 这种格式的变量匹配正则表达中提取出来的元素,`$N` 的值为正则表达式中提取出来的第 N 个元素,比如 `$1` 即为正则表达式提取的第一个元素。 需要注意的是,EMQX 使用倒序读取配置文件中的重写规则,当一条主题可以同时匹配多条主题重写规则的主题过滤器时,EMQX 仅会使用它匹配到的第一条规则进行重写,如果该条规则中的正则表达式与 MQTT 报文主题不匹配,则重写失败,不会再尝试使用其他的规则进行重写。 因此用户在使用时需要谨慎的设计 MQTT 报文主题以及主题重写规则。""" } @@ -40,12 +40,15 @@ Therefore, users need to carefully design MQTT message topics and topic rewritin tr_action { desc { - en: """subscribe: Rewrite topic when client do subscribe. -publish: Rewrite topic when client do publish. -all: Both""" - zh: """subscribe:订阅时重写主题; -publish:发布时重写主题; -all:全部重写主题""" + en: """Topic rewriting takes effect on the type of operation: + - `subscribe`: Rewrite topic when client do subscribe. + - `publish`: Rewrite topic when client do publish. + - `all`: Both""" + + zh: """主题重写在哪种操作上生效: + - `subscribe`:订阅时重写主题; + - `publish`:发布时重写主题; + -`all`:全部重写主题""" } label { en: """Action""" diff --git a/apps/emqx_retainer/i18n/emqx_retainer_i18n.conf b/apps/emqx_retainer/i18n/emqx_retainer_i18n.conf index 4bcf68576..1808f3fe7 100644 --- a/apps/emqx_retainer/i18n/emqx_retainer_i18n.conf +++ b/apps/emqx_retainer/i18n/emqx_retainer_i18n.conf @@ -16,7 +16,7 @@ emqx_retainer_schema { flow_control { desc { - en: "flow control." + en: "Flow control." zh: "流控设置" } } diff --git a/scripts/spellcheck b/scripts/spellcheck index 869e6637b..8b5ba53bb 100755 --- a/scripts/spellcheck +++ b/scripts/spellcheck @@ -7,7 +7,7 @@ else SCHEMA="$1" fi -docker run -d --name langtool "ghcr.io/iequ1/emqx-schema-validate:0.2.1" +docker run -d --name langtool "ghcr.io/iequ1/emqx-schema-validate:0.3.1" docker exec -i langtool ./emqx_schema_validate - < "${SCHEMA}" success="$?"