libp2p: limit max gossip writes (#1739)

* libp2p: limit max gossip writes

* bump
This commit is contained in:
Jacek Sieka 2020-09-24 19:03:17 +02:00 committed by GitHub
parent 1a9e9fc398
commit b3a9afa0b1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 9 deletions

View File

@ -516,7 +516,7 @@ proc makeEth2Request(peer: Peer, protocolId: string, requestBytes: Bytes,
await readResponse(when useNativeSnappy: libp2pInput(stream) else: stream,
peer, ResponseMsg, timeout)
finally:
await stream.close()
await stream.closeWithEOF()
proc init*[MsgType](T: type MultipleChunksResponse[MsgType],
peer: Peer, conn: Connection): T =
@ -676,17 +676,11 @@ proc handleIncomingStream(network: Eth2Node,
await sendErrorResponse(peer, conn, ServerError,
ErrorMsg err.msg.toBytes)
var buf: array[1, byte]
# Check that there is no extra data on the socket
if (await conn.readOnce(addr buf[0], buf.len)) != 0:
await sendErrorResponse(peer, conn, ServerError,
ErrorMsg "Extra data".toBytes)
except CatchableError as err:
debug "Error processing an incoming request", err = err.msg, msgName
finally:
await conn.close()
await conn.closeWithEOF()
proc toPeerAddr*(r: enr.TypedRecord):
Result[PeerAddr, cstring] {.raises: [Defect].} =

2
vendor/nim-libp2p vendored

@ -1 +1 @@
Subproject commit 25bd0a18f41d8adebb1ef05ec00e7c714cc39662
Subproject commit 17e00e642a513d21744e03f16531cc286c548721