This commit is contained in:
kerwincui
2024-03-17 14:59:23 +08:00
parent 3d44f4674c
commit 5539c1b6af
999 changed files with 115642 additions and 10757 deletions

View File

@@ -0,0 +1,32 @@
%%--------------------------------------------------------------------
%% -type(ipaddr() :: {ipaddr, string()}).
%%
%% -type(ipaddrs() :: {ipaddrs, string()}).
%%
%% -type(username() :: {user | username, string()} | {user | username, {re, regex()}}).
%%
%% -type(clientid() :: {client | clientid, string()} | {client | clientid, {re, regex()}}).
%%
%% -type(who() :: ipaddr() | ipaddrs() |username() | clientid() |
%% {'and', [ipaddr() | ipaddrs()| username() | clientid()]} |
%% {'or', [ipaddr() | ipaddrs()| username() | clientid()]} |
%% all).
%%
%% -type(action() :: subscribe | publish | all).
%%
%% -type(topic_filters() :: string()).
%%
%% -type(topics() :: [topic_filters() | {eq, topic_filters()}]).
%%
%% -type(permission() :: allow | deny).
%%
%% -type(rule() :: {permission(), who(), access(), topics()} | {permission(), all}).
%%--------------------------------------------------------------------
{allow, {username, {re, "^dashboard$"}}, subscribe, ["$SYS/#"]}.
{allow, {ipaddr, "127.0.0.1"}, all, ["$SYS/#", "#"]}.
{deny, all, subscribe, ["$SYS/#", {eq, "#"}]}.
{allow, all}.

View File

@@ -0,0 +1,92 @@
## NOTE:
## This config file overrides data/configs/cluster.hocon,
## and is merged with environment variables which start with 'EMQX_' prefix.
##
## Config changes made from EMQX dashboard UI, management HTTP API, or CLI
## are stored in data/configs/cluster.hocon.
## To avoid confusion, please do not store the same configs in both files.
##
## See https://docs.emqx.com/en/enterprise/v5.0/configuration/configuration.html
## Configuration full example can be found in emqx.conf.example
node {
name = "emqx@177.7.0.12"
cookie = "emqxsecretcookie"
data_dir = "data"
}
cluster {
name = emqxcl
discovery_strategy = manual
}
dashboard {
listeners.http {
bind = 18083
}
default_username = "admin"
default_password = "admin123"
}
authorization {
deny_action = ignore
no_match = allow
cache = { enable = true }
}
## http 认证
authentication = [
{
mechanism = password_based
backend = http
enable = true
method = post
url = "http://java:8080/iot/tool/mqtt/authv5"
body {
clientid = "${clientid}"
username = "${username}"
password = "${password}"
peerhost = "${peerhost}"
}
headers {
"Content-Type" = "application/json"
"X-Request-Source" = "EMQX"
}
}
]
# WebHook(匹配上线和下线规则后触发)
bridges {
webhook.fastbee_hook =
{
enable = true
connect_timeout = 15s
retry_interval = 60s
pool_type = random
pool_size = 8
enable_pipelining = 100
max_retries = 2
request_timeout = 15s
method = post
url = "http://java:8080/iot/tool/mqtt/webhookv5"
body = "{\"clientid\" : \"${clientid}\",\"event\" : \"${event}\",\"peername\" : \"${peername}\"}"
headers = { accept = "application/json" "cache-control" = "no-cache" connection = "keep-alive" "content-type" = "application/json" "keep-alive" = "timeout=5"}
}
}
# 规则(处理上线和下线)
rule_engine {
ignore_sys_message = true
jq_function_default_timeout = 10s
rules.fastbee_rule =
{
sql = "SELECT * FROM \"t/#\",\"$events/client_connected\", \"$events/client_disconnected\", \"$events/session_subscribed\""
actions = ["webhook:fastbee_hook"]
enable = true
description = "处理设备上下线和订阅完主题的规则"
}
}