Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

verificationhelper: improve logging on ready and start event handlers #317

Merged
merged 1 commit into from
Nov 20, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions crypto/verificationhelper/verificationhelper.go
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ func (vh *VerificationHelper) AcceptVerification(ctx context.Context, txnID id.V
}
}

log.Info().Msg("Sending ready event")
log.Info().Any("methods", maps.Keys(supportedMethods)).Msg("Sending ready event")
readyEvt := &event.VerificationReadyEventContent{
FromDevice: vh.client.DeviceID,
Methods: maps.Keys(supportedMethods),
Expand Down Expand Up @@ -685,6 +685,11 @@ func (vh *VerificationHelper) onVerificationReady(ctx context.Context, txn Verif
txn.TheirDeviceID = readyEvt.FromDevice
txn.TheirSupportedMethods = readyEvt.Methods

log.Info().
Stringer("their_device_id", txn.TheirDeviceID).
Any("their_supported_methods", txn.TheirSupportedMethods).
Msg("Received verification ready event")

// If we sent this verification request, send cancellations to all of the
// other devices.
if len(txn.SentToDeviceIDs) > 0 {
Expand Down Expand Up @@ -726,8 +731,12 @@ func (vh *VerificationHelper) onVerificationStart(ctx context.Context, txn Verif
log := vh.getLog(ctx).With().
Str("verification_action", "verification start").
Str("method", string(startEvt.Method)).
Stringer("their_device_id", txn.TheirDeviceID).
Any("their_supported_methods", txn.TheirSupportedMethods).
Bool("started_by_us", txn.StartedByUs).
Logger()
ctx = log.WithContext(ctx)
log.Info().Msg("Received verification start event")

vh.activeTransactionsLock.Lock()
defer vh.activeTransactionsLock.Unlock()
Expand Down Expand Up @@ -765,7 +774,7 @@ func (vh *VerificationHelper) onVerificationStart(ctx context.Context, txn Verif
}

if txn.TheirUserID < vh.client.UserID || (txn.TheirUserID == vh.client.UserID && txn.TheirDeviceID < vh.client.DeviceID) {
// Use their start event instead of ours
log.Debug().Msg("Using their start event instead of ours because they are alphabetically before us")
txn.StartedByUs = false
txn.StartEventContent = startEvt
}
Expand All @@ -776,6 +785,7 @@ func (vh *VerificationHelper) onVerificationStart(ctx context.Context, txn Verif

switch startEvt.Method {
case event.VerificationMethodSAS:
log.Info().Msg("Received SAS start event")
txn.VerificationState = VerificationStateSASStarted
if err := vh.onVerificationStartSAS(ctx, txn, evt); err != nil {
vh.cancelVerificationTxn(ctx, txn, event.VerificationCancelCodeUser, "failed to handle SAS verification start: %w", err)
Expand Down Expand Up @@ -804,6 +814,7 @@ func (vh *VerificationHelper) onVerificationDone(ctx context.Context, txn Verifi
log := vh.getLog(ctx).With().
Str("verification_action", "done").
Stringer("transaction_id", txn.TransactionID).
Bool("sent_our_done", txn.SentOurDone).
Logger()
log.Info().Msg("Verification done")
vh.activeTransactionsLock.Lock()
Expand Down