From a703c6b2acd720f6da33fd5df01616977d36db0b Mon Sep 17 00:00:00 2001 From: Randall Winkhart Date: Thu, 16 May 2024 21:26:42 -0400 Subject: [PATCH] Move device ID generation to sync.DeviceIDGen --- src/cli/init.go | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/cli/init.go b/src/cli/init.go index 3477689..b1508c9 100644 --- a/src/cli/init.go +++ b/src/cli/init.go @@ -4,7 +4,6 @@ import ( "fmt" "github.com/rwinkhart/MUTN/src/backend" "github.com/rwinkhart/MUTN/src/sync" - "math/rand" "os" ) @@ -40,12 +39,8 @@ func TempInitCli() { // write config file backend.TempInit(map[string]string{"textEditor": textEditor, "gpgID": gpgID, "sshUser": sshUser, "sshIP": sshIP, "sshPort": sshPort, "sshIdentity": sshIdentity}) - // client device ID (perform after writing config files, as sync.GetSSHOutput must be able to read it) TODO move to backend - deviceIDPrefix, _ := os.Hostname() - deviceIDSuffix := backend.StringGen(rand.Intn(48)+48, false, 0) // TODO consider using complex string generator and removing unsafe characters manually - deviceID := deviceIDPrefix + "-" + deviceIDSuffix - os.Create(backend.ConfigDir + backend.PathSeparator + "devices" + backend.PathSeparator + deviceID) // TODO remove existing device ID file if it exists (from both client and server) - sync.GetSSHOutput("libmuttonserver register "+deviceID, false) // register device ID with server + // generate device ID + sync.DeviceIDGen() } else { // write config file backend.TempInit(map[string]string{"textEditor": textEditor, "gpgID": gpgID})