ginuerzh/gost · error

%s unsupported

Error message

%s unsupported

What it means

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).

Source

Thrown at socks.go:299

type socks5BindConnector struct {
	User *url.Userinfo
}

// SOCKS5BindConnector creates a connector for SOCKS5 bind.
// It accepts an optional auth info for SOCKS5 Username/Password Authentication.
func SOCKS5BindConnector(user *url.Userinfo) Connector {
	return &socks5BindConnector{User: user}
}

func (c *socks5BindConnector) Connect(conn net.Conn, address string, options ...ConnectOption) (net.Conn, error) {
	return c.ConnectContext(context.Background(), conn, "tcp", address, options...)
}

func (c *socks5BindConnector) ConnectContext(ctx context.Context, conn net.Conn, network, address string, options ...ConnectOption) (net.Conn, error) {
	switch network {
	case "udp", "udp4", "udp6":
		return nil, fmt.Errorf("%s unsupported", network)
	}

	opts := &ConnectOptions{}
	for _, option := range options {
		option(opts)
	}

	timeout := opts.Timeout
	if timeout <= 0 {
		timeout = ConnectTimeout
	}

	conn.SetDeadline(time.Now().Add(timeout))
	defer conn.SetDeadline(time.Time{})

	user := opts.User
	if user == nil {
		user = c.User

View on GitHub (pinned to a33fdbf4c9)

Solutions

  1. Pass "tcp" (or "tcp4"/"tcp6") as the network argument for the SOCKS5 BIND connector
  2. Use the SOCKS5 UDP ASSOCIATE flow (or a UDP-capable connector) for UDP traffic instead of BIND
  3. Validate/normalize the network string at the call site before selecting the connector

Example fix

// before
conn, err := bindConnector.ConnectContext(ctx, ctrlConn, "udp6", "target:9999") // %s unsupported
// after
conn, err := bindConnector.ConnectContext(ctx, ctrlConn, "tcp", "target:9999")
Defensive patterns

Strategy: validation

Validate before calling

func validateBindNetwork(network string) error {
    switch network {
    case "", "tcp", "tcp4", "tcp6":
        return nil
    default:
        return fmt.Errorf("SOCKS5 BIND requires TCP, got %q", network)
    }
}
// call before ConnectContext
if err := validateBindNetwork(network); err != nil { return err }

Type guard

func isTCPNetwork(network string) bool {
    return network == "" || network == "tcp" || network == "tcp4" || network == "tcp6"
}

Try / catch

conn, err := bindConnector.ConnectContext(ctx, ctrlConn, network, addr)
if err != nil {
    if strings.Contains(err.Error(), " unsupported") {
        return fmt.Errorf("SOCKS5 BIND does not support %q; use tcp or the UDP ASSOCIATE flow", network)
    }
    return err
}

Prevention

When it happens

Trigger: Calling socks5BindConnector.ConnectContext (directly or via the Connect wrapper) with network set to "udp", "udp4", or "udp6" instead of a TCP variant.

Common situations: 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.

Related errors


AI-assisted analysis of ginuerzh/gost@a33fdbf4c9 (2026-09-02). Data as JSON: /api/errors/c33ea8d272939613. Report an issue: GitHub.