shadow1ng/fscan · critical
initialize http client: %w
Error message
initialize http client: %w
What it means
RunScan initializes the global HTTP client via lib.Inithttp before scanning. If client construction fails (proxy misconfiguration, bad TLS settings, invalid options), the scan is aborted, the failure is logged through i18n.Tr("http_client_init_failed", ...), and a wrapped error is returned alongside a partial scan report.
Source
Thrown at core/scanner.go:115
config := session.Config
// 全局超时:-gt 参数设置整个扫描的硬性截止时间
var cancel context.CancelFunc
if config.GlobalTimeout > 0 {
ctx, cancel = context.WithTimeout(ctx, config.GlobalTimeout)
} else {
ctx, cancel = context.WithCancel(ctx)
}
defer cancel()
state := session.State
// 设置全局 State(兼容旧代码路径中未传 state 的调用)
SetGlobalState(state)
// 初始化HTTP客户端(静默,无需日志)
if err := lib.Inithttp(config); err != nil {
session.LogError(i18n.Tr("http_client_init_failed", err))
return buildScanReport(state, start), fmt.Errorf("initialize http client: %w", err)
}
// 选择策略
strategy := selectStrategy(config, state, info)
// 并发控制初始化
ch := make(chan struct{}, config.ThreadNum)
wg := sync.WaitGroup{}
// 执行策略
strategy.Execute(ctx, session, info, ch, &wg)
// 等待所有扫描完成
wg.Wait()
// 检查是否有活跃的连接需要维持
if state.IsReverseShellActive() || state.IsSocks5ProxyActive() || state.IsForwardShellActive() {
if state.IsReverseShellActive() {View on GitHub (pinned to 95cc12e753)
Solutions
- Inspect the wrapped inner error (see the %w suffix in the chain) to find the concrete Inithttp failure cause.
- Check proxy configuration (proxy URL format, reachability) and remove/fix it if unnecessary.
- Validate TLS settings: CA file paths exist, cert/key parse, scheme is http/https.
- Compare config struct fields against the current lib.Inithttp signature — remove deprecated options after upgrades.
- Log session errors and retry with default HTTP client settings to isolate the offending option.
Example fix
// before
cfg.Proxy = "http://127.0.0.1:80" // proxy not running
report, err := core.RunScan(cfg)
// after
cfg.Proxy = "" // or a reachable proxy
if err := checkProxyReachable(cfg.Proxy); err != nil { return err }
report, err := core.RunScan(cfg) Defensive patterns
Strategy: try-catch
Validate before calling
if cfg.Proxy != "" {
u, err := url.Parse(cfg.Proxy)
if err != nil || u.Scheme == "" || u.Host == "" {
return fmt.Errorf("invalid proxy URL %q", cfg.Proxy)
}
}
for _, ca := range cfg.CAFiles {
if _, err := os.Stat(ca); err != nil { return err }
} Try / catch
report, err := core.RunScan(config)
if err != nil && strings.HasPrefix(err.Error(), "initialize http client") {
log.Printf("http client init failed: %v", err) // inspect %w chain
return report, err
} Prevention
- Validate proxy URL and TLS/CA settings before scanning
- Verify config fields against the current Inithttp signature after upgrades
- Smoke-test client init with default settings to isolate bad options
When it happens
Trigger: Calling RunScan/runScan/scanOne with a config whose HTTP client settings are invalid — e.g. unreachable or malformed proxy URL, bad certificate/CA configuration, or unsupported client options passed to lib.Inithttp.
Common situations: Proxy env/config pointing at a dead host, self-signed or malformed CA bundles, invalid timeout or dialer options, or config fields changed between versions that Inithttp no longer accepts.
Related errors
- failed to get server public key
- empty certificate chain
- portfinger_probe_file_empty
- parse target failed: %w
- fscan: target cannot set both Host and URL
AI-assisted analysis of shadow1ng/fscan@95cc12e753 (2026-09-06).
Data as JSON: /api/errors/0b8ff4ea35c98958.
Report an issue: GitHub.