~kf5jwc/dns-server-rs

9f1ca74e62a81f0120c0028a7f11816945fea04a — Kyle Jones 6 months ago 6aeb124
Revert accepting multiple domains for query

For some reason I'm not currently aware of, requesting more than 1 question appears to be a nono.
1 files changed, 10 insertions(+), 12 deletions(-)

M src/bin/stub_resolver.rs
M src/bin/stub_resolver.rs => src/bin/stub_resolver.rs +10 -12
@@ 20,7 20,7 @@ use dns_server::{
#[structopt()]
struct Args {
    #[structopt()]
    domains: Vec<String>,
    domain: String,
    #[structopt(short, parse(try_from_str), default_value="A")]
    record_type: QueryType,
    #[structopt(short, parse(try_from_str), default_value="192.168.1.1")]


@@ 34,7 34,7 @@ fn main() {
    let args = Args::from_args();

    info!("Generating query packet");
    let packet = make_dns_query_packet(args.domains, args.record_type);
    let packet = make_dns_query_packet(args.domain, args.record_type);
    let req_buffer: BytePacketBuffer = packet.into();

    info!("Starting resolver");


@@ 65,20 65,18 @@ fn main() {
    }
}

fn make_dns_query_packet(qnames: Vec<String>, qtype: QueryType) -> DnsPacket {
fn make_dns_query_packet(qname: String, qtype: QueryType) -> DnsPacket {
    let mut rng = rand::thread_rng();
    let mut packet = DnsPacket::default();
    packet.header.id = rng.gen();
    packet.header.questions = qnames.len() as u16;
    packet.header.questions = 1;
    packet.header.recursion_desired = true;
    for qname in qnames {
        packet.questions.push({
            DnsQuestion{
                name: qname,
                qtype: qtype,
            }
        });
    }
    packet.questions.push({
        DnsQuestion{
            name: qname,
            qtype: qtype,
        }
    });

    return packet;
}