diff --git a/.github/actions/spelling/allow.txt b/.github/actions/spelling/allow.txt index 79f0d10a9a33b..83105c50c224b 100644 --- a/.github/actions/spelling/allow.txt +++ b/.github/actions/spelling/allow.txt @@ -131,6 +131,7 @@ dockercmd Dockerfiles doha DOOV +DOQ Douban downsides downwardapi diff --git a/changelog.d/25495_dnstap_parser_doq_support.fix.md b/changelog.d/25495_dnstap_parser_doq_support.fix.md new file mode 100644 index 0000000000000..a36198bd34b70 --- /dev/null +++ b/changelog.d/25495_dnstap_parser_doq_support.fix.md @@ -0,0 +1,4 @@ +Added support for DOQ socket protocol in dnstap source. This will prevent error messages when DOQ +traffic is encountered. + +authors: esensar Quad9DNS diff --git a/lib/vector-vrl/dnstap-parser/src/parser.rs b/lib/vector-vrl/dnstap-parser/src/parser.rs index 5e14303c4a5a2..73c7ccdde0142 100644 --- a/lib/vector-vrl/dnstap-parser/src/parser.rs +++ b/lib/vector-vrl/dnstap-parser/src/parser.rs @@ -1009,23 +1009,9 @@ fn to_socket_family_name(socket_family: i32) -> Result<&'static str> { } fn to_socket_protocol_name(socket_protocol: i32) -> Result<&'static str> { - if socket_protocol == SocketProtocol::Udp as i32 { - Ok("UDP") - } else if socket_protocol == SocketProtocol::Tcp as i32 { - Ok("TCP") - } else if socket_protocol == SocketProtocol::Dot as i32 { - Ok("DOT") - } else if socket_protocol == SocketProtocol::Doh as i32 { - Ok("DOH") - } else if socket_protocol == SocketProtocol::DnsCryptUdp as i32 { - Ok("DNSCryptUDP") - } else if socket_protocol == SocketProtocol::DnsCryptTcp as i32 { - Ok("DNSCryptTCP") - } else { - Err(Error::from(format!( - "Unknown socket protocol: {socket_protocol}" - ))) - } + SocketProtocol::try_from(socket_protocol) + .map_err(|_| Error::from(format!("Unknown socket protocol: {socket_protocol}"))) + .map(|sp| sp.as_str_name()) } fn to_dnstap_data_type(data_type_id: i32) -> Option { @@ -1449,6 +1435,7 @@ mod tests { assert_eq!("DOH", to_socket_protocol_name(4).unwrap()); assert_eq!("DNSCryptUDP", to_socket_protocol_name(5).unwrap()); assert_eq!("DNSCryptTCP", to_socket_protocol_name(6).unwrap()); - assert!(to_socket_protocol_name(7).is_err()); + assert_eq!("DOQ", to_socket_protocol_name(7).unwrap()); + assert!(to_socket_protocol_name(8).is_err()); } }