proxy_checker

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2023 License: MIT Imports: 4 Imported by: 2

README

Proxy Checker

The proxy_checker package provides a library for checking the availability of proxies (HTTP, HTTPS, SOCKS4, SOCKS5).

Installation

To use this library, you need to have Go installed and set up your Go workspace.

Run the following command to install the proxy_checker package:

go get github.com/trananhtung/proxy_checker

Usage

To check the availability of a proxy, use the ProxyTest function. It performs a test request to the specified target URL using the provided proxy.

import (
	"fmt"
	"github.com/trananhtung/proxy_checker"
)

func main() {
	proxy := "http://1.1.1.1:8080"
	targetURL := "http://example.com"
	timeout := uint(5) // Timeout in seconds

	result := proxy_checker.ProxyTest(proxy, targetURL, timeout)

	if result {
		fmt.Println("Proxy is available")
	} else {
		fmt.Println("Proxy is not available")
	}
}

Function Documentation

func ProxyTest
func ProxyTest(proxy, urlTarget string, timeout uint) bool

ProxyTest checks the availability of a proxy by performing a test request.

  • It sends an HTTP GET request to the specified target URL using the provided proxy.
  • The function supports both HTTP and HTTPS proxies .
  • It uses the specified timeout duration for the request.

The function returns true if the proxy is available and the test request succeeds. It returns false if the proxy is unavailable or the test request fails.

Parameters:
  • proxy: The proxy URL in the format http://:, https://:, socks4://:, socks5://:.
  • urlTarget: The target URL to send the test request to.
  • timeout: The timeout duration in seconds for the test request.

Documentation

Overview

Package proxy_checker provides a library for checking the availability of proxies.

Index

Constants

View Source
const (
	// AMAZON_CHECK_IP_URL is the URL used for checking the availability of a proxy.
	AMAZON_CHECK_IP_URL = "http://checkip.amazonaws.com/"
	IPINFO_CHECK_IP_URL = "https://ipinfo.io/"
)

Variables

This section is empty.

Functions

func ProxyTest

func ProxyTest(proxy, urlTarget string, timeout uint) bool

ProxyTest checks the availability of a proxy by performing a test request.

It sends an HTTP GET request to the specified target URL using the provided proxy. The function supports both HTTP and HTTPS proxies. It uses the specified timeout duration for the request.

The function returns true if the proxy is available and the test request succeeds. It returns false if the proxy is unavailable or the test request fails.

Example:

proxy := "http://1.1.1.1:8080"
targetURL := "http://example.com"
timeout := uint(5) // Timeout in seconds
result := ProxyTest(proxy, targetURL, timeout)
if result {
    fmt.Println("Proxy is available")
} else {
    fmt.Println("Proxy is not available")
}

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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