proxycheck

package module
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2026 License: MIT Imports: 16 Imported by: 0

README

proxycheck

Proxy list checker for Go — feed it a list of ip:port proxies and it reports which are alive, which protocols (http, https, socks4, socks5) each supports, and how fast each responds.

Release Go Reference Go Report Card Go version CI golangci-lint codecov

proxycheck validates raw proxy lists. Each proxy is tested by routing a request to an external proxy judge through it: if the judge answers HTTP 200, the proxy is considered to work for that protocol. The tool tries all four protocols per address and reports the ones that succeed, together with a response-speed figure.

It ships two ways:

  • a CLI binary (proxycheck) that reads proxies from arguments or stdin and prints the working ones, and
  • an importable Go package (github.com/memclutter/proxycheck) exposing the Check function and the Feed / Judge interfaces for use in other programs.

Contents

Install

Build the binary from source (Go 1.18+):

go install github.com/memclutter/proxycheck/cmd@latest

or clone and build locally:

git clone https://github.com/memclutter/proxycheck.git
cd proxycheck
go build -o proxycheck ./cmd

CLI usage

Pass proxies as arguments:

proxycheck 108.20.30.1:8080 89.33.123.100:3128

or pipe a list (one ip:port per line, blank lines ignored) on stdin:

cat proxies.txt | proxycheck --threads 50
Flag Default Description
--threads 10 Number of proxies checked concurrently.
--judge proxyjudge.us Proxy judge name (see How it works).

An address may be a bare ip, in which case port 80 is assumed.

Output format

Working proxies are written to stdout, one per line, tab-separated:

<addr>\t<protocols>\t<speed>
  • <protocols> — a comma-separated subset of http,https,socks4,socks5.
  • <speed> — a Go duration string, e.g. 412ms.

Proxies that fail every protocol are reported on stderr and are absent from stdout, so you can pipe the clean list onward while still seeing failures:

cat proxies.txt | proxycheck > working.tsv 2> failures.log

Library usage

package main

import (
	"fmt"

	"github.com/memclutter/proxycheck"
)

func main() {
	res := proxycheck.Check("108.20.30.1:8080", proxycheck.AZEnvPhpJudge{})
	if res.Online {
		fmt.Printf("online via %v in %s\n", res.Protocols, res.Speed)
	} else {
		fmt.Printf("offline: %v\n", res.Err)
	}
}

The package also exports the Feed interface (SliceFeed, FileFeed) for streaming proxy sources, the Judge interface with the shipped judges and the Judges registry, and ProxyRequest for a single timed request through a proxy.

How it works

A judge is an external endpoint that echoes request details; reaching it through a proxy proves the proxy forwards traffic. Two judges ship:

Name Target URL Timeout
azenv.php http://www.wfuchs.de/azenv.php 3s
proxyjudge.us http://proxyjudge.us/ 1s

For each proxy, Check tries http, https, socks4, and socks5 in turn (HTTP/HTTPS via Go's proxy transport, SOCKS via h12.io/socks). A protocol counts as working only when the request completes with an HTTP 200. The proxy is "online" if at least one protocol succeeds.

Contributing

Contributions are welcome — see CONTRIBUTING.md for setup, coding conventions, and the commit/PR process. Changes are recorded in CHANGELOG.md.

License

Released under the MIT License.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// FeedEnd this error happens when the feed runs out of proxies to check.
	// Named without the conventional Err* prefix to preserve the public API.
	//nolint:staticcheck // ST1012: renaming would break importers of the package
	FeedEnd = errors.New("feed end")
)
View Source
var Judges = map[string]Judge{
	"azenv.php":     AZEnvPhpJudge{},
	"proxyjudge.us": ProxyjudgeUsJudge{},
}

Functions

func Action

func Action(c *cli.Context) error

func NewApp added in v0.0.6

func NewApp() *cli.App

NewApp builds the proxycheck CLI application. It is shared by the cmd binary and the tests so both exercise the same flag wiring.

func ProxyRequest added in v0.0.2

func ProxyRequest(target string, proxyURL *url.URL, timeout time.Duration) ([]byte, error)

ProxyRequest Performs an HTTP request through the proxy specified in the proxyUrl

Types

type AZEnvPhpJudge added in v0.0.2

type AZEnvPhpJudge struct{}

func (AZEnvPhpJudge) TargetURL added in v0.0.2

func (j AZEnvPhpJudge) TargetURL() string

func (AZEnvPhpJudge) Timeout added in v0.0.2

func (j AZEnvPhpJudge) Timeout() time.Duration

type CheckResult added in v0.0.2

type CheckResult struct {
	Protocols []string
	Online    bool
	Err       map[string]error
	Speed     time.Duration
}

func Check added in v0.0.2

func Check(proxyAddr string, judge Judge) (result CheckResult)

type Feed added in v0.0.2

type Feed interface {
	// Next
	// Returns a string in ip:port format of the next proxy to check
	Next() (string, error)
}

Feed Data source interface. Encapsulates the logic of extracting the next proxy for verification.

type FileFeed added in v0.0.2

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

FileFeed Proxy feed from file stream, like stdin, os file.

func NewFileFeed added in v0.0.2

func NewFileFeed(file io.Reader) *FileFeed

func (FileFeed) Next added in v0.0.2

func (f FileFeed) Next() (string, error)

type Judge added in v0.0.2

type Judge interface {
	// TargetURL Returns the url to which you need to contact through the proxy
	TargetURL() string
	// Timeout Returns the recommended timeout for this referee
	Timeout() time.Duration
}

Judge The proxy judge encapsulates the logic of interaction with the proxy judge

func ResolveJudge added in v0.0.6

func ResolveJudge(name string) (Judge, error)

ResolveJudge returns the Judge registered under name. An unknown name yields an error that lists the available judge names.

type ProxyjudgeUsJudge added in v0.0.5

type ProxyjudgeUsJudge struct{}

func (ProxyjudgeUsJudge) TargetURL added in v0.0.5

func (j ProxyjudgeUsJudge) TargetURL() string

func (ProxyjudgeUsJudge) Timeout added in v0.0.5

func (j ProxyjudgeUsJudge) Timeout() time.Duration

type SliceFeed added in v0.0.2

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

SliceFeed Proxy feed from string slice like this []string{"108.20.30.1:500", "89.33.123.100:40", "50.73.100.1:55"}

func NewSliceFeed added in v0.0.2

func NewSliceFeed(slice []string) *SliceFeed

func (*SliceFeed) Next added in v0.0.2

func (f *SliceFeed) Next() (string, error)

Directories

Path Synopsis