{"record":{"id":"0eba288fc1150ade","repo":"siyuan-note/siyuan","slug":"agent-http-tools-support-http-https-and-socks5-pr","errorCode":null,"errorMessage":"agent HTTP tools support HTTP, HTTPS and SOCKS5 proxies","messagePattern":"agent HTTP tools support HTTP, HTTPS and SOCKS5 proxies","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/util/httprequest.go","lineNumber":264,"sourceCode":"\t\tresp.Body.Close()\n\t\tconn.Close()\n\t\treturn nil, nil, fmt.Errorf(\"proxy CONNECT returned %s\", resp.Status)\n\t}\n\treturn conn, reader, nil\n}\n\nfunc proxyAddress(proxyURL *url.URL) (string, error) {\n\tport := proxyURL.Port()\n\tif port == \"\" {\n\t\tswitch strings.ToLower(proxyURL.Scheme) {\n\t\tcase \"http\":\n\t\t\tport = \"80\"\n\t\tcase \"https\":\n\t\t\tport = \"443\"\n\t\tcase \"socks5\", \"socks5h\":\n\t\t\tport = \"1080\"\n\t\tdefault:\n\t\t\treturn \"\", errors.New(\"agent HTTP tools support HTTP, HTTPS and SOCKS5 proxies\")\n\t\t}\n\t}\n\treturn net.JoinHostPort(proxyURL.Hostname(), port), nil\n}\n\ntype connectionReadCloser struct {\n\tio.ReadCloser\n\tconn      net.Conn\n\tdone      chan struct{}\n\tcloseOnce sync.Once\n\tcloseErr  error\n}\n\nfunc newConnectionReadCloser(ctx context.Context, body io.ReadCloser, conn net.Conn) *connectionReadCloser {\n\tret := &connectionReadCloser{ReadCloser: body, conn: conn, done: make(chan struct{})}\n\tgo func() {\n\t\tselect {\n\t\tcase <-ctx.Done():","sourceCodeStart":246,"sourceCodeEnd":282,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/8641553a1f07374001902d3ce773285db1292b2d/kernel/util/httprequest.go#L246-L282","documentation":"proxyAddress parses the proxy URL to extract host:port and only accepts http, https, socks5, and socks5h schemes (filling default ports 80/443/1080). Any other scheme yields 'agent HTTP tools support HTTP, HTTPS and SOCKS5 proxies'. It enforces the proxy types the SSRF-safe client supports.","triggerScenarios":"A proxy URL with scheme other than http/https/socks5/socks5h is passed — e.g. `socks4://`, `ftp://`, or a proxy string with no scheme at all (url.Parse leaves Scheme empty, falling into default).","commonSituations":"Users setting SOCKS4 or QUIC proxies in config; copying a proxy address from a provider that omits the scheme (`proxy.corp:8080` instead of `http://proxy.corp:8080`); environment variable ALL_PROXY pointing at an unsupported scheme.","solutions":["Prefix the proxy address with its scheme: `http://`, `https://`, or `socks5://`","Replace SOCKS4/other proxies with a SOCKS5 or HTTP equivalent","Fix the proxy environment variable or app proxy setting to a supported scheme"],"exampleFix":"// before\nproxyURL = \"socks4://proxy.corp:1080\"\n// after\nproxyURL = \"socks5://proxy.corp:1080\"","handlingStrategy":"validation","validationCode":"u, err := url.Parse(proxy)\nif err != nil || (u.Scheme != \"http\" && u.Scheme != \"https\" && u.Scheme != \"socks5\" && u.Scheme != \"socks5h\") {\n    return errors.New(\"proxy must use http://, https://, socks5:// or socks5h://\")\n}","typeGuard":"func isSupportedProxy(raw string) bool {\n    u, err := url.Parse(raw)\n    if err != nil {\n        return false\n    }\n    switch u.Scheme {\n    case \"http\", \"https\", \"socks5\", \"socks5h\":\n        return true\n    }\n    return false\n}","tryCatchPattern":null,"preventionTips":["Always write the scheme explicitly in proxy URLs (http://, https://, socks5://)","Replace SOCKS4 or other exotic proxies with SOCKS5/HTTP equivalents","Audit ALL_PROXY/HTTP_PROXY environment variables for unsupported schemes"],"tags":["proxy","configuration","url"],"backgroundTag":"invalid-config-value","analyzedSha":"8641553a1f07374001902d3ce773285db1292b2d","analyzedAt":"2026-09-11T16:08:28.414Z","contentChangedAt":"2026-09-11T16:08:28.414Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}