rush-sync-server

Crates.iorush-sync-server
lib.rsrush-sync-server
version0.3.6
created_at2025-07-27 11:35:02.564278+00
updated_at2025-09-06 08:45:02.305876+00
descriptionModern asynchronous TUI application with i18n and modular command system
homepage
repositoryhttps://github.com/LEVOGNE/rush.sync.server
max_upload_size
id1769944
size1,079,740
LEVOGNE (LEVOGNE)

documentation

README

Rush Sync Server

Rust Build License Crates.io

NOTE: Version 0.2.2 on crates.io has a critical bug in language file loading (*.json not embedded correctly). Please use version 0.3.6+ for a stable release!

Rush Sync Server is a professional web server orchestration platform written in Rust. It combines a robust Terminal UI (TUI) with internationalization, theming, a modular command system, production HTTPS/TLS, reverse proxy, WebSocket-based hot reload, and a live dashboard.

NEW in v0.3.6: Anti-Flicker color mapping for display labels, hardened terminal lifecycle (TerminalManager + safe restart flow), unified widget/input system with viewported rendering and blinking cursor, multi-terminal cursor coloring (Apple Terminal/iTerm/tmux), minimal dashboard CSS reset, viewport safety guards, and extended logging/i18n.


Project Vision

Rush Sync Server development phases:

  • Phase 0 βœ…: Terminal UI foundation with command system
  • Phase 1 βœ… COMPLETE: Production-ready server orchestration with enterprise features
  • Phase 2: Advanced automation & centralized management dashboard
  • Phase 3: Redis clustering & distributed communication
  • Phase 4: AI-powered monitoring & predictive scaling

What's New in v0.3.6

πŸ– Anti-Flicker Display Colors

A pre-compiled DISPLAY β†’ Color mapping eliminates per-frame lookups and flicker when rendering label texts (e.g., ERROR, DEBUG, THEME, VERSION). Includes helpers like available_display_texts() and ANSI-aware color conversion for the renderer.

πŸ–₯ Terminal Stability & Safe Restart

A new TerminalManager coordinates raw-mode setup/cleanup with emergency destructors. restart now performs a full-screen re-init (terminal, input state, message area) after a confirm prompt, with --force bypass support.

⌨️ Unified Widget/Input System

InputState implements Widget, CursorWidget, StatefulWidget, and AnimatedWidget. Text input renders through a viewport (no overflow), with a blinking cursor and selection-safe drawing logic. Widgets are easier to compose/test and reuse across app screens.

🎯 Cursor Styling & Cross-Terminal Coloring

Cursor shapes: PIPE, BLOCK, UNDERSCORE. Optional RGB cursor color across terminals (Apple Terminal, iTerm, tmux) with graceful fallbacks if true-color is not supported.

🧰 System Commands w/ Confirmation

Centralized internal command processor adds __CLEAR__, __EXIT__, __RESTART__, __CLEAR_HISTORY__ with structured confirm prompts (incl. cleanup actions). Exposed user commands: clear, restart [-f|--force].

πŸ—Ί Viewport Safety & Render Guards

Safer layout math and bounds checks to avoid rendering outside terminal area; improved messaging for tiny terminals; emergency fallback render for extreme cases.

πŸ–Ό Dashboard UX & Minimal CSS Reset

The aggressive global reset was replaced by a minimal reset; dashboard styles were tuned for consistency and resilience. A graceful server-shutdown page was added. Monitoring can be paused/resumed; real logs integrate more cleanly.

πŸ“ Logging & i18n Extensions

The server logger uses rotation configuration derived from LoggingConfig. Numerous i18n strings were added for screen/theme/viewport/restart diagnostics and user feedback.


πŸš€ Production-Ready Server Infrastructure (recap from v0.3.5)

Version 0.3.5 introduced the complete production platform:

  • πŸ” Enterprise HTTPS/TLS β€” Automatic certificate generation with RSA‑2048 and wildcard/SAN support
  • 🌍 Reverse Proxy System β€” nginx‑style proxy with SSL termination on port 8443
  • ⚑ Hot Reload Development β€” Real-time file watching with WebSocket-based browser refresh
  • πŸ›‘οΈ Advanced Security Suite β€” Intrusion detection, rate limiting, and audit logging
  • πŸ“Š Live Dashboard Interface β€” Professional web UI with metrics, logs, TLS management
  • πŸ”„ Intelligent Performance β€” Optimized middleware pipeline for faster request handling

