{"record":{"id":"c33ea8d272939613","repo":"ginuerzh/gost","slug":"s-unsupported-c33ea8","errorCode":null,"errorMessage":"%s unsupported","messagePattern":"(.+?) unsupported","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"socks.go","lineNumber":299,"sourceCode":"\ntype socks5BindConnector struct {\n\tUser *url.Userinfo\n}\n\n// SOCKS5BindConnector creates a connector for SOCKS5 bind.\n// It accepts an optional auth info for SOCKS5 Username/Password Authentication.\nfunc SOCKS5BindConnector(user *url.Userinfo) Connector {\n\treturn &socks5BindConnector{User: user}\n}\n\nfunc (c *socks5BindConnector) Connect(conn net.Conn, address string, options ...ConnectOption) (net.Conn, error) {\n\treturn c.ConnectContext(context.Background(), conn, \"tcp\", address, options...)\n}\n\nfunc (c *socks5BindConnector) ConnectContext(ctx context.Context, conn net.Conn, network, address string, options ...ConnectOption) (net.Conn, error) {\n\tswitch network {\n\tcase \"udp\", \"udp4\", \"udp6\":\n\t\treturn nil, fmt.Errorf(\"%s unsupported\", network)\n\t}\n\n\topts := &ConnectOptions{}\n\tfor _, option := range options {\n\t\toption(opts)\n\t}\n\n\ttimeout := opts.Timeout\n\tif timeout <= 0 {\n\t\ttimeout = ConnectTimeout\n\t}\n\n\tconn.SetDeadline(time.Now().Add(timeout))\n\tdefer conn.SetDeadline(time.Time{})\n\n\tuser := opts.User\n\tif user == nil {\n\t\tuser = c.User","sourceCodeStart":281,"sourceCodeEnd":317,"githubUrl":"https://github.com/ginuerzh/gost/blob/a33fdbf4c98034f4bfeeaea9868909822b9c526d/socks.go#L281-L317","documentation":"The SOCKS5 BIND connector's ConnectContext (socks.go:299) rejects any network type other than TCP. SOCKS5 BIND operations run over TCP streams, so passing \"udp\", \"udp4\", or \"udp6\" returns this error before any SOCKS negotiation begins (UDP ASSOCIATE is a separate SOCKS5 command not handled here).","triggerScenarios":"Calling socks5BindConnector.ConnectContext (directly or via the Connect wrapper) with network set to \"udp\", \"udp4\", or \"udp6\" instead of a TCP variant.","commonSituations":"Trying to do UDP relay through the SOCKS5 BIND connector instead of the UDP ASSOCIATE path; generic dialer code that tries both tcp and udp through the same connector chain; misconfiguration of a proxy chain that routes UDP traffic to a TCP-only BIND hop.","solutions":["Pass \"tcp\" (or \"tcp4\"/\"tcp6\") as the network argument for the SOCKS5 BIND connector","Use the SOCKS5 UDP ASSOCIATE flow (or a UDP-capable connector) for UDP traffic instead of BIND","Validate/normalize the network string at the call site before selecting the connector"],"exampleFix":"// before\nconn, err := bindConnector.ConnectContext(ctx, ctrlConn, \"udp6\", \"target:9999\") // %s unsupported\n// after\nconn, err := bindConnector.ConnectContext(ctx, ctrlConn, \"tcp\", \"target:9999\")","handlingStrategy":"validation","validationCode":"func validateBindNetwork(network string) error {\n    switch network {\n    case \"\", \"tcp\", \"tcp4\", \"tcp6\":\n        return nil\n    default:\n        return fmt.Errorf(\"SOCKS5 BIND requires TCP, got %q\", network)\n    }\n}\n// call before ConnectContext\nif err := validateBindNetwork(network); err != nil { return err }","typeGuard":"func isTCPNetwork(network string) bool {\n    return network == \"\" || network == \"tcp\" || network == \"tcp4\" || network == \"tcp6\"\n}","tryCatchPattern":"conn, err := bindConnector.ConnectContext(ctx, ctrlConn, network, addr)\nif err != nil {\n    if strings.Contains(err.Error(), \" unsupported\") {\n        return fmt.Errorf(\"SOCKS5 BIND does not support %q; use tcp or the UDP ASSOCIATE flow\", network)\n    }\n    return err\n}","preventionTips":["Only issue BIND requests over TCP control connections","Use the SOCKS5 UDP ASSOCIATE command/connector for UDP relay needs","Lowercase and normalize the network argument before dialing","Keep connector selection driven by the network type so UDP traffic never reaches TCP-only connectors"],"tags":["network","udp","tcp","socks5","go"],"backgroundTag":"unsupported-network-type","analyzedSha":"a33fdbf4c98034f4bfeeaea9868909822b9c526d","analyzedAt":"2026-09-02T22:15:54.506Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-10T02:17:09.455Z"}