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)
| 994 | // Literal IP addresses and absolute FQDNs are not permitted as SNI values. |
| 995 | // See RFC 6066, Section 3. |
| 996 | func 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 | } |
no outgoing calls
no test coverage detected
searching dependent graphs…