Skip to main content

hickory_server/
lib.rs

1/*
2 * Copyright (C) 2015 Benjamin Fry <benjaminfry@me.com>
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *     https://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#![warn(clippy::dbg_macro, clippy::print_stdout, missing_docs)]
18#![cfg_attr(docsrs, feature(doc_cfg))]
19
20//! Hickory DNS is intended to be a fully compliant domain name server and client library.
21//!
22//! # Goals
23//!
24//! * Only safe Rust
25//! * All errors handled
26//! * Simple to manage servers
27//! * High level abstraction for clients
28//! * Secure dynamic update
29//! * New features for securing public information
30
31#[cfg(feature = "blocklist")]
32pub use crate::store::blocklist;
33pub use hickory_net as net;
34pub use hickory_proto as proto;
35#[cfg(any(feature = "resolver", feature = "recursor"))]
36pub use hickory_resolver as resolver;
37
38mod access;
39#[cfg(feature = "metrics")]
40pub mod metrics;
41pub mod server;
42pub mod store;
43pub mod zone_handler;
44
45pub use self::server::Server;
46
47/// Low-level types for DNSSEC operations
48#[cfg(feature = "__dnssec")]
49pub mod dnssec {
50    use crate::proto::dnssec::Nsec3HashAlgorithm;
51    use serde::Deserialize;
52    use std::sync::Arc;
53
54    /// The kind of non-existence proof provided by the nameserver
55    #[derive(Debug, Deserialize, Clone, PartialEq, Eq)]
56    #[serde(rename_all = "lowercase")]
57    pub enum NxProofKind {
58        /// Use NSEC
59        Nsec,
60        /// Use NSEC3
61        Nsec3 {
62            /// The algorithm used to hash the names.
63            #[serde(default)]
64            algorithm: Nsec3HashAlgorithm,
65            /// The salt used for hashing.
66            #[serde(default = "default_salt")]
67            salt: Arc<[u8]>,
68            /// The number of hashing iterations.
69            #[serde(default)]
70            iterations: u16,
71            /// The Opt-Out flag.
72            #[serde(default)]
73            opt_out: bool,
74        },
75    }
76
77    // MSRV: works in 1.80, fails in 1.78
78    fn default_salt() -> Arc<[u8]> {
79        Arc::new([])
80    }
81}
82
83/// Returns the current version of Hickory DNS
84pub fn version() -> &'static str {
85    env!("CARGO_PKG_VERSION")
86}