quic: log user agent when available

pull/6819/head
Victor Julien 4 years ago
parent da8b024b99
commit 4c13b73c4d

@ -26,6 +26,9 @@ fn log_template(tx: &QuicTransaction, js: &mut JsonBuilder) -> Result<(), JsonEr
if let Some(sni) = &tx.sni { if let Some(sni) = &tx.sni {
js.set_string("sni", &String::from_utf8_lossy(&sni))?; js.set_string("sni", &String::from_utf8_lossy(&sni))?;
} }
if let Some(ua) = &tx.ua {
js.set_string("ua", &String::from_utf8_lossy(&ua))?;
}
} }
js.open_array("cyu")?; js.open_array("cyu")?;
for cyu in &tx.cyu { for cyu in &tx.cyu {

@ -34,17 +34,19 @@ pub struct QuicTransaction {
pub header: QuicHeader, pub header: QuicHeader,
pub cyu: Vec<Cyu>, pub cyu: Vec<Cyu>,
pub sni: Option<Vec<u8>>, pub sni: Option<Vec<u8>>,
pub ua: Option<Vec<u8>>,
tx_data: AppLayerTxData, tx_data: AppLayerTxData,
} }
impl QuicTransaction { impl QuicTransaction {
fn new(header: QuicHeader, data: QuicData, sni: Option<Vec<u8>>) -> Self { fn new(header: QuicHeader, data: QuicData, sni: Option<Vec<u8>>, ua: Option<Vec<u8>>) -> Self {
let cyu = Cyu::generate(&header, &data.frames); let cyu = Cyu::generate(&header, &data.frames);
QuicTransaction { QuicTransaction {
tx_id: 0, tx_id: 0,
header, header,
cyu, cyu,
sni, sni,
ua,
tx_data: AppLayerTxData::new(), tx_data: AppLayerTxData::new(),
} }
} }
@ -84,8 +86,8 @@ impl QuicState {
self.transactions.iter().find(|&tx| tx.tx_id == tx_id + 1) self.transactions.iter().find(|&tx| tx.tx_id == tx_id + 1)
} }
fn new_tx(&mut self, header: QuicHeader, data: QuicData, sni: Option<Vec<u8>>) -> QuicTransaction { fn new_tx(&mut self, header: QuicHeader, data: QuicData, sni: Option<Vec<u8>>, ua: Option<Vec<u8>>) -> QuicTransaction {
let mut tx = QuicTransaction::new(header, data, sni); let mut tx = QuicTransaction::new(header, data, sni, ua);
self.max_tx_id += 1; self.max_tx_id += 1;
tx.tx_id = self.max_tx_id; tx.tx_id = self.max_tx_id;
return tx; return tx;
@ -117,12 +119,17 @@ impl QuicState {
// no tx for the short header (data) frames // no tx for the short header (data) frames
if header.ty != QuicType::Short { if header.ty != QuicType::Short {
let mut sni : Option<Vec<u8>> = None; let mut sni : Option<Vec<u8>> = None;
let mut ua : Option<Vec<u8>> = None;
for frame in &data.frames { for frame in &data.frames {
if let Frame::Stream(s) = frame { if let Frame::Stream(s) = frame {
if let Some(tags) = &s.tags { if let Some(tags) = &s.tags {
for (tag, value) in tags { for (tag, value) in tags {
if tag == &StreamTag::Sni { if tag == &StreamTag::Sni {
sni = Some(value.to_vec()); sni = Some(value.to_vec());
} else if tag == &StreamTag::Uaid {
ua = Some(value.to_vec());
}
if sni.is_some() && ua.is_some() {
break; break;
} }
} }
@ -130,7 +137,7 @@ impl QuicState {
} }
} }
let transaction = self.new_tx(header, data, sni); let transaction = self.new_tx(header, data, sni, ua);
self.transactions.push(transaction); self.transactions.push(transaction);
} }
return true; return true;

Loading…
Cancel
Save