diff --git a/libgm/client.go b/libgm/client.go index e382499..eb2faf5 100644 --- a/libgm/client.go +++ b/libgm/client.go @@ -212,7 +212,7 @@ func (c *Client) DownloadMedia(mediaID string, key []byte) ([]byte, error) { return nil, err2 } downloadMetadataEncoded := base64.StdEncoding.EncodeToString(downloadMetadataBytes) - req, err := http.NewRequest("GET", util.UPLOAD_MEDIA, nil) + req, err := http.NewRequest("GET", util.UploadMediaURL, nil) if err != nil { return nil, err } @@ -221,7 +221,7 @@ func (c *Client) DownloadMedia(mediaID string, key []byte) ([]byte, error) { if reqErr != nil { return nil, reqErr } - c.Logger.Info().Any("url", util.UPLOAD_MEDIA).Any("headers", res.Request.Header).Msg("Decrypt Image Headers") + c.Logger.Info().Any("url", util.UploadMediaURL).Any("headers", res.Request.Header).Msg("Decrypt Image Headers") defer res.Body.Close() encryptedBuffImg, err3 := io.ReadAll(res.Body) if err3 != nil { @@ -240,7 +240,7 @@ func (c *Client) DownloadMedia(mediaID string, key []byte) ([]byte, error) { } func (c *Client) FetchConfigVersion() { - req, bErr := http.NewRequest("GET", util.CONFIG_URL, nil) + req, bErr := http.NewRequest("GET", util.ConfigUrl, nil) if bErr != nil { panic(bErr) } @@ -345,7 +345,7 @@ func (c *Client) refreshAuthToken() error { c.Logger.Info().Any("payload", string(payloadMessage)).Msg("Attempting to refresh auth token") - refreshResponse, requestErr := c.rpc.sendMessageRequest(util.REGISTER_REFRESH, payloadMessage) + refreshResponse, requestErr := c.rpc.sendMessageRequest(util.RegisterRefreshURL, payloadMessage) if requestErr != nil { return requestErr } diff --git a/libgm/media_processor.go b/libgm/media_processor.go index c0bff6e..c36b1a7 100644 --- a/libgm/media_processor.go +++ b/libgm/media_processor.go @@ -88,7 +88,7 @@ func (c *Client) StartUploadMedia(encryptedImageBytes []byte, mime string) (*Sta return nil, buildPayloadErr } - req, reqErr := http.NewRequest("POST", util.UPLOAD_MEDIA, bytes.NewBuffer([]byte(startUploadPayload))) + req, reqErr := http.NewRequest("POST", util.UploadMediaURL, bytes.NewBuffer([]byte(startUploadPayload))) if reqErr != nil { return nil, reqErr } diff --git a/libgm/pair.go b/libgm/pair.go index 2c583dc..ac2211e 100644 --- a/libgm/pair.go +++ b/libgm/pair.go @@ -50,7 +50,7 @@ func (p *Pairer) RegisterPhoneRelay() (*binary.RegisterPhoneRelayResponse, error p.client.Logger.Err(err) return &binary.RegisterPhoneRelayResponse{}, err } - relayResponse, reqErr := p.client.MakeRelayRequest(util.REGISTER_PHONE_RELAY, body) + relayResponse, reqErr := p.client.MakeRelayRequest(util.RegisterPhoneRelayURL, body) if reqErr != nil { p.client.Logger.Err(reqErr) return nil, err @@ -102,7 +102,7 @@ func (p *Pairer) RefreshPhoneRelay() { p.client.Logger.Err(err).Msg("refresh phone relay err") return } - relayResponse, reqErr := p.client.MakeRelayRequest(util.REFRESH_PHONE_RELAY, body) + relayResponse, reqErr := p.client.MakeRelayRequest(util.RefreshPhoneRelayURL, body) if reqErr != nil { p.client.Logger.Err(reqErr).Msg("refresh phone relay err") } @@ -137,7 +137,7 @@ func (c *Client) GetWebEncryptionKey() (*binary.WebEncryptionKeyResponse, error) if err != nil { return nil, err } - webKeyResponse, err := c.MakeRelayRequest(util.GET_WEB_ENCRYPTION_KEY, body) + webKeyResponse, err := c.MakeRelayRequest(util.GetWebEncryptionKeyURL, body) if err != nil { return nil, err } @@ -174,7 +174,7 @@ func (c *Client) Unpair() (*binary.RevokeRelayPairingResponse, error) { if err != nil { return nil, err } - revokeResp, err := c.MakeRelayRequest(util.REVOKE_RELAY_PAIRING, payload) + revokeResp, err := c.MakeRelayRequest(util.RevokeRelayPairingURL, payload) if err != nil { return nil, err } diff --git a/libgm/rpc.go b/libgm/rpc.go index 987477d..8d04de9 100644 --- a/libgm/rpc.go +++ b/libgm/rpc.go @@ -49,7 +49,7 @@ func (r *RPC) ListenReceiveMessages(payload []byte) { } } r.client.Logger.Debug().Msg("Starting new long-polling request") - req, err := http.NewRequest("POST", util.RECEIVE_MESSAGES, bytes.NewReader(payload)) + req, err := http.NewRequest("POST", util.ReceiveMessagesURL, bytes.NewReader(payload)) if err != nil { panic(fmt.Errorf("Error creating request: %v", err)) } diff --git a/libgm/session_handler.go b/libgm/session_handler.go index 2f20ebf..322d250 100644 --- a/libgm/session_handler.go +++ b/libgm/session_handler.go @@ -41,7 +41,7 @@ func (s *SessionHandler) sendMessageNoResponse(actionType binary.ActionType, enc return err } - _, err = s.client.rpc.sendMessageRequest(util.SEND_MESSAGE, payload) + _, err = s.client.rpc.sendMessageRequest(util.SendMessageURL, payload) return err } @@ -52,7 +52,7 @@ func (s *SessionHandler) sendAsyncMessage(actionType binary.ActionType, encrypte } ch := s.waitResponse(requestID) - _, reqErr := s.client.rpc.sendMessageRequest(util.SEND_MESSAGE, payload) + _, reqErr := s.client.rpc.sendMessageRequest(util.SendMessageURL, payload) if reqErr != nil { s.cancelResponse(requestID, ch) return nil, reqErr @@ -157,7 +157,7 @@ func (s *SessionHandler) sendAckRequest() { if err != nil { panic(err) } - _, err = s.client.rpc.sendMessageRequest(util.ACK_MESSAGES, jsonData) + _, err = s.client.rpc.sendMessageRequest(util.AckMessagesURL, jsonData) if err != nil { panic(err) } diff --git a/libgm/util/paths.go b/libgm/util/paths.go index 686910d..a618cd3 100644 --- a/libgm/util/paths.go +++ b/libgm/util/paths.go @@ -1,26 +1,26 @@ package util -var MESSAGES_GOOGLE_BASE_URL = "https://messages.google.com" +const messagesBaseURL = "https://messages.google.com" -var MESSAGES_GOOGLE_AUTHENTICATION = MESSAGES_GOOGLE_BASE_URL + "/web/authentication" -var MESSAGES_GOOGLE_TIMESOURCE = MESSAGES_GOOGLE_BASE_URL + "/web/timesource" +const GoogleAuthenticationURL = messagesBaseURL + "/web/authentication" +const GoogleTimesourceURL = messagesBaseURL + "/web/timesource" -var INSTANT_MESSAGING = "https://instantmessaging-pa.googleapis.com" +const instantMessangingBaseURL = "https://instantmessaging-pa.googleapis.com" -var UPLOAD_MEDIA = INSTANT_MESSAGING + "/upload" +const UploadMediaURL = instantMessangingBaseURL + "/upload" -var PAIRING = INSTANT_MESSAGING + "/$rpc/google.internal.communications.instantmessaging.v1.Pairing" -var REGISTER_PHONE_RELAY = PAIRING + "/RegisterPhoneRelay" -var REFRESH_PHONE_RELAY = PAIRING + "/RefreshPhoneRelay" -var GET_WEB_ENCRYPTION_KEY = PAIRING + "/GetWebEncryptionKey" -var REVOKE_RELAY_PAIRING = PAIRING + "/RevokeRelayPairing" +const pairingBaseURL = instantMessangingBaseURL + "/$rpc/google.internal.communications.instantmessaging.v1.Pairing" +const RegisterPhoneRelayURL = pairingBaseURL + "/RegisterPhoneRelay" +const RefreshPhoneRelayURL = pairingBaseURL + "/RefreshPhoneRelay" +const GetWebEncryptionKeyURL = pairingBaseURL + "/GetWebEncryptionKey" +const RevokeRelayPairingURL = pairingBaseURL + "/RevokeRelayPairing" -var MESSAGING = INSTANT_MESSAGING + "/$rpc/google.internal.communications.instantmessaging.v1.Messaging" -var RECEIVE_MESSAGES = MESSAGING + "/ReceiveMessages" -var SEND_MESSAGE = MESSAGING + "/SendMessage" -var ACK_MESSAGES = MESSAGING + "/AckMessages" +const messagingBaseURL = instantMessangingBaseURL + "/$rpc/google.internal.communications.instantmessaging.v1.Messaging" +const ReceiveMessagesURL = messagingBaseURL + "/ReceiveMessages" +const SendMessageURL = messagingBaseURL + "/SendMessage" +const AckMessagesURL = messagingBaseURL + "/AckMessages" -var REGISTRATION = INSTANT_MESSAGING + "/$rpc/google.internal.communications.instantmessaging.v1.Registration" -var REGISTER_REFRESH = REGISTRATION + "/RegisterRefresh" +const registrationBaseURL = instantMessangingBaseURL + "/$rpc/google.internal.communications.instantmessaging.v1.Registration" +const RegisterRefreshURL = registrationBaseURL + "/RegisterRefresh" -var CONFIG_URL = "https://messages.google.com/web/config" +const ConfigUrl = "https://messages.google.com/web/config"