No description
- Rust 81.5%
- Python 16.4%
- Dockerfile 2.1%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
|
|
||
| src | ||
| .dockerignore | ||
| .gitignore | ||
| build.rs | ||
| Cargo.lock | ||
| Cargo.toml | ||
| config.json | ||
| docker-compose.yml | ||
| Dockerfile | ||
| LICENSE.txt | ||
| matrix-rs-rebuilder.service | ||
| README.md | ||
| rebuilder.py | ||
Matrix pinger rust
matrix-pinger rewritten in rust with limited functionality
How to run
- fill details to
config.json mkdir store- put password to
password.txt docker compose up
Rebuilding Mechanism
This project includes an automated rebuilding mechanism via the ?rebuild command. It allows authorized administrators to trigger a Git pull and rebuild the Docker container remotely from within Matrix.
Architectural Overview
-
Rust Bot (
src/main.rs):- Listens for the
?rebuildcommand. - Checks if the sender's Matrix ID is listed in the
"admins"list inconfig.json. - Connects to the host system via
host.docker.internalon the port specified by"rebuild_port"inconfig.json(default:52738). - Sends
"rebuild\r\n"and waits for a response. - If the response is
"rebuilding\r\n", it alerts the Matrix room that the bot is rebuilding and terminates. If"no-new-changes\r\n", it alerts that there are no updates and aborts.
- Listens for the
-
Host Rebuilder Script (
rebuilder.py):- Runs directly on the host system.
- Listens on
rebuild_bind_addressandrebuild_portfromconfig.json. - Validates that the connecting client's IP falls within one of the
rebuild_allowed_subnets(typically loopback and Docker subnet172.16.0.0/12) to prevent unauthorized network access. - Runs a
git pullin the repository root and compares the HEAD commit hash. - If changes are pulled:
- Replies
"rebuilding\r\n"to the bot. - Closes the connection to let the bot output its notification.
- Executes
docker compose downanddocker compose up --build -d.
- Replies
- If no changes are pulled, replies
"no-new-changes\r\n".
Host Service Installation
- Create a symlink to the systemd service file:
sudo ln -s /home/vita/matrix-pinger-rs/matrix-rs-rebuilder.service /etc/systemd/system/matrix-rs-rebuilder.service - Reload systemd configuration:
sudo systemctl daemon-reload - Enable and start the service:
sudo systemctl enable matrix-rs-rebuilder.service sudo systemctl start matrix-rs-rebuilder.service
Note: if you're running UFW, you also need
udo ufw allow in on docker0 to any port 52738 proto tcp comment matrix-rs-rebuilder
Security Considerations
- Authorization: Restrict
?rebuildto trusted accounts in theconfig.json's"admins"array. - Port Security: The script validates that TCP connections originate from the local loopback or Docker bridge network. We recommend using local firewalls (e.g.
ufw deny 52738/tcp) to block external traffic to the port.