Configure http2 with higher maxconcurrent streams (#7363)
This value is needed for Minio's internode communication, read the meaning of this value as per the HTTP 2.0 spec https://http2.github.io/http2-spec/#rfc.section.5.1.2master
parent
a0ee7be050
commit
233824bf92
@ -0,0 +1,641 @@ |
||||
// Copyright 2017 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package http2 |
||||
|
||||
// A list of the possible cipher suite ids. Taken from
|
||||
// https://www.iana.org/assignments/tls-parameters/tls-parameters.txt
|
||||
|
||||
const ( |
||||
cipher_TLS_NULL_WITH_NULL_NULL uint16 = 0x0000 |
||||
cipher_TLS_RSA_WITH_NULL_MD5 uint16 = 0x0001 |
||||
cipher_TLS_RSA_WITH_NULL_SHA uint16 = 0x0002 |
||||
cipher_TLS_RSA_EXPORT_WITH_RC4_40_MD5 uint16 = 0x0003 |
||||
cipher_TLS_RSA_WITH_RC4_128_MD5 uint16 = 0x0004 |
||||
cipher_TLS_RSA_WITH_RC4_128_SHA uint16 = 0x0005 |
||||
cipher_TLS_RSA_EXPORT_WITH_RC2_CBC_40_MD5 uint16 = 0x0006 |
||||
cipher_TLS_RSA_WITH_IDEA_CBC_SHA uint16 = 0x0007 |
||||
cipher_TLS_RSA_EXPORT_WITH_DES40_CBC_SHA uint16 = 0x0008 |
||||
cipher_TLS_RSA_WITH_DES_CBC_SHA uint16 = 0x0009 |
||||
cipher_TLS_RSA_WITH_3DES_EDE_CBC_SHA uint16 = 0x000A |
||||
cipher_TLS_DH_DSS_EXPORT_WITH_DES40_CBC_SHA uint16 = 0x000B |
||||
cipher_TLS_DH_DSS_WITH_DES_CBC_SHA uint16 = 0x000C |
||||
cipher_TLS_DH_DSS_WITH_3DES_EDE_CBC_SHA uint16 = 0x000D |
||||
cipher_TLS_DH_RSA_EXPORT_WITH_DES40_CBC_SHA uint16 = 0x000E |
||||
cipher_TLS_DH_RSA_WITH_DES_CBC_SHA uint16 = 0x000F |
||||
cipher_TLS_DH_RSA_WITH_3DES_EDE_CBC_SHA uint16 = 0x0010 |
||||
cipher_TLS_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA uint16 = 0x0011 |
||||
cipher_TLS_DHE_DSS_WITH_DES_CBC_SHA uint16 = 0x0012 |
||||
cipher_TLS_DHE_DSS_WITH_3DES_EDE_CBC_SHA uint16 = 0x0013 |
||||
cipher_TLS_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA uint16 = 0x0014 |
||||
cipher_TLS_DHE_RSA_WITH_DES_CBC_SHA uint16 = 0x0015 |
||||
cipher_TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA uint16 = 0x0016 |
||||
cipher_TLS_DH_anon_EXPORT_WITH_RC4_40_MD5 uint16 = 0x0017 |
||||
cipher_TLS_DH_anon_WITH_RC4_128_MD5 uint16 = 0x0018 |
||||
cipher_TLS_DH_anon_EXPORT_WITH_DES40_CBC_SHA uint16 = 0x0019 |
||||
cipher_TLS_DH_anon_WITH_DES_CBC_SHA uint16 = 0x001A |
||||
cipher_TLS_DH_anon_WITH_3DES_EDE_CBC_SHA uint16 = 0x001B |
||||
// Reserved uint16 = 0x001C-1D
|
||||
cipher_TLS_KRB5_WITH_DES_CBC_SHA uint16 = 0x001E |
||||
cipher_TLS_KRB5_WITH_3DES_EDE_CBC_SHA uint16 = 0x001F |
||||
cipher_TLS_KRB5_WITH_RC4_128_SHA uint16 = 0x0020 |
||||
cipher_TLS_KRB5_WITH_IDEA_CBC_SHA uint16 = 0x0021 |
||||
cipher_TLS_KRB5_WITH_DES_CBC_MD5 uint16 = 0x0022 |
||||
cipher_TLS_KRB5_WITH_3DES_EDE_CBC_MD5 uint16 = 0x0023 |
||||
cipher_TLS_KRB5_WITH_RC4_128_MD5 uint16 = 0x0024 |
||||
cipher_TLS_KRB5_WITH_IDEA_CBC_MD5 uint16 = 0x0025 |
||||
cipher_TLS_KRB5_EXPORT_WITH_DES_CBC_40_SHA uint16 = 0x0026 |
||||
cipher_TLS_KRB5_EXPORT_WITH_RC2_CBC_40_SHA uint16 = 0x0027 |
||||
cipher_TLS_KRB5_EXPORT_WITH_RC4_40_SHA uint16 = 0x0028 |
||||
cipher_TLS_KRB5_EXPORT_WITH_DES_CBC_40_MD5 uint16 = 0x0029 |
||||
cipher_TLS_KRB5_EXPORT_WITH_RC2_CBC_40_MD5 uint16 = 0x002A |
||||
cipher_TLS_KRB5_EXPORT_WITH_RC4_40_MD5 uint16 = 0x002B |
||||
cipher_TLS_PSK_WITH_NULL_SHA uint16 = 0x002C |
||||
cipher_TLS_DHE_PSK_WITH_NULL_SHA uint16 = 0x002D |
||||
cipher_TLS_RSA_PSK_WITH_NULL_SHA uint16 = 0x002E |
||||
cipher_TLS_RSA_WITH_AES_128_CBC_SHA uint16 = 0x002F |
||||
cipher_TLS_DH_DSS_WITH_AES_128_CBC_SHA uint16 = 0x0030 |
||||
cipher_TLS_DH_RSA_WITH_AES_128_CBC_SHA uint16 = 0x0031 |
||||
cipher_TLS_DHE_DSS_WITH_AES_128_CBC_SHA uint16 = 0x0032 |
||||
cipher_TLS_DHE_RSA_WITH_AES_128_CBC_SHA uint16 = 0x0033 |
||||
cipher_TLS_DH_anon_WITH_AES_128_CBC_SHA uint16 = 0x0034 |
||||
cipher_TLS_RSA_WITH_AES_256_CBC_SHA uint16 = 0x0035 |
||||
cipher_TLS_DH_DSS_WITH_AES_256_CBC_SHA uint16 = 0x0036 |
||||
cipher_TLS_DH_RSA_WITH_AES_256_CBC_SHA uint16 = 0x0037 |
||||
cipher_TLS_DHE_DSS_WITH_AES_256_CBC_SHA uint16 = 0x0038 |
||||
cipher_TLS_DHE_RSA_WITH_AES_256_CBC_SHA uint16 = 0x0039 |
||||
cipher_TLS_DH_anon_WITH_AES_256_CBC_SHA uint16 = 0x003A |
||||
cipher_TLS_RSA_WITH_NULL_SHA256 uint16 = 0x003B |
||||
cipher_TLS_RSA_WITH_AES_128_CBC_SHA256 uint16 = 0x003C |
||||
cipher_TLS_RSA_WITH_AES_256_CBC_SHA256 uint16 = 0x003D |
||||
cipher_TLS_DH_DSS_WITH_AES_128_CBC_SHA256 uint16 = 0x003E |
||||
cipher_TLS_DH_RSA_WITH_AES_128_CBC_SHA256 uint16 = 0x003F |
||||
cipher_TLS_DHE_DSS_WITH_AES_128_CBC_SHA256 uint16 = 0x0040 |
||||
cipher_TLS_RSA_WITH_CAMELLIA_128_CBC_SHA uint16 = 0x0041 |
||||
cipher_TLS_DH_DSS_WITH_CAMELLIA_128_CBC_SHA uint16 = 0x0042 |
||||
cipher_TLS_DH_RSA_WITH_CAMELLIA_128_CBC_SHA uint16 = 0x0043 |
||||
cipher_TLS_DHE_DSS_WITH_CAMELLIA_128_CBC_SHA uint16 = 0x0044 |
||||
cipher_TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA uint16 = 0x0045 |
||||
cipher_TLS_DH_anon_WITH_CAMELLIA_128_CBC_SHA uint16 = 0x0046 |
||||
// Reserved uint16 = 0x0047-4F
|
||||
// Reserved uint16 = 0x0050-58
|
||||
// Reserved uint16 = 0x0059-5C
|
||||
// Unassigned uint16 = 0x005D-5F
|
||||
// Reserved uint16 = 0x0060-66
|
||||
cipher_TLS_DHE_RSA_WITH_AES_128_CBC_SHA256 uint16 = 0x0067 |
||||
cipher_TLS_DH_DSS_WITH_AES_256_CBC_SHA256 uint16 = 0x0068 |
||||
cipher_TLS_DH_RSA_WITH_AES_256_CBC_SHA256 uint16 = 0x0069 |
||||
cipher_TLS_DHE_DSS_WITH_AES_256_CBC_SHA256 uint16 = 0x006A |
||||
cipher_TLS_DHE_RSA_WITH_AES_256_CBC_SHA256 uint16 = 0x006B |
||||
cipher_TLS_DH_anon_WITH_AES_128_CBC_SHA256 uint16 = 0x006C |
||||
cipher_TLS_DH_anon_WITH_AES_256_CBC_SHA256 uint16 = 0x006D |
||||
// Unassigned uint16 = 0x006E-83
|
||||
cipher_TLS_RSA_WITH_CAMELLIA_256_CBC_SHA uint16 = 0x0084 |
||||
cipher_TLS_DH_DSS_WITH_CAMELLIA_256_CBC_SHA uint16 = 0x0085 |
||||
cipher_TLS_DH_RSA_WITH_CAMELLIA_256_CBC_SHA uint16 = 0x0086 |
||||
cipher_TLS_DHE_DSS_WITH_CAMELLIA_256_CBC_SHA uint16 = 0x0087 |
||||
cipher_TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA uint16 = 0x0088 |
||||
cipher_TLS_DH_anon_WITH_CAMELLIA_256_CBC_SHA uint16 = 0x0089 |
||||
cipher_TLS_PSK_WITH_RC4_128_SHA uint16 = 0x008A |
||||
cipher_TLS_PSK_WITH_3DES_EDE_CBC_SHA uint16 = 0x008B |
||||
cipher_TLS_PSK_WITH_AES_128_CBC_SHA uint16 = 0x008C |
||||
cipher_TLS_PSK_WITH_AES_256_CBC_SHA uint16 = 0x008D |
||||
cipher_TLS_DHE_PSK_WITH_RC4_128_SHA uint16 = 0x008E |
||||
cipher_TLS_DHE_PSK_WITH_3DES_EDE_CBC_SHA uint16 = 0x008F |
||||
cipher_TLS_DHE_PSK_WITH_AES_128_CBC_SHA uint16 = 0x0090 |
||||
cipher_TLS_DHE_PSK_WITH_AES_256_CBC_SHA uint16 = 0x0091 |
||||
cipher_TLS_RSA_PSK_WITH_RC4_128_SHA uint16 = 0x0092 |
||||
cipher_TLS_RSA_PSK_WITH_3DES_EDE_CBC_SHA uint16 = 0x0093 |
||||
cipher_TLS_RSA_PSK_WITH_AES_128_CBC_SHA uint16 = 0x0094 |
||||
cipher_TLS_RSA_PSK_WITH_AES_256_CBC_SHA uint16 = 0x0095 |
||||
cipher_TLS_RSA_WITH_SEED_CBC_SHA uint16 = 0x0096 |
||||
cipher_TLS_DH_DSS_WITH_SEED_CBC_SHA uint16 = 0x0097 |
||||
cipher_TLS_DH_RSA_WITH_SEED_CBC_SHA uint16 = 0x0098 |
||||
cipher_TLS_DHE_DSS_WITH_SEED_CBC_SHA uint16 = 0x0099 |
||||
cipher_TLS_DHE_RSA_WITH_SEED_CBC_SHA uint16 = 0x009A |
||||
cipher_TLS_DH_anon_WITH_SEED_CBC_SHA uint16 = 0x009B |
||||
cipher_TLS_RSA_WITH_AES_128_GCM_SHA256 uint16 = 0x009C |
||||
cipher_TLS_RSA_WITH_AES_256_GCM_SHA384 uint16 = 0x009D |
||||
cipher_TLS_DHE_RSA_WITH_AES_128_GCM_SHA256 uint16 = 0x009E |
||||
cipher_TLS_DHE_RSA_WITH_AES_256_GCM_SHA384 uint16 = 0x009F |
||||
cipher_TLS_DH_RSA_WITH_AES_128_GCM_SHA256 uint16 = 0x00A0 |
||||
cipher_TLS_DH_RSA_WITH_AES_256_GCM_SHA384 uint16 = 0x00A1 |
||||
cipher_TLS_DHE_DSS_WITH_AES_128_GCM_SHA256 uint16 = 0x00A2 |
||||
cipher_TLS_DHE_DSS_WITH_AES_256_GCM_SHA384 uint16 = 0x00A3 |
||||
cipher_TLS_DH_DSS_WITH_AES_128_GCM_SHA256 uint16 = 0x00A4 |
||||
cipher_TLS_DH_DSS_WITH_AES_256_GCM_SHA384 uint16 = 0x00A5 |
||||
cipher_TLS_DH_anon_WITH_AES_128_GCM_SHA256 uint16 = 0x00A6 |
||||
cipher_TLS_DH_anon_WITH_AES_256_GCM_SHA384 uint16 = 0x00A7 |
||||
cipher_TLS_PSK_WITH_AES_128_GCM_SHA256 uint16 = 0x00A8 |
||||
cipher_TLS_PSK_WITH_AES_256_GCM_SHA384 uint16 = 0x00A9 |
||||
cipher_TLS_DHE_PSK_WITH_AES_128_GCM_SHA256 uint16 = 0x00AA |
||||
cipher_TLS_DHE_PSK_WITH_AES_256_GCM_SHA384 uint16 = 0x00AB |
||||
cipher_TLS_RSA_PSK_WITH_AES_128_GCM_SHA256 uint16 = 0x00AC |
||||
cipher_TLS_RSA_PSK_WITH_AES_256_GCM_SHA384 uint16 = 0x00AD |
||||
cipher_TLS_PSK_WITH_AES_128_CBC_SHA256 uint16 = 0x00AE |
||||
cipher_TLS_PSK_WITH_AES_256_CBC_SHA384 uint16 = 0x00AF |
||||
cipher_TLS_PSK_WITH_NULL_SHA256 uint16 = 0x00B0 |
||||
cipher_TLS_PSK_WITH_NULL_SHA384 uint16 = 0x00B1 |
||||
cipher_TLS_DHE_PSK_WITH_AES_128_CBC_SHA256 uint16 = 0x00B2 |
||||
cipher_TLS_DHE_PSK_WITH_AES_256_CBC_SHA384 uint16 = 0x00B3 |
||||
cipher_TLS_DHE_PSK_WITH_NULL_SHA256 uint16 = 0x00B4 |
||||
cipher_TLS_DHE_PSK_WITH_NULL_SHA384 uint16 = 0x00B5 |
||||
cipher_TLS_RSA_PSK_WITH_AES_128_CBC_SHA256 uint16 = 0x00B6 |
||||
cipher_TLS_RSA_PSK_WITH_AES_256_CBC_SHA384 uint16 = 0x00B7 |
||||
cipher_TLS_RSA_PSK_WITH_NULL_SHA256 uint16 = 0x00B8 |
||||
cipher_TLS_RSA_PSK_WITH_NULL_SHA384 uint16 = 0x00B9 |
||||
cipher_TLS_RSA_WITH_CAMELLIA_128_CBC_SHA256 uint16 = 0x00BA |
||||
cipher_TLS_DH_DSS_WITH_CAMELLIA_128_CBC_SHA256 uint16 = 0x00BB |
||||
cipher_TLS_DH_RSA_WITH_CAMELLIA_128_CBC_SHA256 uint16 = 0x00BC |
||||
cipher_TLS_DHE_DSS_WITH_CAMELLIA_128_CBC_SHA256 uint16 = 0x00BD |
||||
cipher_TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA256 uint16 = 0x00BE |
||||
cipher_TLS_DH_anon_WITH_CAMELLIA_128_CBC_SHA256 uint16 = 0x00BF |
||||
cipher_TLS_RSA_WITH_CAMELLIA_256_CBC_SHA256 uint16 = 0x00C0 |
||||
cipher_TLS_DH_DSS_WITH_CAMELLIA_256_CBC_SHA256 uint16 = 0x00C1 |
||||
cipher_TLS_DH_RSA_WITH_CAMELLIA_256_CBC_SHA256 uint16 = 0x00C2 |
||||
cipher_TLS_DHE_DSS_WITH_CAMELLIA_256_CBC_SHA256 uint16 = 0x00C3 |
||||
cipher_TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA256 uint16 = 0x00C4 |
||||
cipher_TLS_DH_anon_WITH_CAMELLIA_256_CBC_SHA256 uint16 = 0x00C5 |
||||
// Unassigned uint16 = 0x00C6-FE
|
||||
cipher_TLS_EMPTY_RENEGOTIATION_INFO_SCSV uint16 = 0x00FF |
||||
// Unassigned uint16 = 0x01-55,*
|
||||
cipher_TLS_FALLBACK_SCSV uint16 = 0x5600 |
||||
// Unassigned uint16 = 0x5601 - 0xC000
|
||||
cipher_TLS_ECDH_ECDSA_WITH_NULL_SHA uint16 = 0xC001 |
||||
cipher_TLS_ECDH_ECDSA_WITH_RC4_128_SHA uint16 = 0xC002 |
||||
cipher_TLS_ECDH_ECDSA_WITH_3DES_EDE_CBC_SHA uint16 = 0xC003 |
||||
cipher_TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA uint16 = 0xC004 |
||||
cipher_TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA uint16 = 0xC005 |
||||
cipher_TLS_ECDHE_ECDSA_WITH_NULL_SHA uint16 = 0xC006 |
||||
cipher_TLS_ECDHE_ECDSA_WITH_RC4_128_SHA uint16 = 0xC007 |
||||
cipher_TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA uint16 = 0xC008 |
||||
cipher_TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA uint16 = 0xC009 |
||||
cipher_TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA uint16 = 0xC00A |
||||
cipher_TLS_ECDH_RSA_WITH_NULL_SHA uint16 = 0xC00B |
||||
cipher_TLS_ECDH_RSA_WITH_RC4_128_SHA uint16 = 0xC00C |
||||
cipher_TLS_ECDH_RSA_WITH_3DES_EDE_CBC_SHA uint16 = 0xC00D |
||||
cipher_TLS_ECDH_RSA_WITH_AES_128_CBC_SHA uint16 = 0xC00E |
||||
cipher_TLS_ECDH_RSA_WITH_AES_256_CBC_SHA uint16 = 0xC00F |
||||
cipher_TLS_ECDHE_RSA_WITH_NULL_SHA uint16 = 0xC010 |
||||
cipher_TLS_ECDHE_RSA_WITH_RC4_128_SHA uint16 = 0xC011 |
||||
cipher_TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA uint16 = 0xC012 |
||||
cipher_TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA uint16 = 0xC013 |
||||
cipher_TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA uint16 = 0xC014 |
||||
cipher_TLS_ECDH_anon_WITH_NULL_SHA uint16 = 0xC015 |
||||
cipher_TLS_ECDH_anon_WITH_RC4_128_SHA uint16 = 0xC016 |
||||
cipher_TLS_ECDH_anon_WITH_3DES_EDE_CBC_SHA uint16 = 0xC017 |
||||
cipher_TLS_ECDH_anon_WITH_AES_128_CBC_SHA uint16 = 0xC018 |
||||
cipher_TLS_ECDH_anon_WITH_AES_256_CBC_SHA uint16 = 0xC019 |
||||
cipher_TLS_SRP_SHA_WITH_3DES_EDE_CBC_SHA uint16 = 0xC01A |
||||
cipher_TLS_SRP_SHA_RSA_WITH_3DES_EDE_CBC_SHA uint16 = 0xC01B |
||||
cipher_TLS_SRP_SHA_DSS_WITH_3DES_EDE_CBC_SHA uint16 = 0xC01C |
||||
cipher_TLS_SRP_SHA_WITH_AES_128_CBC_SHA uint16 = 0xC01D |
||||
cipher_TLS_SRP_SHA_RSA_WITH_AES_128_CBC_SHA uint16 = 0xC01E |
||||
cipher_TLS_SRP_SHA_DSS_WITH_AES_128_CBC_SHA uint16 = 0xC01F |
||||
cipher_TLS_SRP_SHA_WITH_AES_256_CBC_SHA uint16 = 0xC020 |
||||
cipher_TLS_SRP_SHA_RSA_WITH_AES_256_CBC_SHA uint16 = 0xC021 |
||||
cipher_TLS_SRP_SHA_DSS_WITH_AES_256_CBC_SHA uint16 = 0xC022 |
||||
cipher_TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256 uint16 = 0xC023 |
||||
cipher_TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384 uint16 = 0xC024 |
||||
cipher_TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA256 uint16 = 0xC025 |
||||
cipher_TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA384 uint16 = 0xC026 |
||||
cipher_TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256 uint16 = 0xC027 |
||||
cipher_TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384 uint16 = 0xC028 |
||||
cipher_TLS_ECDH_RSA_WITH_AES_128_CBC_SHA256 uint16 = 0xC029 |
||||
cipher_TLS_ECDH_RSA_WITH_AES_256_CBC_SHA384 uint16 = 0xC02A |
||||
cipher_TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256 uint16 = 0xC02B |
||||
cipher_TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384 uint16 = 0xC02C |
||||
cipher_TLS_ECDH_ECDSA_WITH_AES_128_GCM_SHA256 uint16 = 0xC02D |
||||
cipher_TLS_ECDH_ECDSA_WITH_AES_256_GCM_SHA384 uint16 = 0xC02E |
||||
cipher_TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 uint16 = 0xC02F |
||||
cipher_TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 uint16 = 0xC030 |
||||
cipher_TLS_ECDH_RSA_WITH_AES_128_GCM_SHA256 uint16 = 0xC031 |
||||
cipher_TLS_ECDH_RSA_WITH_AES_256_GCM_SHA384 uint16 = 0xC032 |
||||
cipher_TLS_ECDHE_PSK_WITH_RC4_128_SHA uint16 = 0xC033 |
||||
cipher_TLS_ECDHE_PSK_WITH_3DES_EDE_CBC_SHA uint16 = 0xC034 |
||||
cipher_TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA uint16 = 0xC035 |
||||
cipher_TLS_ECDHE_PSK_WITH_AES_256_CBC_SHA uint16 = 0xC036 |
||||
cipher_TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA256 uint16 = 0xC037 |
||||
cipher_TLS_ECDHE_PSK_WITH_AES_256_CBC_SHA384 uint16 = 0xC038 |
||||
cipher_TLS_ECDHE_PSK_WITH_NULL_SHA uint16 = 0xC039 |
||||
cipher_TLS_ECDHE_PSK_WITH_NULL_SHA256 uint16 = 0xC03A |
||||
cipher_TLS_ECDHE_PSK_WITH_NULL_SHA384 uint16 = 0xC03B |
||||
cipher_TLS_RSA_WITH_ARIA_128_CBC_SHA256 uint16 = 0xC03C |
||||
cipher_TLS_RSA_WITH_ARIA_256_CBC_SHA384 uint16 = 0xC03D |
||||
cipher_TLS_DH_DSS_WITH_ARIA_128_CBC_SHA256 uint16 = 0xC03E |
||||
cipher_TLS_DH_DSS_WITH_ARIA_256_CBC_SHA384 uint16 = 0xC03F |
||||
cipher_TLS_DH_RSA_WITH_ARIA_128_CBC_SHA256 uint16 = 0xC040 |
||||
cipher_TLS_DH_RSA_WITH_ARIA_256_CBC_SHA384 uint16 = 0xC041 |
||||
cipher_TLS_DHE_DSS_WITH_ARIA_128_CBC_SHA256 uint16 = 0xC042 |
||||
cipher_TLS_DHE_DSS_WITH_ARIA_256_CBC_SHA384 uint16 = 0xC043 |
||||
cipher_TLS_DHE_RSA_WITH_ARIA_128_CBC_SHA256 uint16 = 0xC044 |
||||
cipher_TLS_DHE_RSA_WITH_ARIA_256_CBC_SHA384 uint16 = 0xC045 |
||||
cipher_TLS_DH_anon_WITH_ARIA_128_CBC_SHA256 uint16 = 0xC046 |
||||
cipher_TLS_DH_anon_WITH_ARIA_256_CBC_SHA384 uint16 = 0xC047 |
||||
cipher_TLS_ECDHE_ECDSA_WITH_ARIA_128_CBC_SHA256 uint16 = 0xC048 |
||||
cipher_TLS_ECDHE_ECDSA_WITH_ARIA_256_CBC_SHA384 uint16 = 0xC049 |
||||
cipher_TLS_ECDH_ECDSA_WITH_ARIA_128_CBC_SHA256 uint16 = 0xC04A |
||||
cipher_TLS_ECDH_ECDSA_WITH_ARIA_256_CBC_SHA384 uint16 = 0xC04B |
||||
cipher_TLS_ECDHE_RSA_WITH_ARIA_128_CBC_SHA256 uint16 = 0xC04C |
||||
cipher_TLS_ECDHE_RSA_WITH_ARIA_256_CBC_SHA384 uint16 = 0xC04D |
||||
cipher_TLS_ECDH_RSA_WITH_ARIA_128_CBC_SHA256 uint16 = 0xC04E |
||||
cipher_TLS_ECDH_RSA_WITH_ARIA_256_CBC_SHA384 uint16 = 0xC04F |
||||
cipher_TLS_RSA_WITH_ARIA_128_GCM_SHA256 uint16 = 0xC050 |
||||
cipher_TLS_RSA_WITH_ARIA_256_GCM_SHA384 uint16 = 0xC051 |
||||
cipher_TLS_DHE_RSA_WITH_ARIA_128_GCM_SHA256 uint16 = 0xC052 |
||||
cipher_TLS_DHE_RSA_WITH_ARIA_256_GCM_SHA384 uint16 = 0xC053 |
||||
cipher_TLS_DH_RSA_WITH_ARIA_128_GCM_SHA256 uint16 = 0xC054 |
||||
cipher_TLS_DH_RSA_WITH_ARIA_256_GCM_SHA384 uint16 = 0xC055 |
||||
cipher_TLS_DHE_DSS_WITH_ARIA_128_GCM_SHA256 uint16 = 0xC056 |
||||
cipher_TLS_DHE_DSS_WITH_ARIA_256_GCM_SHA384 uint16 = 0xC057 |
||||
cipher_TLS_DH_DSS_WITH_ARIA_128_GCM_SHA256 uint16 = 0xC058 |
||||
cipher_TLS_DH_DSS_WITH_ARIA_256_GCM_SHA384 uint16 = 0xC059 |
||||
cipher_TLS_DH_anon_WITH_ARIA_128_GCM_SHA256 uint16 = 0xC05A |
||||
cipher_TLS_DH_anon_WITH_ARIA_256_GCM_SHA384 uint16 = 0xC05B |
||||
cipher_TLS_ECDHE_ECDSA_WITH_ARIA_128_GCM_SHA256 uint16 = 0xC05C |
||||
cipher_TLS_ECDHE_ECDSA_WITH_ARIA_256_GCM_SHA384 uint16 = 0xC05D |
||||
cipher_TLS_ECDH_ECDSA_WITH_ARIA_128_GCM_SHA256 uint16 = 0xC05E |
||||
cipher_TLS_ECDH_ECDSA_WITH_ARIA_256_GCM_SHA384 uint16 = 0xC05F |
||||
cipher_TLS_ECDHE_RSA_WITH_ARIA_128_GCM_SHA256 uint16 = 0xC060 |
||||
cipher_TLS_ECDHE_RSA_WITH_ARIA_256_GCM_SHA384 uint16 = 0xC061 |
||||
cipher_TLS_ECDH_RSA_WITH_ARIA_128_GCM_SHA256 uint16 = 0xC062 |
||||
cipher_TLS_ECDH_RSA_WITH_ARIA_256_GCM_SHA384 uint16 = 0xC063 |
||||
cipher_TLS_PSK_WITH_ARIA_128_CBC_SHA256 uint16 = 0xC064 |
||||
cipher_TLS_PSK_WITH_ARIA_256_CBC_SHA384 uint16 = 0xC065 |
||||
cipher_TLS_DHE_PSK_WITH_ARIA_128_CBC_SHA256 uint16 = 0xC066 |
||||
cipher_TLS_DHE_PSK_WITH_ARIA_256_CBC_SHA384 uint16 = 0xC067 |
||||
cipher_TLS_RSA_PSK_WITH_ARIA_128_CBC_SHA256 uint16 = 0xC068 |
||||
cipher_TLS_RSA_PSK_WITH_ARIA_256_CBC_SHA384 uint16 = 0xC069 |
||||
cipher_TLS_PSK_WITH_ARIA_128_GCM_SHA256 uint16 = 0xC06A |
||||
cipher_TLS_PSK_WITH_ARIA_256_GCM_SHA384 uint16 = 0xC06B |
||||
cipher_TLS_DHE_PSK_WITH_ARIA_128_GCM_SHA256 uint16 = 0xC06C |
||||
cipher_TLS_DHE_PSK_WITH_ARIA_256_GCM_SHA384 uint16 = 0xC06D |
||||
cipher_TLS_RSA_PSK_WITH_ARIA_128_GCM_SHA256 uint16 = 0xC06E |
||||
cipher_TLS_RSA_PSK_WITH_ARIA_256_GCM_SHA384 uint16 = 0xC06F |
||||
cipher_TLS_ECDHE_PSK_WITH_ARIA_128_CBC_SHA256 uint16 = 0xC070 |
||||
cipher_TLS_ECDHE_PSK_WITH_ARIA_256_CBC_SHA384 uint16 = 0xC071 |
||||
cipher_TLS_ECDHE_ECDSA_WITH_CAMELLIA_128_CBC_SHA256 uint16 = 0xC072 |
||||
cipher_TLS_ECDHE_ECDSA_WITH_CAMELLIA_256_CBC_SHA384 uint16 = 0xC073 |
||||
cipher_TLS_ECDH_ECDSA_WITH_CAMELLIA_128_CBC_SHA256 uint16 = 0xC074 |
||||
cipher_TLS_ECDH_ECDSA_WITH_CAMELLIA_256_CBC_SHA384 uint16 = 0xC075 |
||||
cipher_TLS_ECDHE_RSA_WITH_CAMELLIA_128_CBC_SHA256 uint16 = 0xC076 |
||||
cipher_TLS_ECDHE_RSA_WITH_CAMELLIA_256_CBC_SHA384 uint16 = 0xC077 |
||||
cipher_TLS_ECDH_RSA_WITH_CAMELLIA_128_CBC_SHA256 uint16 = 0xC078 |
||||
cipher_TLS_ECDH_RSA_WITH_CAMELLIA_256_CBC_SHA384 uint16 = 0xC079 |
||||
cipher_TLS_RSA_WITH_CAMELLIA_128_GCM_SHA256 uint16 = 0xC07A |
||||
cipher_TLS_RSA_WITH_CAMELLIA_256_GCM_SHA384 uint16 = 0xC07B |
||||
cipher_TLS_DHE_RSA_WITH_CAMELLIA_128_GCM_SHA256 uint16 = 0xC07C |
||||
cipher_TLS_DHE_RSA_WITH_CAMELLIA_256_GCM_SHA384 uint16 = 0xC07D |
||||
cipher_TLS_DH_RSA_WITH_CAMELLIA_128_GCM_SHA256 uint16 = 0xC07E |
||||
cipher_TLS_DH_RSA_WITH_CAMELLIA_256_GCM_SHA384 uint16 = 0xC07F |
||||
cipher_TLS_DHE_DSS_WITH_CAMELLIA_128_GCM_SHA256 uint16 = 0xC080 |
||||
cipher_TLS_DHE_DSS_WITH_CAMELLIA_256_GCM_SHA384 uint16 = 0xC081 |
||||
cipher_TLS_DH_DSS_WITH_CAMELLIA_128_GCM_SHA256 uint16 = 0xC082 |
||||
cipher_TLS_DH_DSS_WITH_CAMELLIA_256_GCM_SHA384 uint16 = 0xC083 |
||||
cipher_TLS_DH_anon_WITH_CAMELLIA_128_GCM_SHA256 uint16 = 0xC084 |
||||
cipher_TLS_DH_anon_WITH_CAMELLIA_256_GCM_SHA384 uint16 = 0xC085 |
||||
cipher_TLS_ECDHE_ECDSA_WITH_CAMELLIA_128_GCM_SHA256 uint16 = 0xC086 |
||||
cipher_TLS_ECDHE_ECDSA_WITH_CAMELLIA_256_GCM_SHA384 uint16 = 0xC087 |
||||
cipher_TLS_ECDH_ECDSA_WITH_CAMELLIA_128_GCM_SHA256 uint16 = 0xC088 |
||||
cipher_TLS_ECDH_ECDSA_WITH_CAMELLIA_256_GCM_SHA384 uint16 = 0xC089 |
||||
cipher_TLS_ECDHE_RSA_WITH_CAMELLIA_128_GCM_SHA256 uint16 = 0xC08A |
||||
cipher_TLS_ECDHE_RSA_WITH_CAMELLIA_256_GCM_SHA384 uint16 = 0xC08B |
||||
cipher_TLS_ECDH_RSA_WITH_CAMELLIA_128_GCM_SHA256 uint16 = 0xC08C |
||||
cipher_TLS_ECDH_RSA_WITH_CAMELLIA_256_GCM_SHA384 uint16 = 0xC08D |
||||
cipher_TLS_PSK_WITH_CAMELLIA_128_GCM_SHA256 uint16 = 0xC08E |
||||
cipher_TLS_PSK_WITH_CAMELLIA_256_GCM_SHA384 uint16 = 0xC08F |
||||
cipher_TLS_DHE_PSK_WITH_CAMELLIA_128_GCM_SHA256 uint16 = 0xC090 |
||||
cipher_TLS_DHE_PSK_WITH_CAMELLIA_256_GCM_SHA384 uint16 = 0xC091 |
||||
cipher_TLS_RSA_PSK_WITH_CAMELLIA_128_GCM_SHA256 uint16 = 0xC092 |
||||
cipher_TLS_RSA_PSK_WITH_CAMELLIA_256_GCM_SHA384 uint16 = 0xC093 |
||||
cipher_TLS_PSK_WITH_CAMELLIA_128_CBC_SHA256 uint16 = 0xC094 |
||||
cipher_TLS_PSK_WITH_CAMELLIA_256_CBC_SHA384 uint16 = 0xC095 |
||||
cipher_TLS_DHE_PSK_WITH_CAMELLIA_128_CBC_SHA256 uint16 = 0xC096 |
||||
cipher_TLS_DHE_PSK_WITH_CAMELLIA_256_CBC_SHA384 uint16 = 0xC097 |
||||
cipher_TLS_RSA_PSK_WITH_CAMELLIA_128_CBC_SHA256 uint16 = 0xC098 |
||||
cipher_TLS_RSA_PSK_WITH_CAMELLIA_256_CBC_SHA384 uint16 = 0xC099 |
||||
cipher_TLS_ECDHE_PSK_WITH_CAMELLIA_128_CBC_SHA256 uint16 = 0xC09A |
||||
cipher_TLS_ECDHE_PSK_WITH_CAMELLIA_256_CBC_SHA384 uint16 = 0xC09B |
||||
cipher_TLS_RSA_WITH_AES_128_CCM uint16 = 0xC09C |
||||
cipher_TLS_RSA_WITH_AES_256_CCM uint16 = 0xC09D |
||||
cipher_TLS_DHE_RSA_WITH_AES_128_CCM uint16 = 0xC09E |
||||
cipher_TLS_DHE_RSA_WITH_AES_256_CCM uint16 = 0xC09F |
||||
cipher_TLS_RSA_WITH_AES_128_CCM_8 uint16 = 0xC0A0 |
||||
cipher_TLS_RSA_WITH_AES_256_CCM_8 uint16 = 0xC0A1 |
||||
cipher_TLS_DHE_RSA_WITH_AES_128_CCM_8 uint16 = 0xC0A2 |
||||
cipher_TLS_DHE_RSA_WITH_AES_256_CCM_8 uint16 = 0xC0A3 |
||||
cipher_TLS_PSK_WITH_AES_128_CCM uint16 = 0xC0A4 |
||||
cipher_TLS_PSK_WITH_AES_256_CCM uint16 = 0xC0A5 |
||||
cipher_TLS_DHE_PSK_WITH_AES_128_CCM uint16 = 0xC0A6 |
||||
cipher_TLS_DHE_PSK_WITH_AES_256_CCM uint16 = 0xC0A7 |
||||
cipher_TLS_PSK_WITH_AES_128_CCM_8 uint16 = 0xC0A8 |
||||
cipher_TLS_PSK_WITH_AES_256_CCM_8 uint16 = 0xC0A9 |
||||
cipher_TLS_PSK_DHE_WITH_AES_128_CCM_8 uint16 = 0xC0AA |
||||
cipher_TLS_PSK_DHE_WITH_AES_256_CCM_8 uint16 = 0xC0AB |
||||
cipher_TLS_ECDHE_ECDSA_WITH_AES_128_CCM uint16 = 0xC0AC |
||||
cipher_TLS_ECDHE_ECDSA_WITH_AES_256_CCM uint16 = 0xC0AD |
||||
cipher_TLS_ECDHE_ECDSA_WITH_AES_128_CCM_8 uint16 = 0xC0AE |
||||
cipher_TLS_ECDHE_ECDSA_WITH_AES_256_CCM_8 uint16 = 0xC0AF |
||||
// Unassigned uint16 = 0xC0B0-FF
|
||||
// Unassigned uint16 = 0xC1-CB,*
|
||||
// Unassigned uint16 = 0xCC00-A7
|
||||
cipher_TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256 uint16 = 0xCCA8 |
||||
cipher_TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256 uint16 = 0xCCA9 |
||||
cipher_TLS_DHE_RSA_WITH_CHACHA20_POLY1305_SHA256 uint16 = 0xCCAA |
||||
cipher_TLS_PSK_WITH_CHACHA20_POLY1305_SHA256 uint16 = 0xCCAB |
||||
cipher_TLS_ECDHE_PSK_WITH_CHACHA20_POLY1305_SHA256 uint16 = 0xCCAC |
||||
cipher_TLS_DHE_PSK_WITH_CHACHA20_POLY1305_SHA256 uint16 = 0xCCAD |
||||
cipher_TLS_RSA_PSK_WITH_CHACHA20_POLY1305_SHA256 uint16 = 0xCCAE |
||||
) |
||||
|
||||
// isBadCipher reports whether the cipher is blacklisted by the HTTP/2 spec.
|
||||
// References:
|
||||
// https://tools.ietf.org/html/rfc7540#appendix-A
|
||||
// Reject cipher suites from Appendix A.
|
||||
// "This list includes those cipher suites that do not
|
||||
// offer an ephemeral key exchange and those that are
|
||||
// based on the TLS null, stream or block cipher type"
|
||||
func isBadCipher(cipher uint16) bool { |
||||
switch cipher { |
||||
case cipher_TLS_NULL_WITH_NULL_NULL, |
||||
cipher_TLS_RSA_WITH_NULL_MD5, |
||||
cipher_TLS_RSA_WITH_NULL_SHA, |
||||
cipher_TLS_RSA_EXPORT_WITH_RC4_40_MD5, |
||||
cipher_TLS_RSA_WITH_RC4_128_MD5, |
||||
cipher_TLS_RSA_WITH_RC4_128_SHA, |
||||
cipher_TLS_RSA_EXPORT_WITH_RC2_CBC_40_MD5, |
||||
cipher_TLS_RSA_WITH_IDEA_CBC_SHA, |
||||
cipher_TLS_RSA_EXPORT_WITH_DES40_CBC_SHA, |
||||
cipher_TLS_RSA_WITH_DES_CBC_SHA, |
||||
cipher_TLS_RSA_WITH_3DES_EDE_CBC_SHA, |
||||
cipher_TLS_DH_DSS_EXPORT_WITH_DES40_CBC_SHA, |
||||
cipher_TLS_DH_DSS_WITH_DES_CBC_SHA, |
||||
cipher_TLS_DH_DSS_WITH_3DES_EDE_CBC_SHA, |
||||
cipher_TLS_DH_RSA_EXPORT_WITH_DES40_CBC_SHA, |
||||
cipher_TLS_DH_RSA_WITH_DES_CBC_SHA, |
||||
cipher_TLS_DH_RSA_WITH_3DES_EDE_CBC_SHA, |
||||
cipher_TLS_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA, |
||||
cipher_TLS_DHE_DSS_WITH_DES_CBC_SHA, |
||||
cipher_TLS_DHE_DSS_WITH_3DES_EDE_CBC_SHA, |
||||
cipher_TLS_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA, |
||||
cipher_TLS_DHE_RSA_WITH_DES_CBC_SHA, |
||||
cipher_TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA, |
||||
cipher_TLS_DH_anon_EXPORT_WITH_RC4_40_MD5, |
||||
cipher_TLS_DH_anon_WITH_RC4_128_MD5, |
||||
cipher_TLS_DH_anon_EXPORT_WITH_DES40_CBC_SHA, |
||||
cipher_TLS_DH_anon_WITH_DES_CBC_SHA, |
||||
cipher_TLS_DH_anon_WITH_3DES_EDE_CBC_SHA, |
||||
cipher_TLS_KRB5_WITH_DES_CBC_SHA, |
||||
cipher_TLS_KRB5_WITH_3DES_EDE_CBC_SHA, |
||||
cipher_TLS_KRB5_WITH_RC4_128_SHA, |
||||
cipher_TLS_KRB5_WITH_IDEA_CBC_SHA, |
||||
cipher_TLS_KRB5_WITH_DES_CBC_MD5, |
||||
cipher_TLS_KRB5_WITH_3DES_EDE_CBC_MD5, |
||||
cipher_TLS_KRB5_WITH_RC4_128_MD5, |
||||
cipher_TLS_KRB5_WITH_IDEA_CBC_MD5, |
||||
cipher_TLS_KRB5_EXPORT_WITH_DES_CBC_40_SHA, |
||||
cipher_TLS_KRB5_EXPORT_WITH_RC2_CBC_40_SHA, |
||||
cipher_TLS_KRB5_EXPORT_WITH_RC4_40_SHA, |
||||
cipher_TLS_KRB5_EXPORT_WITH_DES_CBC_40_MD5, |
||||
cipher_TLS_KRB5_EXPORT_WITH_RC2_CBC_40_MD5, |
||||
cipher_TLS_KRB5_EXPORT_WITH_RC4_40_MD5, |
||||
cipher_TLS_PSK_WITH_NULL_SHA, |
||||
cipher_TLS_DHE_PSK_WITH_NULL_SHA, |
||||
cipher_TLS_RSA_PSK_WITH_NULL_SHA, |
||||
cipher_TLS_RSA_WITH_AES_128_CBC_SHA, |
||||
cipher_TLS_DH_DSS_WITH_AES_128_CBC_SHA, |
||||
cipher_TLS_DH_RSA_WITH_AES_128_CBC_SHA, |
||||
cipher_TLS_DHE_DSS_WITH_AES_128_CBC_SHA, |
||||
cipher_TLS_DHE_RSA_WITH_AES_128_CBC_SHA, |
||||
cipher_TLS_DH_anon_WITH_AES_128_CBC_SHA, |
||||
cipher_TLS_RSA_WITH_AES_256_CBC_SHA, |
||||
cipher_TLS_DH_DSS_WITH_AES_256_CBC_SHA, |
||||
cipher_TLS_DH_RSA_WITH_AES_256_CBC_SHA, |
||||
cipher_TLS_DHE_DSS_WITH_AES_256_CBC_SHA, |
||||
cipher_TLS_DHE_RSA_WITH_AES_256_CBC_SHA, |
||||
cipher_TLS_DH_anon_WITH_AES_256_CBC_SHA, |
||||
cipher_TLS_RSA_WITH_NULL_SHA256, |
||||
cipher_TLS_RSA_WITH_AES_128_CBC_SHA256, |
||||
cipher_TLS_RSA_WITH_AES_256_CBC_SHA256, |
||||
cipher_TLS_DH_DSS_WITH_AES_128_CBC_SHA256, |
||||
cipher_TLS_DH_RSA_WITH_AES_128_CBC_SHA256, |
||||
cipher_TLS_DHE_DSS_WITH_AES_128_CBC_SHA256, |
||||
cipher_TLS_RSA_WITH_CAMELLIA_128_CBC_SHA, |
||||
cipher_TLS_DH_DSS_WITH_CAMELLIA_128_CBC_SHA, |
||||
cipher_TLS_DH_RSA_WITH_CAMELLIA_128_CBC_SHA, |
||||
cipher_TLS_DHE_DSS_WITH_CAMELLIA_128_CBC_SHA, |
||||
cipher_TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA, |
||||
cipher_TLS_DH_anon_WITH_CAMELLIA_128_CBC_SHA, |
||||
cipher_TLS_DHE_RSA_WITH_AES_128_CBC_SHA256, |
||||
cipher_TLS_DH_DSS_WITH_AES_256_CBC_SHA256, |
||||
cipher_TLS_DH_RSA_WITH_AES_256_CBC_SHA256, |
||||
cipher_TLS_DHE_DSS_WITH_AES_256_CBC_SHA256, |
||||
cipher_TLS_DHE_RSA_WITH_AES_256_CBC_SHA256, |
||||
cipher_TLS_DH_anon_WITH_AES_128_CBC_SHA256, |
||||
cipher_TLS_DH_anon_WITH_AES_256_CBC_SHA256, |
||||
cipher_TLS_RSA_WITH_CAMELLIA_256_CBC_SHA, |
||||
cipher_TLS_DH_DSS_WITH_CAMELLIA_256_CBC_SHA, |
||||
cipher_TLS_DH_RSA_WITH_CAMELLIA_256_CBC_SHA, |
||||
cipher_TLS_DHE_DSS_WITH_CAMELLIA_256_CBC_SHA, |
||||
cipher_TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA, |
||||
cipher_TLS_DH_anon_WITH_CAMELLIA_256_CBC_SHA, |
||||
cipher_TLS_PSK_WITH_RC4_128_SHA, |
||||
cipher_TLS_PSK_WITH_3DES_EDE_CBC_SHA, |
||||
cipher_TLS_PSK_WITH_AES_128_CBC_SHA, |
||||
cipher_TLS_PSK_WITH_AES_256_CBC_SHA, |
||||
cipher_TLS_DHE_PSK_WITH_RC4_128_SHA, |
||||
cipher_TLS_DHE_PSK_WITH_3DES_EDE_CBC_SHA, |
||||
cipher_TLS_DHE_PSK_WITH_AES_128_CBC_SHA, |
||||
cipher_TLS_DHE_PSK_WITH_AES_256_CBC_SHA, |
||||
cipher_TLS_RSA_PSK_WITH_RC4_128_SHA, |
||||
cipher_TLS_RSA_PSK_WITH_3DES_EDE_CBC_SHA, |
||||
cipher_TLS_RSA_PSK_WITH_AES_128_CBC_SHA, |
||||
cipher_TLS_RSA_PSK_WITH_AES_256_CBC_SHA, |
||||
cipher_TLS_RSA_WITH_SEED_CBC_SHA, |
||||
cipher_TLS_DH_DSS_WITH_SEED_CBC_SHA, |
||||
cipher_TLS_DH_RSA_WITH_SEED_CBC_SHA, |
||||
cipher_TLS_DHE_DSS_WITH_SEED_CBC_SHA, |
||||
cipher_TLS_DHE_RSA_WITH_SEED_CBC_SHA, |
||||
cipher_TLS_DH_anon_WITH_SEED_CBC_SHA, |
||||
cipher_TLS_RSA_WITH_AES_128_GCM_SHA256, |
||||
cipher_TLS_RSA_WITH_AES_256_GCM_SHA384, |
||||
cipher_TLS_DH_RSA_WITH_AES_128_GCM_SHA256, |
||||
cipher_TLS_DH_RSA_WITH_AES_256_GCM_SHA384, |
||||
cipher_TLS_DH_DSS_WITH_AES_128_GCM_SHA256, |
||||
cipher_TLS_DH_DSS_WITH_AES_256_GCM_SHA384, |
||||
cipher_TLS_DH_anon_WITH_AES_128_GCM_SHA256, |
||||
cipher_TLS_DH_anon_WITH_AES_256_GCM_SHA384, |
||||
cipher_TLS_PSK_WITH_AES_128_GCM_SHA256, |
||||
cipher_TLS_PSK_WITH_AES_256_GCM_SHA384, |
||||
cipher_TLS_RSA_PSK_WITH_AES_128_GCM_SHA256, |
||||
cipher_TLS_RSA_PSK_WITH_AES_256_GCM_SHA384, |
||||
cipher_TLS_PSK_WITH_AES_128_CBC_SHA256, |
||||
cipher_TLS_PSK_WITH_AES_256_CBC_SHA384, |
||||
cipher_TLS_PSK_WITH_NULL_SHA256, |
||||
cipher_TLS_PSK_WITH_NULL_SHA384, |
||||
cipher_TLS_DHE_PSK_WITH_AES_128_CBC_SHA256, |
||||
cipher_TLS_DHE_PSK_WITH_AES_256_CBC_SHA384, |
||||
cipher_TLS_DHE_PSK_WITH_NULL_SHA256, |
||||
cipher_TLS_DHE_PSK_WITH_NULL_SHA384, |
||||
cipher_TLS_RSA_PSK_WITH_AES_128_CBC_SHA256, |
||||
cipher_TLS_RSA_PSK_WITH_AES_256_CBC_SHA384, |
||||
cipher_TLS_RSA_PSK_WITH_NULL_SHA256, |
||||
cipher_TLS_RSA_PSK_WITH_NULL_SHA384, |
||||
cipher_TLS_RSA_WITH_CAMELLIA_128_CBC_SHA256, |
||||
cipher_TLS_DH_DSS_WITH_CAMELLIA_128_CBC_SHA256, |
||||
cipher_TLS_DH_RSA_WITH_CAMELLIA_128_CBC_SHA256, |
||||
cipher_TLS_DHE_DSS_WITH_CAMELLIA_128_CBC_SHA256, |
||||
cipher_TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA256, |
||||
cipher_TLS_DH_anon_WITH_CAMELLIA_128_CBC_SHA256, |
||||
cipher_TLS_RSA_WITH_CAMELLIA_256_CBC_SHA256, |
||||
cipher_TLS_DH_DSS_WITH_CAMELLIA_256_CBC_SHA256, |
||||
cipher_TLS_DH_RSA_WITH_CAMELLIA_256_CBC_SHA256, |
||||
cipher_TLS_DHE_DSS_WITH_CAMELLIA_256_CBC_SHA256, |
||||
cipher_TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA256, |
||||
cipher_TLS_DH_anon_WITH_CAMELLIA_256_CBC_SHA256, |
||||
cipher_TLS_EMPTY_RENEGOTIATION_INFO_SCSV, |
||||
cipher_TLS_ECDH_ECDSA_WITH_NULL_SHA, |
||||
cipher_TLS_ECDH_ECDSA_WITH_RC4_128_SHA, |
||||
cipher_TLS_ECDH_ECDSA_WITH_3DES_EDE_CBC_SHA, |
||||
cipher_TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA, |
||||
cipher_TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA, |
||||
cipher_TLS_ECDHE_ECDSA_WITH_NULL_SHA, |
||||
cipher_TLS_ECDHE_ECDSA_WITH_RC4_128_SHA, |
||||
cipher_TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA, |
||||
cipher_TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA, |
||||
cipher_TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA, |
||||
cipher_TLS_ECDH_RSA_WITH_NULL_SHA, |
||||
cipher_TLS_ECDH_RSA_WITH_RC4_128_SHA, |
||||
cipher_TLS_ECDH_RSA_WITH_3DES_EDE_CBC_SHA, |
||||
cipher_TLS_ECDH_RSA_WITH_AES_128_CBC_SHA, |
||||
cipher_TLS_ECDH_RSA_WITH_AES_256_CBC_SHA, |
||||
cipher_TLS_ECDHE_RSA_WITH_NULL_SHA, |
||||
cipher_TLS_ECDHE_RSA_WITH_RC4_128_SHA, |
||||
cipher_TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA, |
||||
cipher_TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA, |
||||
cipher_TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA, |
||||
cipher_TLS_ECDH_anon_WITH_NULL_SHA, |
||||
cipher_TLS_ECDH_anon_WITH_RC4_128_SHA, |
||||
cipher_TLS_ECDH_anon_WITH_3DES_EDE_CBC_SHA, |
||||
cipher_TLS_ECDH_anon_WITH_AES_128_CBC_SHA, |
||||
cipher_TLS_ECDH_anon_WITH_AES_256_CBC_SHA, |
||||
cipher_TLS_SRP_SHA_WITH_3DES_EDE_CBC_SHA, |
||||
cipher_TLS_SRP_SHA_RSA_WITH_3DES_EDE_CBC_SHA, |
||||
cipher_TLS_SRP_SHA_DSS_WITH_3DES_EDE_CBC_SHA, |
||||
cipher_TLS_SRP_SHA_WITH_AES_128_CBC_SHA, |
||||
cipher_TLS_SRP_SHA_RSA_WITH_AES_128_CBC_SHA, |
||||
cipher_TLS_SRP_SHA_DSS_WITH_AES_128_CBC_SHA, |
||||
cipher_TLS_SRP_SHA_WITH_AES_256_CBC_SHA, |
||||
cipher_TLS_SRP_SHA_RSA_WITH_AES_256_CBC_SHA, |
||||
cipher_TLS_SRP_SHA_DSS_WITH_AES_256_CBC_SHA, |
||||
cipher_TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256, |
||||
cipher_TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384, |
||||
cipher_TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA256, |
||||
cipher_TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA384, |
||||
cipher_TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256, |
||||
cipher_TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384, |
||||
cipher_TLS_ECDH_RSA_WITH_AES_128_CBC_SHA256, |
||||
cipher_TLS_ECDH_RSA_WITH_AES_256_CBC_SHA384, |
||||
cipher_TLS_ECDH_ECDSA_WITH_AES_128_GCM_SHA256, |
||||
cipher_TLS_ECDH_ECDSA_WITH_AES_256_GCM_SHA384, |
||||
cipher_TLS_ECDH_RSA_WITH_AES_128_GCM_SHA256, |
||||
cipher_TLS_ECDH_RSA_WITH_AES_256_GCM_SHA384, |
||||
cipher_TLS_ECDHE_PSK_WITH_RC4_128_SHA, |
||||
cipher_TLS_ECDHE_PSK_WITH_3DES_EDE_CBC_SHA, |
||||
cipher_TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA, |
||||
cipher_TLS_ECDHE_PSK_WITH_AES_256_CBC_SHA, |
||||
cipher_TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA256, |
||||
cipher_TLS_ECDHE_PSK_WITH_AES_256_CBC_SHA384, |
||||
cipher_TLS_ECDHE_PSK_WITH_NULL_SHA, |
||||
cipher_TLS_ECDHE_PSK_WITH_NULL_SHA256, |
||||
cipher_TLS_ECDHE_PSK_WITH_NULL_SHA384, |
||||
cipher_TLS_RSA_WITH_ARIA_128_CBC_SHA256, |
||||
cipher_TLS_RSA_WITH_ARIA_256_CBC_SHA384, |
||||
cipher_TLS_DH_DSS_WITH_ARIA_128_CBC_SHA256, |
||||
cipher_TLS_DH_DSS_WITH_ARIA_256_CBC_SHA384, |
||||
cipher_TLS_DH_RSA_WITH_ARIA_128_CBC_SHA256, |
||||
cipher_TLS_DH_RSA_WITH_ARIA_256_CBC_SHA384, |
||||
cipher_TLS_DHE_DSS_WITH_ARIA_128_CBC_SHA256, |
||||
cipher_TLS_DHE_DSS_WITH_ARIA_256_CBC_SHA384, |
||||
cipher_TLS_DHE_RSA_WITH_ARIA_128_CBC_SHA256, |
||||
cipher_TLS_DHE_RSA_WITH_ARIA_256_CBC_SHA384, |
||||
cipher_TLS_DH_anon_WITH_ARIA_128_CBC_SHA256, |
||||
cipher_TLS_DH_anon_WITH_ARIA_256_CBC_SHA384, |
||||
cipher_TLS_ECDHE_ECDSA_WITH_ARIA_128_CBC_SHA256, |
||||
cipher_TLS_ECDHE_ECDSA_WITH_ARIA_256_CBC_SHA384, |
||||
cipher_TLS_ECDH_ECDSA_WITH_ARIA_128_CBC_SHA256, |
||||
cipher_TLS_ECDH_ECDSA_WITH_ARIA_256_CBC_SHA384, |
||||
cipher_TLS_ECDHE_RSA_WITH_ARIA_128_CBC_SHA256, |
||||
cipher_TLS_ECDHE_RSA_WITH_ARIA_256_CBC_SHA384, |
||||
cipher_TLS_ECDH_RSA_WITH_ARIA_128_CBC_SHA256, |
||||
cipher_TLS_ECDH_RSA_WITH_ARIA_256_CBC_SHA384, |
||||
cipher_TLS_RSA_WITH_ARIA_128_GCM_SHA256, |
||||
cipher_TLS_RSA_WITH_ARIA_256_GCM_SHA384, |
||||
cipher_TLS_DH_RSA_WITH_ARIA_128_GCM_SHA256, |
||||
cipher_TLS_DH_RSA_WITH_ARIA_256_GCM_SHA384, |
||||
cipher_TLS_DH_DSS_WITH_ARIA_128_GCM_SHA256, |
||||
cipher_TLS_DH_DSS_WITH_ARIA_256_GCM_SHA384, |
||||
cipher_TLS_DH_anon_WITH_ARIA_128_GCM_SHA256, |
||||
cipher_TLS_DH_anon_WITH_ARIA_256_GCM_SHA384, |
||||
cipher_TLS_ECDH_ECDSA_WITH_ARIA_128_GCM_SHA256, |
||||
cipher_TLS_ECDH_ECDSA_WITH_ARIA_256_GCM_SHA384, |
||||
cipher_TLS_ECDH_RSA_WITH_ARIA_128_GCM_SHA256, |
||||
cipher_TLS_ECDH_RSA_WITH_ARIA_256_GCM_SHA384, |
||||
cipher_TLS_PSK_WITH_ARIA_128_CBC_SHA256, |
||||
cipher_TLS_PSK_WITH_ARIA_256_CBC_SHA384, |
||||
cipher_TLS_DHE_PSK_WITH_ARIA_128_CBC_SHA256, |
||||
cipher_TLS_DHE_PSK_WITH_ARIA_256_CBC_SHA384, |
||||
cipher_TLS_RSA_PSK_WITH_ARIA_128_CBC_SHA256, |
||||
cipher_TLS_RSA_PSK_WITH_ARIA_256_CBC_SHA384, |
||||
cipher_TLS_PSK_WITH_ARIA_128_GCM_SHA256, |
||||
cipher_TLS_PSK_WITH_ARIA_256_GCM_SHA384, |
||||
cipher_TLS_RSA_PSK_WITH_ARIA_128_GCM_SHA256, |
||||
cipher_TLS_RSA_PSK_WITH_ARIA_256_GCM_SHA384, |
||||
cipher_TLS_ECDHE_PSK_WITH_ARIA_128_CBC_SHA256, |
||||
cipher_TLS_ECDHE_PSK_WITH_ARIA_256_CBC_SHA384, |
||||
cipher_TLS_ECDHE_ECDSA_WITH_CAMELLIA_128_CBC_SHA256, |
||||
cipher_TLS_ECDHE_ECDSA_WITH_CAMELLIA_256_CBC_SHA384, |
||||
cipher_TLS_ECDH_ECDSA_WITH_CAMELLIA_128_CBC_SHA256, |
||||
cipher_TLS_ECDH_ECDSA_WITH_CAMELLIA_256_CBC_SHA384, |
||||
cipher_TLS_ECDHE_RSA_WITH_CAMELLIA_128_CBC_SHA256, |
||||
cipher_TLS_ECDHE_RSA_WITH_CAMELLIA_256_CBC_SHA384, |
||||
cipher_TLS_ECDH_RSA_WITH_CAMELLIA_128_CBC_SHA256, |
||||
cipher_TLS_ECDH_RSA_WITH_CAMELLIA_256_CBC_SHA384, |
||||
cipher_TLS_RSA_WITH_CAMELLIA_128_GCM_SHA256, |
||||
cipher_TLS_RSA_WITH_CAMELLIA_256_GCM_SHA384, |
||||
cipher_TLS_DH_RSA_WITH_CAMELLIA_128_GCM_SHA256, |
||||
cipher_TLS_DH_RSA_WITH_CAMELLIA_256_GCM_SHA384, |
||||
cipher_TLS_DH_DSS_WITH_CAMELLIA_128_GCM_SHA256, |
||||
cipher_TLS_DH_DSS_WITH_CAMELLIA_256_GCM_SHA384, |
||||
cipher_TLS_DH_anon_WITH_CAMELLIA_128_GCM_SHA256, |
||||
cipher_TLS_DH_anon_WITH_CAMELLIA_256_GCM_SHA384, |
||||
cipher_TLS_ECDH_ECDSA_WITH_CAMELLIA_128_GCM_SHA256, |
||||
cipher_TLS_ECDH_ECDSA_WITH_CAMELLIA_256_GCM_SHA384, |
||||
cipher_TLS_ECDH_RSA_WITH_CAMELLIA_128_GCM_SHA256, |
||||
cipher_TLS_ECDH_RSA_WITH_CAMELLIA_256_GCM_SHA384, |
||||
cipher_TLS_PSK_WITH_CAMELLIA_128_GCM_SHA256, |
||||
cipher_TLS_PSK_WITH_CAMELLIA_256_GCM_SHA384, |
||||
cipher_TLS_RSA_PSK_WITH_CAMELLIA_128_GCM_SHA256, |
||||
cipher_TLS_RSA_PSK_WITH_CAMELLIA_256_GCM_SHA384, |
||||
cipher_TLS_PSK_WITH_CAMELLIA_128_CBC_SHA256, |
||||
cipher_TLS_PSK_WITH_CAMELLIA_256_CBC_SHA384, |
||||
cipher_TLS_DHE_PSK_WITH_CAMELLIA_128_CBC_SHA256, |
||||
cipher_TLS_DHE_PSK_WITH_CAMELLIA_256_CBC_SHA384, |
||||
cipher_TLS_RSA_PSK_WITH_CAMELLIA_128_CBC_SHA256, |
||||
cipher_TLS_RSA_PSK_WITH_CAMELLIA_256_CBC_SHA384, |
||||
cipher_TLS_ECDHE_PSK_WITH_CAMELLIA_128_CBC_SHA256, |
||||
cipher_TLS_ECDHE_PSK_WITH_CAMELLIA_256_CBC_SHA384, |
||||
cipher_TLS_RSA_WITH_AES_128_CCM, |
||||
cipher_TLS_RSA_WITH_AES_256_CCM, |
||||
cipher_TLS_RSA_WITH_AES_128_CCM_8, |
||||
cipher_TLS_RSA_WITH_AES_256_CCM_8, |
||||
cipher_TLS_PSK_WITH_AES_128_CCM, |
||||
cipher_TLS_PSK_WITH_AES_256_CCM, |
||||
cipher_TLS_PSK_WITH_AES_128_CCM_8, |
||||
cipher_TLS_PSK_WITH_AES_256_CCM_8: |
||||
return true |
||||
default: |
||||
return false |
||||
} |
||||
} |
@ -1,80 +0,0 @@ |
||||
// Copyright 2015 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// +build go1.6
|
||||
|
||||
package http2 |
||||
|
||||
import ( |
||||
"crypto/tls" |
||||
"fmt" |
||||
"net/http" |
||||
) |
||||
|
||||
func configureTransport(t1 *http.Transport) (*Transport, error) { |
||||
connPool := new(clientConnPool) |
||||
t2 := &Transport{ |
||||
ConnPool: noDialClientConnPool{connPool}, |
||||
t1: t1, |
||||
} |
||||
connPool.t = t2 |
||||
if err := registerHTTPSProtocol(t1, noDialH2RoundTripper{t2}); err != nil { |
||||
return nil, err |
||||
} |
||||
if t1.TLSClientConfig == nil { |
||||
t1.TLSClientConfig = new(tls.Config) |
||||
} |
||||
if !strSliceContains(t1.TLSClientConfig.NextProtos, "h2") { |
||||
t1.TLSClientConfig.NextProtos = append([]string{"h2"}, t1.TLSClientConfig.NextProtos...) |
||||
} |
||||
if !strSliceContains(t1.TLSClientConfig.NextProtos, "http/1.1") { |
||||
t1.TLSClientConfig.NextProtos = append(t1.TLSClientConfig.NextProtos, "http/1.1") |
||||
} |
||||
upgradeFn := func(authority string, c *tls.Conn) http.RoundTripper { |
||||
addr := authorityAddr("https", authority) |
||||
if used, err := connPool.addConnIfNeeded(addr, t2, c); err != nil { |
||||
go c.Close() |
||||
return erringRoundTripper{err} |
||||
} else if !used { |
||||
// Turns out we don't need this c.
|
||||
// For example, two goroutines made requests to the same host
|
||||
// at the same time, both kicking off TCP dials. (since protocol
|
||||
// was unknown)
|
||||
go c.Close() |
||||
} |
||||
return t2 |
||||
} |
||||
if m := t1.TLSNextProto; len(m) == 0 { |
||||
t1.TLSNextProto = map[string]func(string, *tls.Conn) http.RoundTripper{ |
||||
"h2": upgradeFn, |
||||
} |
||||
} else { |
||||
m["h2"] = upgradeFn |
||||
} |
||||
return t2, nil |
||||
} |
||||
|
||||
// registerHTTPSProtocol calls Transport.RegisterProtocol but
|
||||
// convering panics into errors.
|
||||
func registerHTTPSProtocol(t *http.Transport, rt http.RoundTripper) (err error) { |
||||
defer func() { |
||||
if e := recover(); e != nil { |
||||
err = fmt.Errorf("%v", e) |
||||
} |
||||
}() |
||||
t.RegisterProtocol("https", rt) |
||||
return nil |
||||
} |
||||
|
||||
// noDialH2RoundTripper is a RoundTripper which only tries to complete the request
|
||||
// if there's already has a cached connection to the host.
|
||||
type noDialH2RoundTripper struct{ t *Transport } |
||||
|
||||
func (rt noDialH2RoundTripper) RoundTrip(req *http.Request) (*http.Response, error) { |
||||
res, err := rt.t.RoundTrip(req) |
||||
if err == ErrNoCachedConn { |
||||
return nil, http.ErrSkipAltProtocol |
||||
} |
||||
return res, err |
||||
} |
@ -0,0 +1,29 @@ |
||||
// Copyright 2018 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// +build go1.11
|
||||
|
||||
package http2 |
||||
|
||||
import ( |
||||
"net/http/httptrace" |
||||
"net/textproto" |
||||
) |
||||
|
||||
func traceHasWroteHeaderField(trace *httptrace.ClientTrace) bool { |
||||
return trace != nil && trace.WroteHeaderField != nil |
||||
} |
||||
|
||||
func traceWroteHeaderField(trace *httptrace.ClientTrace, k, v string) { |
||||
if trace != nil && trace.WroteHeaderField != nil { |
||||
trace.WroteHeaderField(k, []string{v}) |
||||
} |
||||
} |
||||
|
||||
func traceGot1xxResponseFunc(trace *httptrace.ClientTrace) func(int, textproto.MIMEHeader) error { |
||||
if trace != nil { |
||||
return trace.Got1xxResponse |
||||
} |
||||
return nil |
||||
} |
@ -1,43 +0,0 @@ |
||||
// Copyright 2016 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// +build go1.6
|
||||
|
||||
package http2 |
||||
|
||||
import ( |
||||
"crypto/tls" |
||||
"net/http" |
||||
"time" |
||||
) |
||||
|
||||
func transportExpectContinueTimeout(t1 *http.Transport) time.Duration { |
||||
return t1.ExpectContinueTimeout |
||||
} |
||||
|
||||
// isBadCipher reports whether the cipher is blacklisted by the HTTP/2 spec.
|
||||
func isBadCipher(cipher uint16) bool { |
||||
switch cipher { |
||||
case tls.TLS_RSA_WITH_RC4_128_SHA, |
||||
tls.TLS_RSA_WITH_3DES_EDE_CBC_SHA, |
||||
tls.TLS_RSA_WITH_AES_128_CBC_SHA, |
||||
tls.TLS_RSA_WITH_AES_256_CBC_SHA, |
||||
tls.TLS_RSA_WITH_AES_128_GCM_SHA256, |
||||
tls.TLS_RSA_WITH_AES_256_GCM_SHA384, |
||||
tls.TLS_ECDHE_ECDSA_WITH_RC4_128_SHA, |
||||
tls.TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA, |
||||
tls.TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA, |
||||
tls.TLS_ECDHE_RSA_WITH_RC4_128_SHA, |
||||
tls.TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA, |
||||
tls.TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA, |
||||
tls.TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA: |
||||
// Reject cipher suites from Appendix A.
|
||||
// "This list includes those cipher suites that do not
|
||||
// offer an ephemeral key exchange and those that are
|
||||
// based on the TLS null, stream or block cipher type"
|
||||
return true |
||||
default: |
||||
return false |
||||
} |
||||
} |
@ -1,106 +0,0 @@ |
||||
// Copyright 2016 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// +build go1.7
|
||||
|
||||
package http2 |
||||
|
||||
import ( |
||||
"context" |
||||
"net" |
||||
"net/http" |
||||
"net/http/httptrace" |
||||
"time" |
||||
) |
||||
|
||||
type contextContext interface { |
||||
context.Context |
||||
} |
||||
|
||||
func serverConnBaseContext(c net.Conn, opts *ServeConnOpts) (ctx contextContext, cancel func()) { |
||||
ctx, cancel = context.WithCancel(context.Background()) |
||||
ctx = context.WithValue(ctx, http.LocalAddrContextKey, c.LocalAddr()) |
||||
if hs := opts.baseConfig(); hs != nil { |
||||
ctx = context.WithValue(ctx, http.ServerContextKey, hs) |
||||
} |
||||
return |
||||
} |
||||
|
||||
func contextWithCancel(ctx contextContext) (_ contextContext, cancel func()) { |
||||
return context.WithCancel(ctx) |
||||
} |
||||
|
||||
func requestWithContext(req *http.Request, ctx contextContext) *http.Request { |
||||
return req.WithContext(ctx) |
||||
} |
||||
|
||||
type clientTrace httptrace.ClientTrace |
||||
|
||||
func reqContext(r *http.Request) context.Context { return r.Context() } |
||||
|
||||
func (t *Transport) idleConnTimeout() time.Duration { |
||||
if t.t1 != nil { |
||||
return t.t1.IdleConnTimeout |
||||
} |
||||
return 0 |
||||
} |
||||
|
||||
func setResponseUncompressed(res *http.Response) { res.Uncompressed = true } |
||||
|
||||
func traceGotConn(req *http.Request, cc *ClientConn) { |
||||
trace := httptrace.ContextClientTrace(req.Context()) |
||||
if trace == nil || trace.GotConn == nil { |
||||
return |
||||
} |
||||
ci := httptrace.GotConnInfo{Conn: cc.tconn} |
||||
cc.mu.Lock() |
||||
ci.Reused = cc.nextStreamID > 1 |
||||
ci.WasIdle = len(cc.streams) == 0 && ci.Reused |
||||
if ci.WasIdle && !cc.lastActive.IsZero() { |
||||
ci.IdleTime = time.Now().Sub(cc.lastActive) |
||||
} |
||||
cc.mu.Unlock() |
||||
|
||||
trace.GotConn(ci) |
||||
} |
||||
|
||||
func traceWroteHeaders(trace *clientTrace) { |
||||
if trace != nil && trace.WroteHeaders != nil { |
||||
trace.WroteHeaders() |
||||
} |
||||
} |
||||
|
||||
func traceGot100Continue(trace *clientTrace) { |
||||
if trace != nil && trace.Got100Continue != nil { |
||||
trace.Got100Continue() |
||||
} |
||||
} |
||||
|
||||
func traceWait100Continue(trace *clientTrace) { |
||||
if trace != nil && trace.Wait100Continue != nil { |
||||
trace.Wait100Continue() |
||||
} |
||||
} |
||||
|
||||
func traceWroteRequest(trace *clientTrace, err error) { |
||||
if trace != nil && trace.WroteRequest != nil { |
||||
trace.WroteRequest(httptrace.WroteRequestInfo{Err: err}) |
||||
} |
||||
} |
||||
|
||||
func traceFirstResponseByte(trace *clientTrace) { |
||||
if trace != nil && trace.GotFirstResponseByte != nil { |
||||
trace.GotFirstResponseByte() |
||||
} |
||||
} |
||||
|
||||
func requestTrace(req *http.Request) *clientTrace { |
||||
trace := httptrace.ContextClientTrace(req.Context()) |
||||
return (*clientTrace)(trace) |
||||
} |
||||
|
||||
// Ping sends a PING frame to the server and waits for the ack.
|
||||
func (cc *ClientConn) Ping(ctx context.Context) error { |
||||
return cc.ping(ctx) |
||||
} |
@ -1,36 +0,0 @@ |
||||
// Copyright 2016 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// +build go1.7,!go1.8
|
||||
|
||||
package http2 |
||||
|
||||
import "crypto/tls" |
||||
|
||||
// temporary copy of Go 1.7's private tls.Config.clone:
|
||||
func cloneTLSConfig(c *tls.Config) *tls.Config { |
||||
return &tls.Config{ |
||||
Rand: c.Rand, |
||||
Time: c.Time, |
||||
Certificates: c.Certificates, |
||||
NameToCertificate: c.NameToCertificate, |
||||
GetCertificate: c.GetCertificate, |
||||
RootCAs: c.RootCAs, |
||||
NextProtos: c.NextProtos, |
||||
ServerName: c.ServerName, |
||||
ClientAuth: c.ClientAuth, |
||||
ClientCAs: c.ClientCAs, |
||||
InsecureSkipVerify: c.InsecureSkipVerify, |
||||
CipherSuites: c.CipherSuites, |
||||
PreferServerCipherSuites: c.PreferServerCipherSuites, |
||||
SessionTicketsDisabled: c.SessionTicketsDisabled, |
||||
SessionTicketKey: c.SessionTicketKey, |
||||
ClientSessionCache: c.ClientSessionCache, |
||||
MinVersion: c.MinVersion, |
||||
MaxVersion: c.MaxVersion, |
||||
CurvePreferences: c.CurvePreferences, |
||||
DynamicRecordSizingDisabled: c.DynamicRecordSizingDisabled, |
||||
Renegotiation: c.Renegotiation, |
||||
} |
||||
} |
@ -1,54 +0,0 @@ |
||||
// Copyright 2015 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// +build go1.8
|
||||
|
||||
package http2 |
||||
|
||||
import ( |
||||
"crypto/tls" |
||||
"io" |
||||
"net/http" |
||||
) |
||||
|
||||
func cloneTLSConfig(c *tls.Config) *tls.Config { |
||||
c2 := c.Clone() |
||||
c2.GetClientCertificate = c.GetClientCertificate // golang.org/issue/19264
|
||||
return c2 |
||||
} |
||||
|
||||
var _ http.Pusher = (*responseWriter)(nil) |
||||
|
||||
// Push implements http.Pusher.
|
||||
func (w *responseWriter) Push(target string, opts *http.PushOptions) error { |
||||
internalOpts := pushOptions{} |
||||
if opts != nil { |
||||
internalOpts.Method = opts.Method |
||||
internalOpts.Header = opts.Header |
||||
} |
||||
return w.push(target, internalOpts) |
||||
} |
||||
|
||||
func configureServer18(h1 *http.Server, h2 *Server) error { |
||||
if h2.IdleTimeout == 0 { |
||||
if h1.IdleTimeout != 0 { |
||||
h2.IdleTimeout = h1.IdleTimeout |
||||
} else { |
||||
h2.IdleTimeout = h1.ReadTimeout |
||||
} |
||||
} |
||||
return nil |
||||
} |
||||
|
||||
func shouldLogPanic(panicValue interface{}) bool { |
||||
return panicValue != nil && panicValue != http.ErrAbortHandler |
||||
} |
||||
|
||||
func reqGetBody(req *http.Request) func() (io.ReadCloser, error) { |
||||
return req.GetBody |
||||
} |
||||
|
||||
func reqBodyIsNoBody(body io.ReadCloser) bool { |
||||
return body == http.NoBody |
||||
} |
@ -0,0 +1,20 @@ |
||||
// Copyright 2018 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// +build !go1.11
|
||||
|
||||
package http2 |
||||
|
||||
import ( |
||||
"net/http/httptrace" |
||||
"net/textproto" |
||||
) |
||||
|
||||
func traceHasWroteHeaderField(trace *httptrace.ClientTrace) bool { return false } |
||||
|
||||
func traceWroteHeaderField(trace *httptrace.ClientTrace, k, v string) {} |
||||
|
||||
func traceGot1xxResponseFunc(trace *httptrace.ClientTrace) func(int, textproto.MIMEHeader) error { |
||||
return nil |
||||
} |
@ -1,46 +0,0 @@ |
||||
// Copyright 2015 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// +build !go1.6
|
||||
|
||||
package http2 |
||||
|
||||
import ( |
||||
"crypto/tls" |
||||
"net/http" |
||||
"time" |
||||
) |
||||
|
||||
func configureTransport(t1 *http.Transport) (*Transport, error) { |
||||
return nil, errTransportVersion |
||||
} |
||||
|
||||
func transportExpectContinueTimeout(t1 *http.Transport) time.Duration { |
||||
return 0 |
||||
|
||||
} |
||||
|
||||
// isBadCipher reports whether the cipher is blacklisted by the HTTP/2 spec.
|
||||
func isBadCipher(cipher uint16) bool { |
||||
switch cipher { |
||||
case tls.TLS_RSA_WITH_RC4_128_SHA, |
||||
tls.TLS_RSA_WITH_3DES_EDE_CBC_SHA, |
||||
tls.TLS_RSA_WITH_AES_128_CBC_SHA, |
||||
tls.TLS_RSA_WITH_AES_256_CBC_SHA, |
||||
tls.TLS_ECDHE_ECDSA_WITH_RC4_128_SHA, |
||||
tls.TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA, |
||||
tls.TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA, |
||||
tls.TLS_ECDHE_RSA_WITH_RC4_128_SHA, |
||||
tls.TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA, |
||||
tls.TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA, |
||||
tls.TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA: |
||||
// Reject cipher suites from Appendix A.
|
||||
// "This list includes those cipher suites that do not
|
||||
// offer an ephemeral key exchange and those that are
|
||||
// based on the TLS null, stream or block cipher type"
|
||||
return true |
||||
default: |
||||
return false |
||||
} |
||||
} |
@ -1,87 +0,0 @@ |
||||
// Copyright 2016 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// +build !go1.7
|
||||
|
||||
package http2 |
||||
|
||||
import ( |
||||
"crypto/tls" |
||||
"net" |
||||
"net/http" |
||||
"time" |
||||
) |
||||
|
||||
type contextContext interface { |
||||
Done() <-chan struct{} |
||||
Err() error |
||||
} |
||||
|
||||
type fakeContext struct{} |
||||
|
||||
func (fakeContext) Done() <-chan struct{} { return nil } |
||||
func (fakeContext) Err() error { panic("should not be called") } |
||||
|
||||
func reqContext(r *http.Request) fakeContext { |
||||
return fakeContext{} |
||||
} |
||||
|
||||
func setResponseUncompressed(res *http.Response) { |
||||
// Nothing.
|
||||
} |
||||
|
||||
type clientTrace struct{} |
||||
|
||||
func requestTrace(*http.Request) *clientTrace { return nil } |
||||
func traceGotConn(*http.Request, *ClientConn) {} |
||||
func traceFirstResponseByte(*clientTrace) {} |
||||
func traceWroteHeaders(*clientTrace) {} |
||||
func traceWroteRequest(*clientTrace, error) {} |
||||
func traceGot100Continue(trace *clientTrace) {} |
||||
func traceWait100Continue(trace *clientTrace) {} |
||||
|
||||
func nop() {} |
||||
|
||||
func serverConnBaseContext(c net.Conn, opts *ServeConnOpts) (ctx contextContext, cancel func()) { |
||||
return nil, nop |
||||
} |
||||
|
||||
func contextWithCancel(ctx contextContext) (_ contextContext, cancel func()) { |
||||
return ctx, nop |
||||
} |
||||
|
||||
func requestWithContext(req *http.Request, ctx contextContext) *http.Request { |
||||
return req |
||||
} |
||||
|
||||
// temporary copy of Go 1.6's private tls.Config.clone:
|
||||
func cloneTLSConfig(c *tls.Config) *tls.Config { |
||||
return &tls.Config{ |
||||
Rand: c.Rand, |
||||
Time: c.Time, |
||||
Certificates: c.Certificates, |
||||
NameToCertificate: c.NameToCertificate, |
||||
GetCertificate: c.GetCertificate, |
||||
RootCAs: c.RootCAs, |
||||
NextProtos: c.NextProtos, |
||||
ServerName: c.ServerName, |
||||
ClientAuth: c.ClientAuth, |
||||
ClientCAs: c.ClientCAs, |
||||
InsecureSkipVerify: c.InsecureSkipVerify, |
||||
CipherSuites: c.CipherSuites, |
||||
PreferServerCipherSuites: c.PreferServerCipherSuites, |
||||
SessionTicketsDisabled: c.SessionTicketsDisabled, |
||||
SessionTicketKey: c.SessionTicketKey, |
||||
ClientSessionCache: c.ClientSessionCache, |
||||
MinVersion: c.MinVersion, |
||||
MaxVersion: c.MaxVersion, |
||||
CurvePreferences: c.CurvePreferences, |
||||
} |
||||
} |
||||
|
||||
func (cc *ClientConn) Ping(ctx contextContext) error { |
||||
return cc.ping(ctx) |
||||
} |
||||
|
||||
func (t *Transport) idleConnTimeout() time.Duration { return 0 } |
@ -1,27 +0,0 @@ |
||||
// Copyright 2016 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// +build !go1.8
|
||||
|
||||
package http2 |
||||
|
||||
import ( |
||||
"io" |
||||
"net/http" |
||||
) |
||||
|
||||
func configureServer18(h1 *http.Server, h2 *Server) error { |
||||
// No IdleTimeout to sync prior to Go 1.8.
|
||||
return nil |
||||
} |
||||
|
||||
func shouldLogPanic(panicValue interface{}) bool { |
||||
return panicValue != nil |
||||
} |
||||
|
||||
func reqGetBody(req *http.Request) func() (io.ReadCloser, error) { |
||||
return nil |
||||
} |
||||
|
||||
func reqBodyIsNoBody(io.ReadCloser) bool { return false } |
File diff suppressed because it is too large
Load Diff
@ -1,351 +0,0 @@ |
||||
// Copyright 2016 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// Package httplex contains rules around lexical matters of various
|
||||
// HTTP-related specifications.
|
||||
//
|
||||
// This package is shared by the standard library (which vendors it)
|
||||
// and x/net/http2. It comes with no API stability promise.
|
||||
package httplex |
||||
|
||||
import ( |
||||
"net" |
||||
"strings" |
||||
"unicode/utf8" |
||||
|
||||
"golang.org/x/net/idna" |
||||
) |
||||
|
||||
var isTokenTable = [127]bool{ |
||||
'!': true, |
||||
'#': true, |
||||
'$': true, |
||||
'%': true, |
||||
'&': true, |
||||
'\'': true, |
||||
'*': true, |
||||
'+': true, |
||||
'-': true, |
||||
'.': true, |
||||
'0': true, |
||||
'1': true, |
||||
'2': true, |
||||
'3': true, |
||||
'4': true, |
||||
'5': true, |
||||
'6': true, |
||||
'7': true, |
||||
'8': true, |
||||
'9': true, |
||||
'A': true, |
||||
'B': true, |
||||
'C': true, |
||||
'D': true, |
||||
'E': true, |
||||
'F': true, |
||||
'G': true, |
||||
'H': true, |
||||
'I': true, |
||||
'J': true, |
||||
'K': true, |
||||
'L': true, |
||||
'M': true, |
||||
'N': true, |
||||
'O': true, |
||||
'P': true, |
||||
'Q': true, |
||||
'R': true, |
||||
'S': true, |
||||
'T': true, |
||||
'U': true, |
||||
'W': true, |
||||
'V': true, |
||||
'X': true, |
||||
'Y': true, |
||||
'Z': true, |
||||
'^': true, |
||||
'_': true, |
||||
'`': true, |
||||
'a': true, |
||||
'b': true, |
||||
'c': true, |
||||
'd': true, |
||||
'e': true, |
||||
'f': true, |
||||
'g': true, |
||||
'h': true, |
||||
'i': true, |
||||
'j': true, |
||||
'k': true, |
||||
'l': true, |
||||
'm': true, |
||||
'n': true, |
||||
'o': true, |
||||
'p': true, |
||||
'q': true, |
||||
'r': true, |
||||
's': true, |
||||
't': true, |
||||
'u': true, |
||||
'v': true, |
||||
'w': true, |
||||
'x': true, |
||||
'y': true, |
||||
'z': true, |
||||
'|': true, |
||||
'~': true, |
||||
} |
||||
|
||||
func IsTokenRune(r rune) bool { |
||||
i := int(r) |
||||
return i < len(isTokenTable) && isTokenTable[i] |
||||
} |
||||
|
||||
func isNotToken(r rune) bool { |
||||
return !IsTokenRune(r) |
||||
} |
||||
|
||||
// HeaderValuesContainsToken reports whether any string in values
|
||||
// contains the provided token, ASCII case-insensitively.
|
||||
func HeaderValuesContainsToken(values []string, token string) bool { |
||||
for _, v := range values { |
||||
if headerValueContainsToken(v, token) { |
||||
return true |
||||
} |
||||
} |
||||
return false |
||||
} |
||||
|
||||
// isOWS reports whether b is an optional whitespace byte, as defined
|
||||
// by RFC 7230 section 3.2.3.
|
||||
func isOWS(b byte) bool { return b == ' ' || b == '\t' } |
||||
|
||||
// trimOWS returns x with all optional whitespace removes from the
|
||||
// beginning and end.
|
||||
func trimOWS(x string) string { |
||||
// TODO: consider using strings.Trim(x, " \t") instead,
|
||||
// if and when it's fast enough. See issue 10292.
|
||||
// But this ASCII-only code will probably always beat UTF-8
|
||||
// aware code.
|
||||
for len(x) > 0 && isOWS(x[0]) { |
||||
x = x[1:] |
||||
} |
||||
for len(x) > 0 && isOWS(x[len(x)-1]) { |
||||
x = x[:len(x)-1] |
||||
} |
||||
return x |
||||
} |
||||
|
||||
// headerValueContainsToken reports whether v (assumed to be a
|
||||
// 0#element, in the ABNF extension described in RFC 7230 section 7)
|
||||
// contains token amongst its comma-separated tokens, ASCII
|
||||
// case-insensitively.
|
||||
func headerValueContainsToken(v string, token string) bool { |
||||
v = trimOWS(v) |
||||
if comma := strings.IndexByte(v, ','); comma != -1 { |
||||
return tokenEqual(trimOWS(v[:comma]), token) || headerValueContainsToken(v[comma+1:], token) |
||||
} |
||||
return tokenEqual(v, token) |
||||
} |
||||
|
||||
// lowerASCII returns the ASCII lowercase version of b.
|
||||
func lowerASCII(b byte) byte { |
||||
if 'A' <= b && b <= 'Z' { |
||||
return b + ('a' - 'A') |
||||
} |
||||
return b |
||||
} |
||||
|
||||
// tokenEqual reports whether t1 and t2 are equal, ASCII case-insensitively.
|
||||
func tokenEqual(t1, t2 string) bool { |
||||
if len(t1) != len(t2) { |
||||
return false |
||||
} |
||||
for i, b := range t1 { |
||||
if b >= utf8.RuneSelf { |
||||
// No UTF-8 or non-ASCII allowed in tokens.
|
||||
return false |
||||
} |
||||
if lowerASCII(byte(b)) != lowerASCII(t2[i]) { |
||||
return false |
||||
} |
||||
} |
||||
return true |
||||
} |
||||
|
||||
// isLWS reports whether b is linear white space, according
|
||||
// to http://www.w3.org/Protocols/rfc2616/rfc2616-sec2.html#sec2.2
|
||||
// LWS = [CRLF] 1*( SP | HT )
|
||||
func isLWS(b byte) bool { return b == ' ' || b == '\t' } |
||||
|
||||
// isCTL reports whether b is a control byte, according
|
||||
// to http://www.w3.org/Protocols/rfc2616/rfc2616-sec2.html#sec2.2
|
||||
// CTL = <any US-ASCII control character
|
||||
// (octets 0 - 31) and DEL (127)>
|
||||
func isCTL(b byte) bool { |
||||
const del = 0x7f // a CTL
|
||||
return b < ' ' || b == del |
||||
} |
||||
|
||||
// ValidHeaderFieldName reports whether v is a valid HTTP/1.x header name.
|
||||
// HTTP/2 imposes the additional restriction that uppercase ASCII
|
||||
// letters are not allowed.
|
||||
//
|
||||
// RFC 7230 says:
|
||||
// header-field = field-name ":" OWS field-value OWS
|
||||
// field-name = token
|
||||
// token = 1*tchar
|
||||
// tchar = "!" / "#" / "$" / "%" / "&" / "'" / "*" / "+" / "-" / "." /
|
||||
// "^" / "_" / "`" / "|" / "~" / DIGIT / ALPHA
|
||||
func ValidHeaderFieldName(v string) bool { |
||||
if len(v) == 0 { |
||||
return false |
||||
} |
||||
for _, r := range v { |
||||
if !IsTokenRune(r) { |
||||
return false |
||||
} |
||||
} |
||||
return true |
||||
} |
||||
|
||||
// ValidHostHeader reports whether h is a valid host header.
|
||||
func ValidHostHeader(h string) bool { |
||||
// The latest spec is actually this:
|
||||
//
|
||||
// http://tools.ietf.org/html/rfc7230#section-5.4
|
||||
// Host = uri-host [ ":" port ]
|
||||
//
|
||||
// Where uri-host is:
|
||||
// http://tools.ietf.org/html/rfc3986#section-3.2.2
|
||||
//
|
||||
// But we're going to be much more lenient for now and just
|
||||
// search for any byte that's not a valid byte in any of those
|
||||
// expressions.
|
||||
for i := 0; i < len(h); i++ { |
||||
if !validHostByte[h[i]] { |
||||
return false |
||||
} |
||||
} |
||||
return true |
||||
} |
||||
|
||||
// See the validHostHeader comment.
|
||||
var validHostByte = [256]bool{ |
||||
'0': true, '1': true, '2': true, '3': true, '4': true, '5': true, '6': true, '7': true, |
||||
'8': true, '9': true, |
||||
|
||||
'a': true, 'b': true, 'c': true, 'd': true, 'e': true, 'f': true, 'g': true, 'h': true, |
||||
'i': true, 'j': true, 'k': true, 'l': true, 'm': true, 'n': true, 'o': true, 'p': true, |
||||
'q': true, 'r': true, 's': true, 't': true, 'u': true, 'v': true, 'w': true, 'x': true, |
||||
'y': true, 'z': true, |
||||
|
||||
'A': true, 'B': true, 'C': true, 'D': true, 'E': true, 'F': true, 'G': true, 'H': true, |
||||
'I': true, 'J': true, 'K': true, 'L': true, 'M': true, 'N': true, 'O': true, 'P': true, |
||||
'Q': true, 'R': true, 'S': true, 'T': true, 'U': true, 'V': true, 'W': true, 'X': true, |
||||
'Y': true, 'Z': true, |
||||
|
||||
'!': true, // sub-delims
|
||||
'$': true, // sub-delims
|
||||
'%': true, // pct-encoded (and used in IPv6 zones)
|
||||
'&': true, // sub-delims
|
||||
'(': true, // sub-delims
|
||||
')': true, // sub-delims
|
||||
'*': true, // sub-delims
|
||||
'+': true, // sub-delims
|
||||
',': true, // sub-delims
|
||||
'-': true, // unreserved
|
||||
'.': true, // unreserved
|
||||
':': true, // IPv6address + Host expression's optional port
|
||||
';': true, // sub-delims
|
||||
'=': true, // sub-delims
|
||||
'[': true, |
||||
'\'': true, // sub-delims
|
||||
']': true, |
||||
'_': true, // unreserved
|
||||
'~': true, // unreserved
|
||||
} |
||||
|
||||
// ValidHeaderFieldValue reports whether v is a valid "field-value" according to
|
||||
// http://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html#sec4.2 :
|
||||
//
|
||||
// message-header = field-name ":" [ field-value ]
|
||||
// field-value = *( field-content | LWS )
|
||||
// field-content = <the OCTETs making up the field-value
|
||||
// and consisting of either *TEXT or combinations
|
||||
// of token, separators, and quoted-string>
|
||||
//
|
||||
// http://www.w3.org/Protocols/rfc2616/rfc2616-sec2.html#sec2.2 :
|
||||
//
|
||||
// TEXT = <any OCTET except CTLs,
|
||||
// but including LWS>
|
||||
// LWS = [CRLF] 1*( SP | HT )
|
||||
// CTL = <any US-ASCII control character
|
||||
// (octets 0 - 31) and DEL (127)>
|
||||
//
|
||||
// RFC 7230 says:
|
||||
// field-value = *( field-content / obs-fold )
|
||||
// obj-fold = N/A to http2, and deprecated
|
||||
// field-content = field-vchar [ 1*( SP / HTAB ) field-vchar ]
|
||||
// field-vchar = VCHAR / obs-text
|
||||
// obs-text = %x80-FF
|
||||
// VCHAR = "any visible [USASCII] character"
|
||||
//
|
||||
// http2 further says: "Similarly, HTTP/2 allows header field values
|
||||
// that are not valid. While most of the values that can be encoded
|
||||
// will not alter header field parsing, carriage return (CR, ASCII
|
||||
// 0xd), line feed (LF, ASCII 0xa), and the zero character (NUL, ASCII
|
||||
// 0x0) might be exploited by an attacker if they are translated
|
||||
// verbatim. Any request or response that contains a character not
|
||||
// permitted in a header field value MUST be treated as malformed
|
||||
// (Section 8.1.2.6). Valid characters are defined by the
|
||||
// field-content ABNF rule in Section 3.2 of [RFC7230]."
|
||||
//
|
||||
// This function does not (yet?) properly handle the rejection of
|
||||
// strings that begin or end with SP or HTAB.
|
||||
func ValidHeaderFieldValue(v string) bool { |
||||
for i := 0; i < len(v); i++ { |
||||
b := v[i] |
||||
if isCTL(b) && !isLWS(b) { |
||||
return false |
||||
} |
||||
} |
||||
return true |
||||
} |
||||
|
||||
func isASCII(s string) bool { |
||||
for i := 0; i < len(s); i++ { |
||||
if s[i] >= utf8.RuneSelf { |
||||
return false |
||||
} |
||||
} |
||||
return true |
||||
} |
||||
|
||||
// PunycodeHostPort returns the IDNA Punycode version
|
||||
// of the provided "host" or "host:port" string.
|
||||
func PunycodeHostPort(v string) (string, error) { |
||||
if isASCII(v) { |
||||
return v, nil |
||||
} |
||||
|
||||
host, port, err := net.SplitHostPort(v) |
||||
if err != nil { |
||||
// The input 'v' argument was just a "host" argument,
|
||||
// without a port. This error should not be returned
|
||||
// to the caller.
|
||||
host = v |
||||
port = "" |
||||
} |
||||
host, err = idna.ToASCII(host) |
||||
if err != nil { |
||||
// Non-UTF-8? Not representable in Punycode, in any
|
||||
// case.
|
||||
return "", err |
||||
} |
||||
if port == "" { |
||||
return host, nil |
||||
} |
||||
return net.JoinHostPort(host, port), nil |
||||
} |
Loading…
Reference in new issue