Limit Kademlia messages to 4kiB (#920)

This commit is contained in:
Pierre Krieger
2019-02-06 14:33:45 +01:00
committed by GitHub
parent 909f50f989
commit a22121c8e7
2 changed files with 9 additions and 3 deletions

View File

@ -159,8 +159,11 @@ where
#[inline]
fn upgrade_inbound(self, incoming: C, _: Self::Info) -> Self::Future {
let mut codec = codec::UviBytes::default();
codec.set_max_len(4096);
future::ok(
Framed::new(incoming, codec::UviBytes::default())
Framed::new(incoming, codec)
.from_err::<IoError>()
.with::<_, fn(_) -> _, _>(|response| -> Result<_, IoError> {
let proto_struct = resp_msg_to_proto(response);
@ -185,8 +188,11 @@ where
#[inline]
fn upgrade_outbound(self, incoming: C, _: Self::Info) -> Self::Future {
let mut codec = codec::UviBytes::default();
codec.set_max_len(4096);
future::ok(
Framed::new(incoming, codec::UviBytes::default())
Framed::new(incoming, codec)
.from_err::<IoError>()
.with::<_, fn(_) -> _, _>(|request| -> Result<_, IoError> {
let proto_struct = req_msg_to_proto(request);