Skip to main content

start

Function start 

Source
pub fn start(preferred_port: u16) -> Result<u16>
Expand description

Starts the DNS server for the CodeEditorLand private network.

This function performs the following steps:

  1. Uses portpicker to find an available port (tries preferred_port first)
  2. Sets the DNS_PORT global variable
  3. Builds the DNS catalog with the editor.land zone
  4. Spawns the DNS server as a background task
  5. Returns the port number

The DNS server runs in the background and can be stopped by dropping the application.

§Parameters

  • preferred_port - The preferred port number to use. If this port is already in use, portpicker will find an alternative available port.

§Returns

Returns Ok(port) with the port number the server is listening on, or an error if the server failed to start.

§Example

use Mist::start;

#[tokio::main]
async fn main() -> anyhow::Result<()> {
    // Start DNS server, preferring port 5353
    let port = start(5353)?;
    println!("DNS server started on port {}", port);
    tokio::signal::ctrl_c().await?;
    Ok(())
}