diff --git a/cmd/init.go b/cmd/init.go index e52fca70b0666e3073400c7e60e92641d952f80a..a126e95e983a99de5693a525dc11b8a25405d8cb 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 9d0709e82bff6f7d282768d9829b7281f57ee524..4b360c8d188b767768548bf2d2904a46a1f0d5db 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")