Documentation
¶
Index ¶
- type Config
- type HttpxClient
- type Option
- func WithBody(body string) Option
- func WithCustomHost(host string) Option
- func WithFaviconMMH3() Option
- func WithFollowRedirects() Option
- func WithHeaders(headers []string) Option
- func WithMethod(method string) Option
- func WithPath(path string) Option
- func WithPorts(ports []string) Option
- func WithProxy(proxy string) Option
- func WithRateLimit(rateLimit int) Option
- func WithResponseBodySize(size int) Option
- func WithRetries(retries int) Option
- func WithShowStatistics() Option
- func WithTechDetect() Option
- func WithThreads(threads int) Option
- func WithTimeout(timeout int) Option
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
type Option ¶
type Option func(*Config)
Option 配置函数类型
func WithCustomHost ¶
WithCustomHost 设置自定义 Host 头(追加模式,可与 WithHeaders 共存)
func WithHeaders ¶
WithHeaders 设置自定义请求头(追加模式,可与 WithCustomHost 共存)
func WithResponseBodySize ¶
WithResponseBodySize 设置响应体最大读取和保存大小(字节)
Click to show internal directories.
Click to hide internal directories.