How mmrmagno/rustguard works
Project Type and Purpose
• Type: A Command Line Interface (CLI) application.
• Purpose: To manage WireGuard VPN profiles (listing, connecting/disconnecting, editing configurations, and displaying logs), acting as a user-friendly front-end for interacting with WireGuard (wg-quick).
File Structure
• Top-Level Directories and Files:
• .github: Contains CI/CD workflows (e.g., release.yml).
• Cargo.toml & Cargo.lock: Standard Rust project configuration files.
• src/main.rs: Contains the application’s main logic.
Key Components
a. User Interface:
b. Business Logic / VPN Manager:
• Profile Manager: Lists available WireGuard VPN profiles.
• Connection Manager: Starts and stops VPN connections based on the user’s command.
• Status and Logging Module: Records and shows recent actions and VPN status logs.
• Configuration Editor: Enables editing of WireGuard configurations directly from within the app.
c. External Interaction:
• WireGuard Integration: Represents calls to system-level commands (e.g., using “wg-quick”) for managing VPN interfaces.
• Sudo/Privileges Management: Indicates that operations requiring elevated privileges are performed (this could be a note), though it mostly factors into the runtime environment rather than the code structure.
Relationships and Interactions
• The CLI Component interacts with the VPN Manager:
• Commands from the CLI (like Connect/Disconnect) are routed to the Connection Manager.
• Navigation commands update and display the list of available profiles.
• The VPN Manager communicates with External Services:
• It invokes system commands (wg-quick) to effect changes on the WireGuard VPN interfaces.
• It manages configuration file reads/writes during edits.
• The Status/Logging Module receives input from all operations and updates the user interface as necessary.
Architectural Patterns & Design Principles
• Separation of Concerns: Even though the code is inside a single main.rs, conceptually break out functionality into modules (even if not physically separated). This shows a clear demarcation between the CLI interface, business logic, and system commands.
• Modularity: Represent each logical component (CLI, Profile Manager, Connection Manager, Config Editor, Logging) as separate blocks.
• External Dependency Encapsulation: Clearly show that interactions with the OS (Invoking wg-quick) are isolated from in-app logic.