ginuerzh/gost · error

invalid name

Error message

invalid name

What it means

Thrown by decodeServerName in sni.go when a decoded server-name blob is shorter than 4 bytes, i.e. the base64 payload does not carry the 4-byte CRC32 checksum prefix that encodeServerName writes. It is a guard against truncated or corrupted SNI extension data (the routing name embedded in the ClientHello), not a DNS failure.

Source

Thrown at sni.go:340

	}

	return buf.Bytes(), host, nil
}

func encodeServerName(name string) string {
	buf := &bytes.Buffer{}
	binary.Write(buf, binary.BigEndian, crc32.ChecksumIEEE([]byte(name)))
	buf.WriteString(base64.RawURLEncoding.EncodeToString([]byte(name)))
	return base64.RawURLEncoding.EncodeToString(buf.Bytes())
}

func decodeServerName(s string) (string, error) {
	b, err := base64.RawURLEncoding.DecodeString(s)
	if err != nil {
		return "", err
	}
	if len(b) < 4 {
		return "", errors.New("invalid name")
	}
	v, err := base64.RawURLEncoding.DecodeString(string(b[4:]))
	if err != nil {
		return "", err
	}
	if crc32.ChecksumIEEE(v) != binary.BigEndian.Uint32(b[:4]) {
		return "", errors.New("invalid name")
	}
	return string(v), nil
}

View on GitHub (pinned to a33fdbf4c9)

Solutions

  1. Regenerate or re-encode the server name with encodeServerName so the 4-byte CRC32 prefix is present
  2. Verify the base64 string was not truncated in transit or by proxy configuration
  3. Check that the raw SNI extension bytes passed to decodeServerName are the exact bytes produced by the encoder
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at sni.go:340 when the library encounters an invalid state.

Common situations: See trigger scenarios.


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