diff --git a/src/server/tracker/inspector/http2/frame/mod.rs b/src/server/tracker/inspector/http2/frame/mod.rs index 82f8aa8..05f469a 100644 --- a/src/server/tracker/inspector/http2/frame/mod.rs +++ b/src/server/tracker/inspector/http2/frame/mod.rs @@ -29,7 +29,7 @@ pub fn parse(data: &[u8]) -> (usize, Option) { match Frame::try_from((ty, flags, stream_id, &payload[..length])) { Ok(frame) => (FRAME_HEADER_LEN + length, Some(frame)), Err(err) => { - tracing::warn!("Failed to parse frame: {:?}", err); + tracing::debug!("Failed to parse frame: {:?}", err); (FRAME_HEADER_LEN + length, None) } } diff --git a/src/server/tracker/inspector/http2/frame/priority.rs b/src/server/tracker/inspector/http2/frame/priority.rs index 2182e50..313eb63 100644 --- a/src/server/tracker/inspector/http2/frame/priority.rs +++ b/src/server/tracker/inspector/http2/frame/priority.rs @@ -64,6 +64,7 @@ impl TryFrom<&[u8]> for StreamDependency { fn try_from(buf: &[u8]) -> Result { if buf.len() != 5 { + tracing::debug!("Invalid PRIORITY frame size: {}", buf.len()); return Err(Error::BadFrameSize); } diff --git a/src/server/tracker/inspector/http2/frame/settings.rs b/src/server/tracker/inspector/http2/frame/settings.rs index 3707844..1ecf9f7 100644 --- a/src/server/tracker/inspector/http2/frame/settings.rs +++ b/src/server/tracker/inspector/http2/frame/settings.rs @@ -1,4 +1,4 @@ -use serde::{Serialize, Serializer}; +use serde::Serialize; use super::{error::Error, FrameType}; @@ -6,17 +6,17 @@ use super::{error::Error, FrameType}; /// frame. /// /// Each setting has a value that is a 32 bit unsigned integer (6.5.1.). -#[derive(Debug)] +#[derive(Debug, Serialize)] pub enum Setting { - HeaderTableSize(u16, u32), - EnablePush(u16, u32), - MaxConcurrentStreams(u16, u32), - InitialWindowSize(u16, u32), - MaxFrameSize(u16, u32), - MaxHeaderListSize(u16, u32), - EnableConnectProtocol(u16, u32), - NoRfc7540Priorities(u16, u32), - Unknown(u16, u32), + HeaderTableSize { id: u16, value: u32 }, + EnablePush { id: u16, value: u32 }, + MaxConcurrentStreams { id: u16, value: u32 }, + InitialWindowSize { id: u16, value: u32 }, + MaxFrameSize { id: u16, value: u32 }, + MaxHeaderListSize { id: u16, value: u32 }, + EnableConnectProtocol { id: u16, value: u32 }, + NoRfc7540Priorities { id: u16, value: u32 }, + Unknown { id: u16, value: u32 }, } /// Representing a SETTINGS frame in HTTP/2. @@ -32,15 +32,15 @@ pub struct SettingsFrame { impl From<(u16, u32)> for Setting { fn from((id, value): (u16, u32)) -> Self { match id { - 1 => Setting::HeaderTableSize(id, value), - 2 => Setting::EnablePush(id, value), - 3 => Setting::MaxConcurrentStreams(id, value), - 4 => Setting::InitialWindowSize(id, value), - 5 => Setting::MaxFrameSize(id, value), - 6 => Setting::MaxHeaderListSize(id, value), - 8 => Setting::EnableConnectProtocol(id, value), - 9 => Setting::NoRfc7540Priorities(id, value), - _ => Setting::Unknown(id, value), + 1 => Setting::HeaderTableSize { id, value }, + 2 => Setting::EnablePush { id, value }, + 3 => Setting::MaxConcurrentStreams { id, value }, + 4 => Setting::InitialWindowSize { id, value }, + 5 => Setting::MaxFrameSize { id, value }, + 6 => Setting::MaxHeaderListSize { id, value }, + 8 => Setting::EnableConnectProtocol { id, value }, + 9 => Setting::NoRfc7540Priorities { id, value }, + _ => Setting::Unknown { id, value }, } } } @@ -48,44 +48,19 @@ impl From<(u16, u32)> for Setting { impl Setting { pub fn value(&self) -> (u16, u32) { match self { - Setting::HeaderTableSize(id, value) => (*id, *value), - Setting::EnablePush(id, value) => (*id, *value), - Setting::MaxConcurrentStreams(id, value) => (*id, *value), - Setting::InitialWindowSize(id, value) => (*id, *value), - Setting::MaxFrameSize(id, value) => (*id, *value), - Setting::MaxHeaderListSize(id, value) => (*id, *value), - Setting::EnableConnectProtocol(id, value) => (*id, *value), - Setting::NoRfc7540Priorities(id, value) => (*id, *value), - Setting::Unknown(id, value) => (*id, *value), + Setting::HeaderTableSize { id, value } => (*id, *value), + Setting::EnablePush { id, value } => (*id, *value), + Setting::MaxConcurrentStreams { id, value } => (*id, *value), + Setting::InitialWindowSize { id, value } => (*id, *value), + Setting::MaxFrameSize { id, value } => (*id, *value), + Setting::MaxHeaderListSize { id, value } => (*id, *value), + Setting::EnableConnectProtocol { id, value } => (*id, *value), + Setting::NoRfc7540Priorities { id, value } => (*id, *value), + Setting::Unknown { id, value } => (*id, *value), } } } -impl Serialize for Setting { - fn serialize(&self, serializer: S) -> Result - where - S: Serializer, - { - let value = match self { - Setting::HeaderTableSize(_, value) => format!("HEADER_TABLE_SIZE = {value}"), - Setting::EnablePush(_, value) => format!("ENABLE_PUSH = {value}"), - Setting::MaxConcurrentStreams(_, value) => { - format!("MAX_CONCURRENT_STREAMS = {value}") - } - Setting::InitialWindowSize(_, value) => format!("INITIAL_WINDOW_SIZE = {value}"), - Setting::MaxFrameSize(_, value) => format!("MAX_FRAME_SIZE = {value}"), - Setting::MaxHeaderListSize(_, value) => format!("MAX_HEADER_LIST_SIZE = {value}"), - Setting::EnableConnectProtocol(_, value) => { - format!("ENABLE_CONNECT_PROTOCOL = {value}") - } - Setting::NoRfc7540Priorities(_, value) => format!("NO_RFC7540_PRIORITIES = {value}"), - Setting::Unknown(_, value) => format!("UNKNOWN_SETTING = {value}"), - }; - - serializer.serialize_str(&value) - } -} - // ==== impl SettingsFrame ==== impl TryFrom<&[u8]> for SettingsFrame { @@ -93,6 +68,7 @@ impl TryFrom<&[u8]> for SettingsFrame { fn try_from(payload: &[u8]) -> Result { if payload.is_empty() { + tracing::debug!("Invalid SETTINGS frame size: {}", payload.len()); return Err(Error::BadFrameSize); } diff --git a/src/server/tracker/inspector/http2/frame/window_update.rs b/src/server/tracker/inspector/http2/frame/window_update.rs index 2a88dfc..5bca632 100644 --- a/src/server/tracker/inspector/http2/frame/window_update.rs +++ b/src/server/tracker/inspector/http2/frame/window_update.rs @@ -25,6 +25,7 @@ impl TryFrom<&[u8]> for WindowUpdateFrame { fn try_from(payload: &[u8]) -> Result { if payload.len() != 4 { + tracing::debug!("Invalid WINDOW_UPDATE frame size: {}", payload.len()); return Err(Error::BadFrameSize); }