A high-performance Go proxy server that handles both HTTP/HTTPS and SOCKS5 protocols on a single port with real-time monitoring capabilities.
- Dual Protocol Support: Automatically detects and handles both HTTP/HTTPS and SOCKS5 connections
- Real-time Monitoring: Web dashboard with live connection tracking via WebSocket
- IP-based Access Control: Configurable whitelist for authorized clients
- Protocol Sniffing: Intelligent detection of connection type without separate ports
- Comprehensive Logging: Debug mode with detailed connection information
- Go 1.18 or later
- Basic networking tools (curl, wget) for testing
- Clone the repository:
git clone <repository-url>
cd proxy
- Build the applications:
go build -o proxy_app main.go
go build -o test_server/test_server_app test_server/main.go
- Start the proxy server:
./proxy_app
- Start the test server (in another terminal):
cd test_server && ./test_server_app
- Test the proxy:
# HTTP proxy
curl --proxy http://localhost:8080 http://localhost:8081/test.txt
# SOCKS5 proxy
curl --proxy socks5://localhost:8080 http://localhost:8081/test.txt
Edit config.yaml
to configure allowed IP addresses:
allowed_ips:
- "127.0.0.1"
- "::1"
- "your.ip.address.here"
./proxy_app [OPTIONS]
Options:
-debug, -d Enable debug logging
-monitor-port, -m PORT Set monitoring dashboard port (default: 8082)
The proxy server includes a comprehensive real-time monitoring interface that provides visibility into all proxy connections.
Access the monitoring dashboard at http://localhost:8082
(or your configured monitoring port):
Features:
- Real-time Connection Tracking: View all active connections with live updates
- Connection Statistics: Total connections processed since startup
- Protocol Breakdown: See HTTP vs SOCKS5 connection distribution
- Client Information: Monitor client IP addresses and connection patterns
- Connection Duration: Track how long connections remain active
- Destination Mapping: View what destinations clients are accessing
Dashboard Elements:
- Statistics cards showing total and active connection counts
- Live connection table with client IP, protocol, destination, and duration
- Real-time updates via WebSocket (no page refresh needed)
- Connection status indicators and timestamps
- Clean, responsive interface that works on desktop and mobile
The monitoring system provides both web interface and programmatic access:
GET /
- Interactive web dashboardGET /api/stats
- JSON statistics for integration with external toolsWebSocket /ws
- Real-time updates stream for custom applications
The monitoring server runs on a separate port (default 8082) and can be configured:
# Custom monitoring port
./proxy_app -monitor-port 9090
# Access dashboard at http://localhost:9090
Run the comprehensive test suite:
./test.sh
This script automatically:
- Builds the applications if needed
- Starts both servers
- Runs tests for HTTP and SOCKS5 protocols
- Cleans up processes after testing
Test HTTP proxy:
curl --proxy http://localhost:8080 https://httpbin.org/ip
wget -e "http_proxy=http://localhost:8080" https://httpbin.org/ip -O -
Test SOCKS5 proxy:
curl --proxy socks5://localhost:8080 https://httpbin.org/ip
all_proxy=socks5://localhost:8080 wget https://httpbin.org/ip -O -
Run monitoring system tests:
go test -v -run TestMonitoring
The server uses protocol sniffing to handle multiple protocols on a single port:
- SOCKS5 connections start with byte
0x05
- All other connections are treated as HTTP
- Connection Handler: Manages incoming connections and protocol detection
- HTTP Handler: Processes HTTP/HTTPS requests with CONNECT method support
- SOCKS5 Handler: Implements full SOCKS5 protocol with authentication
- Monitoring System: Thread-safe connection tracking with WebSocket broadcasting
- IP-based access control
- No authentication bypass vulnerabilities
- Secure connection handling with proper cleanup
- Debug logging for security auditing
├── main.go # Main proxy server
├── config.yaml # IP whitelist configuration
├── test_server/ # Test HTTP server
│ ├── main.go # Test server implementation
│ └── test.txt # Test file
├── monitoring_test.go # Monitoring system tests
├── test.sh # Automated test suite
└── CLAUDE.md # Development guide
handleConnection()
- Main connection processinghandleHTTP()
- HTTP/HTTPS proxy logichandleSocks5()
- SOCKS5 implementationaddConnection()
- Connection trackingbroadcastUpdate()
- Real-time monitoring updates
github.com/gorilla/websocket
- WebSocket supportgopkg.in/yaml.v2
- YAML configuration parsing- Standard Go libraries for networking
- Port already in use: Check if other services are using ports 8080, 8081, or 8082
- Connection refused: Verify IP address is in the whitelist
- Monitoring not working: Ensure WebSocket connections are not blocked
Enable debug logging to troubleshoot connection issues:
./proxy_app -debug
This provides detailed information about:
- Client connection attempts
- Protocol detection results
- Connection establishment status
- Data relay operations
This project is provided as-is for educational and development purposes.