πŸ” Advanced HTTPS/TLS System

Automatic Certificate Management:

  • Self-Signed Certificates β€” RSA‑2048 encryption with 365‑day validity
  • Wildcard Support β€” *.localhost certificates for seamless subdomain routing
  • Subject Alternative Names β€” Multi-domain support (localhost, 127.0.0.1, custom domains)
  • Auto-Generation β€” Certificates created on-demand per server
  • Secure Key Storage β€” 0600 permissions on private keys with organized directories

Certificate Structure:

.rss/certs/myserver-8080.cert    # Server-specific certificate
.rss/certs/myserver-8080.key     # Private key (0600)
.rss/certs/proxy-8443.cert       # Proxy wildcard certificate
.rss/certs/proxy-8443.key        # Proxy private key

Sample Details:

Common Name: myserver.localhost
Subject Alt Names: localhost, 127.0.0.1, myserver.localhost
Key Type: RSA-2048
Validity: 365 days
Organization: Rush Sync Server

🌍 Professional Reverse Proxy

Enterprise-Grade Features:

  • SSL Termination β€” HTTPS proxy on :8443 with automatic certificates
  • Dynamic Routing β€” Subdomain routing (e.g., api.localhost β†’ 127.0.0.1:8080)
  • Load Balancing β€” Round-robin across multiple instances
  • Health Checks β€” Upstream monitoring with failover
  • Request Rewriting β€” Header injection and path manipulation

Proxy Usage Example:

# Start servers
create api 8080
create admin 8081

# Access via proxy (automatic HTTPS)
https://api.localhost:8443      # β†’ 127.0.0.1:8080
https://admin.localhost:8443    # β†’ 127.0.0.1:8081

# Optional hosts entries for clarity
127.0.0.1 api.localhost
127.0.0.1 admin.localhost

⚑ Hot Reload Development System

Real-Time Development:

  • File Watching β€” HTML, CSS, JS, JSON, SVG, images
  • WebSocket Integration β€” Instant browser refresh
  • Intelligent Filtering β€” Ignores temp/hidden files
  • Debounced Reloading β€” Prevents duplicate refreshes
  • Dev Notifications β€” Visual change feedback

Injection & Endpoint:

<script src="/rss.js"></script>
<link rel="stylesheet" href="/.rss/global-reset.css" />
ws://127.0.0.1:8080/ws/hot-reload

Event Example:

{
  "event_type": "modified",
  "file_path": "www/myserver-[8080]/index.html",
  "server_name": "myserver",
  "port": 8080,
  "timestamp": 1703875457,
  "file_extension": "html"
}

πŸ“Š Professional Dashboard Interface

Comprehensive Management UI:

  • Live Overview β€” Status, metrics, performance
  • Interactive API Testing β€” Inline request/response
  • Live Log Viewer β€” Streaming with filters
  • TLS Manager β€” Certificate status and renewal info
  • Hot Reload Monitor β€” WebSocket status & file changes
  • Performance Metrics β€” Response times, error rates, traffic

Endpoints:

http://127.0.0.1:8080/.rss/         # Main dashboard
http://127.0.0.1:8080/api/status    # Server status API
http://127.0.0.1:8080/api/metrics   # Performance metrics
http://127.0.0.1:8080/api/logs/raw  # Live log stream
http://127.0.0.1:8080/ws/hot-reload # WebSocket hot reload

πŸ›‘οΈ Enterprise Security Suite

Monitoring & Protections:

  • Intrusion Detection β€” Detects traversal, XSS, SSRF patterns
  • Request Size Limits β€” Prevent simple DoS via large bodies
  • Suspicious Pattern Detection β€” Header/path analysis
  • Security Audit Logging β€” Detailed, structured logs
  • Rate Limiting β€” Per-IP throttling with thresholds

Security Event Format:

{
  "event_type": "SecurityAlert",
  "ip_address": "192.168.1.100",
  "alert_reason": "Path Traversal Attempt",
  "alert_details": "Path contains '../' sequence: /../../etc/passwd",
  "timestamp": "2025-01-20 14:30:25.123",
  "headers": {
    "user-agent": "Mozilla/5.0...",
    "referer": "http://malicious-site.com"
  }
}

