import ipv4;
import dns;
let client = 192.168.238.112;
let server = 142.250.207.36;
let google = 8.8.8.8;
let dns = ipv4::udp::flow(
client/13749,
google/53,
);
# There is a low-level DNS API which you can use to construct exact queries,
# and even malformed queries
dns.client_dgram(
dns::hdr(
id: 0x1234,
flags: dns::flags(
opcode: dns::opcode::QUERY,
rd: 1,
),
qdcount: 1,
),
dns::question(
qname: dns::name("www", "google", "com"),
qtype: dns::qtype::A,
qclass: dns::class::IN,
)
);
dns.server_dgram(
dns::hdr(
id: 0x1234,
flags: dns::flags(
response: 1,
opcode: dns::opcode::QUERY,
ra: 1,
),
qdcount: 1,
ancount: 1,
),
dns::question(
qname: dns::name("www", "google", "com"),
qtype: dns::qtype::A,
qclass: dns::class::IN,
),
dns::answer(
aname: dns::name("www", "google", "com"),
atype: dns::rtype::A,
aclass: dns::class::IN,
server,
),
);
# And then there is the high level API which you can use to quickly generate a
# query/response pair to make it lool like our hosts are doing DNS lookups
dns::host(client, "www.google.com", ns: google, server);