Crates.io | edge-captive |
lib.rs | edge-captive |
version | 0.3.0 |
source | src |
created_at | 2023-11-22 21:08:39.304125 |
updated_at | 2024-09-10 19:10:55.511473 |
description | Async + `no_std` + no-alloc implementation of a Captive Portal DNS |
homepage | |
repository | https://github.com/ivmarkov/edge-net |
max_upload_size | |
id | 1045509 |
size | 9,753 |
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.
use core::net::{IpAddr, Ipv4Addr, SocketAddr};
use core::time::Duration;
use edge_captive::io::run;
use log::*;
fn main() {
env_logger::init_from_env(
env_logger::Env::default().filter_or(env_logger::DEFAULT_FILTER_ENV, "info"),
);
let stack = edge_nal_std::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();
}