halle-fucking-luyah it worked
Change-Id: I0c917bcc227e7da0a4b101647bd3acbd368050b7
diff --git a/runtime/internal/flow/conn/grpc/conn.go b/runtime/internal/flow/conn/grpc/conn.go
index 56814a0..e3bbe6e 100644
--- a/runtime/internal/flow/conn/grpc/conn.go
+++ b/runtime/internal/flow/conn/grpc/conn.go
@@ -12,7 +12,7 @@
"io"
"log"
"net"
- "runtime/debug"
+ _ "runtime/debug"
"sync"
"time"
@@ -49,8 +49,8 @@
return bytesRead, err
}
- tmp := make([]byte, bytesRead+box.Overhead) // TODO: is this enough? Also, why do we need both of tmp and out?
- out, ok := box.OpenAfterPrecomputation(tmp, resBuf[:bytesRead], c.currentNonce(), c.sharedKey)
+ // tmp := make([]byte, 0, bytesRead-box.Overhead) // TODO: is this enough? Also, why do we need both of tmp and out?
+ out, ok := box.OpenAfterPrecomputation(nil, resBuf[:bytesRead], c.currentNonce(), c.sharedKey)
c.advanceNonce() // TODO: defer? Is there harm in advancing often than necessary (i.e. on error)?
if !ok {
log.Printf("Failed to decrypt.\n")
@@ -59,22 +59,22 @@
}
copy(b, out)
// should we return bytesRead or len(b)?
- log.Fatalf("Succeeded in reading!\n")
+ log.Printf("Succeeded in reading!\n")
return bytesRead, nil
}
// TODO: all this casting is gross
func (c *conn) Write(b []byte) (n int, err error) {
- log.Printf("Write called:\n%v\n", string(debug.Stack()))
+ // log.Printf("Write called:\n%v\n", string(debug.Stack()))
c.mu.Lock()
defer c.mu.Unlock()
log.Printf("Beginning to write.\n")
- tmp := make([]byte, len(b)+box.Overhead) // TODO: is this enough? Also, why do we need both of tmp and out?
- out := box.SealAfterPrecomputation(tmp, b, c.currentNonce(), c.sharedKey)
+ // tmp := make([]byte, 0, len(b)+box.Overhead) // TODO: is this enough? Also, why do we need both of tmp and out?
+ out := box.SealAfterPrecomputation(nil, b, c.currentNonce(), c.sharedKey)
c.advanceNonce()
bytesCopied, err := io.Copy(c.rawConn, bytes.NewReader(out))
if err != nil {
- log.Printf("Failed to copy too rawConn.\n")
+ log.Printf("Failed to copy to rawConn.\n")
log.Fatal(err)
return int(bytesCopied), err
}