diff --git a/1shared.go b/daemon/1shared.go similarity index 93% rename from 1shared.go rename to daemon/1shared.go index d783a36..166e153 100644 --- a/1shared.go +++ b/daemon/1shared.go @@ -1,4 +1,4 @@ -package main +package daemon import ( "os" diff --git a/2server.go b/daemon/2server.go similarity index 97% rename from 2server.go rename to daemon/2server.go index 5d50665..4eebbfa 100644 --- a/2server.go +++ b/daemon/2server.go @@ -1,4 +1,4 @@ -package main +package daemon import ( "bytes" @@ -19,8 +19,8 @@ var daemonHash []byte // RCWService provides an RPC method. type RCWService struct{} -// StartDaemon should be called to start an RPC server. -func StartDaemon() { +// Run should be called to start an RPC server. +func Run() { // store the hash of the daemon binary daemonHash = getFileHash(binPath) diff --git a/3client.go b/daemon/3client.go similarity index 84% rename from 3client.go rename to daemon/3client.go index eec3c5b..92db596 100644 --- a/3client.go +++ b/daemon/3client.go @@ -1,4 +1,4 @@ -package main +package daemon import ( "log" @@ -6,7 +6,8 @@ import ( "net/rpc" ) -func CallDaemon() string { +// Call connects to the RPC server and requests the passphrase. +func Call() string { // connect to the UNIX domain socket conn, err := net.Dial("unix", socketPath) if err != nil { diff --git a/4mainTempExample.go b/example.go similarity index 61% rename from 4mainTempExample.go rename to example.go index 68811c9..5c5c2e0 100644 --- a/4mainTempExample.go +++ b/example.go @@ -3,17 +3,18 @@ package main import ( "fmt" "os" + "rcw/daemon" ) func main() { if len(os.Args) > 1 { switch os.Args[1] { case "client": - fmt.Println("RPC Reply: " + CallDaemon()) + fmt.Println("RPC Reply: " + daemon.Call()) default: - StartDaemon() + daemon.Run() } } else { - StartDaemon() + daemon.Run() } }