mirror of
https://github.com/rwinkhart/rcw.git
synced 2026-09-05 16:47:24 -04:00
Add high-level function for calling the daemon if it is open
This commit is contained in:
+13
-3
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user