mirror of
https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake.git
synced 2025-10-13 20:11:19 -04:00
Add name to utls client hello id
This commit is contained in:
parent
c1b0f763ef
commit
c1c3596cf8
1 changed files with 38 additions and 0 deletions
38
common/utls/client_hello_id.go
Normal file
38
common/utls/client_hello_id.go
Normal file
|
@ -0,0 +1,38 @@
|
|||
package utls
|
||||
|
||||
import (
|
||||
"errors"
|
||||
utls "github.com/refraction-networking/utls"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// ported from https://github.com/max-b/snowflake/commit/9dded063cb74c6941a16ad90b9dd0e06e618e55e
|
||||
var clientHelloIDMap = map[string]utls.ClientHelloID{
|
||||
// No HelloCustom: not useful for external configuration.
|
||||
// No HelloRandomized: doesn't negotiate consistent ALPN.
|
||||
"hellorandomizedalpn": utls.HelloRandomizedALPN,
|
||||
"hellorandomizednoalpn": utls.HelloRandomizedNoALPN,
|
||||
"hellofirefox_auto": utls.HelloFirefox_Auto,
|
||||
"hellofirefox_55": utls.HelloFirefox_55,
|
||||
"hellofirefox_56": utls.HelloFirefox_56,
|
||||
"hellofirefox_63": utls.HelloFirefox_63,
|
||||
"hellofirefox_65": utls.HelloFirefox_65,
|
||||
"hellochrome_auto": utls.HelloChrome_Auto,
|
||||
"hellochrome_58": utls.HelloChrome_58,
|
||||
"hellochrome_62": utls.HelloChrome_62,
|
||||
"hellochrome_70": utls.HelloChrome_70,
|
||||
"hellochrome_72": utls.HelloChrome_72,
|
||||
"helloios_auto": utls.HelloIOS_Auto,
|
||||
"helloios_11_1": utls.HelloIOS_11_1,
|
||||
"helloios_12_1": utls.HelloIOS_12_1,
|
||||
}
|
||||
|
||||
var errNameNotFound = errors.New("client hello name is unrecognized")
|
||||
|
||||
func NameToUTlsID(name string) (utls.ClientHelloID, error) {
|
||||
normalizedName := strings.ToLower(name)
|
||||
if id, ok := clientHelloIDMap[normalizedName]; ok {
|
||||
return id, nil
|
||||
}
|
||||
return utls.ClientHelloID{}, errNameNotFound
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue