{"record":{"id":"d4bbcc5bcc3baab3","repo":"fish2018/pansou","slug":"socks5-w-d4bbcc","errorCode":null,"errorMessage":"创建SOCKS5代理失败: %w","messagePattern":"创建SOCKS5代理失败: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"plugin/gying/gying.go","lineNumber":1640,"sourceCode":"\tif !baseTransportField.IsValid() || baseTransportField.IsNil() {\n\t\treturn fmt.Errorf(\"未找到底层 transport\")\n\t}\n\n\tbaseTransportValue := reflect.NewAt(baseTransportField.Type(), unsafe.Pointer(baseTransportField.UnsafeAddr())).Elem()\n\tbaseTransport, ok := baseTransportValue.Interface().(*http.Transport)\n\tif !ok || baseTransport == nil {\n\t\treturn fmt.Errorf(\"底层 transport 无效\")\n\t}\n\n\tproxyURL, err := url.Parse(config.AppConfig.ProxyURL)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"解析代理地址失败: %w\", err)\n\t}\n\n\tif proxyURL.Scheme == \"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\t\tbaseTransport.Proxy = nil\n\t\tbaseTransport.DialContext = func(ctx context.Context, network, addr string) (net.Conn, error) {\n\t\t\treturn dialer.Dial(network, addr)\n\t\t}\n\t} else {\n\t\tbaseTransport.Proxy = http.ProxyURL(proxyURL)\n\t}\n\n\tif DebugLog {\n\t\tfmt.Printf(\"[Gying] 已应用代理到scraper: %s\\n\", config.AppConfig.ProxyURL)\n\t}\n\n\treturn nil\n}\n\nfunc (p *GyingPlugin) solveBotChallenge(scraper *cloudscraper.Scraper, requestURL string, body []byte) error {\n\tmatches := challengeJSONPattern.FindSubmatch(body)","sourceCodeStart":1622,"sourceCodeEnd":1658,"githubUrl":"https://github.com/fish2018/pansou/blob/beaa56133755a548ebc51b090b3816e2ae044aa6/plugin/gying/gying.go#L1622-L1658","documentation":"If the configured proxy URL has scheme socks5, the plugin calls golang.org/x/net/proxy.FromURL to build a SOCKS5 dialer. FromURL returns an error when it cannot construct the dialer — most commonly an unknown scheme (the socks5 dialer must be registered, e.g. via an import of x/net/proxy/socks5) or invalid embedded credentials — and the plugin wraps it as '创建SOCKS5代理失败: %w'.","triggerScenarios":"ProxyURL scheme is socks5 (or socks5h) and proxy.FromURL fails: typically because the x/net/proxy/socks5 package isn't linked (FromURL returns 'proxy: unknown scheme' for socks5 without a registered dialer), or the userinfo (username/password) in the URL is invalid/undecodable.","commonSituations":"Project missing the blank import _ \"golang.org/x/net/proxy/socks5\"; proxy requires auth and credentials contain characters needing escaping; user set socks5:// but the proxy is actually HTTP; typo like sock5:// handled elsewhere.","solutions":["Ensure the socks5 dialer is registered: import _ \"golang.org/x/net/proxy/socks5\" so proxy.FromURL recognizes the socks5 scheme.","Check the wrapped %w error; if it says unknown scheme, fix the scheme spelling (socks5, not sock5/socks) or register a custom dialer.","URL-encode username/password in the proxy URL (url.QueryEscape) if credentials contain special characters.","If the proxy is actually HTTP, use scheme http:// instead of socks5:// so the non-socks branch builds the transport."],"exampleFix":"// before (dialer unknown)\nimport \"golang.org/x/net/proxy\"\n// after\nimport (\n    \"golang.org/x/net/proxy\"\n    _ \"golang.org/x/net/proxy/socks5\" // registers socks5/socks5h schemes\n)","handlingStrategy":"try-catch","validationCode":"// verify the socks5 dialer is available before configuring the proxy\nif strings.HasPrefix(strings.ToLower(cfg.ProxyURL), \"socks5\") {\n    u, _ := url.Parse(cfg.ProxyURL)\n    if _, err := proxy.FromURL(u, proxy.Direct); err != nil {\n        return fmt.Errorf(\"socks5 dialer unavailable: %w\", err)\n    }\n}","typeGuard":null,"tryCatchPattern":"transport, err := buildProxyTransport(cfg)\nif err != nil && strings.Contains(err.Error(), \"创建SOCKS5代理失败\") {\n    log.Warn(\"SOCKS5 proxy unavailable, using direct connection\")\n    transport, err = buildPlainTransport(cfg)\n}","preventionTips":["Keep the blank import _ \"golang.org/x/net/proxy/socks5\" so proxy.FromURL supports socks5 schemes.","Pin/upgrade golang.org/x/net deliberately and re-test SOCKS5 after upgrades.","Encode proxy auth credentials properly; test with a real socks5 proxy in CI.","Confirm the proxy actually speaks SOCKS5 before setting the socks5:// scheme."],"tags":["proxy","socks5","network","configuration"],"backgroundTag":"proxy-dialer-creation-failed","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"}