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
+13 -3
View File
@@ -5,8 +5,18 @@ import (
"net/rpc"
)
// Call connects to the RPC server and requests the passphrase.
func Call() string {
// CallDaemonIfOpen returns the passphrase served by the RCW daemon
// (if one is available). If no RCW daemon is accessible, nil is returned.
func CallDaemonIfOpen() []byte {
if daemonIsOpen() {
call()
return call()
}
return nil
}
// call connects to the RPC server and requests the passphrase.
func call() []byte {
// connect to the UNIX domain socket/Windows named pipe
conn := getConn()
defer conn.Close()
@@ -22,5 +32,5 @@ func Call() string {
}
// return the passphrase
return reply
return []byte(reply)
}