ProxyGun
Go library providing an HTTP client with automatic proxy server pool management.
Features
- Automatic proxy downloading from known sources
- Proxy validation through google.com requests
- Proxy rotation for each request
- Proxy statistics and automatic Bad Pool placement
- HTTP and SOCKS5 proxy support
- Automatic pool replenishment when needed
Usage
package main
import (
"fmt"
"log"
"time"
"github.com/aredoff/proxygun"
)
func main() {
config := proxygun.DefaultConfig()
config.PoolSize = 20
config.MaxRetries = 5
client := proxygun.NewClient(config)
defer client.Close()
// Wait for proxy loading
time.Sleep(5 * time.Second)
resp, err := client.Get("https://httpbin.org/ip")
if err != nil {
log.Printf("Error: %v", err)
return
}
defer resp.Body.Close()
fmt.Printf("Status: %s\n", resp.Status)
fmt.Printf("Stats: %+v\n", client.Stats())
}
Configuration
type Config struct {
PoolSize int // Proxy pool size (default 50)
MaxRetries int // Maximum retry attempts (default 3)
RefreshInterval time.Duration // Proxy refresh interval (default 10 seconds)
ValidationWorkers int // Number of validation workers (default 30, max 50)
BadProxyMaxAge time.Duration // Bad proxy retention time (default 24 hours)
}
Architecture
The library consists of the following components:
client.go - main HTTP client with proxy rotation
internal/proxy/ - structures for proxy representation and statistics
internal/pool/ - proxy pool management (main, free, bad)
internal/parser/ - parsers for proxy websites
internal/validator/ - proxy validator through test requests
Proxy Sources
License
MIT