v2.0.1
π¦ CHANGELOG
π v2.0.1 β Loop-Safe Release (2025-11-19)
This release fixes all infinite loop issues, improves Docker compatibility, and introduces automatic port-offset routing.
π₯ New Features
-
Port Offset System (9443β443, 9080β80)
Prevents infinite NAT loops inside Docker by mapping incoming 9xxx ports back to real service ports.- Incoming
9443β backend443 - Incoming
9080β backend80 - Generic:
9xxxβxxx
- Incoming
-
Automatic Backend Port Calculation
AddedcalculateBackendPort()to derive correct upstream port from incoming port. -
Docker-Safe Architecture
Now the proxy can run safely inside Docker without ever looping back into itself:docker run -p 443:9443 -p 80:9080 proxy
-
Local-IP Loop Detection
Blocks requests targeting:127.0.0.1- container IPs (e.g.
172.17.x.x) - any loopback scenario
-
Improved SNI & Host Parsing
- Robust TLS ClientHello reading
- Safe fallback for malformed HTTP requests
- Better error reporting
π Enhancements
-
Cleaner multi-port handling
- Supports lists (
9443,9080) - Supports ranges (
9000-9999) - Mixed formats now work reliably
- Supports lists (
-
Improved logging with slog
- Context-aware fields
- Debug mode shows detailed inbound/outbound flow
-
Removed broken waitgroup logic
- Listeners now run asynchronously without blocking startup
-
Refined connection lifecycle
- Safe CloseWrite usage
- No panics due to non-TCPConn types
-
Better error readability
- TLS handshake failures explained
- Invalid ports detected early
π Bug Fixes
-
Fixed infinite self-connection loop
- Proxy no longer dials its own listening port
- Works correctly behind Docker NAT
-
Fixed HTTP detection deadlock
- Prevented long hangs when reading initial bytes
-
Fixed TLS handshake stalling
- Added read deadlines
- Improved ClientHello extraction using corrected ReadOnlyConn
-
Fixed crash when port ranges were malformed
- Handling of cases like
8080-or-9000
- Handling of cases like
-
Fixed missing pointer receiver on ReadOnlyConn
- Deadlines now work
- Avoids handshake blockages
π¦ Technical Notes
-
Using
9xxx β xxxport-offset model is now required for Docker deployments. -
All tests confirm zero looping under:
- Host network mode
- Bridge network mode
- Exposed port mode
- NAT rewrites
Example deployment:
docker run \
-p 443:9443 \
-p 80:9080 \
ghcr.io/mrmohebi/forward-proxy:latest \
-port 9443,9080 \
-log-level info