MCPcopy Create free account
hub / github.com/XTLS/Go / hostnameInSNI

Function hostnameInSNI

handshake_client.go:996–1011  ·  view source on GitHub ↗

hostnameInSNI converts name into an appropriate hostname for SNI. Literal IP addresses and absolute FQDNs are not permitted as SNI values. See RFC 6066, Section 3.

(name string)

Source from the content-addressed store, hash-verified

994// Literal IP addresses and absolute FQDNs are not permitted as SNI values.
995// See RFC 6066, Section 3.
996func hostnameInSNI(name string) string {
997 host := name
998 if len(host) > 0 && host[0] == '[' && host[len(host)-1] == ']' {
999 host = host[1 : len(host)-1]
1000 }
1001 if i := strings.LastIndex(host, "%"); i > 0 {
1002 host = host[:i]
1003 }
1004 if net.ParseIP(host) != nil {
1005 return ""
1006 }
1007 for len(name) > 0 && name[len(name)-1] == '.' {
1008 name = name[:len(name)-1]
1009 }
1010 return name
1011}

Callers 1

makeClientHelloMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…