Update stdout logging regarding clipboard refresher

This commit is contained in:
2025-11-10 01:02:05 -05:00
parent 14dda0b091
commit b39a40407f
6 changed files with 20 additions and 21 deletions
+4 -3
View File
@@ -40,15 +40,16 @@ func CopyArgument(targetLocation string, field int) error {
} }
if realField == 2 { // TOTP mode if realField == 2 { // TOTP mode
if field != -1 { fmt.Println(back.AnsiWarning + "[Starting]" + back.AnsiReset + " TOTP clipboard refresher")
fmt.Println("Clipboard refreshing with the current TOTP code until this process is closed")
}
errorChan := make(chan error) errorChan := make(chan error)
go TOTPCopier(decSlice[2], field, errorChan, nil) // "done" is not needed because the process runs until the program is killed go TOTPCopier(decSlice[2], field, errorChan, nil) // "done" is not needed because the process runs until the program is killed
err = <-errorChan err = <-errorChan
if err != nil { // handle error from first copy if err != nil { // handle error from first copy
return errors.New("error encountered in TOTP refresh process: " + err.Error()) return errors.New("error encountered in TOTP refresh process: " + err.Error())
} }
if field != -1 {
fmt.Println(back.AnsiGreen + "[Started]" + back.AnsiReset + " TOTP clipboard refresher\n\nService will run until the process is exited")
}
select {} // block indefinitely select {} // block indefinitely
} else { // other } else { // other
copySubject = decSlice[realField] copySubject = decSlice[realField]
+1 -1
View File
@@ -5,7 +5,7 @@ go 1.25.4
require ( require (
github.com/pkg/sftp v1.13.10 github.com/pkg/sftp v1.13.10
github.com/pquerna/otp v1.5.0 github.com/pquerna/otp v1.5.0
github.com/rwinkhart/go-boilerplate v0.1.0 github.com/rwinkhart/go-boilerplate v0.1.1-0.20251110055016-10ee4f91fcb6
github.com/rwinkhart/rcw v0.2.3 github.com/rwinkhart/rcw v0.2.3
golang.design/x/clipboard v0.7.1 // only for mobile builds golang.design/x/clipboard v0.7.1 // only for mobile builds
golang.org/x/crypto v0.43.0 golang.org/x/crypto v0.43.0
+2
View File
@@ -14,6 +14,8 @@ github.com/pquerna/otp v1.5.0 h1:NMMR+WrmaqXU4EzdGJEE1aUUI0AMRzsp96fFFWNPwxs=
github.com/pquerna/otp v1.5.0/go.mod h1:dkJfzwRKNiegxyNb54X/3fLwhCynbMspSyWKnvi1AEg= github.com/pquerna/otp v1.5.0/go.mod h1:dkJfzwRKNiegxyNb54X/3fLwhCynbMspSyWKnvi1AEg=
github.com/rwinkhart/go-boilerplate v0.1.0 h1:EzlVj6R7Bxtl79Nl7R5zRcg6s+Cf2FAqGIzR4giWTQg= github.com/rwinkhart/go-boilerplate v0.1.0 h1:EzlVj6R7Bxtl79Nl7R5zRcg6s+Cf2FAqGIzR4giWTQg=
github.com/rwinkhart/go-boilerplate v0.1.0/go.mod h1:cnzIF45I0FCOvE4YIB+26pLCUx2kWyY2llKYZruNaRY= github.com/rwinkhart/go-boilerplate v0.1.0/go.mod h1:cnzIF45I0FCOvE4YIB+26pLCUx2kWyY2llKYZruNaRY=
github.com/rwinkhart/go-boilerplate v0.1.1-0.20251110055016-10ee4f91fcb6 h1:tGGtw5Wr4laDrU7Ooe95g4E+O6c+oY18atamcMPaMY8=
github.com/rwinkhart/go-boilerplate v0.1.1-0.20251110055016-10ee4f91fcb6/go.mod h1:cnzIF45I0FCOvE4YIB+26pLCUx2kWyY2llKYZruNaRY=
github.com/rwinkhart/go-winio v0.1.0 h1:b72agLW+dETGmhR3VbcbwnStfgKfc5AfgJOXBJDkaHg= github.com/rwinkhart/go-winio v0.1.0 h1:b72agLW+dETGmhR3VbcbwnStfgKfc5AfgJOXBJDkaHg=
github.com/rwinkhart/go-winio v0.1.0/go.mod h1:ZWa7ssZJT30CCDGJ7fk/2SBTq9BIQrrVjrcss0UW2s0= github.com/rwinkhart/go-winio v0.1.0/go.mod h1:ZWa7ssZJT30CCDGJ7fk/2SBTq9BIQrrVjrcss0UW2s0=
github.com/rwinkhart/peercred-mini v0.1.2 h1:4cGWDbv0whvLeVvbUdx84V/9p+2fS+DEXgrA1KxlRFo= github.com/rwinkhart/peercred-mini v0.1.2 h1:4cGWDbv0whvLeVvbUdx84V/9p+2fS+DEXgrA1KxlRFo=
+5 -7
View File
@@ -14,8 +14,6 @@ import (
"github.com/rwinkhart/libmutton/syncserver" "github.com/rwinkhart/libmutton/syncserver"
) )
const ansiBold = "\033[1m"
func main() { func main() {
args := os.Args args := os.Args
if len(args) < 2 { if len(args) < 2 {
@@ -93,13 +91,13 @@ func main() {
} }
func helpServer() { func helpServer() {
fmt.Print(ansiBold + "\nlibmuttonserver | Copyright (c) 2024-2025 Randall Winkhart\n" + back.AnsiReset + ` fmt.Print(back.AnsiBold + "\nlibmuttonserver | Copyright (c) 2024-2025 Randall Winkhart\n" + back.AnsiReset + `
This software exists under the MIT license; you may redistribute it under certain conditions. This software exists under the MIT license; you may redistribute it under certain conditions.
This program comes with absolutely no warranty; type "libmuttonserver version" for details. This program comes with absolutely no warranty; type "libmuttonserver version" for details.
` + ansiBold + "Usage:" + back.AnsiReset + ` libmuttonserver <argument> ` + back.AnsiBold + "Usage:" + back.AnsiReset + ` libmuttonserver <argument>
` + ansiBold + "Arguments (user):" + back.AnsiReset + ` ` + back.AnsiBold + "Arguments (user):" + back.AnsiReset + `
help Bring up this menu help Bring up this menu
version Display version and license information version Display version and license information
init Create the necessary directories for libmuttonserver to function` + "\n\n") init Create the necessary directories for libmuttonserver to function` + "\n\n")
@@ -107,7 +105,7 @@ This program comes with absolutely no warranty; type "libmuttonserver version" f
} }
func versionServer() { func versionServer() {
fmt.Print(ansiBold + "\n MIT License" + back.AnsiReset + ` fmt.Print(back.AnsiBold + "\n MIT License" + back.AnsiReset + `
Permission is hereby granted, free of charge, to any Permission is hereby granted, free of charge, to any
person obtaining a copy of this software and associated person obtaining a copy of this software and associated
@@ -132,5 +130,5 @@ ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
OR OTHER DEALINGS IN THE SOFTWARE.` + "\n\n---------------------------------------------------------") OR OTHER DEALINGS IN THE SOFTWARE.` + "\n\n---------------------------------------------------------")
fmt.Print(ansiBold + "\n\n libmuttonserver" + back.AnsiReset + " Version " + global.LibmuttonVersion + "\n\n Copyright (c) 2024-2025: Randall Winkhart" + "\n\n") fmt.Print(back.AnsiBold + "\n\n libmuttonserver" + back.AnsiReset + " Version " + global.LibmuttonVersion + "\n\n Copyright (c) 2024-2025: Randall Winkhart" + "\n\n")
} }
+6 -6
View File
@@ -225,7 +225,7 @@ func sftpSync(sshClient *ssh.Client, sshEntryRoot string, sshIsWindows bool, dow
for _, entryName := range downloadList { for _, entryName := range downloadList {
filesTransferred = true // set a flag to indicate that files have been downloaded (used to determine whether to print a gap between download and upload messages) filesTransferred = true // set a flag to indicate that files have been downloaded (used to determine whether to print a gap between download and upload messages)
fmt.Println("Downloading " + synccommon.AnsiDownload + entryName + back.AnsiReset) fmt.Println("Downloading " + back.AnsiGreen + entryName + back.AnsiReset)
// store path to remote entry // store path to remote entry
remoteEntryFullPath := targetLocationFormatSFTP(entryName, sshEntryRoot, sshIsWindows) remoteEntryFullPath := targetLocationFormatSFTP(entryName, sshEntryRoot, sshIsWindows)
@@ -281,7 +281,7 @@ func sftpSync(sshClient *ssh.Client, sshEntryRoot string, sshIsWindows bool, dow
for _, entryName := range uploadList { for _, entryName := range uploadList {
filesTransferred = true // set a flag to indicate that files have been uploaded (used to determine whether to print a gap between upload and sync complete messages) filesTransferred = true // set a flag to indicate that files have been uploaded (used to determine whether to print a gap between upload and sync complete messages)
fmt.Println("Uploading " + synccommon.AnsiUpload + entryName + back.AnsiReset) fmt.Println("Uploading " + back.AnsiBlue + entryName + back.AnsiReset)
// store path to local entry // store path to local entry
localEntryFullPath := global.TargetLocationFormat(entryName) localEntryFullPath := global.TargetLocationFormat(entryName)
@@ -353,23 +353,23 @@ func syncLists(sshClient *ssh.Client, sshEntryRoot string, sshIsWindows, timeSyn
if remoteModTime, present := remoteEntryModMap[entry]; present { if remoteModTime, present := remoteEntryModMap[entry]; present {
// entry exists on both client and server, compare mod times // entry exists on both client and server, compare mod times
if remoteModTime > localModTime { if remoteModTime > localModTime {
fmt.Println(synccommon.AnsiDownload+entry+back.AnsiReset, "is newer on server, adding to download list") fmt.Println(back.AnsiGreen+entry+back.AnsiReset, "is newer on server, adding to download list")
downloadList = append(downloadList, entry) downloadList = append(downloadList, entry)
} else if remoteModTime < localModTime { } else if remoteModTime < localModTime {
fmt.Println(synccommon.AnsiUpload+entry+back.AnsiReset, "is newer on client, adding to upload list") fmt.Println(back.AnsiBlue+entry+back.AnsiReset, "is newer on client, adding to upload list")
uploadList = append(uploadList, entry) uploadList = append(uploadList, entry)
} }
// remove entry from remoteEntryModMap (process of elimination) // remove entry from remoteEntryModMap (process of elimination)
delete(remoteEntryModMap, entry) delete(remoteEntryModMap, entry)
} else { } else {
fmt.Println(synccommon.AnsiUpload+entry+back.AnsiReset, "does not exist on server, adding to upload list") fmt.Println(back.AnsiBlue+entry+back.AnsiReset, "does not exist on server, adding to upload list")
uploadList = append(uploadList, entry) uploadList = append(uploadList, entry)
} }
} }
// iterate over remaining entries in remoteEntryModMap // iterate over remaining entries in remoteEntryModMap
for entry := range remoteEntryModMap { for entry := range remoteEntryModMap {
fmt.Println(synccommon.AnsiDownload+entry+back.AnsiReset, "does not exist on client, adding to download list") fmt.Println(back.AnsiGreen+entry+back.AnsiReset, "does not exist on client, adding to download list")
downloadList = append(downloadList, entry) downloadList = append(downloadList, entry)
} }
+2 -4
View File
@@ -12,9 +12,7 @@ import (
// ANSI color constants used only in this file // ANSI color constants used only in this file
const ( const (
AnsiDelete = "\033[38;5;1m" AnsiDelete = "\033[38;5;1m"
AnsiDownload = "\033[38;5;2m"
AnsiUpload = "\033[38;5;4m"
) )
var RootLength = len(global.EntryRoot) // length of global.EntryRoot string var RootLength = len(global.EntryRoot) // length of global.EntryRoot string
@@ -119,7 +117,7 @@ func AddFolderLocal(targetLocationIncomplete string) error {
err := os.Mkdir(targetLocationComplete, 0700) err := os.Mkdir(targetLocationComplete, 0700)
if err != nil { if err != nil {
if os.IsExist(err) { if os.IsExist(err) {
fmt.Println(AnsiUpload + "Directory already exists - libmutton will still ensure it exists on the server") fmt.Println(back.AnsiBlue + "Directory already exists - libmutton will still ensure it exists on the server")
} else { } else {
return errors.New("unable to create directory: " + err.Error()) return errors.New("unable to create directory: " + err.Error())
} }