Files
MediaServer/README.md
T
2026-05-10 18:22:19 +00:00

83 lines
3.0 KiB
Markdown

# GMMC Media Server
A high-performance, public media download server built with Rust and Axum. It is designed to serve extremely large files (100GB+) seamlessly and features a retro, Minecraft-themed web dashboard for easy access.
## Features
- **Blazing Fast & Lightweight**: Powered by Rust, Axum, and Tokio.
- **Large File Optimization**: Streams files using configurable chunk sizes (default 8MB) to handle massive files with low memory footprint.
- **Resume Support**: Full support for HTTP `Range` requests, allowing paused or interrupted downloads to be resumed.
- **Retro Dashboard**: A dynamic, Minecraft-style UI built with vanilla HTML/CSS and the VT323 font. Includes 1-click copy-to-clipboard commands for terminal downloading.
- **No Authentication Required**: Built for public, hassle-free access.
- **Security & Access Control**: Built-in security headers and optional IP whitelisting.
## Prerequisites
- [Rust & Cargo](https://rustup.rs/) (edition 2021)
- A `.env` file for server configuration
- A `media_config.json` file for file registry
## Configuration
### 1. Environment Variables (`.env`)
Create a `.env` file in the root directory:
```env
PORT=3000
HOST=0.0.0.0
# Request timeout in seconds (default 3600 for 1 hour)
REQUEST_TIMEOUT_SECS=3600
# Streaming chunk size in KB (default 8192 for 8MB)
CHUNK_SIZE_KB=8192
# Optional: comma-separated list of allowed IPs
# ALLOWED_IPS=127.0.0.1,192.168.1.100
# Optional: Domain for generating absolute download URLs
# DOMAIN=https://downloads.example.com
```
### 2. Media Registry (`media_config.json`)
Define the files you want to host. Create a `media_config.json` in the root directory:
```json
{
"files": {
"ubuntu-iso": {
"name": "Ubuntu 24.04 LTS",
"path": "/path/to/ubuntu-24.04-desktop-amd64.iso",
"description": "The latest LTS release of Ubuntu.",
"content_type": "application/x-iso9660-image"
},
"large-dataset": {
"name": "AI Training Dataset",
"path": "./data/dataset.tar.gz",
"description": "Huge 150GB dataset for machine learning models."
}
}
}
```
## Running the Server
1. Clone the repository and navigate to the project root.
2. Build and run the server:
```bash
cargo run --release
```
3. Open your browser and navigate to `http://localhost:3000` (or your configured `HOST` and `PORT`).
## Usage
- **Web Dashboard**: Visit the root URL to view available files, their sizes, and descriptions. Click "Download" or copy the provided cURL commands.
- **Direct Download (Browser)**: `http://localhost:3000/download/{file_id}`
- **cURL Download**:
```bash
curl -O http://localhost:3000/download/{file_id}
```
*(For resumable downloads via cURL, add `-C -`)*
## Tech Stack
- **[Rust](https://www.rust-lang.org/)**
- **[Axum](https://github.com/tokio-rs/axum)** (Web Framework)
- **[Tokio](https://tokio.rs/)** (Asynchronous Runtime)
- **[Tower](https://github.com/tower-rs/tower)** (Middleware & Networking)
- **[Serde](https://serde.rs/)** (Serialization/Deserialization)