5 releases

0.2.4 Sep 30, 2024
0.2.3 Apr 9, 2024
0.2.1 Mar 28, 2024
0.1.0 Apr 26, 2022

#1183 in Network programming

Download history 62/week @ 2024-07-29 24/week @ 2024-08-05 37/week @ 2024-08-12 70/week @ 2024-08-19 20/week @ 2024-08-26 9/week @ 2024-09-02 76/week @ 2024-09-09 33/week @ 2024-09-16 39/week @ 2024-09-23 246/week @ 2024-09-30 87/week @ 2024-10-07 106/week @ 2024-10-14 68/week @ 2024-10-21 100/week @ 2024-10-28 51/week @ 2024-11-04 42/week @ 2024-11-11

269 downloads per month

Apache-2.0

93KB
1.5K SLoC

dns-server

crates.io version license: Apache 2.0 unsafe forbidden pipeline status

A threaded DNS server library.

Use Cases

  • Make your API server its own DNS server. This eliminates the DNS server as a separate point of failure.
  • Keep your DNS config in code, next to your server code. Include it in code reviews and integration tests.
  • DNS-based domain validation for free ACME certificates. This is useful for servers that don't listen on port 80. Servers on port 80 can use HTTP for domain validation and don't need to use this.

Features

  • Depends only on std
  • forbid(unsafe_code)
  • ?% test coverage

Limitations

  • Brand new.

Example

use dns_server::DnsRecord;
use permit::Permit;
use signal_hook::consts::{SIGHUP, SIGINT, SIGQUIT, SIGTERM};
use signal_hook::iterator::Signals;

let top_permit = Permit::new();
let permit = top_permit.new_sub();
std::thread::spawn(move || {
    Signals::new([SIGHUP, SIGINT, SIGQUIT, SIGTERM])
        .unwrap()
        .forever()
        .next();
    drop(top_permit);
});
let records = vec![
    DnsRecord::new_a("aaa.example.com", "10.0.0.1").unwrap(),
    DnsRecord::new_aaaa("aaa.example.com", "2606:2800:220:1:248:1893:25c8:1946").unwrap(),
    DnsRecord::new_cname("bbb.example.com", "ccc.example.com").unwrap(),
];
dns_server::Builder::new_port(8053)
    .unwrap()
    .with_permit(permit)
    .serve_static(&records)
    .unwrap();

Related Crates

Cargo Geiger Safety Report


Metric output format: x/y
    x = unsafe code used by the build
    y = total unsafe code found in the crate

Symbols: 
    🔒  = No `unsafe` usage found, declares #![forbid(unsafe_code)]= No `unsafe` usage found, missing #![forbid(unsafe_code)]
    ☢️  = `unsafe` usage found

Functions  Expressions  Impls  Traits  Methods  Dependency

0/0        0/0          0/0    0/0     0/0      🔒  dns-server 0.2.4
0/0        0/0          0/0    0/0     0/0      🔒  ├── prob-rate-limiter 0.1.1
0/0        0/0          0/0    0/0     0/0      🔒  │   └── oorandom 11.1.3
0/0        0/0          0/0    0/0     0/0      🔒  ├── fixed-buffer 0.3.1
0/0        0/0          0/0    0/0     0/0      🔒  ├── oorandom 11.1.3
0/0        0/0          0/0    0/0     0/0      🔒  └── permit 0.2.1

0/0        0/0          0/0    0/0     0/0    

Changelog

  • v0.2.4 - Depend on permit v0.2
  • v0.2.3 - Remove a dependency
  • v0.2.2 - Support case randomization.
  • v0.2.1
    • New API supporting dynamic responses.
    • Randomize order of static responses.
  • v0.1.0 - Initial version

To Do

  • Message compression
  • Decide whether to send back error responses.
  • Ergonomic constructors that take OsStr, for using environment variables
  • Custom TTLs
  • NS records (and glue)
  • Client
  • Caching client
  • Recursive resolver

Alternatives

License: Apache-2.0

Dependencies

~84KB