MCPcopy Create free account
hub / github.com/HyBuildNet/quic-relay / parseSNI

Function parseSNI

internal/proxy/parser.go:797–820  ·  view source on GitHub ↗

parseSNI extracts the server name from SNI extension.

(data []byte)

Source from the content-addressed store, hash-verified

795
796// parseSNI extracts the server name from SNI extension.
797func parseSNI(data []byte) string {
798 if len(data) < 5 {
799 return ""
800 }
801
802 // List length (2 bytes)
803 offset := 2
804
805 // Name type (1 byte, should be 0 for hostname)
806 if data[offset] != 0 {
807 return ""
808 }
809 offset++
810
811 // Name length (2 bytes)
812 nameLen := int(data[offset])<<8 | int(data[offset+1])
813 offset += 2
814
815 if offset+nameLen > len(data) {
816 return ""
817 }
818
819 return string(data[offset : offset+nameLen])
820}
821
822// parseALPN extracts protocol names from ALPN extension.
823func parseALPN(data []byte) []string {

Callers 1

parseTLSClientHelloFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected