smirrors 0.1.0

Automatic mirror list updater for Linux distributions
Documentation
# SMirrors 🪞

<p align="center">
  <img src="https://img.shields.io/badge/rust-%23000000.svg?style=for-the-badge&logo=rust&logoColor=white" alt="Rust">
  <img src="https://img.shields.io/badge/Linux-FCC624?style=for-the-badge&logo=linux&logoColor=black" alt="Linux">
  <img src="https://img.shields.io/github/license/Aryagorjipour/smirrors?style=for-the-badge" alt="License">
  <img src="https://img.shields.io/github/v/release/Aryagorjipour/smirrors?style=for-the-badge" alt="Release">
</p>

**Automatic mirror list updater for Linux distributions** - Keep your package manager mirrors fast and up-to-date with zero effort.

SMirrors intelligently selects the fastest mirrors for your Linux distribution based on real-time download speed and latency tests. Run it once, or set it up as a background service to keep your mirrors optimized 24/7.

## ✨ Features

- 🚀 **Automatic Mirror Optimization** - Tests and ranks mirrors by speed and latency
- 🐧 **Multi-Distro Support** - APT, DNF, Pacman, Zypper and more
-**Flexible Scheduling** - Hourly auto-updates, custom intervals, or manual control
- 📌 **Static Mirror Pinning** - Preserve critical mirrors (Docker, custom repos)
- 🎨 **Beautiful TUI** - Interactive terminal interface for easy management
- 🔒 **Safe & Reliable** - Automatic backups, rollback on failure, validation
- 📊 **History Tracking** - Monitor performance over time
-**Fast & Efficient** - Parallel testing, minimal resource usage
- 🛡️ **Systemd Integration** - Run as a background service

## 📦 Installation

### From Binary Release

```bash
# Download latest release
curl -L https://github.com/Aryagorjipour/smirrors/releases/latest/download/smirrors-x86_64-linux.tar.gz | tar xz

# Install
sudo mv smirrors /usr/local/bin/
sudo chmod +x /usr/local/bin/smirrors
````

### From Source

```bash
# Clone repository
git clone https://github.com/Aryagorjipour/smirrors.git
cd smirrors

# Build and install
cargo build --release
sudo cp target/release/smirrors /usr/local/bin/
```

### Post-Installation

```bash
# Initialize configuration
smirrors init

# Enable systemd service (optional)
sudo smirrors enable
```

## 🚀 Quick Start

### Test mirrors without updating

```bash
smirrors test
```

### Update mirror list now

```bash
sudo smirrors update
```

### Launch interactive TUI

```bash
smirrors tui
```

### Enable automatic updates

```bash
sudo smirrors enable
```

## 📖 Usage

### Basic Commands

|Command|Description|
|---|---|
|`smirrors test`|Test mirrors and show results (no changes)|
|`smirrors update`|Update mirror list with fastest mirrors|
|`smirrors list`|Display current mirrors|
|`smirrors tui`|Launch interactive TUI|
|`smirrors status`|Show service status and last update|
|`smirrors history`|View update history|
|`smirrors rollback`|Restore previous mirror configuration|

### Static Mirror Management

```bash
# Add static mirror for Docker
smirrors add --repo docker https://download.docker.com/linux/ubuntu

# Remove a mirror
smirrors remove https://old-mirror.example.com

# List static mirrors
smirrors list --static
```

### Configuration

```bash
# Edit configuration
smirrors config

# Set update interval
smirrors config set interval 2h

# Enable/disable specific distro handlers
smirrors config set distro.apt.enabled true
```

### Service Management

```bash
# Enable automatic updates
sudo smirrors enable

# Disable automatic updates
sudo smirrors disable

# Check service status
smirrors status

# View logs
journalctl -u smirrors -f
```

## ⚙️ Configuration

Configuration file: `/etc/smirrors/config.toml` or `~/.config/smirrors/config.toml`

```toml
[general]
update_interval = "1h"          # Auto-update interval
auto_update = true              # Enable automatic updates
concurrent_tests = 10           # Parallel mirror tests
timeout = 10                    # Test timeout in seconds

