Skip to content

Commit

Permalink
map_parser
Browse files Browse the repository at this point in the history
  • Loading branch information
jrouaix committed Nov 29, 2024
1 parent 75a3c76 commit 03b31e1
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions src/decoders/dns.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use byteorder::{BigEndian, WriteBytesExt};
use log::{error, warn};
use nom::{
bytes::complete::take,
combinator::{fail, iterator},
combinator::{fail, iterator, map_parser},
multi::fold_many0,
number::complete::{be_u128, be_u16, be_u32, be_u8, le_u32},
sequence::tuple,
Expand Down Expand Up @@ -205,14 +205,11 @@ fn parse_svcb(input: &[u8]) -> nom::IResult<&[u8], String> {

// ALPN = Application Layer Protocol Negotation
let (input, alpn_size) = be_u8(input)?;

let (dns_data, alpn_data) = take(alpn_size)(input)?;
let (_, alpn_message) = parse_svcb_alpn(alpn_data)?;

let (dns_data, ip_message) = parse_svcb_ip(dns_data)?;
let (input, alpn_message) = map_parser(take(alpn_size), parse_svcb_alpn)(input)?;
let (input, ip_message) = parse_svcb_ip(input)?;

let message = format!("rdata: {} . {} {}", id, alpn_message, ip_message);
Ok((dns_data, message))
Ok((input, message))
}

/// Parse the Application Layer Protocol Negotation
Expand Down

0 comments on commit 03b31e1

Please sign in to comment.