ProductPromotion
Logo

Go.Lang

made by https://0x3d.site

GitHub - presbrey/go-multiproxy: Go HTTP client w/ HTTPS and SOCKS5 Proxy Load-balancing, Failover, Retries, Authentication, and RoundTripper
Go HTTP client w/ HTTPS and SOCKS5 Proxy Load-balancing, Failover, Retries, Authentication, and RoundTripper - presbrey/go-multiproxy
Visit Site

GitHub - presbrey/go-multiproxy: Go HTTP client w/ HTTPS and SOCKS5 Proxy Load-balancing, Failover, Retries, Authentication, and RoundTripper

GitHub - presbrey/go-multiproxy: Go HTTP client w/ HTTPS and SOCKS5 Proxy Load-balancing, Failover, Retries, Authentication, and RoundTripper

MultiProxy Client for Go

Go Report Card codecov Go Test GoDoc License: MIT

Overview

MultiProxy Client is a robust Go library designed to manage multiple HTTP/HTTPS and SOCKS5 proxies efficiently. It provides a fault-tolerant and load-balanced approach to making HTTP requests through a pool of proxies, with features like automatic retries, backoff mechanisms, and proxy rotation.

Features

  • Multiple proxy support
  • Automatic proxy rotation
  • Fault tolerance with retry mechanism
  • Configurable timeouts and delays
  • Cookie management
  • Basic authentication support for proxies
  • User-Agent rotation
  • HTTPS and SOCKS5 proxy support
  • Concurrent request handling using singleflight pattern
  • Rate limiting for individual proxies
  • Configurable proxy rotation
  • Backoff mechanism for failed proxies

Installation

To use MultiProxy Client in your Go project, you can install it using go get:

go get github.com/presbrey/go-multiproxy

Replace yourusername with the actual GitHub username or organization where this project is hosted.

Usage

Here's a basic example of how to use the MultiProxy Client:

package main

import (
    "fmt"
    "net/http"
    "time"
    
    "github.com/presbrey/go-multiproxy"
)

func main() {
    config := multiproxy.Config{
        Proxies: []multiproxy.Proxy{
            {
                URL:  &url.URL{Scheme: "http", Host: "proxy1.example.com:8080"},
                Auth: &multiproxy.ProxyAuth{Username: "user1", Password: "pass1"},
            },
            {
                URL:  &url.URL{Scheme: "socks5", Host: "proxy2.example.com:1080"},
                Auth: &multiproxy.ProxyAuth{Username: "user2", Password: "pass2"},
            },
        },
        CookieTimeout:    10 * time.Minute,
        CookieOptions:    &cookiejar.Options{PublicSuffixList: publicsuffix.List},
        DialTimeout:      30 * time.Second,
        RequestTimeout:   1 * time.Minute,
        RetryAttempts:    3,
        RetryDelay:       5 * time.Second,
        ProxyRotateCount: 10,
    }

    client, err := multiproxy.NewClient(config)
    if err != nil {
        panic(err)
    }

    resp, err := client.Get("https://example.com")
    if err != nil {
        panic(err)
    }
    defer resp.Body.Close()

    fmt.Printf("Response status: %s\n", resp.Status)
}

Configuration

The Config struct allows you to customize the behavior of the MultiProxy Client:

  • Proxies: List of Proxy structs, each containing:

    • URL: The URL of the proxy
    • Auth: Pointer to ProxyAuth struct with Username and Password
    • UserAgent: User-Agent string for this specific proxy
    • RateLimit: Duration for rate limiting requests to this specific proxy
  • ProxyRotateCount: Number of requests after which to rotate to the next proxy

  • BackoffTime: Time to wait before retrying a failed proxy

  • DialTimeout: Timeout for establishing a connection to a proxy

  • RequestTimeout: Timeout for the entire request (including dialing, writing request, and reading response)

  • RetryDelay: Delay between retry attempts

  • CookieOptions: Options for configuring the cookie jar (see http.cookiejar.Options)

  • CookieTimeout: Duration for which cookies are valid

  • DefaultUserAgent: Default User-Agent string to use if not specified in ProxyUserAgents

  • RetryAttempts: Number of times to retry a failed request

  • RetryDelay: Delay between retry attempts

  • BackoffTime: Time to wait before retrying a failed proxy

  • InsecureSkipVerify: Whether to skip TLS certificate verification

Using the RoundTripper

The MultiProxy Client provides a RoundTripper() method that returns an http.RoundTripper. This allows you to use the multi-proxy functionality with any http.Client. Here's an example:

config := multiproxy.Config{
    // ... your config here ...
}

client, err := multiproxy.NewClient(config)
if err != nil {
    // handle error
}

httpClient := &http.Client{
    Transport: client.RoundTripper(),
}

// Now use httpClient for your requests
resp, err := httpClient.Get("https://example.com")

This is particularly useful when you need to use the multi-proxy functionality with libraries or APIs that accept an http.Client.

Testing

The project includes comprehensive test suites:

  • multiproxy_test.go: Tests for the main MultiProxy Client functionality
  • connect_test.go: Tests for HTTPS and CONNECT proxy functionality
  • errors_test.go: Tests for error handling scenarios

To run the tests, use the following command:

go test ./...

Contributing

Contributions to the MultiProxy Client are welcome! Please feel free to submit issues, fork the repository and send pull requests.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Disclaimer

This software is provided as-is, and users should be aware of the legal and ethical considerations when using proxy servers. Always ensure you have the right to use the proxy servers you configure with this client.

Articles
to learn more about the golang concepts.

Resources
which are currently available to browse on.

mail [email protected] to add your project or resources here ๐Ÿ”ฅ.

FAQ's
to know more about the topic.

mail [email protected] to add your project or resources here ๐Ÿ”ฅ.

Queries
or most google FAQ's about GoLang.

mail [email protected] to add more queries here ๐Ÿ”.

More Sites
to check out once you're finished browsing here.

0x3d
https://www.0x3d.site/
0x3d is designed for aggregating information.
NodeJS
https://nodejs.0x3d.site/
NodeJS Online Directory
Cross Platform
https://cross-platform.0x3d.site/
Cross Platform Online Directory
Open Source
https://open-source.0x3d.site/
Open Source Online Directory
Analytics
https://analytics.0x3d.site/
Analytics Online Directory
JavaScript
https://javascript.0x3d.site/
JavaScript Online Directory
GoLang
https://golang.0x3d.site/
GoLang Online Directory
Python
https://python.0x3d.site/
Python Online Directory
Swift
https://swift.0x3d.site/
Swift Online Directory
Rust
https://rust.0x3d.site/
Rust Online Directory
Scala
https://scala.0x3d.site/
Scala Online Directory
Ruby
https://ruby.0x3d.site/
Ruby Online Directory
Clojure
https://clojure.0x3d.site/
Clojure Online Directory
Elixir
https://elixir.0x3d.site/
Elixir Online Directory
Elm
https://elm.0x3d.site/
Elm Online Directory
Lua
https://lua.0x3d.site/
Lua Online Directory
C Programming
https://c-programming.0x3d.site/
C Programming Online Directory
C++ Programming
https://cpp-programming.0x3d.site/
C++ Programming Online Directory
R Programming
https://r-programming.0x3d.site/
R Programming Online Directory
Perl
https://perl.0x3d.site/
Perl Online Directory
Java
https://java.0x3d.site/
Java Online Directory
Kotlin
https://kotlin.0x3d.site/
Kotlin Online Directory
PHP
https://php.0x3d.site/
PHP Online Directory
React JS
https://react.0x3d.site/
React JS Online Directory
Angular
https://angular.0x3d.site/
Angular JS Online Directory