#client-server #server #client #notifications #http-interface #notify #named-pipe

bin+lib pass-it-on

A library that provides a simple notification client and server that receives messages and passes them on to endpoints

22 releases (13 breaking)

0.14.3 Mar 8, 2024
0.13.0 Feb 26, 2024
0.9.0 Oct 27, 2023
0.6.0 Jul 20, 2023

#69 in HTTP server

Download history 599/week @ 2024-02-16 225/week @ 2024-02-23 513/week @ 2024-03-01 302/week @ 2024-03-08 136/week @ 2024-03-15 1/week @ 2024-03-22 184/week @ 2024-03-29

648 downloads per month
Used in 2 crates

MIT license

125KB
2.5K SLoC

Pass-It-On

crates.io Released API docs MIT licensed Docker Image Size (tag)

A library that provides a simple notification client and server that receives messages and passes them on to endpoints.

Usage

This library was designed to enable the creation of processes that handle the business of when and what notification should be sent and then pass those notifications to the pass-it-on client which handles sending it across the configured interface to the pass-it-on server where the endpoints are configured. The idea is to allow a single instance of the server to handle messages from many clients which may or may not be going to the same endpoint.

Which notifications are go to a particular endpoint can be controlled by adding a notification name notifications field in the server configuration that matches the notification name that is used in the ClientReadyMessage by the client.

Key Features

  • A configurable server that monitors interfaces and passes notifications to endpoints.
  • A configurable client to use as part of a binary to send notifications to the server.
  • Traits to support extension of Interfaces and their inclusion in the configuration file.
    • Interface
    • InterfaceConfig
  • Traits to support extension of Endpoints and their inclusion in the configuration file.
    • Endpoint
    • EndpointConfig

Interfaces

Interfaces can be used for both the server and the client.

Interface Description
Http Communication between the client and server using the Http/Https protocol.
Pipe Communication between the client and server using a FIFO Named Pipe. (Unix Only)

Endpoints

Endpoints are the destinations for notifications received by the server.

Endpoint Description
Regular File Write notifications to a file.
Matrix Send notifications to Matrix room(s).
Discord Webhook Send notifications to Discord via a webhook.
Email Send notifications via SMTP email.

Configuration

The Server and Client support configuration via a TOML file. At least one interface must be setup for a Client and at least one interface and endpoint must be setup for the Server.

Server Configuration Example

[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'
session_store_password = "storepass123"

[[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 Configuration Example

[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

Feature Flags

Feature Description
client Enables the client but not any particular interface.
discord Enables the discord webhook endpoint.
email Enables the email endpoint.
endpoints Enables the Endpoint and EndpointConfig traits.
file Enables the regular file endpoint.
http Enables the Http interface client and server.
http-client Enables the Http interface for just the client.
http-server Enables the Http interface for just the server.
interfaces Enables the Interface and InterfaceConfig traits.
matrix Enables the matrix endpoint.
parse-cfg Enables parsing of client or server configurations from TOML when those features are also enabled.
pipe Enables the named pipe interface client and server. (Unix only)
pipe-client Enables the named pipe interface client. (Unix only)
pipe-server Enables the named pipe interface server. (Unix only)
server Enables the server but not any particular interface or endpoint.
server-bin-full Enables the building of the provided pass-it-on-server binary with all available interfaces and endpoints
server-bin-minimal Enables the building of the provided pass-it-on-server binary while not requiring any specific interface or endpoint
vendored-tls Enables vendored tls for reqwest.

Dependencies

~2–27MB
~443K SLoC