Make constants actual constants

This commit is contained in:
Tulir Asokan 2023-06-30 16:31:35 +03:00
parent f2853d78b5
commit 9aa0894115
5 changed files with 13 additions and 13 deletions

View file

@ -43,7 +43,7 @@ func RegisterPhoneRelay(jwk *crypto.JWK) ([]byte, *binary.Container, error) {
}, },
}, },
BrowserDetails: &binary.BrowserDetails{ BrowserDetails: &binary.BrowserDetails{
UserAgent: util.USER_AGENT, UserAgent: util.UserAgent,
SomeInt: 2, SomeInt: 2,
SomeBool: true, SomeBool: true,
Os: util.OS, Os: util.OS,

View file

@ -18,5 +18,5 @@ func (p *Pairer) GenerateQRCodeData() (string, error) {
return "", err return "", err
} }
cData := base64.StdEncoding.EncodeToString(encodedUrlData) cData := base64.StdEncoding.EncodeToString(encodedUrlData)
return util.QR_CODE_URL + cData, nil return util.QRCodeURLBase + cData, nil
} }

View file

@ -1,7 +1,7 @@
package util package util
var GOOG_API_KEY = "AIzaSyCA4RsOZUFrm9whhtGosPlJLmVPnfSHKz8" const GoogleAPIKey = "AIzaSyCA4RsOZUFrm9whhtGosPlJLmVPnfSHKz8"
var USER_AGENT = "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.0.0 Safari/537.36" const UserAgent = "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.0.0 Safari/537.36"
var OS = "Linux" const OS = "Linux"
var X_USER_AGENT = "grpc-web-javascript/0.1" const XUserAgent = "grpc-web-javascript/0.1"
var QR_CODE_URL = "https://support.google.com/messages/?p=web_computer#?c=" const QRCodeURLBase = "https://support.google.com/messages/?p=web_computer#?c="

View file

@ -64,13 +64,13 @@ func BuildRelayHeaders(req *http.Request, contentType string, accept string) {
req.Header.Add("host", "instantmessaging-pa.googleapis.com") req.Header.Add("host", "instantmessaging-pa.googleapis.com")
req.Header.Add("connection", "keep-alive") req.Header.Add("connection", "keep-alive")
req.Header.Add("sec-ch-ua", "\"Google Chrome\";v=\"113\", \"Chromium\";v=\"113\", \"Not-A.Brand\";v=\"24\"") req.Header.Add("sec-ch-ua", "\"Google Chrome\";v=\"113\", \"Chromium\";v=\"113\", \"Not-A.Brand\";v=\"24\"")
req.Header.Add("x-user-agent", X_USER_AGENT) req.Header.Add("x-user-agent", XUserAgent)
req.Header.Add("x-goog-api-key", GOOG_API_KEY) req.Header.Add("x-goog-api-key", GoogleAPIKey)
if len(contentType) > 0 { if len(contentType) > 0 {
req.Header.Add("content-type", contentType) req.Header.Add("content-type", contentType)
} }
req.Header.Add("sec-ch-ua-mobile", "?0") req.Header.Add("sec-ch-ua-mobile", "?0")
req.Header.Add("user-agent", USER_AGENT) req.Header.Add("user-agent", UserAgent)
req.Header.Add("sec-ch-ua-platform", "\""+OS+"\"") req.Header.Add("sec-ch-ua-platform", "\""+OS+"\"")
req.Header.Add("accept", accept) req.Header.Add("accept", accept)
req.Header.Add("origin", "https://messages.google.com") req.Header.Add("origin", "https://messages.google.com")
@ -87,7 +87,7 @@ func BuildUploadHeaders(req *http.Request, metadata string) {
req.Header.Add("x-goog-download-metadata", metadata) req.Header.Add("x-goog-download-metadata", metadata)
req.Header.Add("sec-ch-ua", "\"Google Chrome\";v=\"113\", \"Chromium\";v=\"113\", \"Not-A.Brand\";v=\"24\"") req.Header.Add("sec-ch-ua", "\"Google Chrome\";v=\"113\", \"Chromium\";v=\"113\", \"Not-A.Brand\";v=\"24\"")
req.Header.Add("sec-ch-ua-mobile", "?0") req.Header.Add("sec-ch-ua-mobile", "?0")
req.Header.Add("user-agent", USER_AGENT) req.Header.Add("user-agent", UserAgent)
req.Header.Add("sec-ch-ua-platform", "\""+OS+"\"") req.Header.Add("sec-ch-ua-platform", "\""+OS+"\"")
req.Header.Add("accept", "*/*") req.Header.Add("accept", "*/*")
req.Header.Add("origin", "https://messages.google.com") req.Header.Add("origin", "https://messages.google.com")
@ -110,7 +110,7 @@ func NewMediaUploadHeaders(imageSize string, command string, uploadOffset string
} }
headers.Add("x-goog-upload-header-content-length", imageSize) headers.Add("x-goog-upload-header-content-length", imageSize)
headers.Add("sec-ch-ua-mobile", "?0") headers.Add("sec-ch-ua-mobile", "?0")
headers.Add("user-agent", USER_AGENT) headers.Add("user-agent", UserAgent)
if imageContentType != "" { if imageContentType != "" {
headers.Add("x-goog-upload-header-content-type", imageContentType) headers.Add("x-goog-upload-header-content-type", imageContentType)
} }

View file

@ -32,7 +32,7 @@ func (h *Headers) Build() {
h.SecChUaMobile = "?0" h.SecChUaMobile = "?0"
h.SecChUaPlatform = `"Linux"` h.SecChUaPlatform = `"Linux"`
h.UpgradeInsecureRequests = "1" h.UpgradeInsecureRequests = "1"
h.UserAgent = USER_AGENT h.UserAgent = UserAgent
h.Accept = `text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7` h.Accept = `text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7`
h.SecFetchSite = "none" h.SecFetchSite = "none"
h.SecFetchMode = "navigate" h.SecFetchMode = "navigate"