{"record":{"id":"dd309747e7d88ba8","repo":"fish2018/pansou","slug":"s-dd3097","errorCode":null,"errorMessage":"不支持的代理协议: %s","messagePattern":"不支持的代理协议: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"util/http_util.go","lineNumber":111,"sourceCode":"\t\t\tclone := *proxyURL\n\t\t\tclone.Scheme = \"socks5\"\n\t\t\tproxyURL = &clone\n\t\t}\n\n\t\t// 创建SOCKS5代理拨号器\n\t\tdialer, err := proxy.FromURL(proxyURL, proxy.Direct)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"SOCKS5代理初始化失败: %w\", err)\n\t\t}\n\n\t\ttransport.DialContext = func(ctx context.Context, network, addr string) (net.Conn, error) {\n\t\t\treturn dialer.Dial(network, addr)\n\t\t}\n\tcase \"http\", \"https\":\n\t\t// HTTP/HTTPS代理\n\t\ttransport.Proxy = http.ProxyURL(proxyURL)\n\tdefault:\n\t\treturn fmt.Errorf(\"不支持的代理协议: %s\", proxyURL.Scheme)\n\t}\n\n\treturn nil\n}\n\n// GetHTTPClient 获取HTTP客户端\nfunc GetHTTPClient() *http.Client {\n\tif httpClient == nil {\n\t\tInitHTTPClient()\n\t}\n\treturn httpClient\n}\n\n// FetchHTML 获取HTML内容\nfunc FetchHTML(targetURL string) (string, error) {\n\t// 使用优化后的HTTP客户端\n\tclient := GetHTTPClient()\n","sourceCodeStart":93,"sourceCodeEnd":129,"githubUrl":"https://github.com/fish2018/pansou/blob/beaa56133755a548ebc51b090b3816e2ae044aa6/util/http_util.go#L93-L129","documentation":"applyProxy only supports socks5/socks5h and http/https proxy schemes; any other scheme reaches the default branch and produces this error naming the unsupported scheme. It is a whitelist validation so misconfigured proxies fail fast instead of silently being ignored.","triggerScenarios":"NewHTTPClient called with a proxy using a scheme like 'ftp://', 'socks4://', 'socks://', or a garbage scheme such as '127.0.0.1' alone (where the host part becomes the scheme after parsing).","commonSituations":"Users configuring SOCKS4 proxies the library does not support; bare 'host:port' values where 'host' is misparsed as a scheme; typos like 'htt://' or 'socks5:// ' variants; copying proxy settings from tools that accept more schemes.","solutions":["Change the proxy scheme to a supported one: 'http', 'https', 'socks5', or 'socks5h'.","If you have a SOCKS4 proxy, switch to a SOCKS5 or HTTP endpoint (most proxy servers offer both).","Fully qualify bare host:port values as 'http://host:port' so the scheme parses correctly.","Check the error's %s value to see what scheme was actually parsed — it often reveals a malformed URL."],"exampleFix":"// before\nclient, err := NewHTTPClient(WithProxy(\"socks4://127.0.0.1:1080\"))\n\n// after\nclient, err := NewHTTPClient(WithProxy(\"socks5://127.0.0.1:1080\"))","handlingStrategy":"validation","validationCode":"allowed := map[string]bool{\"http\": true, \"https\": true, \"socks5\": true, \"socks5h\": true}\nif u, err := url.Parse(cfg.Proxy); err == nil && !allowed[strings.ToLower(u.Scheme)] {\n    return fmt.Errorf(\"unsupported proxy scheme %q\", u.Scheme)\n}","typeGuard":null,"tryCatchPattern":"if err := NewHTTPClient(WithProxy(cfg.Proxy)); err != nil {\n    if strings.Contains(err.Error(), \"不支持的代理协议\") {\n        // switch config to http/https/socks5 scheme\n    }\n    return err\n}","preventionTips":["Only configure http, https, socks5, or socks5h proxies.","Fully qualify proxy URLs so the intended scheme parses as the scheme.","Check the parsed scheme in the error message to diagnose malformed proxy strings."],"tags":["network","proxy","unsupported-scheme","configuration"],"backgroundTag":"unsupported-operation","analyzedSha":"beaa56133755a548ebc51b090b3816e2ae044aa6","analyzedAt":"2026-09-07T00:31:18.025Z","contentChangedAt":"2026-09-07T00:31:18.025Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}