🎯 Performance Optimizations

  • Optimized Middleware β€” Reduced overhead
  • Efficient Memory β€” Buffer reuse and allocation trims
  • Concurrency β€” Tuned worker pool
  • Intelligent Caching β€” Static asset cache headers
  • DB Connection Pooling β€” Efficient registry access

πŸš€ Installation & Usage

πŸ“¦ As Binary β€” Version 0.3.6+

# Install from crates.io
cargo install rush-sync-server

# Run with full production features
rush-sync

πŸ“š As Library β€” Version 0.3.6+

Add to your Cargo.toml:

[dependencies]
rush-sync-server = "0.3.6"
tokio = { version = "1.36", features = ["full"] }

Quick Start Examples:

use rush_sync_server::*;

#[tokio::main]
async fn main() -> Result<()> {
    // Run with full production features (HTTPS, Proxy, Hot Reload)
    run().await?;
    Ok(())
}
use rush_sync_server::*;

#[tokio::main]
async fn main() -> Result<()> {
    // Custom configuration with enhanced security
    let mut config = load_config().await?;
    config.server.enable_https = true;
    config.proxy.enabled = true;
    config.logging.log_security_alerts = true;

    run_with_config(config).await?;
    Ok(())
}

🌟 Enterprise Features (v0.3.6)

The configuration surface remains consistent with v0.3.5. The sections below summarize the production-related knobs and the new terminal/UI aspects of v0.3.6.

πŸ” HTTPS/TLS Configuration

# rush.toml
[server]
enable_https = true
auto_cert = true
cert_dir = ".rss/certs"
cert_validity_days = 365
https_port_offset = 1000

[proxy]
enabled = true
port = 8443
ssl_termination = true
health_check_interval = 30

🌍 Reverse Proxy System

[proxy]
enabled = true
port = 8443
max_connections = 1000
timeout_seconds = 30
buffer_size_kb = 64
worker_threads = 4

[proxy.health_check]
enabled = true
interval_seconds = 30
timeout_seconds = 5
unhealthy_threshold = 3
healthy_threshold = 2

Dynamic Routing Examples:

# Create multiple servers
create api 8080
create admin 8081
create docs 8082

# Access via proxy (automatic HTTPS + routing)
https://api.localhost:8443    β†’ 127.0.0.1:8080
https://admin.localhost:8443  β†’ 127.0.0.1:8081
https://docs.localhost:8443   β†’ 127.0.0.1:8082

⚑ Hot Reload Development

[development]
hot_reload = true
watch_extensions = ["html", "css", "js", "json", "svg", "png", "jpg", "ico"]
ignore_patterns = ["*.tmp", "*.swp", ".*", "*~"]
debounce_ms = 250
auto_refresh_browser = true

[development.notifications]
enabled = true
duration_ms = 3000
position = "top-right"

πŸ“Š Advanced Logging System

[logging]
max_file_size_mb = 100          # Log rotation size
max_archive_files = 9           # Number of compressed archives
compress_archives = true        # GZIP compressed archives
log_requests = true
log_security_alerts = true
log_performance = true
log_format = "json"

Log Entry Structure:

{
  "timestamp": "2025-01-20 14:30:25.123",
  "timestamp_unix": 1705757425,
  "event_type": "Request",
  "ip_address": "127.0.0.1",
  "user_agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7)...",
  "method": "GET",
  "path": "/api/status",
  "status_code": 200,
  "response_time_ms": 15,
  "bytes_sent": 1024,
  "referer": "https://myserver.localhost:8443/",
  "headers": {
    "accept": "application/json",
    "host": "myserver.localhost:8443",
    "x-forwarded-for": "127.0.0.1",
    "x-forwarded-proto": "https"
  },
  "session_id": "sess_abc123",
  "tls_version": "TLSv1.3",
  "cipher_suite": "TLS_AES_256_GCM_SHA384"
}

πŸ’» Enhanced Server Management Commands

🌍 Production Server Commands

Command Description Examples
create Create server with HTTPS/TLS create, create api, create docs 8090
list Show servers with TLS status list
start Start with proxy registration start 1, start api, start abc123
stop Stop with proxy cleanup stop 1, stop api, stop abc123
cleanup Remove servers and certificates cleanup, cleanup failed, cleanup all

