Skip to main content

secured_client

Function secured_client 

Source
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 from mist::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.land domains resolve only to 127.x.x.x addresses
  • Protection against DNS spoofing and cache poisoning
  • Defense-in-depth security for the local network