Skip to content

Mistβ€πŸŒ«οΈβ€+ Landβ€πŸžοΈ

Notifications You must be signed in to change notification settings

CodeEditorLand/Mist

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

7 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Mist

🌫️

+

🏞️

+


Mistβ€πŸŒ«οΈβ€DNS Isolation for the editor.land Private Network

License: CC0-1.0 Rust Version Hickory DNS Version

Welcome to Mist! This element provides DNS isolation and private network resolution for the Land Code Editor. It creates a secure DNS sandbox that resolves all *.editor.land domains locally to 127.0.0.1, ensuring that all private network communication remains local and secure.

Mist is engineered to:

  1. Provide Private DNS Resolution: Operate a local DNS server authoritative for the editor.land zone, resolving all subdomains to localhost for secure local communication.
  2. Enforce Forward Security: Implement a forward allowlist that only permits DNS resolution to specific, trusted external domains (e.g., update.editor.land, cdn.crashlytics.com).
  3. Support DNSSEC: Sign the editor.land zone with ECDSA P-256 keys for DNSSEC, providing cryptographic assurance of DNS responses.
  4. Enable Sidecar Isolation: Allow Node.js sidecars (like Cocoon) to use the local DNS server via a custom DNS override, ensuring they cannot access arbitrary external hosts.

Key Featuresβ€πŸŒ«οΈ

  • Hickory DNS Server: Built on the high-performance Hickory DNS library (formerly Trust-DNS), providing a robust, async DNS server implementation.
  • Authoritative Zone: Operates as an authoritative DNS server for editor.land, resolving all subdomains (*.editor.land) to 127.0.0.1 for secure local communication.
  • Forward Security: Implements a strict allowlist for external DNS queries, preventing sidecars from reaching unauthorized external hosts by default.
  • DNSSEC Support: Signs the authoritative zone with ECDSA P-256 keys, providing cryptographic integrity and authenticity for DNS responses.
  • Dynamic Port Selection: Automatically selects an available port if the preferred port (5380) is unavailable, ensuring robust startup behavior.
  • Async Runtime: Built on Tokio for efficient, non-blocking DNS query handling.
  • Cross-Platform: Works on macOS, Linux, and Windows with consistent behavior.

Architectureβ€πŸ—οΈ

Mist follows a layered architecture:

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                     Applications (Wind, Cocoon)                  β”‚
β”‚                        (DNS Queries)                            β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                     β”‚
                                     β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                     Mist DNS Server (127.0.0.1:PORT)             β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚
β”‚  β”‚                   DNS Catalog                             β”‚  β”‚
β”‚  β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”        β”‚  β”‚
β”‚  β”‚  β”‚ Editor.land Zone   β”‚  β”‚ Forward Allowlist    β”‚        β”‚  β”‚
β”‚  β”‚  β”‚ (Authoritative)    β”‚  β”‚ (Restricted Access) β”‚        β”‚  β”‚
β”‚  β”‚  β”‚ *.editor.land β†’    β”‚  β”‚ update.editor.land  β”‚        β”‚  β”‚
β”‚  β”‚  β”‚ 127.0.0.1          β”‚  β”‚ cdn.crashlytics.com  β”‚        β”‚  β”‚
β”‚  β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜        β”‚  β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚
β”‚                                                               β”‚
β”‚  Hickory DNS Server Core (UDP + TCP)                          β”‚
β”‚  - Request parsing and response construction                  β”‚
β”‚  - Zone lookup and record matching                             β”‚
β”‚  - DNSSEC signature verification                               β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Components

  • lib.rs: Main library entry point, exports public API and manages the DNS server state.
  • server.rs: DNS server implementation using Hickory, handles UDP/TCP listeners and catalog management.
  • zone.rs: DNS zone configuration for editor.land, including record definitions and authority creation.
  • resolver.rs: DNS resolver for use by other components, provides interface to the local DNS server.
  • forward_security.rs: Forward allowlist management, restricts which external domains can be resolved.
  • tests/integration.rs: Comprehensive integration tests for DNS server functionality.

Usageβ€πŸ”§

Starting the DNS Server

Start the DNS server on a specific port (or 0 for auto-selection):

use Mist::start;

