mirror of
https://github.com/refraction-networking/utls.git
synced 2025-04-05 04:57:35 +03:00
fix: generate ClientHelloSpec only once (#306)
* fix: generate ClientHelloSpec only once * chore: remove empty line in u_parrots.go Co-authored-by: Gaukas Wang <i@gauk.as> Signed-off-by: adotkhan <61702862+adotkhan@users.noreply.github.com> --------- Signed-off-by: adotkhan <61702862+adotkhan@users.noreply.github.com> Co-authored-by: Gaukas Wang <i@gauk.as>
This commit is contained in:
parent
841ef93712
commit
4a28d1af44
2 changed files with 23 additions and 16 deletions
|
@ -32,6 +32,7 @@ type UConn struct {
|
||||||
sessionController *sessionController
|
sessionController *sessionController
|
||||||
|
|
||||||
clientHelloBuildStatus ClientHelloBuildStatus
|
clientHelloBuildStatus ClientHelloBuildStatus
|
||||||
|
clientHelloSpec *ClientHelloSpec
|
||||||
|
|
||||||
HandshakeState PubClientHandshakeState
|
HandshakeState PubClientHandshakeState
|
||||||
|
|
||||||
|
|
38
u_parrots.go
38
u_parrots.go
|
@ -2588,25 +2588,31 @@ func ShuffleChromeTLSExtensions(exts []TLSExtension) []TLSExtension {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (uconn *UConn) applyPresetByID(id ClientHelloID) (err error) {
|
func (uconn *UConn) applyPresetByID(id ClientHelloID) (err error) {
|
||||||
var spec ClientHelloSpec
|
|
||||||
uconn.ClientHelloID = id
|
if uconn.clientHelloSpec == nil {
|
||||||
// choose/generate the spec
|
var spec ClientHelloSpec
|
||||||
switch id.Client {
|
uconn.ClientHelloID = id
|
||||||
case helloRandomized, helloRandomizedNoALPN, helloRandomizedALPN:
|
|
||||||
spec, err = uconn.generateRandomizedSpec()
|
// choose/generate the spec
|
||||||
if err != nil {
|
switch id.Client {
|
||||||
return err
|
case helloRandomized, helloRandomizedNoALPN, helloRandomizedALPN:
|
||||||
}
|
spec, err = uconn.generateRandomizedSpec()
|
||||||
case helloCustom:
|
if err != nil {
|
||||||
return nil
|
return err
|
||||||
default:
|
}
|
||||||
spec, err = UTLSIdToSpec(id)
|
case helloCustom:
|
||||||
if err != nil {
|
return nil
|
||||||
return err
|
default:
|
||||||
|
spec, err = UTLSIdToSpec(id)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uconn.clientHelloSpec = &spec
|
||||||
}
|
}
|
||||||
|
|
||||||
return uconn.ApplyPreset(&spec)
|
return uconn.ApplyPreset(uconn.clientHelloSpec)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ApplyPreset should only be used in conjunction with HelloCustom to apply custom specs.
|
// ApplyPreset should only be used in conjunction with HelloCustom to apply custom specs.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue