|
|
@@ -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 {
|