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ยง
- DnsCache
Key ๐ - Identifier for a DNS request, composed of its source IP and transaction ID
- DnsIsolation
Key ๐ - A Key used to isolate dns requests.
- DnsProxy
- A DNS proxy server that can run indefinitely.
- DnsResponse
Target ๐ - 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.