{"record":{"id":"8ce68e21ac94ca2c","repo":"ginuerzh/gost","slug":"invalid-name","errorCode":null,"errorMessage":"invalid name","messagePattern":"invalid name","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sni.go","lineNumber":340,"sourceCode":"\t}\n\n\treturn buf.Bytes(), host, nil\n}\n\nfunc encodeServerName(name string) string {\n\tbuf := &bytes.Buffer{}\n\tbinary.Write(buf, binary.BigEndian, crc32.ChecksumIEEE([]byte(name)))\n\tbuf.WriteString(base64.RawURLEncoding.EncodeToString([]byte(name)))\n\treturn base64.RawURLEncoding.EncodeToString(buf.Bytes())\n}\n\nfunc decodeServerName(s string) (string, error) {\n\tb, err := base64.RawURLEncoding.DecodeString(s)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\tif len(b) < 4 {\n\t\treturn \"\", errors.New(\"invalid name\")\n\t}\n\tv, err := base64.RawURLEncoding.DecodeString(string(b[4:]))\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\tif crc32.ChecksumIEEE(v) != binary.BigEndian.Uint32(b[:4]) {\n\t\treturn \"\", errors.New(\"invalid name\")\n\t}\n\treturn string(v), nil\n}\n","sourceCodeStart":322,"sourceCodeEnd":351,"githubUrl":"https://github.com/ginuerzh/gost/blob/a33fdbf4c98034f4bfeeaea9868909822b9c526d/sni.go#L322-L351","documentation":"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.","triggerScenarios":"Thrown at sni.go:340 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Regenerate or re-encode the server name with encodeServerName so the 4-byte CRC32 prefix is present","Verify the base64 string was not truncated in transit or by proxy configuration","Check that the raw SNI extension bytes passed to decodeServerName are the exact bytes produced by the encoder"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"a33fdbf4c98034f4bfeeaea9868909822b9c526d","analyzedAt":"2026-09-02T22:15:54.506Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-10T02:17:09.455Z"}