make remote flag handle save/load commands
This commit is contained in:
1 parent
7c15ed69c8
commit
466829e73b
1 file changed
+16
-1
@@ -3,6 +3,7 @@ package main
|
||||
import (
|
||||
"bufio"
|
||||
"fmt"
|
||||
"io"
|
||||
"log"
|
||||
"net"
|
||||
"os"
|
||||
@@ -164,9 +165,23 @@ func sendRemote(cmd string) error {
|
||||
if err != nil {
|
||||
return fmt.Errorf("dialing to send server: %s", err)
|
||||
}
|
||||
defer c.Close()
|
||||
|
||||
fmt.Fprintln(c, cmd)
|
||||
|
||||
// XXX: Standard net.Conn interface does not include a CloseWrite method
|
||||
// but net.UnixConn and net.TCPConn implement it so the following should be
|
||||
// safe as long as we do not use other types of connections. We need
|
||||
// CloseWrite to notify the server that this is not a persistent connection
|
||||
// and it should be closed after the response.
|
||||
if v, ok := c.(interface {
|
||||
CloseWrite() error
|
||||
}); ok {
|
||||
v.CloseWrite()
|
||||
}
|
||||
|
||||
io.Copy(os.Stdout, c)
|
||||
|
||||
c.Close()
|
||||
|
||||
return nil
|
||||
}
|
||||
Reference in new issue
Block a user