Эх сурвалжийг харах

Add more debug logs in post-connection code

Tulir Asokan 4 жил өмнө
parent
commit
bf5be3fe62
2 өөрчлөгдсөн 12 нэмэгдсэн , 2 устгасан
  1. 1 0
      custompuppet.go
  2. 11 2
      user.go

+ 1 - 0
custompuppet.go

@@ -64,6 +64,7 @@ func (puppet *Puppet) SwitchCustomMXID(accessToken string, mxid id.UserID) error
 }
 }
 
 
 func (puppet *Puppet) loginWithSharedSecret(mxid id.UserID) (string, error) {
 func (puppet *Puppet) loginWithSharedSecret(mxid id.UserID) (string, error) {
+	puppet.log.Debugfln("Logging into %s with shared secret", mxid)
 	mac := hmac.New(sha512.New, []byte(puppet.bridge.Config.Bridge.LoginSharedSecret))
 	mac := hmac.New(sha512.New, []byte(puppet.bridge.Config.Bridge.LoginSharedSecret))
 	mac.Write([]byte(mxid))
 	mac.Write([]byte(mxid))
 	resp, err := puppet.bridge.AS.BotClient().Login(&mautrix.ReqLogin{
 	resp, err := puppet.bridge.AS.BotClient().Login(&mautrix.ReqLogin{

+ 11 - 2
user.go

@@ -427,9 +427,10 @@ func (user *User) tryAutomaticDoublePuppeting() {
 		// user is on another homeserver
 		// user is on another homeserver
 		return
 		return
 	}
 	}
-
+	user.log.Debugln("Checking if double puppeting needs to be enabled")
 	puppet := user.bridge.GetPuppetByJID(user.JID)
 	puppet := user.bridge.GetPuppetByJID(user.JID)
 	if len(puppet.CustomMXID) > 0 {
 	if len(puppet.CustomMXID) > 0 {
+		user.log.Debugln("User already has double-puppeting enabled")
 		// Custom puppet already enabled
 		// Custom puppet already enabled
 		return
 		return
 	}
 	}
@@ -464,6 +465,7 @@ func (user *User) sendMarkdownBridgeAlert(formatString string, args ...interface
 }
 }
 
 
 func (user *User) postConnPing() bool {
 func (user *User) postConnPing() bool {
+	user.log.Debugln("Making post-connection ping")
 	err := user.Conn.AdminTest()
 	err := user.Conn.AdminTest()
 	if err != nil {
 	if err != nil {
 		user.log.Errorfln("Post-connection ping failed: %v. Disconnecting and then reconnecting after a second", err)
 		user.log.Errorfln("Post-connection ping failed: %v. Disconnecting and then reconnecting after a second", err)
@@ -491,6 +493,7 @@ func (user *User) intPostLogin() {
 	user.createCommunity()
 	user.createCommunity()
 	user.tryAutomaticDoublePuppeting()
 	user.tryAutomaticDoublePuppeting()
 
 
+	user.log.Debugln("Waiting for chat list receive confirmation")
 	select {
 	select {
 	case <-user.chatListReceived:
 	case <-user.chatListReceived:
 		user.log.Debugln("Chat list receive confirmation received in PostLogin")
 		user.log.Debugln("Chat list receive confirmation received in PostLogin")
@@ -499,12 +502,16 @@ func (user *User) intPostLogin() {
 		user.postConnPing()
 		user.postConnPing()
 		return
 		return
 	}
 	}
+
 	if !user.postConnPing() {
 	if !user.postConnPing() {
+		user.log.Debugln("Post-connection ping failed, unlocking processing of incoming messages.")
 		return
 		return
 	}
 	}
+
+	user.log.Debugln("Waiting for portal sync complete confirmation")
 	select {
 	select {
 	case <-user.syncPortalsDone:
 	case <-user.syncPortalsDone:
-		user.log.Debugln("Post-login portal sync complete, unlocking processing of incoming messages.")
+		user.log.Debugln("Post-connection portal sync complete, unlocking processing of incoming messages.")
 	case <-time.After(time.Duration(user.bridge.Config.Bridge.PortalSyncWait) * time.Second):
 	case <-time.After(time.Duration(user.bridge.Config.Bridge.PortalSyncWait) * time.Second):
 		user.log.Warnln("Timed out waiting for portal sync to complete! Unlocking processing of incoming messages.")
 		user.log.Warnln("Timed out waiting for portal sync to complete! Unlocking processing of incoming messages.")
 	}
 	}
@@ -790,7 +797,9 @@ func (user *User) handleMessageLoop() {
 		case msg := <-user.messages:
 		case msg := <-user.messages:
 			user.GetPortalByJID(msg.chat).messages <- msg
 			user.GetPortalByJID(msg.chat).messages <- msg
 		case <-user.syncStart:
 		case <-user.syncStart:
+			user.log.Debugln("Processing of incoming messages is locked")
 			user.syncWait.Wait()
 			user.syncWait.Wait()
+			user.log.Debugln("Processing of incoming messages unlocked")
 		}
 		}
 	}
 	}
 }
 }