Skip to main content

Module dns

Module dns 

Source
Expand description

Implement a simple DNS resolver that relay request over Tor.

A resolver is created with bind_dns_resolver(), which opens a set of listener ports. DnsProxy::run_dns_proxy then listens for DNS requests, and sends back replies in response.

Re-exportsยง

use futures::lock::Mutex; ๐Ÿ”’
use futures::stream::StreamExt; ๐Ÿ”’
use hickory_proto::op::Message; ๐Ÿ”’
use hickory_proto::op::OpCode; ๐Ÿ”’
use hickory_proto::op::Query; ๐Ÿ”’
use hickory_proto::op::ResponseCode; ๐Ÿ”’
use hickory_proto::rr::DNSClass; ๐Ÿ”’
use hickory_proto::rr::Name; ๐Ÿ”’
use hickory_proto::rr::RData; ๐Ÿ”’
use hickory_proto::rr::Record; ๐Ÿ”’
use hickory_proto::rr::RecordType; ๐Ÿ”’
use hickory_proto::rr::rdata; ๐Ÿ”’
use hickory_proto::serialize::binary::BinDecodable; ๐Ÿ”’
use hickory_proto::serialize::binary::BinEncodable; ๐Ÿ”’
use std::collections::HashMap; ๐Ÿ”’
use std::net::IpAddr; ๐Ÿ”’
use std::net::SocketAddr; ๐Ÿ”’
use std::sync::Arc; ๐Ÿ”’
use tor_rtcompat::SpawnExt; ๐Ÿ”’
use tor_rtcompat::UdpProvider; ๐Ÿ”’
use tracing::debug; ๐Ÿ”’
use tracing::error; ๐Ÿ”’
use tracing::info; ๐Ÿ”’
use tracing::warn; ๐Ÿ”’
use arti_client::Error; ๐Ÿ”’
use arti_client::HasKind; ๐Ÿ”’
use arti_client::StreamPrefs; ๐Ÿ”’
use arti_client::TorClient; ๐Ÿ”’
use safelog::sensitive as sv; ๐Ÿ”’
use tor_config::Listen; ๐Ÿ”’
use tor_error::error_report; ๐Ÿ”’
use tor_error::warn_report; ๐Ÿ”’
use tor_rtcompat::Runtime; ๐Ÿ”’
use tor_rtcompat::UdpSocket; ๐Ÿ”’
use anyhow::Result; ๐Ÿ”’
use anyhow::anyhow; ๐Ÿ”’
use crate::proxy::port_info; ๐Ÿ”’

Structsยง

DnsCacheKey ๐Ÿ”’
Identifier for a DNS request, composed of its source IP and transaction ID
DnsIsolationKey ๐Ÿ”’
A Key used to isolate dns requests.
DnsProxy
A DNS proxy server that can run indefinitely.
DnsResponseTarget ๐Ÿ”’
Target for a DNS response

Constantsยง

MAX_DATAGRAM_SIZE ๐Ÿ”’
Maximum length for receiving a single datagram

Functionsยง

bind_dns_resolver
Bind to a set of DNS ports, and return a new DnsProxy.
do_query ๐Ÿ”’
Run a DNS query over tor, returning either a list of answers, or a DNS error code.
handle_dns_req ๐Ÿ”’
Given a datagram containing a DNS query, resolve the query over the Tor network and send the response back.
run_dns_resolver_with_listeners ๐Ÿ”’
Inner task: Receive incoming DNS requests and process them.