πŸ” TLS Management Commands

Command Description Examples
cert list Show all certificates cert list
cert info Certificate details cert info myserver
cert renew Regenerate certificate cert renew myserver
cert cleanup Remove expired certificates cert cleanup

🌍 Proxy Management Commands

Command Description Examples
proxy status Show proxy status proxy status
proxy routes List all proxy routes proxy routes
proxy start Start proxy server proxy start
proxy stop Stop proxy server proxy stop
proxy reload Reload proxy configuration proxy reload

⚑ Development Commands

Command Description Examples
dev mode on Enable development mode dev mode on
dev mode off Disable development mode dev mode off
dev watch Show file watching status dev watch
dev reload Trigger manual reload dev reload myserver

🧰 New System Commands (v0.3.6)

Command Description Examples
restart Restart the application restart, restart -f
clear Clear the screen clear, cls

πŸ“Š Advanced Server Examples

πŸš€ Production Server Deployment

# Create production API server with HTTPS
create api 8080
# Result: Server created: 'api' (ID: abc12345) on Port 8080
# HTTPS: https://api.localhost:8443 (via proxy)
# HTTP: http://127.0.0.1:8080 (direct)
# Certificate: .rss/certs/api-8080.cert
# Hot Reload: WebSocket on ws://127.0.0.1:8080/ws/hot-reload

# Enhanced server list with production details
list
# Result:
# Server List (Production Mode - Max: 10 concurrent):
#   1. api - abc12345 (Port: 8080) [Running] πŸ”’ HTTPS
#      URLs: https://api.localhost:8443 | http://127.0.0.1:8080
#      Certificate: Valid (362 days remaining)
#      Hot Reload: Active | Proxy: Registered
#      Log: .rss/servers/api-[8080].log (23.4MB, 2 archives)
#      Requests: 5,847 | Errors: 12 | Security Alerts: 0
#      Avg Response: 18ms | Uptime: 4h 32m
#
#   2. admin - def67890 (Port: 8081) [Running] πŸ”’ HTTPS
#      URLs: https://admin.localhost:8443 | http://127.0.0.1:8081
#      Certificate: Valid (364 days remaining)
#      Hot Reload: Active | Proxy: Registered

πŸ“Š Advanced Monitoring & Statistics

curl https://api.localhost:8443/api/metrics
{
  "server_info": {
    "id": "abc12345",
    "name": "api",
    "port": 8080,
    "status": "running",
    "uptime_seconds": 16320,
    "version": "0.3.6"
  },
  "security": {
    "tls_enabled": true,
    "certificate_valid": true,
    "certificate_expires": "2025-12-31T23:59:59Z",
    "security_alerts_24h": 0,
    "blocked_ips": []
  },
  "performance": {
    "total_requests": 5847,
    "requests_per_second": 1.2,
    "avg_response_time_ms": 18,
    "max_response_time_ms": 245,
    "error_rate_percent": 0.21
  },
  "proxy": {
    "registered": true,
    "health_check_status": "healthy",
    "last_health_check": "2025-01-20T14:29:55Z",
    "proxy_requests": 4203,
    "direct_requests": 1644
  },
  "hot_reload": {
    "enabled": true,
    "websocket_connections": 2,
    "file_changes_24h": 47,
    "last_reload": "2025-01-20T13:15:32Z"
  },
  "logging": {
    "log_file_size_mb": 23.4,
    "archive_count": 2,
    "log_entries_24h": 5847,
    "security_events_24h": 0,
    "error_events_24h": 12
  }
}

πŸ” TLS Certificate Management

# View all certificates
cert list
# Result:
# TLS Certificate List:
#   api-8080.cert
#     Common Name: api.localhost
#     Valid Until: 2025-12-31 (362 days)
#     Key Type: RSA-2048
#     File Size: 1.2KB
#
#   proxy-8443.cert
#     Common Name: *.localhost (Wildcard)
#     Valid Until: 2025-12-31 (364 days)
#     Key Type: RSA-2048
#     File Size: 1.3KB

