Browse Source

Update vendored utls

- Fixes GREASE bug
Rod Hynes 5 years ago
parent
commit
e03c264a00

+ 25 - 0
vendor/github.com/refraction-networking/utls/u_conn.go

@@ -30,6 +30,8 @@ type UConn struct {
 	GetSessionID func(ticket []byte) [32]byte
 
 	greaseSeed [ssl_grease_last_index]uint16
+
+	omitSNIExtension bool
 }
 
 // UClient returns a new uTLS client, with behavior depending on clientHelloID.
@@ -78,6 +80,9 @@ func (uconn *UConn) BuildHandshakeState() error {
 			if err != nil {
 				return err
 			}
+			if uconn.omitSNIExtension {
+				uconn.removeSNIExtension()
+			}
 		}
 
 		err := uconn.ApplyConfig()
@@ -162,6 +167,26 @@ func (uconn *UConn) SetSNI(sni string) {
 	}
 }
 
+// RemoveSNIExtension removes SNI from the list of extensions sent in ClientHello
+// It returns an error when used with HelloGolang ClientHelloID
+func (uconn *UConn) RemoveSNIExtension() error {
+	if uconn.ClientHelloID == HelloGolang {
+		return fmt.Errorf("Cannot call RemoveSNIExtension on a UConn with a HelloGolang ClientHelloID")
+	}
+	uconn.omitSNIExtension = true
+	return nil
+}
+
+func (uconn *UConn) removeSNIExtension() {
+	filteredExts := make([]TLSExtension, 0, len(uconn.Extensions))
+	for _, e := range uconn.Extensions {
+		if _, ok := e.(*SNIExtension); !ok {
+			filteredExts = append(filteredExts, e)
+		}
+	}
+	uconn.Extensions = filteredExts
+}
+
 // Handshake runs the client handshake using given clientHandshakeState
 // Requires hs.hello, and, optionally, hs.session to be set.
 func (c *UConn) Handshake() error {

+ 1 - 1
vendor/github.com/refraction-networking/utls/u_parrots.go

@@ -602,7 +602,7 @@ func (uconn *UConn) ApplyPreset(p *ClientHelloSpec) error {
 	for i := range uconn.greaseSeed {
 		uconn.greaseSeed[i] = binary.LittleEndian.Uint16(grease_bytes[2*i : 2*i+2])
 	}
-	if uconn.greaseSeed[ssl_grease_extension1] == uconn.greaseSeed[ssl_grease_extension2] {
+	if GetBoringGREASEValue(uconn.greaseSeed, ssl_grease_extension1) == GetBoringGREASEValue(uconn.greaseSeed, ssl_grease_extension2) {
 		uconn.greaseSeed[ssl_grease_extension2] ^= 0x1010
 	}
 

+ 3 - 3
vendor/vendor.json

@@ -490,10 +490,10 @@
 			"revisionTime": "2019-09-09T20:29:46Z"
 		},
 		{
-			"checksumSHA1": "1HFgQE+SHogT82ebPmvCUnGwrxo=",
+			"checksumSHA1": "OagdWaWcbCBQZR5bBGgGaK3nddE=",
 			"path": "github.com/refraction-networking/utls",
-			"revision": "ada0bb9b38a0975b15bb4591cd4a939fe74d1a1b",
-			"revisionTime": "2020-06-01T20:02:09Z"
+			"revision": "186025ac7b77465439618d1aeb2a5e444714d1cc",
+			"revisionTime": "2020-07-29T01:25:36Z"
 		},
 		{
 			"checksumSHA1": "Fn9JW8u40ABN9Uc9wuvquuyOB+8=",