mirror of
https://github.com/outbackdingo/firezone.git
synced 2026-01-27 10:18:54 +00:00
fix(connlib): classify WireGuard first (#10890)
WireGuard packets can have all kinds of byte-patterns at the very front of the packet. Thus, we need to first check if a payload is a WireGuard packet before attempting to classify it as anything else. This function is currently only used for logging purposes. `snownet` has its own logic for de-multiplexing and classifying packets.
This commit is contained in:
@@ -37,14 +37,14 @@ impl From<Kind> for opentelemetry::Value {
|
||||
|
||||
pub fn classify(packet: &[u8]) -> Kind {
|
||||
match packet {
|
||||
[0..=3, ..] => Kind::Stun,
|
||||
// Channel-data is a 4-byte header so the actual payload starts on the 5th byte
|
||||
[64..=79, _, _, _, 0..=3, ..] => Kind::StunOverTurn,
|
||||
payload if snownet::is_wireguard(payload) => Kind::Wireguard,
|
||||
[64..=79, _, _, _, payload @ ..] if snownet::is_wireguard(payload) => {
|
||||
Kind::WireguardOverTurn
|
||||
}
|
||||
[0..=3, ..] => Kind::Stun,
|
||||
// Channel-data is a 4-byte header so the actual payload starts on the 5th byte
|
||||
[64..=79, _, _, _, 0..=3, ..] => Kind::StunOverTurn,
|
||||
[64..=79, _, _, _, ..] => Kind::UnknownOverTurn,
|
||||
payload if snownet::is_wireguard(payload) => Kind::Wireguard,
|
||||
_ => Kind::Unknown,
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user