# Detailed certificate information
cert info api
# Result:
# Certificate Details: api-8080.cert
# ====================================
# Subject: CN=api.localhost, O=Rush Sync Server
# Issuer: CN=api.localhost, O=Rush Sync Server (Self-Signed)
# Valid From: 2025-01-20 00:00:00 UTC
# Valid Until: 2025-12-31 23:59:59 UTC (362 days remaining)
# Serial Number: 1a:2b:3c:4d:5e:6f
# Key Algorithm: RSA-2048
# Signature Algorithm: SHA256-RSA
# Subject Alt Names:
#   - DNS: localhost
#   - DNS: api.localhost
#   - IP: 127.0.0.1
# Certificate File: .rss/certs/api-8080.cert (1,247 bytes)
# Private Key File: .rss/certs/api-8080.key (1,679 bytes, 0600)

βš™οΈ Production Configuration

πŸ“ File Structure

.rss/
β”œβ”€β”€ rush.toml                    # Main configuration
β”œβ”€β”€ rush.history                 # Command history
β”œβ”€β”€ rush.logs                    # Application logs
β”œβ”€β”€ servers.list                 # Server registry
β”œβ”€β”€ certs/                       # TLS certificates
β”‚   β”œβ”€β”€ api-8080.cert
β”‚   β”œβ”€β”€ api-8080.key             # Private keys (0600)
β”‚   β”œβ”€β”€ proxy-8443.cert
β”‚   └── proxy-8443.key
β”œβ”€β”€ servers/                     # Individual server logs
β”‚   β”œβ”€β”€ api-[8080].log           # Current log file
β”‚   β”œβ”€β”€ api-[8080].1.log.gz      # Compressed archive
β”‚   └── api-[8080].2.log.gz      # Older archives
└── proxy/                       # Proxy configuration
    β”œβ”€β”€ routes.json              # Dynamic routing table
    β”œβ”€β”€ health_checks.json       # Health check results
    └── access.log               # Proxy access logs

πŸ›  Complete Configuration (v0.3.6)

[general]
max_messages = 1000
typewriter_delay = 5
input_max_length = 100
max_history = 30
poll_rate = 16
log_level = "info"
current_theme = "dark"

[language]
current = "en"

# Server Configuration
[server]
port_range_start = 8080
port_range_end = 8180
max_concurrent = 10
shutdown_timeout = 5
startup_delay_ms = 500
workers = 1

# HTTPS/TLS Configuration
enable_https = true
auto_cert = true
cert_dir = ".rss/certs"
cert_validity_days = 365
https_port_offset = 1000

# Reverse Proxy Configuration
[proxy]
enabled = true
port = 8443
max_connections = 1000
timeout_seconds = 30
buffer_size_kb = 64
worker_threads = 4
ssl_termination = true

[proxy.health_check]
enabled = true
interval_seconds = 30
timeout_seconds = 5
unhealthy_threshold = 3
healthy_threshold = 2

# Advanced Logging
[logging]
max_file_size_mb = 100
max_archive_files = 9
compress_archives = true
log_requests = true
log_security_alerts = true
log_performance = true
log_format = "json"

# Development
[development]
hot_reload = true
watch_extensions = ["html", "css", "js", "json", "svg", "png", "jpg", "ico"]
ignore_patterns = ["*.tmp", "*.swp", ".*", "*~"]
debounce_ms = 250
auto_refresh_browser = true

[development.notifications]
enabled = true
duration_ms = 3000
position = "top-right"

# Security
[security]
max_request_size_mb = 10
rate_limit_requests_per_minute = 60
enable_intrusion_detection = true
log_security_events = true
block_suspicious_ips = false

# Theme
[theme.dark]
output_bg = "Black"
output_text = "White"
output_cursor = "PIPE"
output_cursor_color = "White"
input_bg = "White"
input_text = "Black"
input_cursor_prefix = "/// "
input_cursor = "PIPE"
input_cursor_color = "Black"

πŸ§ͺ Quality Assurance & Testing

πŸ“ˆ Performance Benchmarks (v0.3.5 baseline)

Server Creation: ~300ms (40% faster than v0.3.3)
TLS Certificate Generation: ~150ms per certificate
Proxy Route Registration: ~50ms per server
Hot Reload WebSocket Setup: ~25ms

