Linux to Android notification bridge.
Project description
GuGa Server — Technical Deep Dive
This document provides a comprehensive technical overview of the GuGa-Nexus backend. It is intended for developers, maintainers, or anyone looking to understand the inner workings of the system.
🏗️ System Architecture
GuGa is a distributed notification relay system. The architecture consists of three main local components interacting with a remote Android client:
- Core Server (
server.py): The central hub. It manages client sessions (browsers and Android apps), handles authentication (pairing), and provides a private REST/SocketIO interface for message ingestion. - OS Alerter (
os_notification_alerter.py): A passive listener that monitors the Linux D-Bus fororg.freedesktop.Notifications. When an OS notification is detected, it cleans the text and forwards it to the Core Server via a local POST request. - CLI Tool (
guga_push.py): An active pusher. It allows users or scripts to manually trigger notifications. It handles both simple messages and "command watching" (monitoring a subprocess and notifying on completion).
graph TD
A[OS Notifications] -->|D-Bus| B(OS Alerter)
C[User/Scripts] -->|CLI| D(guga CLI)
B -->|Local POST| E[Core Server]
D -->|Local POST| E
E -->|SocketIO / AES-GCM| F{Network}
F -->|Local/Cloudflare| G[Android App]
F -->|HTTPS| H[Web Dashboard]
📂 Project Structure (Technical)
| File / Directory | Purpose |
|---|---|
server.py |
Main application entry point. Handles Flask routes, SocketIO events, and device pairing logic. |
setup.py |
Environment initialization script. Detects package managers, installs system deps (dbus), and downloads cloudflared. |
os_notification_alerter.py |
Subprocess-based D-Bus monitor. Forwards desktop alerts to the server. |
guga_push.py |
The logic for the guga CLI tool. Uses only Python standard library where possible for maximum portability. |
trusted_devices.json |
Persistent store for paired device IDs, encryption tokens, and expiry timestamps. |
requirements.txt |
Python dependency list (Flask, SocketIO, Cryptography, python-dotenv). |
cloudflared |
(Generated) The Cloudflare Tunnel binary used for zero-config remote access. |
man/ |
Contains the manual pages for the guga tool. |
🔐 Security Implementation
End-to-End Encryption (AES-256-GCM)
Except for the initial pairing handshake, all data sent to Android apps is encrypted locally using AES-256-GCM.
- Key Generation: During pairing, a unique 256-bit hex token is generated via
secrets.token_hex(32). - Persistence: This token is stored on the server in
trusted_devices.jsonand on the phone in secure storage. - Payload: Each message includes a random 12-byte IV and the base64-encoded ciphertext.
Zero-Trust Handshake
Pairing follows a strict 8-digit PIN protocol:
- Device sends a
hellowith a unique ID. - Server generates a random 8-digit PIN and prints it to the physical terminal.
- User enters the PIN on the device.
- If the PIN matches, the server issues a long-lived hex token.
Network Isolation
- The
/sendroute (used by the Alerter and CLI) only accepts requests from127.0.0.1or::1. - This ensures that only local processes can "push" notifications to your phone.
📡 D-Bus Alerter Logic
The os_notification_alerter.py script spawns dbus-monitor as an asynchronous subprocess. It filters specifically for:
interface='org.freedesktop.Notifications', member='Notify'
It uses a state-machine parser to extract the App Name, Summary (Title), and Body from the multi-line D-Bus output. It also includes a clean_text utility to strip HTML tags and Markdown formatting that some Linux desktop environments include in notifications.
⚙️ Environment Configuration (.env)
The server and its adapters read configuration from server/.env.
| Key | Type | Default | Description |
|---|---|---|---|
PORT |
int |
6769 |
The port the Flask/SocketIO server listens on. |
MODE |
str |
public |
lan for local network only, or public to spawn a Cloudflare Tunnel. |
ENABLE_OS_NOTIFICATIONS |
bool |
False |
Whether server.py should automatically spawn the Alerter subprocess. |
ALERTER_SERVER_URL |
url |
http://localhost:6769/send |
The endpoint the Alerter targets. |
GUGA_VERBOSE |
bool |
false |
Enable detailed debug logging (encryption/decryption traces). |
🛠️ Development & Maintenance
🔍 Logging & Debugging
The server uses a structured event logging system. To see more detailed information, including raw SocketIO traffic and encryption/decryption traces, set the GUGA_VERBOSE environment variable:
GUGA_VERBOSE=true python server.py
Event Symbols
| Symbol | Meaning |
|---|---|
✓ |
Success (e.g., device paired) |
✗ |
Error / Failure (e.g., PIN rejected, decrypt failed) |
↑ |
Connected (New session established) |
↓ |
Disconnected (Session ended) |
→ |
Command (Received phrase to process) |
↩ |
Reconnected (Known device identified) |
⚠ |
Warning (e.g., token expired, tunnel fallback) |
Resetting All Trust
To revoke access for all devices, simply delete trusted_devices.json and restart the server.
Adding New Commands
The process_command function in server.py is the hook for adding remote execution capabilities. Currently, it acts as a placeholder for future feature expansion.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file guga-1.0.1.tar.gz.
File metadata
- Download URL: guga-1.0.1.tar.gz
- Upload date:
- Size: 52.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a1176ec20b0c7ade06df2ede8345e2f5dabbccf5df5fbcaaea9aab75dec51e67
|
|
| MD5 |
dfc0c84ec79d71c494bc0ef91146ad1b
|
|
| BLAKE2b-256 |
0513c3d4866d1fe640aa4e35bf320d9d1dda6204014395aa8036f7af575bdff1
|
File details
Details for the file guga-1.0.1-py3-none-any.whl.
File metadata
- Download URL: guga-1.0.1-py3-none-any.whl
- Upload date:
- Size: 52.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
29e308a6ab5bd3ba2028f9b843dc387e5975769f676c64113a233cedb0914867
|
|
| MD5 |
24ebc9701336cada0d88310bd3604039
|
|
| BLAKE2b-256 |
7ac74a4e1d763b513895a7e8e250e6d82bd3dba37c14bda352796e6815a50c00
|