proxygun

package module
v0.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 15, 2025 License: MIT Imports: 13 Imported by: 0

README

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

func NewClient

func NewClient(config *Config) *Client

func (*Client) Close

func (c *Client) Close() error

func (*Client) Do

func (c *Client) Do(req *http.Request) (*http.Response, error)

func (*Client) Get

func (c *Client) Get(url string) (*http.Response, error)

func (*Client) Post

func (c *Client) Post(url, contentType string, body interface{}) (*http.Response, error)

func (*Client) Stats

func (c *Client) Stats() map[string]interface{}

type Config

type Config struct {
	PoolSize          int
	MaxRetries        int
	RefreshInterval   time.Duration
	ValidationWorkers int
	BadProxyMaxAge    time.Duration
}

func DefaultConfig

func DefaultConfig() *Config

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL