pub fn secured_client(dns_port: u16) -> Result<Client>
Expand description
Creates a secured reqwest Client with DNS override.
This client uses the local DNS server (running
on the specified port) for all DNS resolution.
This is a security measure to ensure that all
*.editor.land queries go through
the local Hickory DNS server, which validates
that they only resolve to
127.x.x.x addresses.
§Parameters
-
dns_port- The port of the local DNS server (obtained frommist::dns_port())
§Returns
Returns a configured
reqwest::Client that uses the local
DNS resolver.
§Example
use AirLibrary::HTTP::secured_client;
use Mist;
#[tokio::main]
async fn main() -> anyhow::Result<()> {
let dns_port = mist::dns_port();
let client = secured_client(dns_port)?;
// All HTTP requests will use the local DNS server
let response = client.get("https://code.editor.land").send().await?;
Ok(())
}
§Security
The DNS override ensures:
- All DNS queries go through the local DNS server
-
*.editor.landdomains resolve only to127.x.x.xaddresses - Protection against DNS spoofing and cache poisoning
- Defense-in-depth security for the local network