zerodns 0.1.0-alpha.10

A DNS server in Rust, which is inspired from chinadns/dnsmasq.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use once_cell::sync::Lazy;

pub(crate) mod http;
pub(crate) mod tcp;
pub(crate) mod tls;

pub(crate) fn is_valid_domain(domain: &str) -> bool {
    if domain == "." {
        return true;
    }

    static RE: Lazy<regex::Regex> = Lazy::new(|| {
        regex::Regex::new("^([a-zA-Z0-9_-]{1,63})(\\.[a-zA-Z0-9_-]{1,63})*\\.?$").unwrap()
    });

    RE.is_match(domain)
}