diff --git a/cmd/main.go b/cmd/main.go index adc59c7..702f2ae 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -117,7 +117,7 @@ func doSink(c *cli.Context) (err error) { PullMapping: findMapping(conf.PullACLs), } - if err = rpc.ListenByteStreamRPC(sshByteStream, handler); err != nil { + if err = rpc.ListenByteStreamRPC(sshByteStream, handler, sinkLogger); err != nil { //os.Exit(1) err = cli.NewExitError(err, 1) defaultLog.Printf("listenbytestreamerror: %#v\n", err) diff --git a/rpc/rpc.go b/rpc/rpc.go index 0dff457..f643e5b 100644 --- a/rpc/rpc.go +++ b/rpc/rpc.go @@ -27,12 +27,17 @@ type RPCHandler interface { HandleIncrementalTransferRequest(r IncrementalTransferRequest) (io.Reader, error) } +type Logger interface { + Printf(format string, args ...interface{}) +} + const ByteStreamRPCProtocolVersion = 1 type ByteStreamRPC struct { conn io.ReadWriteCloser encoder *json.Encoder decoder *json.Decoder + log Logger } func ConnectByteStreamRPC(conn io.ReadWriteCloser) (RPCRequester, error) { @@ -52,7 +57,7 @@ func ConnectByteStreamRPC(conn io.ReadWriteCloser) (RPCRequester, error) { return rpc, nil } -func ListenByteStreamRPC(conn io.ReadWriteCloser, handler RPCHandler) error { +func ListenByteStreamRPC(conn io.ReadWriteCloser, handler RPCHandler, log Logger) error { // A request consists of two subsequent JSON objects // Object 1: RequestHeader => contains type of Request Body