// Start on preferred port 5380
let port = Mist::start(5380)?;

// Or let the system select an available port
let port = Mist::start(0)?;

println!("DNS server running on 127.0.0.1:{}", port);

Getting the DNS Server Port

Retrieve the current DNS server port:

use Mist::dns_port;

let port = dns_port();
println!("DNS server is on port: {}", port);

Creating a DNS Resolver

Create a resolver that uses the local DNS server:

use Mist::resolver::{land_resolver, LandDnsResolver};

// Simple resolver
let port = Mist::dns_port();
let resolver = land_resolver(port);

// Or with explicit interface
let resolver = LandDnsResolver::new(port);

Building a DNS Catalog

Build a DNS catalog with authoritative zones:

use Mist::server::build_catalog;

let catalog = build_catalog(5380)?;

DNS Zone Configurationβ€πŸ“‹

Authoritative Zone: editor.land

All subdomains of editor.land resolve to 127.0.0.1:

  • code.editor.land β†’ 127.0.0.1
  • api.editor.land β†’ 127.0.0.1
  • *.editor.land β†’ 127.0.0.1

Forward Allowlist

Only allowlisted external domains can be resolved:

  • update.editor.land - For application updates
  • cdn.crashlytics.com - For crash reporting

All other external queries are refused by default.

DNSSEC

The editor.land zone is signed with ECDSA P-256 keys:

  • DNSKEY records provide the public signing key
  • RRSIG records provide cryptographic signatures
  • Clients can verify the authenticity of DNS responses

Dependenciesβ€πŸ“¦

Mist depends on the following crates:

  • hickory-server (0.24): DNS server implementation
  • hickory-proto (0.24): DNS protocol implementation
  • hickory-client (0.24): DNS client for resolvers
  • ring (0.17): Cryptographic signing for DNSSEC
  • tokio (1.49): Async runtime
  • anyhow (1.0): Error handling
  • tracing (0.1): Logging and instrumentation
  • once_cell (1.21): Thread-safe lazy initialization
  • portpicker (0.1.1): Random port selection
  • async-trait (0.1): Async trait support
  • reqwest (0.13): HTTP client with DNS integration

Building & Testingβ€πŸ”¨

Building

Build the library:

cargo build --release

Running Tests

Run all tests:

cargo test

Run integration tests:

cargo test --test integration

Run with logging:

RUST_LOG=debug cargo test

Security Considerationsβ€πŸ”’

Mist implements several security features:

  1. Private Network Isolation: All editor.land domains resolve to localhost, preventing any external network access for private services.
  2. Forward Allowlist: External DNS queries are restricted to a trusted allowlist, preventing sidecars from accessing arbitrary external hosts.
  3. DNSSEC: Zone signing provides cryptographic assurance of DNS responses, preventing DNS spoofing attacks.
  4. Loopback Binding: The DNS server only binds to 127.0.0.1, preventing external access to the private DNS server.

Integration with Landβ€πŸ”—

Mist is integrated into the Land ecosystem:

  • Mountain: Starts the DNS server during application initialization and provides the port to other components via the DnsPort managed state.
  • Air: Uses the DNS server for secure HTTP requests, configuring HTTP clients to use the local DNS resolver.
  • SideCar: Spawns Node.js sidecars with DNS override configuration, ensuring all DNS queries go through the local server.
  • Cocoon: The Node.js extension host can resolve editor.land domains via the local DNS server for gRPC communication with Mountain.

Licenseβ€πŸ“œ

This project is licensed under the CC0 1.0 Universal license - see the LICENSE file for details.


Contributingβ€πŸ€

Contributions are welcome! Please ensure:

  1. All tests pass: cargo test
  2. Code follows Rust style guidelines: cargo fmt
  3. No clippy warnings: cargo clippy
  4. Documentation is updated as needed

Acknowledgmentsβ€πŸ™

  • Hickory DNS Team - For creating an excellent DNS library
  • Trust-DNS Team - For the original implementation that Hickory builds upon
  • Land Team - For the vision of a secure, private development environment

About

Mistβ€πŸŒ«οΈβ€+ Landβ€πŸžοΈ

Resources

Code of conduct

Security policy

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

Packages

 
 
 

Languages