Concurrent Users: 1000+ users per server
Request Throughput: 5000+ requests/second
Memory Usage: <50MB per server instance
CPU Usage: <5% under normal load

HTTPS Handshake: ~15ms average
Certificate Validation: ~2ms average
SSL Termination Overhead: <5% vs HTTP

(v0.3.6 does not change these baseline numbers; focus was stability, UI/UX, and DX.)

πŸ›‘οΈ Testing Suite

# Core functionality tests
cargo test server_lifecycle_with_tls
cargo test proxy_routing_and_ssl
cargo test hot_reload_websocket
cargo test security_monitoring
cargo test certificate_management

# Load and stress testing
cargo test --release concurrent_https_servers
cargo test --release proxy_load_balancing
cargo test --release tls_performance_under_load
cargo test --release hot_reload_stress_test

# Security testing
cargo test intrusion_detection_patterns
cargo test rate_limiting_enforcement
cargo test certificate_validation
cargo test suspicious_request_blocking

πŸ“Š Version History

v0.3.6 (Current) β€” UI/Terminal & DX Enhancements

  • Anti-Flicker Color System for display labels (zero-delay color mapping).
  • TerminalManager with raw-mode tracking, safe cleanup, emergency destructor.
  • Safe Restart Flow (restart, confirm prompts, re-init of terminal & UI).
  • Widget/Input Unification with viewported rendering & blinking cursor.
  • Cursor Styling (PIPE/BLOCK/UNDERSCORE + RGB across terminals/tmux).
  • Dashboard UX: minimal reset CSS, shutdown screen, improved monitoring.
  • Logging: Server logger API w/ rotation config; i18n keys expanded.

v0.3.5 β€” Production Infrastructure

  • Complete HTTPS/TLS system, enterprise reverse proxy with SSL termination, advanced hot reload, security monitoring suite, professional dashboard, and performance pipeline optimizations.

v0.3.3 β€” Optimized Architecture & Logging

  • 35% Code Reduction while preserving functionality
  • Structured Logging with rotation and compression
  • Performance Improvements (~40% faster request processing)

v0.3.2 β€” Complete Server Management

  • Actix-Web Integration: production web server creation and management
  • Dynamic Server Lifecycle: full orchestration capabilities

πŸ† Code Quality Metrics (v0.3.6)

  • βœ… Zero Cargo errors on full feature set
  • βœ… Hardened terminal lifecycle (raw-mode detection, emergency cleanup)
  • βœ… UI stability via viewport checks & anti-flicker colors
  • βœ… Thread/Memory Safety (Rust guarantees; async-safe state)
  • βœ… Enterprise Logging (structured JSON + rotation)
  • βœ… Performance-Optimized (no regressions vs 0.3.5)
  • βœ… Comprehensive Testing (incl. TLS, proxy, security)
  • βœ… Professional UI (modern dashboard with live metrics & TLS status)
  • βœ… Cross-Platform (macOS, Linux, Windows)

Security

  • TLS 1.3 with modern cipher suites
  • Proper certificate validation
  • Intrusion detection & rate limiting
  • Security audit logging

πŸ“œ License

Dual-Licensing Model

  1. Community License (GPLv3) β€” Free for private and non-commercial use
  2. Commercial License β€” Required for commercial applications and enterprise deployments

Commercial licensing inquiries: πŸ“§ l.ersen@icloud.com


🀝 Contributing

Phase 2 Targets:

  • Advanced load balancing with health-aware routing
  • Docker/Kubernetes integration
  • Real-time analytics dashboard
  • Centralized configuration across clusters

Security Enhancements:

  • Let’s Encrypt integration
  • Sliding-window rate limiting
  • WAF integration
  • OAuth2/JWT auth

Performance & Scalability:

  • Redis-based sessions/caching
  • DB connection pooling
  • CDN for static assets
  • Auto-scaling triggers

Development Guidelines:

  • Keep clippy clean; comprehensive lints
  • Tests for every security-sensitive feature
  • Async/await best practices
  • Error handling with context (anyhow/thiserror)

πŸ“ž Contact & Support


Rush Sync Server v0.3.6 β€” Production-grade orchestration with hardened terminal lifecycle, anti-flicker UI, safe restart flow, minimal CSS reset, live dashboard, and comprehensive security/monitoring.

Commit count: 53

cargo fmt