From aa4e9ac3755aae9c81270f10ce36b0a897b4919d Mon Sep 17 00:00:00 2001 From: Jake Taylor <jake@elixxir.io> Date: Wed, 13 Jul 2022 17:36:03 -0500 Subject: [PATCH] added force-legacy flag --- cmd/init.go | 11 ++++++++--- cmd/root.go | 9 ++++++++- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/cmd/init.go b/cmd/init.go index e52fca70b..a126e95e9 100644 --- a/cmd/init.go +++ b/cmd/init.go @@ -71,9 +71,9 @@ func init() { rootCmd.AddCommand(initCmd) } -// loadOrInitClient will build a new xxdk.E2e from existing storage +// loadOrInitMessenger will build a new xxdk.E2e from existing storage // or from a new storage that it will create if none already exists -func loadOrInitClient(password []byte, storeDir, regCode string, +func loadOrInitMessenger(forceLegacy bool, password []byte, storeDir, regCode string, cmixParams xxdk.CMIXParams, e2eParams xxdk.E2EParams) *xxdk.E2e { jww.INFO.Printf("Using normal sender") @@ -93,7 +93,12 @@ func loadOrInitClient(password []byte, storeDir, regCode string, jww.FATAL.Panicf("%+v", err) } - identity, err = xxdk.MakeReceptionIdentity(net) + if forceLegacy { + jww.INFO.Printf("Forcing legacy sender") + identity, err = xxdk.MakeLegacyReceptionIdentity(net) + } else { + identity, err = xxdk.MakeReceptionIdentity(net) + } if err != nil { jww.FATAL.Panicf("%+v", err) } diff --git a/cmd/root.go b/cmd/root.go index 9d0709e82..4b360c8d1 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -585,6 +585,7 @@ func initE2e(cmixParams xxdk.CMIXParams, e2eParams xxdk.E2EParams) *xxdk.E2e { storePassword := parsePassword(viper.GetString("password")) storeDir := viper.GetString("session") regCode := viper.GetString("regcode") + forceLegacy := viper.GetBool("force-legacy") jww.DEBUG.Printf("sessionDir: %v", storeDir) // TODO: This probably shouldn't be initialized globally. @@ -602,7 +603,7 @@ func initE2e(cmixParams xxdk.CMIXParams, e2eParams xxdk.E2EParams) *xxdk.E2e { } else if backupPath != "" { messenger = loadOrInitBackup(backupPath, backupPass, storePassword, storeDir, cmixParams, e2eParams) } else { - messenger = loadOrInitClient(storePassword, storeDir, regCode, cmixParams, e2eParams) + messenger = loadOrInitMessenger(forceLegacy, storePassword, storeDir, regCode, cmixParams, e2eParams) } // Handle protoUser output @@ -622,6 +623,9 @@ func initE2e(cmixParams xxdk.CMIXParams, e2eParams xxdk.E2EParams) *xxdk.E2e { // Handle backup output if backupOut := viper.GetString("backupOut"); backupOut != "" { + if !forceLegacy { + jww.FATAL.Panicf("Unable to make backup for non-legacy sender!") + } updateBackupCb := func(encryptedBackup []byte) { jww.INFO.Printf("Backup update received, size %d", len(encryptedBackup)) @@ -1131,6 +1135,9 @@ func init() { "ID to send message to (if below 40, will be precanned. Use "+ "'0x' or 'b64:' for hex and base64 representations)") viper.BindPFlag("destid", rootCmd.Flags().Lookup("destid")) + rootCmd.PersistentFlags().Bool("force-legacy", false, + "Force client to operate using legacy identities.") + viper.BindPFlag("force-legacy", rootCmd.PersistentFlags().Lookup("force-legacy")) rootCmd.Flags().StringP("destfile", "", "", "Read this contact file for the destination id") -- GitLab