[testing]
speed_weight = 0.7              # Weight for download speed (0-1)
latency_weight = 0.3            # Weight for latency (0-1)
test_file_size = "1MB"          # Size of test download
max_mirrors = 5                 # Number of mirrors to include

[distro.apt]
enabled = true
sources_file = "/etc/apt/sources.list"
backup_dir = "/var/backups/smirrors"

[static_mirrors]
# Pin Docker mirror
docker = "https://download.docker.com/linux/ubuntu"

[logging]
level = "info"                  # debug, info, warn, error
format = "human"                # human, json
file = "/var/log/smirrors.log"

[notifications]
enabled = false
on_failure = true
on_success = false
```

## 🎨 TUI Interface

The TUI provides an interactive interface for:

- **Dashboard** - Service status, last update, current mirrors
- **Test Results** - Real-time mirror testing with progress bars
- **History** - Past updates and performance trends
- **Configuration** - Edit settings visually
- **Static Mirrors** - Manage pinned repositories

**Keyboard Shortcuts:**

- `q` - Quit
- `t` - Run test
- `u` - Update mirrors
- `h` - Show history
- `c` - Open configuration
- `r` - Rollback
- `Tab` - Switch views
- `Enter` - Select/Confirm
- `Esc` - Cancel/Back

## 🐧 Supported Distributions

|Distribution|Package Manager|Status|Config Path|
|---|---|---|---|
|Debian/Ubuntu|APT|✅ Full Support|`/etc/apt/sources.list`|
|Fedora/RHEL|DNF|✅ Full Support|`/etc/yum.repos.d/`|
|Arch Linux|Pacman|✅ Full Support|`/etc/pacman.d/mirrorlist`|
|openSUSE|Zypper|✅ Full Support|`/etc/zypp/repos.d/`|
|Linux Mint|APT|✅ Full Support|`/etc/apt/sources.list`|
|Manjaro|Pacman|✅ Full Support|`/etc/pacman.d/mirrorlist`|

## 🛠️ Development

### Prerequisites

- Rust 1.75+ (2024 edition)
- Linux system for testing
- `sudo` access for integration tests

### Building

```bash
# Development build
cargo build

# Release build
cargo build --release

# Run tests
cargo test

# Run with logging
RUST_LOG=debug cargo run -- test
```

### Project Structure

- `src/core/` - Core mirror testing and update logic
- `src/distro/` - Distribution-specific handlers
- `src/tui/` - Terminal UI implementation
- `src/service/` - Background service/daemon
- `src/cli/` - Command-line interface
- `tests/` - Integration and unit tests

### Contributing

Contributions are welcome! Please read CONTRIBUTING.md for guidelines.

1. Fork the repository
2. Create a feature branch (`git checkout -b feature/amazing-feature`)
3. Commit your changes (`git commit -m 'Add amazing feature'`)
4. Push to the branch (`git push origin feature/amazing-feature`)
5. Open a Pull Request

## 🔒 Security

- All mirror list modifications require `sudo` privileges
- Automatic backups before any changes
- Validation of mirror URLs and repository signatures
- Rollback capability in case of issues
- Secure HTTPS for mirror testing

Report security vulnerabilities to arygorji.pour@gmail.com

## 📄 License

This project is licensed under the MIT License - see LICENSE file for details.

## 🙏 Acknowledgments

- Inspired by `reflector` (Arch), `apt-select` (Debian), and `dnf fastest-mirror`
- Built with amazing Rust crates: `tokio`, `clap`, `ratatui`, `reqwest`, `serde`
- Thanks to all Linux mirror maintainers worldwide

## 📞 Support

- 🐛 [Issue Tracker]https://github.com/Aryagorjipour/smirrors/issues

---

<p align="center">Made with ❤️ for the Linux community</p>