feat: parse GREASE ECH from raw ()

This commit is contained in:
Gaukas Wang 2023-12-22 11:16:33 -07:00 committed by GitHub
parent f8beb04616
commit 42e79cb29a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 194 additions and 6 deletions

View file

@ -619,12 +619,19 @@ func (uconn *UConn) ApplyConfig() error {
}
func (uconn *UConn) MarshalClientHello() error {
if uconn.ech != nil {
if len(uconn.config.ECHConfigs) > 0 && uconn.ech != nil {
if err := uconn.ech.Configure(uconn.config.ECHConfigs); err != nil {
return err
}
return uconn.ech.MarshalClientHello(uconn)
}
return uconn.MarshalClientHelloNoECH() // if no ECH pointer, just marshal normally
}
// MarshalClientHelloNoECH marshals ClientHello as if there was no
// ECH extension present.
func (uconn *UConn) MarshalClientHelloNoECH() error {
hello := uconn.HandshakeState.Hello
headerLength := 2 + 32 + 1 + len(hello.SessionId) +
2 + len(hello.CipherSuites)*2 +