Fast Proxy Stars Watchers

banner

Why FastProxy?

FastProxy is lightweight, easy-to-use proxy dialing module that makes using proxies with fasthttp easier. FastProxy also includes proxy formatting for Proxy-Authentication and a connection cache system.

Quick Usage

package main

// Import Fasthttp and FastProxy
import (
    FastProxy "github.com/realTristan/FastProxy"
    "github.com/valyala/fasthttp"
)

// Main Function
func main() {
    // Enable proxy formatting (ex: user:[email protected]:port -> ip:[email protected]:pass)
    var enableProxyFormatting bool = true

    // Create new request object
    var request *fasthttp.Request = fasthttp.AcquireRequest()
    request.SetRequestURI("URL")

    // Create client and use FastProxy Dial
    var client *fasthttp.Client = &fasthttp.Client{}
    client.Dial = FastProxy.Dial("ip:[email protected]:pass", enableProxyFormatting)
    
    // Create Response Object
    var response *fasthttp.Response = fasthttp.AcquireResponse()
    
    // Release Response when not needed anymore
    defer fasthttp.ReleaseResponse(response)

    // Send the http request
    var err = client.Do(request, response)
    if err != nil {
        // Handle Error
        return
    }

    // Print the request Body, StatusCode
    println(string(response.Body()))
    println(response.StatusCode())
}

Request Proxy

package main

// Import FastProxy and fasthttp
import (
	FastProxy "github.com/realTristan/FastProxy"

	"github.com/valyala/fasthttp"
)

// Main Function
func main() {
    // Create an empty error variable
	var err error

	// Create a fasthttp request object
	var req *fasthttp.Request = fasthttp.AcquireRequest()
	req.SetRequestURI("URL")

	// Create a fasthttp response object
	var resp *fasthttp.Response = fasthttp.AcquireResponse()
	defer fasthttp.ReleaseResponse(resp)

	// Create a FastProxy Request Object
	var FastProxyRequest FastProxy.Request = FastProxy.Request{
		Client:      &fasthttp.Client{},
		Request:     req,
		Response:    resp,
		FormatProxy: true,
		Proxy:       "ip:[email protected]:pass",
	}

	// Send the request
	resp, err = FastProxy.SendRequest(FastProxyRequest)

	// Handle Error
	if err != nil {
		return
	}

	// Print Response body and Response status code
	println(resp.Body())
	println(resp.StatusCode())
}

Proxy Formatting

// Format proxies to ip:[email protected]:pass
func FormatProxyList() {

    // Create a new proxy slice
    var proxies []string = []string{
        "ip:[email protected]:pass",
        "user:[email protected]:port",
    }

    // Iterate through the proxy slice
    for i := 0; i < len(proxies); i++ {
        var proxy string = proxies[i]

        // Format the proxy
        proxies[i] = FastProxy.FormatProxy(&proxy)
    }

    // Print the formatted proxies
    println(proxies)
}

GitHub

View Github