[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [pluggable-transports/snowflake] 04/13: Add name to utls client hello id



This is an automated email from the git hooks/post-receive script.

shelikhoo pushed a commit to branch main
in repository pluggable-transports/snowflake.

commit c1c3596cf8bbc87b180e6d916da9515e27609969
Author: Max Bittman <bittmanmax@xxxxxxxxx>
AuthorDate: Thu Feb 10 11:46:58 2022 +0000

    Add name to utls client hello id
---
 common/utls/client_hello_id.go | 38 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 38 insertions(+)

diff --git a/common/utls/client_hello_id.go b/common/utls/client_hello_id.go
new file mode 100644
index 0000000..e423cf3
--- /dev/null
+++ b/common/utls/client_hello_id.go
@@ -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
+}

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits