Skip to content
Snippets Groups Projects
Commit 13c647c4 authored by Richard T. Carback III's avatar Richard T. Carback III
Browse files

debugging comments

parent 3704287c
No related branches found
No related tags found
3 merge requests!510Release,!267Make BuildReceptionIdentity public, and make backup restore function return a...,!263Hotfix/refactor cmd
...@@ -11,6 +11,7 @@ package backup ...@@ -11,6 +11,7 @@ package backup
import ( import (
"github.com/pkg/errors" "github.com/pkg/errors"
jww "github.com/spf13/jwalterweatherman"
"gitlab.com/elixxir/client/e2e" "gitlab.com/elixxir/client/e2e"
"gitlab.com/elixxir/client/e2e/rekey" "gitlab.com/elixxir/client/e2e/rekey"
"gitlab.com/elixxir/client/storage" "gitlab.com/elixxir/client/storage"
...@@ -38,6 +39,9 @@ func NewClientFromBackup(ndfJSON, storageDir string, sessionPassword, ...@@ -38,6 +39,9 @@ func NewClientFromBackup(ndfJSON, storageDir string, sessionPassword,
"Failed to unmarshal decrypted client contents.") "Failed to unmarshal decrypted client contents.")
} }
jww.INFO.Printf("Decrypted backup ID to Restore: %v",
backUp.ReceptionIdentity.ComputedID)
usr := user.NewUserFromBackup(backUp) usr := user.NewUserFromBackup(backUp)
def, err := xxdk.ParseNDF(ndfJSON) def, err := xxdk.ParseNDF(ndfJSON)
......
...@@ -596,6 +596,7 @@ func initCmix() (*xxdk.Cmix, xxdk.ReceptionIdentity) { ...@@ -596,6 +596,7 @@ func initCmix() (*xxdk.Cmix, xxdk.ReceptionIdentity) {
pass, regCode, userIDprefix) pass, regCode, userIDprefix)
} else if backupPath != "" { } else if backupPath != "" {
jww.INFO.Printf("Restoring user from %s", backupPath)
b, backupFile := loadBackup(backupPath, string(backupPass)) b, backupFile := loadBackup(backupPath, string(backupPass))
// Marshal the backup object in JSON // Marshal the backup object in JSON
...@@ -619,6 +620,8 @@ func initCmix() (*xxdk.Cmix, xxdk.ReceptionIdentity) { ...@@ -619,6 +620,8 @@ func initCmix() (*xxdk.Cmix, xxdk.ReceptionIdentity) {
jww.FATAL.Panicf("%+v", err) jww.FATAL.Panicf("%+v", err)
} }
jww.INFO.Printf("User Restored: %v", knownReception.ID)
backupIdListPath := viper.GetString("backupIdList") backupIdListPath := viper.GetString("backupIdList")
if backupIdListPath != "" { if backupIdListPath != "" {
// Marshal backed up ID list to JSON // Marshal backed up ID list to JSON
......
...@@ -39,38 +39,16 @@ var udCmd = &cobra.Command{ ...@@ -39,38 +39,16 @@ var udCmd = &cobra.Command{
// get user and save contact to file // get user and save contact to file
user := client.GetReceptionIdentity() user := client.GetReceptionIdentity()
jww.INFO.Printf("User: %s", user.ID) jww.INFO.Printf("[UD]User: %s", user.ID)
writeContact(user.GetContact()) writeContact(user.GetContact())
// // Set up reception handler
// swBoard := client.GetSwitchboard()
// recvCh := make(chan message.Receive, 10000)
// listenerID := swBoard.RegisterChannel("DefaultCLIReceiver",
// switchboard.AnyUser(), message.XxMessage, recvCh)
// jww.INFO.Printf("Message ListenerID: %v", listenerID)
// // Set up auth request handler, which simply prints the user ID of the
// // requester
// authMgr := client.GetAuthRegistrar()
// authMgr.AddGeneralRequestCallback(printChanRequest)
// // If unsafe channels, add auto-acceptor
// if viper.GetBool("unsafe-channel-creation") {
// authMgr.AddGeneralRequestCallback(func(
// requester contact.Contact) {
// jww.INFO.Printf("Got Request: %s", requester.ID)
// _, err := client.ConfirmAuthenticatedChannel(requester)
// if err != nil {
// jww.FATAL.Panicf("%+v", err)
// }
// })
// }
err := client.StartNetworkFollower(50 * time.Millisecond) err := client.StartNetworkFollower(50 * time.Millisecond)
if err != nil { if err != nil {
jww.FATAL.Panicf("%+v", err) jww.FATAL.Panicf("%+v", err)
} }
jww.TRACE.Printf("[UD] Waiting for connection...")
// Wait until connected or crash on timeout // Wait until connected or crash on timeout
connected := make(chan bool, 10) connected := make(chan bool, 10)
client.GetCmix().AddHealthCallback( client.GetCmix().AddHealthCallback(
...@@ -79,9 +57,12 @@ var udCmd = &cobra.Command{ ...@@ -79,9 +57,12 @@ var udCmd = &cobra.Command{
}) })
waitUntilConnected(connected) waitUntilConnected(connected)
jww.TRACE.Printf("[UD] Connected!")
// Make user discovery manager // Make user discovery manager
rng := client.GetRng() rng := client.GetRng()
userToRegister := viper.GetString("register") userToRegister := viper.GetString("register")
jww.TRACE.Printf("[UD] Registering user %v...", userToRegister)
userDiscoveryMgr, err := ud.NewManager(client, client.GetComms(), userDiscoveryMgr, err := ud.NewManager(client, client.GetComms(),
client.NetworkFollowerStatus, userToRegister, nil) client.NetworkFollowerStatus, userToRegister, nil)
if err != nil { if err != nil {
...@@ -95,6 +76,7 @@ var udCmd = &cobra.Command{ ...@@ -95,6 +76,7 @@ var udCmd = &cobra.Command{
} }
} }
jww.INFO.Printf("[UD] Registered user %v", userToRegister)
var newFacts fact.FactList var newFacts fact.FactList
phone := viper.GetString("addphone") phone := viper.GetString("addphone")
...@@ -116,24 +98,29 @@ var udCmd = &cobra.Command{ ...@@ -116,24 +98,29 @@ var udCmd = &cobra.Command{
} }
for i := 0; i < len(newFacts); i++ { for i := 0; i < len(newFacts); i++ {
jww.INFO.Printf("[UD] Registering Fact: %v",
newFacts[i])
r, err := userDiscoveryMgr.SendRegisterFact(newFacts[i]) r, err := userDiscoveryMgr.SendRegisterFact(newFacts[i])
if err != nil { if err != nil {
fmt.Printf("Failed to register fact: %s\n", fmt.Printf("Failed to register fact: %s\n",
newFacts[i]) newFacts[i])
jww.FATAL.Panicf("Failed to send register fact: %+v", err) jww.FATAL.Panicf("[UD] Failed to send register fact: %+v", err)
} }
// TODO Store the code? // TODO Store the code?
jww.INFO.Printf("Fact Add Response: %+v", r) jww.INFO.Printf("[UD] Fact Add Response: %+v", r)
} }
confirmID := viper.GetString("confirm") confirmID := viper.GetString("confirm")
if confirmID != "" { if confirmID != "" {
jww.INFO.Printf("[UD] Confirming fact: %v", confirmID)
err = userDiscoveryMgr.ConfirmFact(confirmID, confirmID) err = userDiscoveryMgr.ConfirmFact(confirmID, confirmID)
if err != nil { if err != nil {
fmt.Printf("Couldn't confirm fact: %s\n", fmt.Printf("Couldn't confirm fact: %s\n",
err.Error()) err.Error())
jww.FATAL.Panicf("%+v", err) jww.FATAL.Panicf("%+v", err)
} }
jww.INFO.Printf("[UD] Confirmed %v", confirmID)
} }
udContact, err := userDiscoveryMgr.GetContact() udContact, err := userDiscoveryMgr.GetContact()
...@@ -147,9 +134,7 @@ var udCmd = &cobra.Command{ ...@@ -147,9 +134,7 @@ var udCmd = &cobra.Command{
lookupIDStr := viper.GetString("lookup") lookupIDStr := viper.GetString("lookup")
if lookupIDStr != "" { if lookupIDStr != "" {
lookupID := parseRecipient(lookupIDStr) lookupID := parseRecipient(lookupIDStr)
//if !ok { jww.INFO.Printf("[UD] Looking up %v", lookupID)
// jww.FATAL.Panicf("Could not parse recipient: %s", lookupIDStr)
//}
cb := func(newContact contact.Contact, err error) { cb := func(newContact contact.Contact, err error) {
if err != nil { if err != nil {
...@@ -177,7 +162,7 @@ var udCmd = &cobra.Command{ ...@@ -177,7 +162,7 @@ var udCmd = &cobra.Command{
err.Error()) err.Error())
jww.FATAL.Panicf("BATCHADD: Couldn't read file: %+v", err) jww.FATAL.Panicf("BATCHADD: Couldn't read file: %+v", err)
} }
jww.INFO.Printf("BATCHADD: Running") jww.INFO.Printf("[UD] BATCHADD: Running")
restored, _, _, err := xxmutils.RestoreContactsFromBackup( restored, _, _, err := xxmutils.RestoreContactsFromBackup(
idListFile, client, userDiscoveryMgr, nil) idListFile, client, userDiscoveryMgr, nil)
if err != nil { if err != nil {
...@@ -188,7 +173,7 @@ var udCmd = &cobra.Command{ ...@@ -188,7 +173,7 @@ var udCmd = &cobra.Command{
for !client.GetE2E().HasAuthenticatedChannel(uid) { for !client.GetE2E().HasAuthenticatedChannel(uid) {
time.Sleep(time.Second) time.Sleep(time.Second)
} }
jww.INFO.Printf("Authenticated channel established for %s", uid) jww.INFO.Printf("[UD] Authenticated channel established for %s", uid)
} }
} }
usernameSearchStr := viper.GetString("searchusername") usernameSearchStr := viper.GetString("searchusername")
...@@ -233,7 +218,7 @@ var udCmd = &cobra.Command{ ...@@ -233,7 +218,7 @@ var udCmd = &cobra.Command{
"Failed to remove user %s: %+v", "Failed to remove user %s: %+v",
userToRemove, err) userToRemove, err)
} }
fmt.Printf("Removed user from discovery: %s\n", fmt.Printf("[UD] Removed user from discovery: %s\n",
userToRemove) userToRemove)
} }
...@@ -256,6 +241,7 @@ var udCmd = &cobra.Command{ ...@@ -256,6 +241,7 @@ var udCmd = &cobra.Command{
stream := rng.GetStream() stream := rng.GetStream()
defer stream.Close() defer stream.Close()
jww.INFO.Printf("[UD] Search: %v", facts)
_, _, err = ud.Search(client.GetCmix(), _, _, err = ud.Search(client.GetCmix(),
client.GetEventReporter(), client.GetEventReporter(),
stream, client.GetE2E().GetGroup(), stream, client.GetE2E().GetGroup(),
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment