No description
  • Rust 81.5%
  • Python 16.4%
  • Dockerfile 2.1%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Vít Pavlík 0f4eba263e
test commit
just a test to trigger automatic rebuild
2026-07-25 05:57:24 +02:00
src fix issues 2026-07-25 05:30:47 +02:00
.dockerignore add docker thingies 2025-12-28 12:25:25 +01:00
.gitignore implement ?seznam (vibe coded) 2026-07-12 14:22:59 +02:00
build.rs add ?version command (vibe coded) 2026-06-27 04:26:24 +02:00
Cargo.lock implement ?seznam (vibe coded) 2026-07-12 14:22:59 +02:00
Cargo.toml implement ?seznam (vibe coded) 2026-07-12 14:22:59 +02:00
config.json feat: ?rebuild command 2026-07-25 04:34:32 +02:00
docker-compose.yml fix issues 2026-07-25 05:30:47 +02:00
Dockerfile fix ?version 2026-07-12 15:04:47 +02:00
LICENSE.txt add license 2026-07-12 13:37:50 +02:00
matrix-rs-rebuilder.service fix issues 2026-07-25 05:30:47 +02:00
README.md fix issues 2026-07-25 05:30:47 +02:00
rebuilder.py test commit 2026-07-25 05:57:24 +02:00

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

  1. Rust Bot (src/main.rs):

    • Listens for the ?rebuild command.
    • Checks if the sender's Matrix ID is listed in the "admins" list in config.json.
    • Connects to the host system via host.docker.internal on the port specified by "rebuild_port" in config.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.
  2. Host Rebuilder Script (rebuilder.py):

    • Runs directly on the host system.
    • Listens on rebuild_bind_address and rebuild_port from config.json.
    • Validates that the connecting client's IP falls within one of the rebuild_allowed_subnets (typically loopback and Docker subnet 172.16.0.0/12) to prevent unauthorized network access.
    • Runs a git pull in 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 down and docker compose up --build -d.
    • If no changes are pulled, replies "no-new-changes\r\n".

Host Service Installation

  1. 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
    
  2. Reload systemd configuration:
    sudo systemctl daemon-reload
    
  3. 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 ?rebuild to trusted accounts in the config.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.