Share client code for Call()

This commit is contained in:
2025-05-03 15:03:53 -04:00
parent 9458656bdd
commit 9b106e8147
3 changed files with 31 additions and 38 deletions
+26
View File
@@ -0,0 +1,26 @@
package daemon
import (
"log"
"net/rpc"
)
// Call connects to the RPC server and requests the passphrase.
func Call() string {
// connect to the UNIX domain socket/Windows named pipe
conn := getConn()
defer conn.Close()
// create an RPC client using the connection
client := rpc.NewClient(conn)
defer client.Close()
// request the passphrase from the RPC server
var reply string
if err := client.Call("RCWService.GetPass", "hi", &reply); err != nil {
log.Fatalf("Error calling RCWService.GetPass: %v", err)
}
// return the passphrase
return reply
}