Add high-level function for calling the daemon if it is open

This commit is contained in:
2025-05-04 19:38:45 -04:00
parent 0479447f14
commit 9314852f06
6 changed files with 36 additions and 39 deletions
+2 -12
View File
@@ -7,7 +7,7 @@ import (
)
var daemonHash []byte
var passphrase string
var globalPassphrase string
// RCWService provides an RPC method.
type RCWService struct{}
@@ -15,7 +15,7 @@ type RCWService struct{}
// GetPass is the RPC method.
// For now (as a test/example), it returns "hello" if the input is "hi".
func (h *RCWService) GetPass(request string, reply *string) error {
*reply = passphrase
*reply = globalPassphrase
return nil
}
@@ -26,13 +26,3 @@ func getFileHash(path string) []byte {
io.Copy(hash, file)
return hash.Sum(nil)
}
// daemonIsOpen checks if the socket/named pipe for the rcw
// daemon exists and returns a boolean indicator.
func daemonIsOpen() bool {
fileInfo, err := os.Stat(socketPath)
if err != nil {
return false
}
return !fileInfo.IsDir()
}