proxyprobe

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2026 License: AGPL-3.0 Imports: 9 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package proxyprobe:出网代理的连通性自测。

为什么要单独一个包:代理有两处使用者——install.sh 装机期(走 curl)和 运行期(走 Go 的 http.Client)。两边的「怎么算通」必须一致,否则会出现 「装机说通了、运行时却连不上」的割裂。判定口径统一放这里。

判定标准用 GitHub API:装机流程本来就要访问它,自测与实际用途同源。 HTTP 200/301/302 都算通(403 是 GitHub 限流,链路本身是通的)。

Index

Constants

View Source
const DefaultProbeURL = "https://api.github.com/repos/projectdiscovery/nuclei/releases/latest"

DefaultProbeURL 默认探测目标:GitHub 的 release API(装机流程本来就要访问它)。

Variables

This section is empty.

Functions

func ClientFor

func ClientFor(proxyURL string, timeout time.Duration) (*http.Client, error)

ClientFor 按协议构造带代理的 HTTP 客户端。导出给 hostd 的下载器复用, 保证「装机期下载」和「运行期自测」用的是同一套代理语义。

socks5 必须走 x/net/proxy 的 SOCKS5 dialer:net/http 的 ProxyURL 只懂 HTTP CONNECT 代理,喂它 socks5:// 会得到 "unsupported protocol scheme"—— 表现就是「填了 socks 代理但下载照样失败」,而用户完全看不出是协议不匹配。

func Normalize

func Normalize(raw string) string

Normalize 把用户随手写的形式补成标准 URL:

"10.0.0.14:7897"        → http://10.0.0.14:7897(本地代理多是 http 混合口)
"10.0.0.14:7897/"       → 同上
"socks5://h:1080"       → 原样

空串原样返回(=直连)。

func Validate

func Validate(raw string) (string, error)

Validate 校验代理地址格式。空串 = 直连,返回 nil。

只允许 http/https/socks5/socks5h:这三个协议是 hostd 的下载器、 apt 的 Acquire 代理、以及 curl 的 -x 都能理解的交集。写成别的(比如 ss:// 或 vless://)不会有任何组件能用它,静默失败比报错更糟。

Types

type Result

type Result struct {
	OK        bool   `json:"ok"`
	Proxy     string `json:"proxy"`
	Scheme    string `json:"scheme"`
	LatencyMS int64  `json:"latency_ms"`
	Status    int    `json:"status"`
	ExitIP    string `json:"exit_ip,omitempty"`
	Error     string `json:"error,omitempty"`
	Hint      string `json:"hint,omitempty"`
}

Result 是一次代理自测的结果。

func Probe

func Probe(ctx context.Context, proxyURL, probeURL, exitIPURL string) Result

Probe 对一个代理做一次真实请求,给出可用性与诊断信息。

probeURL 为空时用 DefaultProbeURL。exitIPURL 非空时额外请求一次 拿出口 IP(SOCKS5 场景下用户最关心「到底走没走代理」)。

Jump to

Keyboard shortcuts

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