{"record":{"id":"0b8ff4ea35c98958","repo":"shadow1ng/fscan","slug":"initialize-http-client-w","errorCode":null,"errorMessage":"initialize http client: %w","messagePattern":"initialize http client: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"core/scanner.go","lineNumber":115,"sourceCode":"\tconfig := session.Config\n\n\t// 全局超时：-gt 参数设置整个扫描的硬性截止时间\n\tvar cancel context.CancelFunc\n\tif config.GlobalTimeout > 0 {\n\t\tctx, cancel = context.WithTimeout(ctx, config.GlobalTimeout)\n\t} else {\n\t\tctx, cancel = context.WithCancel(ctx)\n\t}\n\tdefer cancel()\n\tstate := session.State\n\n\t// 设置全局 State（兼容旧代码路径中未传 state 的调用）\n\tSetGlobalState(state)\n\n\t// 初始化HTTP客户端（静默，无需日志）\n\tif err := lib.Inithttp(config); err != nil {\n\t\tsession.LogError(i18n.Tr(\"http_client_init_failed\", err))\n\t\treturn buildScanReport(state, start), fmt.Errorf(\"initialize http client: %w\", err)\n\t}\n\n\t// 选择策略\n\tstrategy := selectStrategy(config, state, info)\n\n\t// 并发控制初始化\n\tch := make(chan struct{}, config.ThreadNum)\n\twg := sync.WaitGroup{}\n\n\t// 执行策略\n\tstrategy.Execute(ctx, session, info, ch, &wg)\n\n\t// 等待所有扫描完成\n\twg.Wait()\n\n\t// 检查是否有活跃的连接需要维持\n\tif state.IsReverseShellActive() || state.IsSocks5ProxyActive() || state.IsForwardShellActive() {\n\t\tif state.IsReverseShellActive() {","sourceCodeStart":97,"sourceCodeEnd":133,"githubUrl":"https://github.com/shadow1ng/fscan/blob/95cc12e753bf43de7004e5aef42a9ffba3934303/core/scanner.go#L97-L133","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\ncfg.Proxy = \"http://127.0.0.1:80\" // proxy not running\nreport, err := core.RunScan(cfg)\n// after\ncfg.Proxy = \"\" // or a reachable proxy\nif err := checkProxyReachable(cfg.Proxy); err != nil { return err }\nreport, err := core.RunScan(cfg)","handlingStrategy":"try-catch","validationCode":"if cfg.Proxy != \"\" {\n    u, err := url.Parse(cfg.Proxy)\n    if err != nil || u.Scheme == \"\" || u.Host == \"\" {\n        return fmt.Errorf(\"invalid proxy URL %q\", cfg.Proxy)\n    }\n}\nfor _, ca := range cfg.CAFiles {\n    if _, err := os.Stat(ca); err != nil { return err }\n}","typeGuard":null,"tryCatchPattern":"report, err := core.RunScan(config)\nif err != nil && strings.HasPrefix(err.Error(), \"initialize http client\") {\n    log.Printf(\"http client init failed: %v\", err) // inspect %w chain\n    return report, err\n}","preventionTips":["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"],"tags":["http-client","init","proxy","tls","scanner"],"backgroundTag":"module-init-failed","analyzedSha":"95cc12e753bf43de7004e5aef42a9ffba3934303","analyzedAt":"2026-09-06T17:07:30.094Z","contentChangedAt":"2026-09-06T17:07:30.094Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}