Adjust constants and defaults

This commit is contained in:
Tulir Asokan 2023-08-24 13:37:21 +03:00
parent 6f21016ccf
commit 5f47cbc6e6
5 changed files with 10 additions and 8 deletions

View file

@ -105,6 +105,7 @@ var SpacedBlocks = [][]string{
{"appservice", "as_token"},
{"segment_key"},
{"metrics"},
{"google_messages"},
{"bridge"},
{"bridge", "command_prefix"},
{"bridge", "management_room_text"},

View file

@ -90,10 +90,10 @@ metrics:
google_messages:
# OS name to tell the phone. This is the name that shows up in the paired devices list.
os: mautrix-gmessages
os: Android (mautrix)
# Browser type to tell the phone. This decides which icon is shown.
# Valid types: OTHER, CHROME, FIREFOX, SAFARI, OPERA, IE, EDGE
browser: OTHER
browser: CHROME
# Device type to tell the phone. This also affects the icon, as well as how many sessions are allowed simultaneously.
# One web, two tablets and one PWA should be able to connect at the same time.
# Valid types: WEB, TABLET, PWA

View file

@ -1,8 +1,9 @@
package util
const GoogleAPIKey = "AIzaSyCA4RsOZUFrm9whhtGosPlJLmVPnfSHKz8"
const UserAgent = "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 (Linux; Android 13) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.0.0 Safari/537.36"
const SecUA = `"Google Chrome";v="113", "Chromium";v="113", "Not-A.Brand";v="24"`
const UAPlatform = "Linux"
const UAPlatform = "Android"
const XUserAgent = "grpc-web-javascript/0.1"
const QRCodeURLBase = "https://support.google.com/messages/?p=web_computer#?c="
const SecUAMobile = "?1"

View file

@ -27,7 +27,7 @@ func BuildRelayHeaders(req *http.Request, contentType string, accept string) {
if len(contentType) > 0 {
req.Header.Add("content-type", contentType)
}
req.Header.Add("sec-ch-ua-mobile", "?0")
req.Header.Add("sec-ch-ua-mobile", SecUAMobile)
req.Header.Add("user-agent", UserAgent)
req.Header.Add("sec-ch-ua-platform", "\""+UAPlatform+"\"")
req.Header.Add("accept", accept)
@ -44,7 +44,7 @@ func BuildUploadHeaders(req *http.Request, metadata string) {
req.Header.Add("connection", "keep-alive")
req.Header.Add("x-goog-download-metadata", metadata)
req.Header.Add("sec-ch-ua", SecUA)
req.Header.Add("sec-ch-ua-mobile", "?0")
req.Header.Add("sec-ch-ua-mobile", SecUAMobile)
req.Header.Add("user-agent", UserAgent)
req.Header.Add("sec-ch-ua-platform", "\""+UAPlatform+"\"")
req.Header.Add("accept", "*/*")
@ -67,7 +67,7 @@ func NewMediaUploadHeaders(imageSize string, command string, uploadOffset string
headers.Add("x-goog-upload-protocol", protocol)
}
headers.Add("x-goog-upload-header-content-length", imageSize)
headers.Add("sec-ch-ua-mobile", "?0")
headers.Add("sec-ch-ua-mobile", SecUAMobile)
headers.Add("user-agent", UserAgent)
if imageContentType != "" {
headers.Add("x-goog-upload-header-content-type", imageContentType)

View file

@ -397,7 +397,7 @@ func (user *User) Login(maxAttempts int) (<-chan qrChannelItem, error) {
user.createClient(libgm.NewAuthData())
qr, err := user.Client.StartLogin()
if err != nil {
user.DeleteConnection()
user.unlockedDeleteConnection()
user.pairSuccessChan = nil
user.loginInProgress.Store(false)
return nil, fmt.Errorf("failed to connect to Google Messages: %w", err)