{"record":{"id":"73162f0254aaa756","repo":"ginuerzh/gost","slug":"s-unsupported-73162f","errorCode":null,"errorMessage":"%s unsupported","messagePattern":"(.+?) unsupported","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sni.go","lineNumber":41,"sourceCode":")\n\ntype sniConnector struct {\n\thost string\n}\n\n// SNIConnector creates a Connector for SNI proxy client.\nfunc SNIConnector(host string) Connector {\n\treturn &sniConnector{host: host}\n}\n\nfunc (c *sniConnector) 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 *sniConnector) 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\treturn &sniClientConn{addr: address, host: c.host, Conn: conn}, nil\n}\n\ntype sniHandler struct {\n\toptions *HandlerOptions\n}\n\n// SNIHandler creates a server Handler for SNI proxy server.\nfunc SNIHandler(opts ...HandlerOption) Handler {\n\th := &sniHandler{}\n\th.Init(opts...)\n\n\treturn h\n}\n\nfunc (h *sniHandler) Init(options ...HandlerOption) {","sourceCodeStart":23,"sourceCodeEnd":59,"githubUrl":"https://github.com/ginuerzh/gost/blob/a33fdbf4c98034f4bfeeaea9868909822b9c526d/sni.go#L23-L59","documentation":"The SNI connector's ConnectContext (sni.go:41) rejects any network type other than TCP. SNI (Server Name Indication) tunneling is implemented over TCP streams only, so passing \"udp\", \"udp4\", or \"udp6\" returns this error immediately without attempting a connection.","triggerScenarios":"Calling sniConnector.ConnectContext (directly or via the convenience Connect wrapper) with network set to \"udp\", \"udp4\", or \"udp6\" instead of \"tcp\"/\"tcp4\"/\"tcp6\" or an empty string.","commonSituations":"Configuring a proxy chain where a UDP-based protocol is routed through the SNI connector; code that iterates network types generically (\"tcp\", \"udp\") and hits the SNI hop; typos like \"UDP\" capitalized elsewhere that fall through to a UDP default upstream; misunderstanding SNI as a general-purpose transport.","solutions":["Pass \"tcp\" (or \"tcp4\"/\"tcp6\") as the network argument when using the SNI connector","Remove the SNI connector from any path that must carry UDP traffic and use a UDP-capable connector instead","Normalize/validate the network string at the call site before dialing so it cannot be a UDP variant"],"exampleFix":"// before\nconn, err := connector.ConnectContext(ctx, rawConn, \"udp\", \"example.com:443\") // %s unsupported\n// after\nconn, err := connector.ConnectContext(ctx, rawConn, \"tcp\", \"example.com:443\")","handlingStrategy":"validation","validationCode":"func validateSNINetwork(network string) error {\n    switch network {\n    case \"\", \"tcp\", \"tcp4\", \"tcp6\":\n        return nil\n    default:\n        return fmt.Errorf(\"SNI connector requires TCP, got %q\", network)\n    }\n}\n// call before ConnectContext\nif err := validateSNINetwork(network); err != nil { return err }","typeGuard":"func isTCPNetwork(network string) bool {\n    return network == \"\" || network == \"tcp\" || network == \"tcp4\" || network == \"tcp6\"\n}","tryCatchPattern":"conn, err := sniConnector.ConnectContext(ctx, rawConn, network, addr)\nif err != nil {\n    if strings.Contains(err.Error(), \" unsupported\") {\n        return fmt.Errorf(\"SNI does not support %q; use tcp or a UDP-capable connector\", network)\n    }\n    return err\n}","preventionTips":["Only route TCP dials through the SNI connector","Normalize network strings (lowercase, default to \"tcp\") before dialing","Audit proxy-chain configuration so UDP hops never land on the SNI connector","If you need UDP, pick a connector that supports it instead of forcing SNI"],"tags":["network","udp","tcp","sni","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"}