Skip to content

Commit

Permalink
Add hack to ignore weird pre-response data
Browse files Browse the repository at this point in the history
  • Loading branch information
tulir committed Feb 23, 2024
1 parent 1df5dfe commit a59074a
Show file tree
Hide file tree
Showing 4 changed files with 141 additions and 53 deletions.
168 changes: 119 additions & 49 deletions libgm/gmproto/rpc.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified libgm/gmproto/rpc.pb.raw
Binary file not shown.
13 changes: 10 additions & 3 deletions libgm/gmproto/rpc.proto
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ message LongPollingPayload {
message IncomingRPCMessage {
string responseID = 1;
BugleRoute bugleRoute = 2;
string startExecute = 3;
uint64 startExecute = 3;

MessageType messageType = 5;
string finishExecute = 6;
string microsecondsTaken = 7;
uint64 finishExecute = 6;
uint64 microsecondsTaken = 7;
authentication.Device mobile = 8;
authentication.Device browser = 9;

Expand All @@ -35,6 +35,13 @@ message IncomingRPCMessage {
string signatureID = 17;

string timestamp = 21;

message GDittoSource {
int32 deviceID = 2;
}

// Completely unsure about this, but it seems to be present for weird intermediate responses
GDittoSource gdittoSource = 23;
}

message RPCMessageData {
Expand Down
13 changes: 12 additions & 1 deletion libgm/session_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func typedResponse[T proto.Message](resp *IncomingRPCMessage, err error) (casted
var ok bool
casted, ok = resp.DecryptedMessage.(T)
if !ok {
retErr = fmt.Errorf("unexpected response type %T, expected %T", resp.DecryptedMessage, casted)
retErr = fmt.Errorf("unexpected response type %T for %s, expected %T", resp.DecryptedMessage, resp.ResponseID, casted)
}
return
}
Expand All @@ -100,6 +100,17 @@ func (s *SessionHandler) receiveResponse(msg *IncomingRPCMessage) bool {
if msg.Message == nil {
return false
}
if s.client.AuthData.Cookies != nil {
switch msg.Message.Action {
case gmproto.ActionType_CREATE_GAIA_PAIRING_CLIENT_INIT, gmproto.ActionType_CREATE_GAIA_PAIRING_CLIENT_FINISHED:
default:
// Very hacky way to ignore weird messages that come before real responses
// TODO figure out how to properly handle these
if msg.Message.UnencryptedData != nil && msg.Message.EncryptedData == nil {
return false
}
}
}
requestID := msg.Message.SessionID
s.responseWaitersLock.Lock()
ch, ok := s.responseWaiters[requestID]
Expand Down

0 comments on commit a59074a

Please sign in to comment.