From 19bbde3b2ca4e882277092c912bdf5c4e27da21a Mon Sep 17 00:00:00 2001 From: ayn2op Date: Wed, 12 Aug 2026 02:08:43 -0400 Subject: [PATCH] feat(http): add Chromium client hints --- internal/http/headers.go | 4 ++++ internal/http/properties.go | 5 +++++ internal/http/properties_test.go | 20 ++++++++++++++++++++ internal/tls/profile.go | 8 ++++++-- 4 files changed, 35 insertions(+), 2 deletions(-) diff --git a/internal/http/headers.go b/internal/http/headers.go index ba6e46d..dc9ea3f 100644 --- a/internal/http/headers.go +++ b/internal/http/headers.go @@ -23,6 +23,10 @@ func Headers() stdHttp.Header { headers.Set("Sec-Fetch-Mode", "cors") headers.Set("Sec-Fetch-Site", "same-origin") + headers.Set("Sec-Ch-Ua", BrowserBrands()) + headers.Set("Sec-Ch-Ua-Mobile", "?0") + headers.Set("Sec-Ch-Ua-Platform", `"`+OS+`"`) + headers.Set("X-Debug-Options", "bugReporterEnabled") headers.Set("X-Discord-Locale", string(Locale)) diff --git a/internal/http/properties.go b/internal/http/properties.go index 172c73a..c462198 100644 --- a/internal/http/properties.go +++ b/internal/http/properties.go @@ -19,6 +19,11 @@ func BrowserUserAgent() string { return "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) " + tls.BrowserName() + "/" + tls.BrowserVersion() + " Safari/537.36" } +func BrowserBrands() string { + version := tls.BrowserMajorVersion() + return `"Chromium";v="` + version + `", "Not-A.Brand";v="24", "Google ` + tls.BrowserName() + `";v="` + version + `"` +} + func CommonProperties() gateway.IdentifyProperties { return gateway.IdentifyProperties{ gateway.IdentifyDevice: "", diff --git a/internal/http/properties_test.go b/internal/http/properties_test.go index d4a7147..d1d91ca 100644 --- a/internal/http/properties_test.go +++ b/internal/http/properties_test.go @@ -33,3 +33,23 @@ func TestBrowserIdentity(t *testing.T) { t.Fatalf("user agent does not contain %q", product) } } + +func TestBrowserClientHints(t *testing.T) { + headers := Headers() + tests := []struct { + name string + want string + }{ + {"Sec-Ch-Ua", `"Chromium";v="146", "Not-A.Brand";v="24", "Google Chrome";v="146"`}, + {"Sec-Ch-Ua-Mobile", "?0"}, + {"Sec-Ch-Ua-Platform", `"Windows"`}, + } + + for _, test := range tests { + t.Run(test.name, func(t *testing.T) { + if got := headers.Get(test.name); got != test.want { + t.Fatalf("got = %q, want = %q", got, test.want) + } + }) + } +} diff --git a/internal/tls/profile.go b/internal/tls/profile.go index c836ed6..a87e91f 100644 --- a/internal/tls/profile.go +++ b/internal/tls/profile.go @@ -8,6 +8,10 @@ func BrowserName() string { return clientProfile.GetClientHelloId().Client } -func BrowserVersion() string { - return clientProfile.GetClientHelloId().Version + ".0.0.0" +func BrowserMajorVersion() string { + return clientProfile.GetClientHelloId().Version +} + +func BrowserVersion() string { + return BrowserMajorVersion() + ".0.0.0" }