Proxy Management Documentation
This directory contains the proxy rotation and management functionality.
Proxy Manager (manager.go)
The proxy manager handles rotating through multiple proxy servers to avoid IP bans and distribute load.
Features
- Proxy Rotation: Automatically cycles through available proxies
- Health Monitoring: Tracks proxy availability and response times
- Failure Handling: Automatically disables failing proxies
- Load Balancing: Distributes requests across healthy proxies
Configuration
proxy:
enabled: false
rotation: true # Enable proxy rotation
timeout: 30s # Proxy timeout
# Static proxy list
urls:
- "http://proxy1:8080"
- "http://proxy2:8080"
- "http://proxy3:8080"
# Authentication (if required)
username: ""
password: ""
# Health check settings
healthCheckInterval: 60s # How often to check proxy health
maxFailures: 3 # Failures before disabling proxy
Usage
// Create proxy manager
proxyManager := proxy.NewManager([]string{
"http://proxy1:8080",
"http://proxy2:8080",
}, 30*time.Second)
// Get next available proxy
proxyURL := proxyManager.GetNextProxy()
// Use proxy with HTTP client
transport := &http.Transport{
Proxy: http.ProxyURL(proxyURL),
}
client := &http.Client{
Transport: transport,
Timeout: 30 * time.Second,
}
// Make request through proxy
resp, err := client.Get("https://example.com")
Proxy Types Supported
- HTTP Proxies: Basic HTTP proxy support
- SOCKS5 Proxies: Full SOCKS5 protocol support
- Authenticated Proxies: Username/password authentication
- Rotating Proxies: Automatic rotation through proxy list
Best Practices
- Diverse Proxy Pool: Use proxies from different providers/locations
- Health Monitoring: Regularly check proxy availability
- Rate Limiting: Don't overwhelm individual proxies
- Failover: Have backup proxies ready
- Geographic Distribution: Use proxies from relevant regions
Security Considerations
- Use reputable proxy providers
- Avoid free/public proxies for sensitive operations
- Implement proper authentication
- Monitor for proxy hijacking
- Use HTTPS when possible