introduce magic bytes to stop

This commit is contained in:
Zack Scholl 2018-09-25 09:39:18 -07:00
parent ee7518c7bd
commit 75f7cdcf65
2 changed files with 13 additions and 3 deletions

View File

@ -216,6 +216,10 @@ func receive(forceSend int, serverAddress, serverTCP string, isLocal bool, c *we
log.Error(err)
return err
}
if bytes.Equal(message, []byte("magic")) {
log.Debug("got magic")
break
}
// do decryption
var enc crypt.Encryption
@ -244,9 +248,9 @@ func receive(forceSend int, serverAddress, serverTCP string, isLocal bool, c *we
// update the progress bar
bar.Add(n)
if int64(bytesWritten) == fstats.Size {
break
}
// if int64(bytesWritten) == fstats.Size {
// break
// }
}
c.WriteMessage(websocket.BinaryMessage, []byte("done"))

View File

@ -224,6 +224,12 @@ func send(forceSend int, serverAddress, serverTCP string, isLocal bool, c *webso
}
}
// finish
dataChan <- DataChan{
b: []byte("magic"),
bytesRead: len([]byte("magic")),
err: nil,
}
// finish
dataChan <- DataChan{
b: nil,
bytesRead: 0,