quic: log version as string

Log as Q043, Q044, Q045, Q046. If the version is not supported/recognized,
log the 4 bytes as hex.

Only log for txs based on long headers.
pull/6819/head
Victor Julien 3 years ago
parent 24a21af4ab
commit ccab28aad3

@ -20,8 +20,9 @@ use crate::jsonbuilder::{JsonBuilder, JsonError};
fn log_template(tx: &QuicTransaction, js: &mut JsonBuilder) -> Result<(), JsonError> {
js.open_object("quic")?;
js.set_uint("version", u32::from(tx.header.version).into())?;
if tx.header.flags.is_long {
js.set_string("version", String::from(tx.header.version).as_str())?;
}
js.open_array("cyu")?;
for cyu in &tx.cyu {
js.start_object()?;

@ -52,6 +52,17 @@ impl QuicVersion {
}
}
impl From<QuicVersion> for String {
fn from(from: QuicVersion) -> Self {
match from {
QuicVersion(0x51303433) => "Q043".to_string(),
QuicVersion(0x51303434) => "Q044".to_string(),
QuicVersion(0x51303435) => "Q045".to_string(),
QuicVersion(0x51303436) => "Q046".to_string(),
QuicVersion(x) => format!("{:x}", x),
}
}
}
impl From<QuicVersion> for u32 {
fn from(from: QuicVersion) -> Self {
from.0

Loading…
Cancel
Save