24 个版本 (14 个重大更改)
| 0.15.0 | 2024 年 5 月 18 日 | 
|---|---|
| 0.14.3 | 2024 年 3 月 8 日 | 
| 0.9.0 | 2023 年 10 月 27 日 | 
| 0.6.0 | 2023 年 7 月 20 日 | 
#65 in HTTP 服务器
2,378 每月下载次数
用于  2 crates
125KB
 2.5K  SLoC
Pass-It-On
一个库,提供简单的通知客户端和服务器,接收消息并将它们传递到端点。
用法
这个库旨在允许创建处理何时以及应发送什么通知的过程,然后将这些通知传递给 pass-it-on 客户端,该客户端负责通过配置的接口将通知发送到配置了端点的 pass-it-on 服务器。想法是允许单个服务器实例处理来自许多客户端的消息,这些客户端可能或可能不是发送到同一个端点。
哪些通知将发送到特定的端点可以通过在服务器配置中添加一个通知名称 notifications 字段来控制,该字段与客户端在 ClientReadyMessage 中使用的通知名称相匹配。
主要功能
- 一个可配置的服务器,监控接口并将通知传递到端点。
- 一个可配置的客户端,用作二进制文件的一部分,将通知发送到服务器。
- 特质以支持扩展接口并将其包含在配置文件中。- 接口
- 接口配置
 
- 特质以支持扩展端点并将其包含在配置文件中。- 端点
- 端点配置
 
接口
接口可以用于服务器和客户端。
| 接口 | 描述 | 
|---|---|
| Http | 客户端和服务器之间使用 Http/Https 协议进行通信。 | 
| Pipe | 客户端和服务器之间使用 FIFO 命名管道进行通信。(仅限 Unix) | 
端点
端点是服务器接收到的通知的目标。
| 端点 | 描述 | 
|---|---|
| 常规文件 | 将通知写入文件。 | 
| 矩阵 | 将通知发送到 Matrix 房间。 | 
| Discord Webhook | 通过 webhook 将通知发送到 Discord。 | 
| 电子邮件 | 通过SMTP电子邮件发送通知。 | 
配置
服务器和客户端支持通过TOML文件进行配置。客户端必须至少设置一个接口,服务器必须至少设置一个接口和一个端点。
服务器配置示例
[server]
key = "sdfsf4633ghf44dfhdfhQdhdfhewaasg"
[[server.interface]]
type = "pipe"
path = '/path/to/pipe.fifo'
group_read_permission = true
[[server.interface]]
type = "http"
host = "192.168.1.2"
port = 8080
[[server.endpoint]]
type = "matrix"
home_server = "example.com"
username = "test1"
password = "pass"
session_store_path = '/path/to/session/store/matrix_store'
recovery_passphrase = "recover123"
[[server.endpoint.room]]
room = "!dfsdfsdf:example.com"
notifications = ["notification_id1", "notification_id2"]
[[server.endpoint.room]]
room = "#matrix-room:example.com"
notifications = ["notification_id4"]
[[server.endpoint]]
type = "file"
path = '/test_data/file_endpoint.txt'
notifications = ["notification_id1", "notification_id3"]
[[server.endpoint]]
type = "discord"
url = "https://discord.com/api/webhooks/webhook_id/webhook_token"
notifications = ["notification_id1", "notification_id3"]
[server.endpoint.allowed_mentions]
parse = ["everyone"]
[[server.endpoint]]
type = "email"
hostname = "smtp.example.com"
port = 587
username = "test_user"
password = "test_password"
from = "asdf@example.com"
to = ["qwerty@example.com"]
subject = "test_email"
notifications = ["notification1", "notification2"]
客户端配置示例
[client]
key = "sdfsf4633ghf44dfhdfhQdhdfhewaasg"
[[client.interface]]
type = "pipe"
path = '/path/to/pipe.fifo'
group_read_permission = true
group_write_permission = true
[[client.interface]]
type = "http"
host = "192.168.1.2"
port = 8080
功能标志
| 功能 | 描述 | 
|---|---|
| client | 启用客户端,但不启用任何特定接口。 | 
| discord | 启用Discord webhook端点。 | 
| 启用电子邮件端点。 | |
| endpoints | 启用 Endpoint和EndpointConfig特性。 | 
| file | 启用常规文件端点。 | 
| http | 启用Http接口客户端和服务器。 | 
| http-client | 仅启用客户端的Http接口。 | 
| http-server | 仅启用服务器的Http接口。 | 
| interfaces | 启用接口和接口配置特性。 | 
| matrix | 启用matrix端点。 | 
| parse-cfg | 当这些功能也启用时,启用从TOML解析客户端或服务器配置。 | 
| pipe | 启用命名管道接口客户端和服务器。 (仅限Unix) | 
| pipe-client | 启用命名管道接口客户端。 (仅限Unix) | 
| pipe-server | 启用命名管道接口服务器。 (仅限Unix) | 
| server | 启用服务器,但不启用任何特定接口或端点。 | 
| server-bin-full | 启用构建提供 pass-it-on-server的二进制文件,包括所有可用接口和端点 | 
| server-bin-minimal | 启用构建提供的 pass-it-on-server二进制文件,而不需要任何特定接口或端点 | 
| vendored-tls | 启用reqwest的vendored tls。 | 
依赖项
~2-26MB
~447K SLoC