Fix some things
This commit is contained in:
parent
49a3fd983f
commit
f99201f8e6
3 changed files with 13 additions and 17 deletions
|
@ -94,13 +94,12 @@ func (c *Client) signInGaiaGetToken() (*gmproto.SignInGaiaResponse, error) {
|
||||||
type PairingSession struct {
|
type PairingSession struct {
|
||||||
UUID uuid.UUID
|
UUID uuid.UUID
|
||||||
Start time.Time
|
Start time.Time
|
||||||
DestRegID uuid.UUID
|
|
||||||
PairingKeyDSA *ecdsa.PrivateKey
|
PairingKeyDSA *ecdsa.PrivateKey
|
||||||
InitPayload []byte
|
InitPayload []byte
|
||||||
NextKey []byte
|
NextKey []byte
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewPairingSession(destRegID uuid.UUID) PairingSession {
|
func NewPairingSession() PairingSession {
|
||||||
ec, err := ecdsa.GenerateKey(elliptic.P256(), rand.Reader)
|
ec, err := ecdsa.GenerateKey(elliptic.P256(), rand.Reader)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
|
@ -108,7 +107,6 @@ func NewPairingSession(destRegID uuid.UUID) PairingSession {
|
||||||
return PairingSession{
|
return PairingSession{
|
||||||
UUID: uuid.New(),
|
UUID: uuid.New(),
|
||||||
Start: time.Now(),
|
Start: time.Now(),
|
||||||
DestRegID: destRegID,
|
|
||||||
PairingKeyDSA: ec,
|
PairingKeyDSA: ec,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -255,7 +253,7 @@ func (c *Client) DoGaiaPairing(emojiCallback func(string)) error {
|
||||||
// TODO multiple devices?
|
// TODO multiple devices?
|
||||||
var destRegID string
|
var destRegID string
|
||||||
for _, dev := range sigResp.GetDeviceData().GetUnknownItems2() {
|
for _, dev := range sigResp.GetDeviceData().GetUnknownItems2() {
|
||||||
if dev.GetDestOrSourceUUID() != sigResp.GetMaybeBrowserUUID() {
|
if dev.GetUnknownInt4() == 1 {
|
||||||
destRegID = dev.GetDestOrSourceUUID()
|
destRegID = dev.GetDestOrSourceUUID()
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
@ -269,7 +267,7 @@ func (c *Client) DoGaiaPairing(emojiCallback func(string)) error {
|
||||||
}
|
}
|
||||||
c.AuthData.DestRegID = destRegUUID
|
c.AuthData.DestRegID = destRegUUID
|
||||||
go c.doLongPoll(false)
|
go c.doLongPoll(false)
|
||||||
ps := NewPairingSession(destRegUUID)
|
ps := NewPairingSession()
|
||||||
clientInit, clientFinish, err := ps.PreparePayloads()
|
clientInit, clientFinish, err := ps.PreparePayloads()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to prepare pairing payloads: %w", err)
|
return fmt.Errorf("failed to prepare pairing payloads: %w", err)
|
||||||
|
@ -327,8 +325,7 @@ func (c *Client) sendGaiaPairingMessage(sess PairingSession, action gmproto.Acti
|
||||||
CustomTTL: (300 * time.Second).Microseconds(),
|
CustomTTL: (300 * time.Second).Microseconds(),
|
||||||
MessageType: gmproto.MessageType_GAIA_2,
|
MessageType: gmproto.MessageType_GAIA_2,
|
||||||
|
|
||||||
DestRegistrationIDs: []string{sess.DestRegID.String()},
|
NoPingOnTimeout: true,
|
||||||
NoPingOnTimeout: true,
|
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -347,7 +344,6 @@ func (c *Client) UnpairGaia() error {
|
||||||
Data: &gmproto.RevokeGaiaPairingRequest{
|
Data: &gmproto.RevokeGaiaPairingRequest{
|
||||||
PairingAttemptID: c.AuthData.PairingID.String(),
|
PairingAttemptID: c.AuthData.PairingID.String(),
|
||||||
},
|
},
|
||||||
DestRegistrationIDs: []string{c.AuthData.DestRegID.String()},
|
NoPingOnTimeout: true,
|
||||||
NoPingOnTimeout: true,
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -176,8 +176,7 @@ type SendMessageParams struct {
|
||||||
DontEncrypt bool
|
DontEncrypt bool
|
||||||
MessageType gmproto.MessageType
|
MessageType gmproto.MessageType
|
||||||
|
|
||||||
DestRegistrationIDs []string
|
NoPingOnTimeout bool
|
||||||
NoPingOnTimeout bool
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *SessionHandler) buildMessage(params SendMessageParams) (string, proto.Message, error) {
|
func (s *SessionHandler) buildMessage(params SendMessageParams) (string, proto.Message, error) {
|
||||||
|
@ -192,9 +191,6 @@ func (s *SessionHandler) buildMessage(params SendMessageParams) (string, proto.M
|
||||||
if params.MessageType == 0 {
|
if params.MessageType == 0 {
|
||||||
params.MessageType = gmproto.MessageType_BUGLE_MESSAGE
|
params.MessageType = gmproto.MessageType_BUGLE_MESSAGE
|
||||||
}
|
}
|
||||||
if params.DestRegistrationIDs == nil {
|
|
||||||
params.DestRegistrationIDs = make([]string, 0)
|
|
||||||
}
|
|
||||||
|
|
||||||
message := &gmproto.OutgoingRPCMessage{
|
message := &gmproto.OutgoingRPCMessage{
|
||||||
Mobile: s.client.AuthData.Mobile,
|
Mobile: s.client.AuthData.Mobile,
|
||||||
|
@ -211,7 +207,10 @@ func (s *SessionHandler) buildMessage(params SendMessageParams) (string, proto.M
|
||||||
TachyonAuthToken: s.client.AuthData.TachyonAuthToken,
|
TachyonAuthToken: s.client.AuthData.TachyonAuthToken,
|
||||||
ConfigVersion: util.ConfigMessage,
|
ConfigVersion: util.ConfigMessage,
|
||||||
},
|
},
|
||||||
DestRegistrationIDs: params.DestRegistrationIDs,
|
DestRegistrationIDs: []string{},
|
||||||
|
}
|
||||||
|
if s.client.AuthData != nil && s.client.AuthData.DestRegID != uuid.Nil {
|
||||||
|
message.DestRegistrationIDs = append(message.DestRegistrationIDs, s.client.AuthData.DestRegID.String())
|
||||||
}
|
}
|
||||||
if params.CustomTTL != 0 {
|
if params.CustomTTL != 0 {
|
||||||
message.TTL = params.CustomTTL
|
message.TTL = params.CustomTTL
|
||||||
|
|
|
@ -316,7 +316,8 @@ type ReqGoogleLoginStart struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type RespGoogleLoginStart struct {
|
type RespGoogleLoginStart struct {
|
||||||
Emoji string
|
Status string `json:"status"`
|
||||||
|
Emoji string `json:"emoji"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (prov *ProvisioningAPI) GoogleLoginStart(w http.ResponseWriter, r *http.Request) {
|
func (prov *ProvisioningAPI) GoogleLoginStart(w http.ResponseWriter, r *http.Request) {
|
||||||
|
@ -346,7 +347,7 @@ func (prov *ProvisioningAPI) GoogleLoginStart(w http.ResponseWriter, r *http.Req
|
||||||
})
|
})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
jsonResponse(w, http.StatusOK, &RespGoogleLoginStart{Emoji: emoji})
|
jsonResponse(w, http.StatusOK, &RespGoogleLoginStart{Status: "emoji", Emoji: emoji})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (prov *ProvisioningAPI) GoogleLoginWait(w http.ResponseWriter, r *http.Request) {
|
func (prov *ProvisioningAPI) GoogleLoginWait(w http.ResponseWriter, r *http.Request) {
|
||||||
|
|
Loading…
Reference in a new issue