#dns-server #async-dns #dns #no-alloc #portal #ip-address #networking

no-std edge-captive

Async + no_std + no-alloc implementation of a Captive Portal DNS

3 releases (breaking)

0.2.0 Feb 1, 2024
0.1.0 Jan 27, 2024
0.0.0 Nov 22, 2023

#1793 in Embedded development

Download history 9/week @ 2024-01-24 16/week @ 2024-01-31 7/week @ 2024-02-14 26/week @ 2024-02-21 13/week @ 2024-02-28 1/week @ 2024-03-06 4/week @ 2024-03-13 28/week @ 2024-03-27 33/week @ 2024-04-03

61 downloads per month
Used in edge-net

MIT/Apache

10KB
202 lines

edge-captive

CI crates.io Documentation

Async + no_std + no-alloc implementation of a Captive Portal DNS (i.e. a DNS server that resolves every domain name to a fixed IP address).

The implementation is based on the splendid domain library.

For other protocols, look at the edge-net aggregator crate documentation.

Example

use core::time::Duration;

use edge_captive::io::run;

use embedded_nal_async::{IpAddr, Ipv4Addr, SocketAddr};

use log::*;

fn main() {
    env_logger::init_from_env(
        env_logger::Env::default().filter_or(env_logger::DEFAULT_FILTER_ENV, "info"),
    );

    let stack = edge_std_nal_async::Stack::new();

    let mut tx_buf = [0; 1500];
    let mut rx_buf = [0; 1500];

    info!("Running Captive Portal DNS on UDP port 8853...");

    futures_lite::future::block_on(run(
        &stack,
        // Can't use DEFAULT_SOCKET because it uses DNS port 53 which needs root
        SocketAddr::new(IpAddr::V4(Ipv4Addr::UNSPECIFIED), 8853),
        &mut tx_buf,
        &mut rx_buf,
        Ipv4Addr::new(192, 168, 0, 1),
        Duration::from_secs(60),
    ))
    .unwrap();
}

Dependencies

~3MB
~65K SLoC