Skip to content

Commit

Permalink
quic: use sni from crypto frame with tls
Browse files Browse the repository at this point in the history
for detection
  • Loading branch information
catenacyber committed Mar 2, 2022
1 parent d5ba17e commit f9a89f5
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion rust/src/quic/quic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ use super::{
use crate::applayer::{self, *};
use crate::core::{AppProto, Flow, ALPROTO_FAILED, ALPROTO_UNKNOWN, IPPROTO_UDP};
use std::ffi::CString;
use tls_parser::TlsExtensionType;

static mut ALPROTO_QUIC: AppProto = ALPROTO_UNKNOWN;

Expand Down Expand Up @@ -201,7 +202,7 @@ impl QuicState {
let hlen = buf.len() - rest.len();
let mut output;
if self.keys.is_some() {
output = Vec::with_capacity(framebuf.len()+4);
output = Vec::with_capacity(framebuf.len() + 4);
if !self.decrypt(to_server, &header, framebuf, buf, hlen, &mut output) {
return false;
}
Expand Down Expand Up @@ -232,6 +233,13 @@ impl QuicState {
}
}
Frame::Crypto(c) => {
for e in &c.extv {
if e.etype == TlsExtensionType::ServerName
&& e.values.len() > 0
{
sni = Some(e.values[0].to_vec());
}
}
extv.extend_from_slice(&c.extv);
if to_server {
self.hello_ts = true
Expand Down

0 comments on commit f9a89f5

Please sign in to comment.