RustySquid 🦀🦑
A minimal, memory-safe HTTP caching proxy inspired by Squid, designed for embedded systems and routers.
Features
- ✅ 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
Current Status
✅ v1.1.0 Production Ready - PMAT quality standards integrated
Examples
RustySquid includes comprehensive examples demonstrating various use cases:
Simple Proxy Demo
Demonstrates basic cache operations and proxy setup.
Cache Operations Demo
Shows cacheability tests, TTL calculation, expiration handling, and size limits.
Performance Testing
Measures cache performance including sequential/concurrent operations and hit vs miss timing.
Full Proxy Server
Runs a complete HTTP proxy server on port 8888 with statistics tracking.
Quick Start
Build for ARM64 Router
Deploy to Router
| \
Configure Client
Configuration
Currently uses compile-time constants:
CACHE_SIZE: 10,000 entriesMAX_RESPONSE_SIZE: 10MBCACHE_TTL: 3600 secondsPROXY_PORT: 3128
Testing
# Run all tests
# Property-based tests
# Safety verification
# Benchmarks
Safety Implementation Plan
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.
Performance
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
Why RustySquid?
Unlike full Squid (200MB+ memory), RustySquid targets resource-constrained environments:
- Home routers
- Raspberry Pi
- Edge devices
- IoT gateways
Contributing
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
License
MIT
Acknowledgments
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.