Hotfix noise read usage, replace with readExactly
This commit is contained in:
parent
d96372f820
commit
6ae92eb21a
|
@ -270,7 +270,9 @@ proc receiveHSMessage(sconn: Connection): Future[seq[byte]] {.async.} =
|
||||||
await sconn.readExactly(addr besize[0], 2)
|
await sconn.readExactly(addr besize[0], 2)
|
||||||
let size = uint16.fromBytesBE(besize).int
|
let size = uint16.fromBytesBE(besize).int
|
||||||
trace "receiveHSMessage", size
|
trace "receiveHSMessage", size
|
||||||
return await sconn.read(size)
|
var buffer = newSeq[byte](size)
|
||||||
|
await sconn.readExactly(addr buffer[0], size)
|
||||||
|
return buffer
|
||||||
|
|
||||||
proc sendHSMessage(sconn: Connection; buf: seq[byte]) {.async.} =
|
proc sendHSMessage(sconn: Connection; buf: seq[byte]) {.async.} =
|
||||||
var
|
var
|
||||||
|
@ -422,9 +424,9 @@ method readMessage(sconn: NoiseConnection): Future[seq[byte]] {.async.} =
|
||||||
trace "receiveEncryptedMessage", size, peer = $sconn.peerInfo
|
trace "receiveEncryptedMessage", size, peer = $sconn.peerInfo
|
||||||
if size == 0:
|
if size == 0:
|
||||||
return @[]
|
return @[]
|
||||||
let
|
var buffer = newSeq[byte](size)
|
||||||
cipher = await sconn.read(size)
|
await sconn.readExactly(addr buffer[0], size)
|
||||||
var plain = sconn.readCs.decryptWithAd([], cipher)
|
var plain = sconn.readCs.decryptWithAd([], buffer)
|
||||||
unpackNoisePayload(plain)
|
unpackNoisePayload(plain)
|
||||||
return plain
|
return plain
|
||||||
except LPStreamIncompleteError:
|
except LPStreamIncompleteError:
|
||||||
|
|
Loading…
Reference in New Issue