MCPcopy
hub / github.com/XTLS/REALITY / hostnameInSNI

Function hostnameInSNI

handshake_client.go:1302–1317  ·  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

1300// Literal IP addresses and absolute FQDNs are not permitted as SNI values.
1301// See RFC 6066, Section 3.
1302func hostnameInSNI(name string) string {
1303 host := name
1304 if len(host) > 0 && host[0] == '[' && host[len(host)-1] == ']' {
1305 host = host[1 : len(host)-1]
1306 }
1307 if i := strings.LastIndex(host, "%"); i > 0 {
1308 host = host[:i]
1309 }
1310 if net.ParseIP(host) != nil {
1311 return ""
1312 }
1313 for len(name) > 0 && name[len(name)-1] == '.' {
1314 name = name[:len(name)-1]
1315 }
1316 return name
1317}
1318
1319func computeAndUpdatePSK(m *clientHelloMsg, binderKey []byte, transcript hash.Hash, finishedHash func([]byte, hash.Hash) []byte) error {
1320 helloBytes, err := m.marshalWithoutBinders()

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…