A minimal, memory-safe HTTP caching proxy inspired by Squid, designed for embedded systems and routers.
- ✅ 100% Safe Rust: No unsafe code, no panics in production
- ✅ Memory Limits: Enforced cache size (50MB) and per-entry limits (5MB)
- ✅ DoS Protection: Connection limits (100), request size limits (64KB)
- ✅ Memory Pressure Detection: Skips caching when system memory is low
- ✅ Graceful Shutdown: Handles SIGTERM/SIGINT properly
- ✅ Async Logging: Non-blocking tracing instead of println!
- ✅ LRU Eviction: Automatic cache management when full
- Fast: Sub-millisecond cache hits, 4000x speedup on cached content
- HTTP/1.1 Compliant: Respects Cache-Control headers
- Embedded-Friendly: Single-threaded tokio runtime for low resource usage
✅ v1.1.0 Production Ready - PMAT quality standards integrated
RustySquid includes comprehensive examples demonstrating various use cases:
cargo run --example simple_proxy
Demonstrates basic cache operations and proxy setup.
cargo run --example cache_demo
Shows cacheability tests, TTL calculation, expiration handling, and size limits.
cargo run --example performance_test --release
Measures cache performance including sequential/concurrent operations and hit vs miss timing.
cargo run --example full_proxy
Runs a complete HTTP proxy server on port 8888 with statistics tracking.
cargo build --release --target aarch64-unknown-linux-musl
cat target/aarch64-unknown-linux-musl/release/rustysquid | \
ssh user@router "cat > /tmp/rustysquid && chmod +x /tmp/rustysquid"
ssh user@router "nohup /tmp/rustysquid > /tmp/cache.log 2>&1 &"
export http_proxy=http://router:3128
export https_proxy=http://router:3128
Currently uses compile-time constants:
CACHE_SIZE
: 10,000 entriesMAX_RESPONSE_SIZE
: 10MBCACHE_TTL
: 3600 secondsPROXY_PORT
: 3128
# Run all tests
cargo test
# Property-based tests
cargo test --test property_tests
# Safety verification
make -f Makefile.safety safety-check
# Benchmarks
cargo bench
We're implementing minimal safety features from Squid in 6 phases:
- Memory Safety - Prevent OOM crashes
- Request Safety - Prevent DoS attacks
- Error Handling - Remove panics
- Logging - Async structured logging
- Cache Intelligence - HTTP compliance
- Security - ACLs and rate limiting
See detailed plan for task breakdown.
On ASUS RT-AX88U router (1GB RAM, Quad-core ARM):
- Cache hits: < 1ms latency
- Cache misses: Adds < 5ms overhead
- Memory usage: < 10MB for 1000 cached entries
- Hit rate: 40-60% for typical browsing
Unlike full Squid (200MB+ memory), RustySquid targets resource-constrained environments:
- Home routers
- Raspberry Pi
- Edge devices
- IoT gateways
We follow PMAT methodology:
- Property-based testing for invariants
- Metrics for performance tracking
- Automated testing (unit, integration, doc)
- Testing before merging
Each PR should:
- Add tests for new features
- Pass
make safety-check
- Include benchmarks for performance changes
- Update documentation
MIT
Inspired by:
- Squid Cache - The legendary caching proxy
- Tokio - Async runtime for Rust
- ASUS-WRT firmware community
Note: This is an educational project demonstrating safe Rust practices for network programming. Use in production at your own risk.