#plugin #mosquitto #broker #mqtt #acl #header #write

mosquitto-plugin

使用 Rust 代码为 mosquitto 创建插件的简单方法

11 个版本 (稳定)

2.1.3 2023年3月28日
2.1.2 2022年11月4日
2.1.1 2022年10月11日
1.3.0 2022年8月22日
0.1.0 2020年12月3日

#908网络编程

Download history 70/week @ 2024-04-20 76/week @ 2024-04-27 21/week @ 2024-05-04 22/week @ 2024-05-11 84/week @ 2024-05-18 100/week @ 2024-05-25 25/week @ 2024-06-01 51/week @ 2024-06-08 48/week @ 2024-06-15 53/week @ 2024-06-22 14/week @ 2024-06-29 99/week @ 2024-07-13 20/week @ 2024-07-20 79/week @ 2024-07-27 104/week @ 2024-08-03

每月302 次下载

MIT 许可证

57KB
1K SLoC

CI

Mosquitto Plugin

为与 mosquitto 代理一起使用生成 ACL 和 PASSWORD 插件的简单方法。

需要系统上安装 mosquitto_plugin.h 和 mosquitto.h 文件,在 Linux 系统上通常通过 mosquitto-dev 软件包实现。未在 Windows 上测试。

要从 bindgen 调用中传递额外的(clang)参数到 clang 调用,设置 MOSQUITTO_PLUGIN_CLANG_EXTRA_ARGS,例如为 mosquitto 头文件设置特殊搜索路径:“-I ../mosquitto-2.0.4/include”。

此处未实现可选函数。

调试段错误

由于 mosquitto 以 C ABI 接口的形式调用插件,可能会出现段错误,因为 mosquitto 调用插件时的行为可能出乎意料。在调试模式下编译将启用大多数原始指针使用的断言,有助于调试此类情况。

否则,查看不安全的代码,那里是段错误发生的地方。这包括整个 mosquitto 代码库,但 mosquitto 现在已经得到了很好的测试。因此,从这段代码开始查找

支持

- ease of access to write own mosquitto plugins
- auth_opt_<key> value in the mosquitto_conf
- mutable access to the structure between calls
- ACL implementations
- username/password implementatations

示例用法

在 GitHub 仓库的 "examples/acl" 文件夹下有一个示例用法。

基本身份验证

简单的示例,仅允许密码/用户名组合,其中密码是反转的(由于这些凭证不会调用 ACL 调用,因此需要在 mosquitto 配置中进行配置)

它还仅允许在 mosquitto 配置中指定的 auth_opt_topic 主题上的消息

有关详细信息,请参阅提供的 examples/mosquitto-acl.conf。

开始构建和运行

cargo build --example basic-auth
mosquitto -c examples/basic-auth.conf

扩展身份验证

示例如何与使用 v5 AUTH 包的客户端协商身份验证。

开始构建和运行

cargo build --example extended-auth
mosquitto -c examples/extended-auth.conf

依赖项

~0–2.4MB
~38K SLoC