Skip to content

Commit

Permalink
Merge pull request #3072 from emqx/dev/1.10.3
Browse files Browse the repository at this point in the history
Sync code from refs/heads/dev/1.10.3 to enterprise
  • Loading branch information
Kinplemelon authored Dec 2, 2024
2 parents 0354dd4 + c692359 commit dc135a2
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 8 deletions.
10 changes: 9 additions & 1 deletion src/components/FormItemLabel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@
<InfoTooltip v-if="desc" v-bind="$attrs">
<template #content>
<template v-if="!descMarked">{{ desc }}</template>
<MarkdownContent v-else :content="desc" in-tooltip />
<template v-else>
<el-scrollbar v-if="maxHeight" :max-height="maxHeight">
<MarkdownContent :content="desc" in-tooltip />
</el-scrollbar>
<MarkdownContent v-else :content="desc" in-tooltip />
</template>
</template>
</InfoTooltip>
</template>
Expand All @@ -24,5 +29,8 @@ defineProps({
type: Boolean,
default: false,
},
maxHeight: {
type: Number,
},
})
</script>
10 changes: 9 additions & 1 deletion src/components/ListenerDrawer/ListenerDrawer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,15 @@
<div>
<el-row :gutter="20">
<el-col :span="12">
<el-form-item :label="tl('mountPoint')">
<el-form-item>
<template #label>
<FormItemLabel
:label="tl('mountPoint')"
:desc="tl('mountPointDesc')"
:max-height="200"
desc-marked
/>
</template>
<el-input v-model="listenerRecord.mountpoint" />
</el-form-item>
</el-col>
Expand Down
42 changes: 42 additions & 0 deletions src/i18n/Gateway.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,48 @@ export default {
zh: '挂载点',
en: 'MountPoint',
},
mountPointDesc: {
zh: `为客户端在 \`SUBSCRIBE\` 和 \`UNSUBSCRIBE\` 请求、\`PUBLISH\` 消息以及 Will Message(如果在 \`CONNECT\` 数据包中提供)中使用的主题添加静态或模板前缀(例如 \`n1/\` 或 \`{'$'}{'{'}username{'}'}/\`)。<br />
从发布到相应订阅的消息的主题中移除此前缀。
支持的占位符包括:
- \`{'$'}{'{'}username{'}'}\`
- \`{'$'}{'{'}clientid{'}'}\`
- \`{'$'}{'{'}zone{'}'}\`
- \`{'$'}{'{'}client_attrs.NAME{'}'}\`
例如,使用 \`mountpoint="{'$'}{'{'}username{'}'}/"\` 时,客户端 \`u1\` 将出现以下情况:
- 客户端 SUBSCRIBE \`sensors/#\` -> 在代理中内部转换为 \`u1/sensors/#\`。
- 代理 PUBLISH \`u1/sensors/data\` -> 发送给客户端时变为 \`sensors/data\`。
前缀的挂载/卸载应用于:
- \`CONNECT\` 中的 Will
- \`PUBLISH\`
- \`SUBSCRIBE\`
- \`UNSUBSCRIBE\`
注意:挂载发生在**授权/ACL检查之后**。`,
en: `Adds a static or templated prefix (e.g., \`n1/\` or \`{'$'}{'{'}username{'}'}/\`) to topics used by clients in \`SUBSCRIBE\` and \`UNSUBSCRIBE\` requests, \`PUBLISH\` messages, and Will Message (if supplied in the \`CONNECT\` packet).<br />
Removes this prefix from topics of messages published to the respective subscriptions.
The supported placeholders are:
- \`{'$'}{'{'}username{'}'}\`
- \`{'$'}{'{'}clientid{'}'}\`
- \`{'$'}{'{'}zone{'}'}\`
- \`{'$'}{'{'}client_attrs.NAME{'}'}\`
For example, with \`mountpoint="{'$'}{'{'}username{'}'}/"\`, a client \`u1\` will have:
- Client SUBSCRIBE \`sensors/#\` -> \`u1/sensors/#\` internally in the broker.
- Broker PUBLISH \`u1/sensors/data\` -> \`sensors/data\` sent to the client.
The prefix mount/unmount is applied to:
- Will in \`CONNECT\`
- \`PUBLISH\`
- \`SUBSCRIBE\`
- \`UNSUBSCRIBE\`
Note: mounting occurs **after authorization/ACL checks**.`,
},
lType: {
zh: '类型',
en: 'Type',
Expand Down
6 changes: 3 additions & 3 deletions src/schemaText/schema-text-en.json
Original file line number Diff line number Diff line change
Expand Up @@ -1313,14 +1313,14 @@
},
"mqtt_client_attrs_init": {
"label": "Client Attributes",
"desc": "Set custom attributes on client connection and use them in authentication, authorization, and other functions."
"desc": "Specify how to initialize client attributes.<br />Each client attribute can be initialized as `client_attrs.{'{'}NAME{'}'}`,<br />where `{'{'}NAME{'}'}` is the name of the attribute specified in the config field `set_as_attr`.<br /><br />The initialized client attribute will be stored in the `client_attrs` property with the specified name,<br />and can be used as a variable to render a template for mountpoint, authentication and authorization requests.<br /><br />For example, use `${'{'}client_attrs.tns{'}'}` to render an HTTP POST body when `set_as_attr = tns`,<br />or render listener config `moutpoint = ${'{'}client_attrs.tns{'}'}/` for topic namespacing."
},
"client_attrs_init_set_as_attr": {
"label": "Attribute"
},
"client_attrs_init_expression": {
"label": "Attribute Expression",
"desc": "A single-line expression that dynamically extracts attribute values from existing client information can use the following fields:<br/><br/>- `clientid`: client ID<br/>- `username`: user name<br/>- `cn`: CN field of TLS certificate<br/>- `dn`: DN field of TLS certificate<br/>- `user_property.*`: extracts the property value from the `User-Property` of the MQTT CONNECT packet, e.g. `user_property.foo`<br/><br/>You can use predefined string functions to dynamically process the information. For example, to extract the prefix of a dot-separated client ID: `nth(1, tokens(clientid, '.'))`; to extract a partial username: `substr(username, 0, 5)`. You can read more about variform expressions in EMQX docs.<br/>"
"desc": "A one line expression to evaluate a set of predefined string functions (like in the rule engine SQL statements).<br />The expression can be a function call with nested calls as its arguments, or direct variable reference.<br />So far, it does not provide user-defined variable binding (like `var a=1`) or user-defined functions.<br />As an example, to extract the prefix of client ID delimited by a dot: `nth(1, tokens(clientid, '.'))`.<br /><br />The variables pre-bound variables are:<br />- `clientid`: MQTT Client ID.<br />- `username`: MQTT Client's username.<br />- `user_property.{'{'}NAME{'}'}`: User properties in the CONNECT packet.<br />For TLS clients, connected directly or via proxy-protocol (v2) enabled load balancer,<br />some extra variables can be used:<br />- `cn`: Client's TLS certificate common name.<br />- `dn`: Client's TLS certificate distinguished name (the subject).<br />- `peersni`: TLS server name indication sent by the client.<br /><br />You can read more about variform expressions in EMQX docs."
},
"mqtt_keepalive_check_interval": {
"label": "Keep Alive Check Interval",
Expand All @@ -1332,7 +1332,7 @@
},
"mqtt_clientid_override": {
"label": "Client ID Override Expression",
"desc": "A one line expression to evaluate a set of predefined string functions (like in the rule engine SQL statements).<br />The expression can be a function call with nested calls as its arguments, or direct variable reference.<br />So far, it does not provide user-defined variable binding (like `var a=1`) or user-defined functions.<br />As an example, to extract the prefix of client ID delimited by a dot: `nth(1, tokens(username, '.'))`.<br /><br />The variables pre-bound variables are:<br />- `cn`: Client's TLS certificate common name.<br />- `dn`: Client's TLS certificate distinguished name (the subject).<br />- `clientid`: The original MQTT Client ID.<br />- `username`: MQTT Client's username.<br />- `client_attrs.{'{'}NAME{'}'}`: Client attributes initialized by per config `client_attrs_init`.<br /><br />You can read more about variform expressions in EMQX docs."
"desc": "A one line expression to evaluate a set of predefined string functions (like in the rule engine SQL statements).<br />The expression can be a function call with nested calls as its arguments, or direct variable reference.<br />So far, it does not provide user-defined variable binding (like `var a=1`) or user-defined functions.<br />As an example, to extract the prefix of client ID delimited by a dot: `nth(1, tokens(username, '.'))`.<br /><br />The variables pre-bound variables are:<br />- `clientid`: The original MQTT Client ID.<br />- `username`: MQTT Client's username.<br />- `client_attrs.{'{'}NAME{'}'}`: Client attributes initialized by per config `client_attrs_init`.<br />For TLS clients, connected directly or via proxy-protocol (v2) enabled load balancer,<br />some extra variables can be used:<br />- `cn`: Client's TLS certificate common name.<br />- `dn`: Client's TLS certificate distinguished name (the subject).<br />- `peersni`: TLS server name indication sent by the client.<br /><br />You can read more about variform expressions in EMQX docs."
}
},
"ssl_opts": {
Expand Down
6 changes: 3 additions & 3 deletions src/schemaText/schema-text-zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -1309,14 +1309,14 @@
},
"mqtt_client_attrs_init": {
"label": "客户端属性",
"desc": "在客户端连接时设置自定义属性并将其用于认证、授权等功能中"
"desc": "指定如何初始化客户端属性。<br />每个客户端属性可以初始化为 `client_attrs.{'{'}NAME{'}'}`,<br />其中 `{'{'}NAME{'}'}` 是配置字段 `set_as_attr` 中指定的属性名称。<br /><br />初始化的客户端属性将存储在带有指定名称的 `client_attrs` 属性中,<br />并可用作渲染挂载点、身份验证和授权请求的模板变量。<br /><br />例如,当 `set_as_attr = tns` 时,使用 `${'{'}client_attrs.tns{'}'}` 渲染 HTTP POST 正文,<br />或渲染监听器配置 `moutpoint = ${'{'}client_attrs.tns{'}'}/` 用于主题命名空间"
},
"client_attrs_init_set_as_attr": {
"label": "属性"
},
"client_attrs_init_expression": {
"label": "属性表达式",
"desc": "一个行表达式,用于从客户端现有信息中动态提取属性值,可以使用以下字段:<br/><br/>- `clientid`:客户端 ID<br/>- `username`:用户名<br/>- `cn`:TLS 证书的 CN 字段<br/>- `dn`:TLS 证书的 DN 字段<br/>- `user_property.*`:从 MQTT CONNECT 数据包的 `User-Property` 中提取属性值,例如 `user_property.foo`<br/><br/>支持使用预定义的字符串函数对信息进行动态处理。例如,要提取由点分隔的客户端 ID 的前缀:`nth(1, tokens(clientid, '.'))`;要截取用户名部分信息:`substr(username, 0, 5)`。您可以在 EMQX 文档中了解有关 variform 表达式的更多信息。<br/>"
"desc": "使用行表达式计算一组预定义的字符串函数(类似于规则引擎 SQL 语句)。<br />表达式可以是带有嵌套调用参数的函数调用,或直接引用变量。<br />目前不提供用户自定义变量绑定(如 `var a=1`)或用户自定义函数。<br />例如,要提取以点分隔的客户端 ID 前缀:`nth(1, tokens(clientid, '.'))`。<br /><br />预绑定的变量有:<br />- `clientid`:MQTT 客户端 ID<br />- `username`:MQTT 客户端的用户名。<br />- `user_property.{'{'}NAME{'}'}`:CONNECT 数据包中的用户属性。<br />对于 TLS 客户端,直接连接或通过支持代理协议(v2)的负载均衡器连接,<br />可以使用一些额外的变量:<br />- `cn`:客户端 TLS 证书的通用名称。<br />- `dn`:客户端 TLS 证书的可分辨名称(主题)。<br />- `peersni`:客户端发送的 TLS 服务器名称指示。<br /><br />您可以在 EMQX 文档中阅读更多关于 variform 表达式的信息。"
},
"mqtt_keepalive_check_interval": {
"label": "保活检查间隔",
Expand All @@ -1328,7 +1328,7 @@
},
"mqtt_clientid_override": {
"label": "客户端 ID 重写表达式",
"desc": "单行表达式,用于计算一组预定义字符串函数(如规则引擎 SQL 语句)。<br />表达式可以是以嵌套调用为参数的函数调用,也可以是直接变量引用。<br />目前不支持用户自定义变量绑定(如 `var a=1`)或用户自定义函数。<br />示例:要提取以点号分隔的客户端 ID 的前缀,可使用:`nth(1, tokens(username, '.'))`。<br /><br />预绑定变量有<br />- `cn`: 客户端 TLS 证书的通用名称。<br />- `dn`: 客户端的 TLS 证书标识名称(主体)。<br />- `clientid`: 原始 MQTT 客户端 ID。<br />- `username`: MQTT 客户端的用户名。<br />- `client_attrs.{'{'}NAME{'}'}`: 通过配置 `client_attrs_init` 初始化的客户端属性。<br /><br />有关可变形式表达式的更多信息,请参阅 EMQX 文档。<br />"
"desc": "使用行表达式计算一组预定义的字符串函数(类似于规则引擎 SQL 语句)。<br />表达式可以是带有嵌套调用参数的函数调用,或直接引用变量。<br />目前不提供用户自定义变量绑定(如 `var a=1`)或用户自定义函数。<br />例如,要提取以点分隔的客户端 ID 前缀:`nth(1, tokens(username, '.'))`。<br /><br />预绑定的变量有:<br />- `clientid`:原始 MQTT 客户端 ID。<br />- `username`:MQTT 客户端的用户名。<br />- `client_attrs.{'{'}NAME{'}'}`:通过每个配置的 `client_attrs_init` 初始化的客户端属性。<br />对于 TLS 客户端,直接连接或通过支持代理协议(v2)的负载均衡器连接,<br />可以使用一些额外的变量:<br />- `cn`:客户端 TLS 证书的通用名称。<br />- `dn`:客户端 TLS 证书的可分辨名称(主题)。<br />- `peersni`:客户端发送的 TLS 服务器名称指示。<br /><br />您可以在 EMQX 文档中阅读更多关于 variform 表达式的信息。"
}
},
"ssl_opts": {
Expand Down

0 comments on commit dc135a2

Please sign in to comment.