mirror of
https://github.com/rwinkhart/MUTN.git
synced 2026-09-02 15:17:24 -04:00
Move device ID generation to sync.DeviceIDGen
This commit is contained in:
+2
-7
@@ -4,7 +4,6 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"github.com/rwinkhart/MUTN/src/backend"
|
"github.com/rwinkhart/MUTN/src/backend"
|
||||||
"github.com/rwinkhart/MUTN/src/sync"
|
"github.com/rwinkhart/MUTN/src/sync"
|
||||||
"math/rand"
|
|
||||||
"os"
|
"os"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -40,12 +39,8 @@ func TempInitCli() {
|
|||||||
// write config file
|
// write config file
|
||||||
backend.TempInit(map[string]string{"textEditor": textEditor, "gpgID": gpgID, "sshUser": sshUser, "sshIP": sshIP, "sshPort": sshPort, "sshIdentity": sshIdentity})
|
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
|
// generate device ID
|
||||||
deviceIDPrefix, _ := os.Hostname()
|
sync.DeviceIDGen()
|
||||||
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
|
|
||||||
} else {
|
} else {
|
||||||
// write config file
|
// write config file
|
||||||
backend.TempInit(map[string]string{"textEditor": textEditor, "gpgID": gpgID})
|
backend.TempInit(map[string]string{"textEditor": textEditor, "gpgID": gpgID})
|
||||||
|
|||||||
Reference in New Issue
Block a user