From 8a843a6a8586330d4857b8c46bcb8c13bfe05b27 Mon Sep 17 00:00:00 2001 From: Zack Scholl Date: Fri, 12 Apr 2019 12:01:57 -0700 Subject: [PATCH] update ui --- src/croc/croc.go | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/src/croc/croc.go b/src/croc/croc.go index ab2b0ddf..27927d4a 100644 --- a/src/croc/croc.go +++ b/src/croc/croc.go @@ -19,6 +19,7 @@ import ( "github.com/go-redis/redis" "github.com/mattn/go-colorable" "github.com/pions/webrtc" + "github.com/schollz/croc/v5/src/crypt" "github.com/schollz/croc/v5/src/utils" "github.com/schollz/croc/v5/src/webrtc/pkg/session/common" "github.com/schollz/croc/v5/src/webrtc/pkg/session/receiver" @@ -393,7 +394,14 @@ func (c *Client) processMessage(m Message) (err error) { } case "fileinfo": var senderInfo SenderInfo - err = json.Unmarshal(m.Bytes, &senderInfo) + var decryptedBytes []byte + key, _ := c.Pake.SessionKey() + decryptedBytes, err = crypt.DecryptFromBytes(m.Bytes, key) + if err != nil { + log.Error(err) + return + } + err = json.Unmarshal(decryptedBytes, &senderInfo) if err != nil { log.Error(err) return @@ -415,7 +423,14 @@ func (c *Client) processMessage(m Message) (err error) { c.Step2FileInfoTransfered = true case "recipientready": var remoteFile RemoteFileRequest - err = json.Unmarshal(m.Bytes, &remoteFile) + var decryptedBytes []byte + key, _ := c.Pake.SessionKey() + decryptedBytes, err = crypt.DecryptFromBytes(m.Bytes, key) + if err != nil { + log.Error(err) + return + } + err = json.Unmarshal(decryptedBytes, &remoteFile) if err != nil { return } @@ -498,9 +513,10 @@ func (c *Client) updateState() (err error) { log.Error(err) return } + key, _ := c.Pake.SessionKey() err = c.redisdb.Publish(c.nameOutChannel, Message{ Type: "fileinfo", - Bytes: b, + Bytes: crypt.EncryptToBytes(b, key), }.String()).Err() if err != nil { return @@ -581,9 +597,10 @@ func (c *Client) updateState() (err error) { CurrentFileChunks: c.CurrentFileChunks, FilesToTransferCurrentNum: c.FilesToTransferCurrentNum, }) + key, _ := c.Pake.SessionKey() err = c.redisdb.Publish(c.nameOutChannel, Message{ Type: "recipientready", - Bytes: bRequest, + Bytes: crypt.EncryptToBytes(bRequest, key), }.String()).Err() if err != nil { return