httpx

package
v0.0.0-...-414644b Latest Latest
Warning

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

Go to latest
Published: Jul 4, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// 请求配置
	Method          string
	Path            string
	Body            string
	Headers         []string
	CustomHost      string
	Timeout         int
	FollowRedirects bool

	// 探测配置
	Threads    int
	RateLimit  int
	Retries    int
	Ports      []string
	TechDetect bool
	Favicon    bool

	// 网络配置
	Proxy string

	// 响应体配置
	ResponseBodySize int

	// 输出配置
	ShowStatistics bool
}

Config 封装 httpx 探测的所有可配置项,与上游 runner.Options 解耦

type HttpxClient

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

HttpxClient 封装 projectdiscovery/httpx 的探测客户端

func NewHttpxClient

func NewHttpxClient(opts ...Option) *HttpxClient

NewHttpxClient 创建一个新的 HttpxClient,支持通过 Option 函数自定义配置

Example

示例:创建 HTTP 探测客户端,配置线程数、技术检测、跟随重定向

package main

import (
	"fmt"

	"github.com/polite-007/toolbox/httpx"
)

func main() {
	_ = httpx.NewHttpxClient(
		httpx.WithThreads(50),
		httpx.WithTechDetect(),
		httpx.WithFollowRedirects(),
	)
	fmt.Println("httpx client created")
}
Output:
httpx client created
Example (HeaderMerge)

示例:组合使用 Headers 和 CustomHost(验证追加不覆盖)

package main

import (
	"fmt"

	"github.com/polite-007/toolbox/httpx"
)

func main() {
	_ = httpx.NewHttpxClient(
		httpx.WithHeaders([]string{"X-Token: abc123"}),
		httpx.WithCustomHost("internal.example.com"),
	)
	fmt.Println("httpx client created")
}
Output:
httpx client created
Example (WithProxy)

示例:使用代理和自定义端口创建客户端

package main

import (
	"fmt"

	"github.com/polite-007/toolbox/httpx"
)

func main() {
	_ = httpx.NewHttpxClient(
		httpx.WithProxy("http://127.0.0.1:7890"),
		httpx.WithPorts([]string{"80", "443", "8080"}),
		httpx.WithFaviconMMH3(),
	)
	fmt.Println("httpx client created")
}
Output:
httpx client created

func (*HttpxClient) Run

func (c *HttpxClient) Run(targets []string, onResult func(r runner.Result)) error

Run 执行 HTTP 探测

  • targets: 目标列表(域名或 IP)
  • onResult: 每条结果的回调函数

注意:会将全局 gologger 日志级别设为 Info 以输出探测详情

type Option

type Option func(*Config)

Option 配置函数类型

func WithBody

func WithBody(body string) Option

WithBody 设置请求 Body

func WithCustomHost

func WithCustomHost(host string) Option

WithCustomHost 设置自定义 Host 头(追加模式,可与 WithHeaders 共存)

func WithFaviconMMH3

func WithFaviconMMH3() Option

WithFaviconMMH3 启用 favicon hash 计算

func WithFollowRedirects

func WithFollowRedirects() Option

WithFollowRedirects 启用跟随重定向

func WithHeaders

func WithHeaders(headers []string) Option

WithHeaders 设置自定义请求头(追加模式,可与 WithCustomHost 共存)

func WithMethod

func WithMethod(method string) Option

WithMethod 设置请求方法(GET/POST/HEAD 等)

func WithPath

func WithPath(path string) Option

WithPath 设置请求路径

func WithPorts

func WithPorts(ports []string) Option

WithPorts 设置探测端口列表

func WithProxy

func WithProxy(proxy string) Option

WithProxy 设置 HTTP/SOCKS5 代理

func WithRateLimit

func WithRateLimit(rateLimit int) Option

WithRateLimit 设置每秒最大请求数

func WithResponseBodySize

func WithResponseBodySize(size int) Option

WithResponseBodySize 设置响应体最大读取和保存大小(字节)

func WithRetries

func WithRetries(retries int) Option

WithRetries 设置重试次数

func WithShowStatistics

func WithShowStatistics() Option

WithShowStatistics 启用扫描统计信息输出

func WithTechDetect

func WithTechDetect() Option

WithTechDetect 启用 Web 指纹识别

func WithThreads

func WithThreads(threads int) Option

WithThreads 设置并发线程数

func WithTimeout

func WithTimeout(timeout int) Option

WithTimeout 设置超时时间(秒)

Jump to

Keyboard shortcuts

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