Add hacks to send bad credentials on startup too

This commit is contained in:
Tulir Asokan 2023-12-14 01:32:36 +02:00
parent 62bf2e608b
commit 5b1f6e4c7b
9 changed files with 193 additions and 87 deletions

View file

@ -4,9 +4,11 @@ import (
"crypto/sha256" "crypto/sha256"
"encoding/base64" "encoding/base64"
"fmt" "fmt"
"strings"
"google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"
"go.mau.fi/mautrix-gmessages/libgm/events"
"go.mau.fi/mautrix-gmessages/libgm/gmproto" "go.mau.fi/mautrix-gmessages/libgm/gmproto"
) )
@ -82,6 +84,26 @@ func (c *Client) decryptInternalMessage(data *gmproto.IncomingRPCMessage) (*Inco
return nil, fmt.Errorf("failed to decode decrypted data event: %w", err) return nil, fmt.Errorf("failed to decode decrypted data event: %w", err)
} }
} }
} else if msg.Message.EncryptedData2 != nil {
msg.DecryptedData, err = c.AuthData.RequestCrypto.Decrypt(msg.Message.EncryptedData2)
if err != nil {
return nil, fmt.Errorf("failed to decrypt field 2 in data event: %w", err)
}
var ed2c gmproto.EncryptedData2Container
err = proto.Unmarshal(msg.DecryptedData, &ed2c)
if err != nil {
c.Logger.Trace().
Str("data", base64.StdEncoding.EncodeToString(msg.DecryptedData)).
Msg("Errored decrypted data event content")
return nil, fmt.Errorf("failed to decode decrypted field 2 data event: %w", err)
}
// Hacky hack to have User.handleAccountChange do the right-ish thing on startup
if strings.ContainsRune(ed2c.GetAccountChange().GetAccount(), '@') {
c.triggerEvent(&events.AccountChange{
AccountChangeOrSomethingEvent: ed2c.GetAccountChange(),
IsFake: true,
})
}
} }
default: default:
return nil, fmt.Errorf("unknown bugle route %d", data.BugleRoute) return nil, fmt.Errorf("unknown bugle route %d", data.BugleRoute)
@ -228,7 +250,9 @@ func (c *Client) handleUpdatesEvent(msg *IncomingRPCMessage) {
case *gmproto.UpdateEvents_AccountChange: case *gmproto.UpdateEvents_AccountChange:
c.logContent(msg, "", nil) c.logContent(msg, "", nil)
c.triggerEvent(evt.AccountChange) c.triggerEvent(&events.AccountChange{
AccountChangeOrSomethingEvent: evt.AccountChange,
})
default: default:
c.Logger.Warn(). c.Logger.Warn().

View file

@ -15,6 +15,11 @@ type ClientReady struct {
type AuthTokenRefreshed struct{} type AuthTokenRefreshed struct{}
type AccountChange struct {
*gmproto.AccountChangeOrSomethingEvent
IsFake bool
}
var ErrRequestedEntityNotFound = RequestError{ var ErrRequestedEntityNotFound = RequestError{
Data: &gmproto.ErrorResponse{ Data: &gmproto.ErrorResponse{
Type: 5, Type: 5,

View file

@ -319,6 +319,53 @@ func (*UpdateEvents_BrowserPresenceCheckEvent) isUpdateEvents_Event() {}
func (*UpdateEvents_AccountChange) isUpdateEvents_Event() {} func (*UpdateEvents_AccountChange) isUpdateEvents_Event() {}
type EncryptedData2Container struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
AccountChange *AccountChangeOrSomethingEvent `protobuf:"bytes,2,opt,name=accountChange,proto3" json:"accountChange,omitempty"`
}
func (x *EncryptedData2Container) Reset() {
*x = EncryptedData2Container{}
if protoimpl.UnsafeEnabled {
mi := &file_events_proto_msgTypes[1]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *EncryptedData2Container) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*EncryptedData2Container) ProtoMessage() {}
func (x *EncryptedData2Container) ProtoReflect() protoreflect.Message {
mi := &file_events_proto_msgTypes[1]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use EncryptedData2Container.ProtoReflect.Descriptor instead.
func (*EncryptedData2Container) Descriptor() ([]byte, []int) {
return file_events_proto_rawDescGZIP(), []int{1}
}
func (x *EncryptedData2Container) GetAccountChange() *AccountChangeOrSomethingEvent {
if x != nil {
return x.AccountChange
}
return nil
}
type AccountChangeOrSomethingEvent struct { type AccountChangeOrSomethingEvent struct {
state protoimpl.MessageState state protoimpl.MessageState
sizeCache protoimpl.SizeCache sizeCache protoimpl.SizeCache
@ -331,7 +378,7 @@ type AccountChangeOrSomethingEvent struct {
func (x *AccountChangeOrSomethingEvent) Reset() { func (x *AccountChangeOrSomethingEvent) Reset() {
*x = AccountChangeOrSomethingEvent{} *x = AccountChangeOrSomethingEvent{}
if protoimpl.UnsafeEnabled { if protoimpl.UnsafeEnabled {
mi := &file_events_proto_msgTypes[1] mi := &file_events_proto_msgTypes[2]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi) ms.StoreMessageInfo(mi)
} }
@ -344,7 +391,7 @@ func (x *AccountChangeOrSomethingEvent) String() string {
func (*AccountChangeOrSomethingEvent) ProtoMessage() {} func (*AccountChangeOrSomethingEvent) ProtoMessage() {}
func (x *AccountChangeOrSomethingEvent) ProtoReflect() protoreflect.Message { func (x *AccountChangeOrSomethingEvent) ProtoReflect() protoreflect.Message {
mi := &file_events_proto_msgTypes[1] mi := &file_events_proto_msgTypes[2]
if protoimpl.UnsafeEnabled && x != nil { if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil { if ms.LoadMessageInfo() == nil {
@ -357,7 +404,7 @@ func (x *AccountChangeOrSomethingEvent) ProtoReflect() protoreflect.Message {
// Deprecated: Use AccountChangeOrSomethingEvent.ProtoReflect.Descriptor instead. // Deprecated: Use AccountChangeOrSomethingEvent.ProtoReflect.Descriptor instead.
func (*AccountChangeOrSomethingEvent) Descriptor() ([]byte, []int) { func (*AccountChangeOrSomethingEvent) Descriptor() ([]byte, []int) {
return file_events_proto_rawDescGZIP(), []int{1} return file_events_proto_rawDescGZIP(), []int{2}
} }
func (x *AccountChangeOrSomethingEvent) GetAccount() string { func (x *AccountChangeOrSomethingEvent) GetAccount() string {
@ -385,7 +432,7 @@ type ConversationEvent struct {
func (x *ConversationEvent) Reset() { func (x *ConversationEvent) Reset() {
*x = ConversationEvent{} *x = ConversationEvent{}
if protoimpl.UnsafeEnabled { if protoimpl.UnsafeEnabled {
mi := &file_events_proto_msgTypes[2] mi := &file_events_proto_msgTypes[3]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi) ms.StoreMessageInfo(mi)
} }
@ -398,7 +445,7 @@ func (x *ConversationEvent) String() string {
func (*ConversationEvent) ProtoMessage() {} func (*ConversationEvent) ProtoMessage() {}
func (x *ConversationEvent) ProtoReflect() protoreflect.Message { func (x *ConversationEvent) ProtoReflect() protoreflect.Message {
mi := &file_events_proto_msgTypes[2] mi := &file_events_proto_msgTypes[3]
if protoimpl.UnsafeEnabled && x != nil { if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil { if ms.LoadMessageInfo() == nil {
@ -411,7 +458,7 @@ func (x *ConversationEvent) ProtoReflect() protoreflect.Message {
// Deprecated: Use ConversationEvent.ProtoReflect.Descriptor instead. // Deprecated: Use ConversationEvent.ProtoReflect.Descriptor instead.
func (*ConversationEvent) Descriptor() ([]byte, []int) { func (*ConversationEvent) Descriptor() ([]byte, []int) {
return file_events_proto_rawDescGZIP(), []int{2} return file_events_proto_rawDescGZIP(), []int{3}
} }
func (x *ConversationEvent) GetData() []*Conversation { func (x *ConversationEvent) GetData() []*Conversation {
@ -432,7 +479,7 @@ type TypingEvent struct {
func (x *TypingEvent) Reset() { func (x *TypingEvent) Reset() {
*x = TypingEvent{} *x = TypingEvent{}
if protoimpl.UnsafeEnabled { if protoimpl.UnsafeEnabled {
mi := &file_events_proto_msgTypes[3] mi := &file_events_proto_msgTypes[4]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi) ms.StoreMessageInfo(mi)
} }
@ -445,7 +492,7 @@ func (x *TypingEvent) String() string {
func (*TypingEvent) ProtoMessage() {} func (*TypingEvent) ProtoMessage() {}
func (x *TypingEvent) ProtoReflect() protoreflect.Message { func (x *TypingEvent) ProtoReflect() protoreflect.Message {
mi := &file_events_proto_msgTypes[3] mi := &file_events_proto_msgTypes[4]
if protoimpl.UnsafeEnabled && x != nil { if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil { if ms.LoadMessageInfo() == nil {
@ -458,7 +505,7 @@ func (x *TypingEvent) ProtoReflect() protoreflect.Message {
// Deprecated: Use TypingEvent.ProtoReflect.Descriptor instead. // Deprecated: Use TypingEvent.ProtoReflect.Descriptor instead.
func (*TypingEvent) Descriptor() ([]byte, []int) { func (*TypingEvent) Descriptor() ([]byte, []int) {
return file_events_proto_rawDescGZIP(), []int{3} return file_events_proto_rawDescGZIP(), []int{4}
} }
func (x *TypingEvent) GetData() *TypingData { func (x *TypingEvent) GetData() *TypingData {
@ -479,7 +526,7 @@ type MessageEvent struct {
func (x *MessageEvent) Reset() { func (x *MessageEvent) Reset() {
*x = MessageEvent{} *x = MessageEvent{}
if protoimpl.UnsafeEnabled { if protoimpl.UnsafeEnabled {
mi := &file_events_proto_msgTypes[4] mi := &file_events_proto_msgTypes[5]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi) ms.StoreMessageInfo(mi)
} }
@ -492,7 +539,7 @@ func (x *MessageEvent) String() string {
func (*MessageEvent) ProtoMessage() {} func (*MessageEvent) ProtoMessage() {}
func (x *MessageEvent) ProtoReflect() protoreflect.Message { func (x *MessageEvent) ProtoReflect() protoreflect.Message {
mi := &file_events_proto_msgTypes[4] mi := &file_events_proto_msgTypes[5]
if protoimpl.UnsafeEnabled && x != nil { if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil { if ms.LoadMessageInfo() == nil {
@ -505,7 +552,7 @@ func (x *MessageEvent) ProtoReflect() protoreflect.Message {
// Deprecated: Use MessageEvent.ProtoReflect.Descriptor instead. // Deprecated: Use MessageEvent.ProtoReflect.Descriptor instead.
func (*MessageEvent) Descriptor() ([]byte, []int) { func (*MessageEvent) Descriptor() ([]byte, []int) {
return file_events_proto_rawDescGZIP(), []int{4} return file_events_proto_rawDescGZIP(), []int{5}
} }
func (x *MessageEvent) GetData() []*Message { func (x *MessageEvent) GetData() []*Message {
@ -526,7 +573,7 @@ type UserAlertEvent struct {
func (x *UserAlertEvent) Reset() { func (x *UserAlertEvent) Reset() {
*x = UserAlertEvent{} *x = UserAlertEvent{}
if protoimpl.UnsafeEnabled { if protoimpl.UnsafeEnabled {
mi := &file_events_proto_msgTypes[5] mi := &file_events_proto_msgTypes[6]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi) ms.StoreMessageInfo(mi)
} }
@ -539,7 +586,7 @@ func (x *UserAlertEvent) String() string {
func (*UserAlertEvent) ProtoMessage() {} func (*UserAlertEvent) ProtoMessage() {}
func (x *UserAlertEvent) ProtoReflect() protoreflect.Message { func (x *UserAlertEvent) ProtoReflect() protoreflect.Message {
mi := &file_events_proto_msgTypes[5] mi := &file_events_proto_msgTypes[6]
if protoimpl.UnsafeEnabled && x != nil { if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil { if ms.LoadMessageInfo() == nil {
@ -552,7 +599,7 @@ func (x *UserAlertEvent) ProtoReflect() protoreflect.Message {
// Deprecated: Use UserAlertEvent.ProtoReflect.Descriptor instead. // Deprecated: Use UserAlertEvent.ProtoReflect.Descriptor instead.
func (*UserAlertEvent) Descriptor() ([]byte, []int) { func (*UserAlertEvent) Descriptor() ([]byte, []int) {
return file_events_proto_rawDescGZIP(), []int{5} return file_events_proto_rawDescGZIP(), []int{6}
} }
func (x *UserAlertEvent) GetAlertType() AlertType { func (x *UserAlertEvent) GetAlertType() AlertType {
@ -571,7 +618,7 @@ type BrowserPresenceCheckEvent struct {
func (x *BrowserPresenceCheckEvent) Reset() { func (x *BrowserPresenceCheckEvent) Reset() {
*x = BrowserPresenceCheckEvent{} *x = BrowserPresenceCheckEvent{}
if protoimpl.UnsafeEnabled { if protoimpl.UnsafeEnabled {
mi := &file_events_proto_msgTypes[6] mi := &file_events_proto_msgTypes[7]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi) ms.StoreMessageInfo(mi)
} }
@ -584,7 +631,7 @@ func (x *BrowserPresenceCheckEvent) String() string {
func (*BrowserPresenceCheckEvent) ProtoMessage() {} func (*BrowserPresenceCheckEvent) ProtoMessage() {}
func (x *BrowserPresenceCheckEvent) ProtoReflect() protoreflect.Message { func (x *BrowserPresenceCheckEvent) ProtoReflect() protoreflect.Message {
mi := &file_events_proto_msgTypes[6] mi := &file_events_proto_msgTypes[7]
if protoimpl.UnsafeEnabled && x != nil { if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil { if ms.LoadMessageInfo() == nil {
@ -597,7 +644,7 @@ func (x *BrowserPresenceCheckEvent) ProtoReflect() protoreflect.Message {
// Deprecated: Use BrowserPresenceCheckEvent.ProtoReflect.Descriptor instead. // Deprecated: Use BrowserPresenceCheckEvent.ProtoReflect.Descriptor instead.
func (*BrowserPresenceCheckEvent) Descriptor() ([]byte, []int) { func (*BrowserPresenceCheckEvent) Descriptor() ([]byte, []int) {
return file_events_proto_rawDescGZIP(), []int{6} return file_events_proto_rawDescGZIP(), []int{7}
} }
type TypingData struct { type TypingData struct {
@ -613,7 +660,7 @@ type TypingData struct {
func (x *TypingData) Reset() { func (x *TypingData) Reset() {
*x = TypingData{} *x = TypingData{}
if protoimpl.UnsafeEnabled { if protoimpl.UnsafeEnabled {
mi := &file_events_proto_msgTypes[7] mi := &file_events_proto_msgTypes[8]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi) ms.StoreMessageInfo(mi)
} }
@ -626,7 +673,7 @@ func (x *TypingData) String() string {
func (*TypingData) ProtoMessage() {} func (*TypingData) ProtoMessage() {}
func (x *TypingData) ProtoReflect() protoreflect.Message { func (x *TypingData) ProtoReflect() protoreflect.Message {
mi := &file_events_proto_msgTypes[7] mi := &file_events_proto_msgTypes[8]
if protoimpl.UnsafeEnabled && x != nil { if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil { if ms.LoadMessageInfo() == nil {
@ -639,7 +686,7 @@ func (x *TypingData) ProtoReflect() protoreflect.Message {
// Deprecated: Use TypingData.ProtoReflect.Descriptor instead. // Deprecated: Use TypingData.ProtoReflect.Descriptor instead.
func (*TypingData) Descriptor() ([]byte, []int) { func (*TypingData) Descriptor() ([]byte, []int) {
return file_events_proto_rawDescGZIP(), []int{7} return file_events_proto_rawDescGZIP(), []int{8}
} }
func (x *TypingData) GetConversationID() string { func (x *TypingData) GetConversationID() string {
@ -675,7 +722,7 @@ type User struct {
func (x *User) Reset() { func (x *User) Reset() {
*x = User{} *x = User{}
if protoimpl.UnsafeEnabled { if protoimpl.UnsafeEnabled {
mi := &file_events_proto_msgTypes[8] mi := &file_events_proto_msgTypes[9]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi) ms.StoreMessageInfo(mi)
} }
@ -688,7 +735,7 @@ func (x *User) String() string {
func (*User) ProtoMessage() {} func (*User) ProtoMessage() {}
func (x *User) ProtoReflect() protoreflect.Message { func (x *User) ProtoReflect() protoreflect.Message {
mi := &file_events_proto_msgTypes[8] mi := &file_events_proto_msgTypes[9]
if protoimpl.UnsafeEnabled && x != nil { if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil { if ms.LoadMessageInfo() == nil {
@ -701,7 +748,7 @@ func (x *User) ProtoReflect() protoreflect.Message {
// Deprecated: Use User.ProtoReflect.Descriptor instead. // Deprecated: Use User.ProtoReflect.Descriptor instead.
func (*User) Descriptor() ([]byte, []int) { func (*User) Descriptor() ([]byte, []int) {
return file_events_proto_rawDescGZIP(), []int{8} return file_events_proto_rawDescGZIP(), []int{9}
} }
func (x *User) GetField1() int64 { func (x *User) GetField1() int64 {
@ -733,7 +780,7 @@ type RPCPairData struct {
func (x *RPCPairData) Reset() { func (x *RPCPairData) Reset() {
*x = RPCPairData{} *x = RPCPairData{}
if protoimpl.UnsafeEnabled { if protoimpl.UnsafeEnabled {
mi := &file_events_proto_msgTypes[9] mi := &file_events_proto_msgTypes[10]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi) ms.StoreMessageInfo(mi)
} }
@ -746,7 +793,7 @@ func (x *RPCPairData) String() string {
func (*RPCPairData) ProtoMessage() {} func (*RPCPairData) ProtoMessage() {}
func (x *RPCPairData) ProtoReflect() protoreflect.Message { func (x *RPCPairData) ProtoReflect() protoreflect.Message {
mi := &file_events_proto_msgTypes[9] mi := &file_events_proto_msgTypes[10]
if protoimpl.UnsafeEnabled && x != nil { if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil { if ms.LoadMessageInfo() == nil {
@ -759,7 +806,7 @@ func (x *RPCPairData) ProtoReflect() protoreflect.Message {
// Deprecated: Use RPCPairData.ProtoReflect.Descriptor instead. // Deprecated: Use RPCPairData.ProtoReflect.Descriptor instead.
func (*RPCPairData) Descriptor() ([]byte, []int) { func (*RPCPairData) Descriptor() ([]byte, []int) {
return file_events_proto_rawDescGZIP(), []int{9} return file_events_proto_rawDescGZIP(), []int{10}
} }
func (m *RPCPairData) GetEvent() isRPCPairData_Event { func (m *RPCPairData) GetEvent() isRPCPairData_Event {
@ -817,47 +864,49 @@ func file_events_proto_rawDescGZIP() []byte {
} }
var file_events_proto_enumTypes = make([]protoimpl.EnumInfo, 2) var file_events_proto_enumTypes = make([]protoimpl.EnumInfo, 2)
var file_events_proto_msgTypes = make([]protoimpl.MessageInfo, 10) var file_events_proto_msgTypes = make([]protoimpl.MessageInfo, 11)
var file_events_proto_goTypes = []interface{}{ var file_events_proto_goTypes = []interface{}{
(AlertType)(0), // 0: events.AlertType (AlertType)(0), // 0: events.AlertType
(TypingTypes)(0), // 1: events.TypingTypes (TypingTypes)(0), // 1: events.TypingTypes
(*UpdateEvents)(nil), // 2: events.UpdateEvents (*UpdateEvents)(nil), // 2: events.UpdateEvents
(*AccountChangeOrSomethingEvent)(nil), // 3: events.AccountChangeOrSomethingEvent (*EncryptedData2Container)(nil), // 3: events.EncryptedData2Container
(*ConversationEvent)(nil), // 4: events.ConversationEvent (*AccountChangeOrSomethingEvent)(nil), // 4: events.AccountChangeOrSomethingEvent
(*TypingEvent)(nil), // 5: events.TypingEvent (*ConversationEvent)(nil), // 5: events.ConversationEvent
(*MessageEvent)(nil), // 6: events.MessageEvent (*TypingEvent)(nil), // 6: events.TypingEvent
(*UserAlertEvent)(nil), // 7: events.UserAlertEvent (*MessageEvent)(nil), // 7: events.MessageEvent
(*BrowserPresenceCheckEvent)(nil), // 8: events.BrowserPresenceCheckEvent (*UserAlertEvent)(nil), // 8: events.UserAlertEvent
(*TypingData)(nil), // 9: events.TypingData (*BrowserPresenceCheckEvent)(nil), // 9: events.BrowserPresenceCheckEvent
(*User)(nil), // 10: events.User (*TypingData)(nil), // 10: events.TypingData
(*RPCPairData)(nil), // 11: events.RPCPairData (*User)(nil), // 11: events.User
(*Settings)(nil), // 12: settings.Settings (*RPCPairData)(nil), // 12: events.RPCPairData
(*Conversation)(nil), // 13: conversations.Conversation (*Settings)(nil), // 13: settings.Settings
(*Message)(nil), // 14: conversations.Message (*Conversation)(nil), // 14: conversations.Conversation
(*PairedData)(nil), // 15: authentication.PairedData (*Message)(nil), // 15: conversations.Message
(*RevokePairData)(nil), // 16: authentication.RevokePairData (*PairedData)(nil), // 16: authentication.PairedData
(*RevokePairData)(nil), // 17: authentication.RevokePairData
} }
var file_events_proto_depIdxs = []int32{ var file_events_proto_depIdxs = []int32{
4, // 0: events.UpdateEvents.conversationEvent:type_name -> events.ConversationEvent 5, // 0: events.UpdateEvents.conversationEvent:type_name -> events.ConversationEvent
6, // 1: events.UpdateEvents.messageEvent:type_name -> events.MessageEvent 7, // 1: events.UpdateEvents.messageEvent:type_name -> events.MessageEvent
5, // 2: events.UpdateEvents.typingEvent:type_name -> events.TypingEvent 6, // 2: events.UpdateEvents.typingEvent:type_name -> events.TypingEvent
12, // 3: events.UpdateEvents.settingsEvent:type_name -> settings.Settings 13, // 3: events.UpdateEvents.settingsEvent:type_name -> settings.Settings
7, // 4: events.UpdateEvents.userAlertEvent:type_name -> events.UserAlertEvent 8, // 4: events.UpdateEvents.userAlertEvent:type_name -> events.UserAlertEvent
8, // 5: events.UpdateEvents.browserPresenceCheckEvent:type_name -> events.BrowserPresenceCheckEvent 9, // 5: events.UpdateEvents.browserPresenceCheckEvent:type_name -> events.BrowserPresenceCheckEvent
3, // 6: events.UpdateEvents.accountChange:type_name -> events.AccountChangeOrSomethingEvent 4, // 6: events.UpdateEvents.accountChange:type_name -> events.AccountChangeOrSomethingEvent
13, // 7: events.ConversationEvent.data:type_name -> conversations.Conversation 4, // 7: events.EncryptedData2Container.accountChange:type_name -> events.AccountChangeOrSomethingEvent
9, // 8: events.TypingEvent.data:type_name -> events.TypingData 14, // 8: events.ConversationEvent.data:type_name -> conversations.Conversation
14, // 9: events.MessageEvent.data:type_name -> conversations.Message 10, // 9: events.TypingEvent.data:type_name -> events.TypingData
0, // 10: events.UserAlertEvent.alertType:type_name -> events.AlertType 15, // 10: events.MessageEvent.data:type_name -> conversations.Message
10, // 11: events.TypingData.user:type_name -> events.User 0, // 11: events.UserAlertEvent.alertType:type_name -> events.AlertType
1, // 12: events.TypingData.type:type_name -> events.TypingTypes 11, // 12: events.TypingData.user:type_name -> events.User
15, // 13: events.RPCPairData.paired:type_name -> authentication.PairedData 1, // 13: events.TypingData.type:type_name -> events.TypingTypes
16, // 14: events.RPCPairData.revoked:type_name -> authentication.RevokePairData 16, // 14: events.RPCPairData.paired:type_name -> authentication.PairedData
15, // [15:15] is the sub-list for method output_type 17, // 15: events.RPCPairData.revoked:type_name -> authentication.RevokePairData
15, // [15:15] is the sub-list for method input_type 16, // [16:16] is the sub-list for method output_type
15, // [15:15] is the sub-list for extension type_name 16, // [16:16] is the sub-list for method input_type
15, // [15:15] is the sub-list for extension extendee 16, // [16:16] is the sub-list for extension type_name
0, // [0:15] is the sub-list for field type_name 16, // [16:16] is the sub-list for extension extendee
0, // [0:16] is the sub-list for field type_name
} }
func init() { file_events_proto_init() } func init() { file_events_proto_init() }
@ -882,7 +931,7 @@ func file_events_proto_init() {
} }
} }
file_events_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { file_events_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*AccountChangeOrSomethingEvent); i { switch v := v.(*EncryptedData2Container); i {
case 0: case 0:
return &v.state return &v.state
case 1: case 1:
@ -894,7 +943,7 @@ func file_events_proto_init() {
} }
} }
file_events_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { file_events_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*ConversationEvent); i { switch v := v.(*AccountChangeOrSomethingEvent); i {
case 0: case 0:
return &v.state return &v.state
case 1: case 1:
@ -906,7 +955,7 @@ func file_events_proto_init() {
} }
} }
file_events_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { file_events_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*TypingEvent); i { switch v := v.(*ConversationEvent); i {
case 0: case 0:
return &v.state return &v.state
case 1: case 1:
@ -918,7 +967,7 @@ func file_events_proto_init() {
} }
} }
file_events_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { file_events_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*MessageEvent); i { switch v := v.(*TypingEvent); i {
case 0: case 0:
return &v.state return &v.state
case 1: case 1:
@ -930,7 +979,7 @@ func file_events_proto_init() {
} }
} }
file_events_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { file_events_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*UserAlertEvent); i { switch v := v.(*MessageEvent); i {
case 0: case 0:
return &v.state return &v.state
case 1: case 1:
@ -942,7 +991,7 @@ func file_events_proto_init() {
} }
} }
file_events_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { file_events_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*BrowserPresenceCheckEvent); i { switch v := v.(*UserAlertEvent); i {
case 0: case 0:
return &v.state return &v.state
case 1: case 1:
@ -954,7 +1003,7 @@ func file_events_proto_init() {
} }
} }
file_events_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { file_events_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*TypingData); i { switch v := v.(*BrowserPresenceCheckEvent); i {
case 0: case 0:
return &v.state return &v.state
case 1: case 1:
@ -966,7 +1015,7 @@ func file_events_proto_init() {
} }
} }
file_events_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} { file_events_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*User); i { switch v := v.(*TypingData); i {
case 0: case 0:
return &v.state return &v.state
case 1: case 1:
@ -978,6 +1027,18 @@ func file_events_proto_init() {
} }
} }
file_events_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} { file_events_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*User); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_events_proto_msgTypes[10].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*RPCPairData); i { switch v := v.(*RPCPairData); i {
case 0: case 0:
return &v.state return &v.state
@ -999,7 +1060,7 @@ func file_events_proto_init() {
(*UpdateEvents_BrowserPresenceCheckEvent)(nil), (*UpdateEvents_BrowserPresenceCheckEvent)(nil),
(*UpdateEvents_AccountChange)(nil), (*UpdateEvents_AccountChange)(nil),
} }
file_events_proto_msgTypes[9].OneofWrappers = []interface{}{ file_events_proto_msgTypes[10].OneofWrappers = []interface{}{
(*RPCPairData_Paired)(nil), (*RPCPairData_Paired)(nil),
(*RPCPairData_Revoked)(nil), (*RPCPairData_Revoked)(nil),
} }
@ -1009,7 +1070,7 @@ func file_events_proto_init() {
GoPackagePath: reflect.TypeOf(x{}).PkgPath(), GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_events_proto_rawDesc, RawDescriptor: file_events_proto_rawDesc,
NumEnums: 2, NumEnums: 2,
NumMessages: 10, NumMessages: 11,
NumExtensions: 0, NumExtensions: 0,
NumServices: 0, NumServices: 0,
}, },

Binary file not shown.

View file

@ -25,6 +25,10 @@ message UpdateEvents {
} }
} }
message EncryptedData2Container {
AccountChangeOrSomethingEvent accountChange = 2;
}
message AccountChangeOrSomethingEvent { message AccountChangeOrSomethingEvent {
string account = 1; string account = 1;
bool enabled = 2; bool enabled = 2;

View file

@ -553,6 +553,7 @@ type RPCMessageData struct {
Bool2 bool `protobuf:"varint,7,opt,name=bool2,proto3" json:"bool2,omitempty"` Bool2 bool `protobuf:"varint,7,opt,name=bool2,proto3" json:"bool2,omitempty"`
EncryptedData []byte `protobuf:"bytes,8,opt,name=encryptedData,proto3" json:"encryptedData,omitempty"` EncryptedData []byte `protobuf:"bytes,8,opt,name=encryptedData,proto3" json:"encryptedData,omitempty"`
Bool3 bool `protobuf:"varint,9,opt,name=bool3,proto3" json:"bool3,omitempty"` Bool3 bool `protobuf:"varint,9,opt,name=bool3,proto3" json:"bool3,omitempty"`
EncryptedData2 []byte `protobuf:"bytes,11,opt,name=encryptedData2,proto3" json:"encryptedData2,omitempty"`
} }
func (x *RPCMessageData) Reset() { func (x *RPCMessageData) Reset() {
@ -636,6 +637,13 @@ func (x *RPCMessageData) GetBool3() bool {
return false return false
} }
func (x *RPCMessageData) GetEncryptedData2() []byte {
if x != nil {
return x.EncryptedData2
}
return nil
}
type OutgoingRPCMessage struct { type OutgoingRPCMessage struct {
state protoimpl.MessageState state protoimpl.MessageState
sizeCache protoimpl.SizeCache sizeCache protoimpl.SizeCache

Binary file not shown.

View file

@ -44,6 +44,7 @@ message RPCMessageData {
bool bool2 = 7; bool bool2 = 7;
bytes encryptedData = 8; bytes encryptedData = 8;
bool bool3 = 9; bool bool3 = 9;
bytes encryptedData2 = 11;
} }
message OutgoingRPCMessage { message OutgoingRPCMessage {

View file

@ -659,7 +659,7 @@ func (user *User) syncHandleEvent(event any) {
user.handleUserAlert(v) user.handleUserAlert(v)
case *gmproto.Settings: case *gmproto.Settings:
user.handleSettings(v) user.handleSettings(v)
case *gmproto.AccountChangeOrSomethingEvent: case *events.AccountChange:
user.handleAccountChange(v) user.handleAccountChange(v)
default: default:
user.zlog.Trace().Any("data", v).Type("data_type", v).Msg("Unknown event") user.zlog.Trace().Any("data", v).Type("data_type", v).Msg("Unknown event")
@ -718,17 +718,20 @@ func (user *User) fetchAndSyncConversations() {
} }
} }
func (user *User) handleAccountChange(v *gmproto.AccountChangeOrSomethingEvent) { func (user *User) handleAccountChange(v *events.AccountChange) {
user.zlog.Debug(). user.zlog.Debug().
Str("account", v.GetAccount()). Str("account", v.GetAccount()).
Bool("enabled", v.GetEnabled()). Bool("enabled", v.GetEnabled()).
Bool("fake", v.IsFake).
Msg("Got account change event") Msg("Got account change event")
user.switchedToGoogleLogin = v.GetEnabled() user.switchedToGoogleLogin = v.GetEnabled() || v.IsFake
if !v.IsFake {
if user.switchedToGoogleLogin { if user.switchedToGoogleLogin {
go user.sendMarkdownBridgeAlert(true, "The bridge will not work when the account-based pairing method is enabled in the Google Messages app. Unlink other devices and switch back to the QR code method to continue using the bridge.") go user.sendMarkdownBridgeAlert(true, "The bridge will not work when the account-based pairing method is enabled in the Google Messages app. Unlink other devices and switch back to the QR code method to continue using the bridge.")
} else { } else {
go user.sendMarkdownBridgeAlert(false, "Switched back to QR pairing, bridge should work now") go user.sendMarkdownBridgeAlert(false, "Switched back to QR pairing, bridge should work now")
} }
}
user.BridgeState.Send(status.BridgeState{StateEvent: status.StateConnected}) user.BridgeState.Send(status.BridgeState{StateEvent: status.StateConnected})
} }