netrunner_cli 0.2.6

A feature-rich Rust-based CLI to test and analyze your internet connection
Documentation
# Netrunner CLI ๐Ÿš€

A high-performance, cyberpunk-styled network diagnostics and speed testing tool built in Rust.

[![Crates.io](https://img.shields.io/crates/v/netrunner_cli)](https://crates.io/crates/netrunner_cli)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![Release](https://github.com/sorinirimies/netrunner_cli/actions/workflows/release.yml/badge.svg)](https://github.com/sorinirimies/netrunner_cli/actions/workflows/release.yml)

> **"JACK IN AND TRACE THE NET"** - Professional network diagnostics with cyberpunk aesthetics

![Netrunner CLI Demo](https://via.placeholder.com/800x400/0a0e27/00ff00?text=Netrunner+CLI)

## โœจ Features

### ๐ŸŽฏ Core Capabilities

- **๐Ÿš€ High-Speed Testing** - Optimized for gigabit+ connections (up to 10 Gbps)
  - 50 parallel connections for maximum throughput
  - Large 500MB chunk downloads to minimize overhead
  - 2-second warmup period for connection establishment
  - Progressive speed sampling with intelligent averaging
  
- **๐ŸŒ Smart Server Selection** - Dynamic geolocation-based discovery
  - Automatic detection of your location via IP geolocation
  - Fetches real servers from Speedtest.net API
  - Falls back to LibreSpeed and regional hubs
  - Calculates actual distances and sorts by proximity
  
- **๐Ÿ“Š Comprehensive Metrics**
  - Download/Upload speeds (Mbps)
  - Ping latency (ms)
  - Jitter measurement
  - Packet loss detection
  - Connection quality assessment (Excellent โ†’ Poor)
  
- **๐Ÿ“ˆ Historical Tracking**
  - Automatic 30-day test history retention
  - Powered by sled embedded database
  - View trends and statistics over time
  - Query past results with `--history` flag
  - Automatic cleanup of old records
  
- **๐Ÿ” Network Diagnostics**
  - Public IP detection
  - ISP information
  - DNS server analysis
  - Network interface details
  - Traceroute functionality
  - Connection quality scoring
  
- **๐ŸŽจ Stunning Visuals**
  - Animated intro with color-cycling borders
  - Cyberpunk-themed UI with neon colors
  - Smooth progress bars and gauges
  - Real-time speed updates during tests
  - Beautiful ASCII art logo

### ๐Ÿ’ป Technical Excellence

- **Zero-Copy Performance** - Optimized for minimal overhead
- **Async/Await** - Powered by Tokio for efficient I/O
- **Cross-Platform** - Works on Linux, macOS, and Windows
- **Embedded Database** - No external dependencies for history storage
- **Clean Architecture** - Well-structured, maintainable codebase
- **Comprehensive Tests** - 45+ unit and integration tests

## ๐Ÿ“ฅ Installation

### From Crates.io (Recommended)

```bash
cargo install netrunner_cli
```

### From Source

```bash
git clone https://github.com/sorinirimies/netrunner_cli.git
cd netrunner_cli
cargo install --path .
```

### Binary Releases

Download pre-built binaries from the [Releases](https://github.com/sorinirimies/netrunner_cli/releases) page.

## ๐Ÿš€ Quick Start

### Run with Animated Intro

```bash
netrunner_cli
```

Experience the full cyberpunk intro with animated borders and color-cycling effects!

### Run Speed Test

```bash
# Full speed test with automatic server selection
netrunner_cli speed

# Speed test with JSON output
netrunner_cli speed --json

# Speed test without animations (headless mode)
netrunner_cli speed --no-animation
```

### View Test History

```bash
# View last 30 days of test results
netrunner_cli --history

# Or use the shorthand
netrunner_cli -H
```

### Network Diagnostics

```bash
# Run full network diagnostics
netrunner_cli diag

# Get detailed diagnostics output
netrunner_cli diag --detail detailed
```

### Full Network Analysis

```bash
# Run both speed test and diagnostics
netrunner_cli full
```

## ๐Ÿ“‹ Command Reference

### Commands

```bash
netrunner_cli [OPTIONS] [COMMAND]
```

#### Available Commands

- `speed` - Run a comprehensive internet speed test
- `diag` - Run network diagnostics to analyze your connection
- `full` - Run both speed test and diagnostics
- `help` - Display help information

### Options

| Flag | Long Form | Description |
|------|-----------|-------------|
| `-H` | `--history` | View test history (last 30 days) |
| `-s <URL>` | `--server <URL>` | Custom test server URL |
| `-z <MB>` | `--size <MB>` | Test file size in MB (default: 100) |
| `-t <SEC>` | `--timeout <SEC>` | Timeout in seconds (default: 30) |
| `-j` | `--json` | Output results in JSON format |
| `-n` | `--no-animation` | Disable animations (headless mode) |
| `-d <LEVEL>` | `--detail <LEVEL>` | Detail level: basic, standard, detailed, debug |
| `-m <COUNT>` | `--max-servers <N>` | Maximum servers to test (default: 3) |
| `-h` | `--help` | Display help information |
| `-V` | `--version` | Display version information |

### Examples

```bash
# Run speed test with custom server
netrunner_cli speed --server https://speed.cloudflare.com

# Run diagnostics with debug output
netrunner_cli diag --detail debug

# Get JSON output for scripting
netrunner_cli speed --json > results.json

# Run headless mode (CI/CD)
netrunner_cli speed --no-animation --json

# Test against 5 servers
netrunner_cli speed --max-servers 5

# View your connection history
netrunner_cli --history
```

## ๐Ÿ“Š Understanding Your Results

### Connection Quality Ratings

Netrunner provides a comprehensive assessment based on multiple metrics:

| Quality | Download | Upload | Ping | Jitter | Packet Loss |
|---------|----------|--------|------|--------|-------------|
| โญโญโญโญโญ **Excellent** | โ‰ฅ100 Mbps | โ‰ฅ20 Mbps | <20 ms | <5 ms | <0.1% |
| โญโญโญโญ **Good** | โ‰ฅ50 Mbps | โ‰ฅ10 Mbps | <50 ms | <15 ms | <1% |
| โญโญโญ **Average** | โ‰ฅ25 Mbps | โ‰ฅ5 Mbps | <100 ms | <25 ms | <2.5% |
| โญโญ **Poor** | โ‰ฅ10 Mbps | โ‰ฅ2 Mbps | <150 ms | <40 ms | <5% |
| โญ **Very Poor** | <10 Mbps | <2 Mbps | โ‰ฅ150 ms | โ‰ฅ40 ms | โ‰ฅ5% |

### Metric Explanations

- **Download Speed**: How fast you can receive data (streaming, downloading)
- **Upload Speed**: How fast you can send data (video calls, cloud backups)
- **Ping (Latency)**: Time for data to reach the server and back (gaming, real-time apps)
- **Jitter**: Variation in ping times (video calls, online gaming stability)
- **Packet Loss**: Percentage of data packets that don't arrive (connection reliability)

## ๐Ÿ—๏ธ Architecture

### High-Speed Testing Strategy

Netrunner is optimized for modern high-speed connections:

1. **Parallel Connections**: Uses 50 simultaneous connections to maximize throughput
2. **Large Chunks**: Downloads 500MB chunks to minimize protocol overhead
3. **Warmup Period**: 2-second warmup establishes connections before measurement
4. **Progressive Sampling**: Continuously samples speed and averages for accuracy
5. **Smart Exclusion**: Excludes warmup period from final calculations

### Server Selection Algorithm

1. **Geolocation**: Detects your location via IP
2. **API Query**: Fetches nearby servers from Speedtest.net
3. **Distance Calculation**: Uses Haversine formula for accurate distance
4. **Sorting**: Orders servers by proximity
5. **Fallback**: Uses LibreSpeed and regional hubs if API fails
6. **Multi-Test**: Tests top N servers for best results

### History Storage

- **Database**: Embedded sled database (no external dependencies)
- **Retention**: Automatic 30-day retention with daily cleanup
- **Location**: `~/.netrunner_cli/history.db`
- **Format**: Efficient binary storage with MessagePack serialization
- **Queries**: Fast indexed lookups by timestamp

## ๐ŸŽจ Visual Features

### Animated Intro

Experience the cyberpunk aesthetic with:
- **Color-cycling borders** around the logo
- **Smooth fade-in effects**
- **6-color palette** (cyan, magenta, yellow, neon green)
- **Box drawing characters** for retro terminal vibes
- **60 FPS animation** for smooth visuals

### Progress Indicators

- **Real-time speed updates** during downloads/uploads
- **Animated progress bars** with percentage
- **Color-coded quality indicators**
- **Gauge widgets** for visual metric display

## ๐Ÿ”ง Configuration

### Environment Variables

```bash
# Set custom history database path
export NETRUNNER_HISTORY_PATH="~/custom/path/history.db"

# Disable colors (for CI/CD)
export NO_COLOR=1
```

### History Database

Location: `~/.netrunner_cli/history.db`

You can manually inspect or backup this database using sled tools.

## ๐Ÿงช Development

### Building from Source

```bash
# Clone the repository
git clone https://github.com/sorinirimies/netrunner_cli.git
cd netrunner_cli

# Build in debug mode
cargo build

# Build in release mode (optimized)
cargo build --release

# Run tests
cargo test

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

### Running Tests

```bash
# Run all tests
cargo test

# Run specific test module
cargo test speed_test

# Run with output
cargo test -- --nocapture

# Run integration tests
cargo test --test '*'
```

### Project Structure

```
netrunner_cli/
โ”œโ”€โ”€ src/
โ”‚   โ”œโ”€โ”€ main.rs              # CLI entry point
โ”‚   โ”œโ”€โ”€ lib.rs               # Library exports
โ”‚   โ””โ”€โ”€ modules/
โ”‚       โ”œโ”€โ”€ speed_test.rs    # Speed testing implementation
โ”‚       โ”œโ”€โ”€ history.rs       # History storage with sled
โ”‚       โ”œโ”€โ”€ diagnostics.rs   # Network diagnostics
โ”‚       โ”œโ”€โ”€ intro.rs         # Animated intro screen
โ”‚       โ”œโ”€โ”€ logo.rs          # ASCII logo rendering
โ”‚       โ”œโ”€โ”€ ui.rs            # UI components and gauges
โ”‚       โ””โ”€โ”€ types.rs         # Shared types and traits
โ”œโ”€โ”€ tests/                   # Integration tests
โ”œโ”€โ”€ examples/                # Example usage
โ””โ”€โ”€ Cargo.toml              # Project dependencies
```

## ๐Ÿค Contributing

Contributions are welcome! Here's how you can help:

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

### Development Guidelines

- Write tests for new features
- Follow Rust idioms and best practices
- Update documentation for API changes
- Run `cargo fmt` and `cargo clippy` before committing
- Ensure all tests pass with `cargo test`

## ๐Ÿ“„ License

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

## ๐Ÿ™ Acknowledgments

- **[Ratatui]https://github.com/ratatui-org/ratatui** - Terminal UI framework
- **[Tokio]https://tokio.rs/** - Async runtime
- **[Sled]https://github.com/spacejam/sled** - Embedded database
- **[Reqwest]https://github.com/seanmonstar/reqwest** - HTTP client
- **[Colored]https://github.com/mackwic/colored** - Terminal colors

## ๐Ÿ“œ Changelog

See [CHANGELOG.md](CHANGELOG.md) for detailed version history.

## ๐Ÿ› Bug Reports

Found a bug? Please [open an issue](https://github.com/sorinirimies/netrunner_cli/issues) with:
- Your OS and terminal emulator
- Steps to reproduce
- Expected vs actual behavior
- Relevant logs (run with `RUST_LOG=debug`)

## ๐Ÿ’ก Feature Requests

Have an idea? [Open an issue](https://github.com/sorinirimies/netrunner_cli/issues) with the `enhancement` label!

## ๐Ÿ“Š Project Stats

- **Language**: Rust ๐Ÿฆ€
- **Tests**: 45+ passing
- **Dependencies**: Carefully curated, security-focused
- **Performance**: Optimized for gigabit+ speeds
- **Maintenance**: Actively maintained

---

**Built with โค๏ธ and Rust by [Sorin Irimies](https://github.com/sorinirimies)**

*Jack in, trace the net, and measure your connection with style.* ๐Ÿš€