upgrade toml

This commit is contained in:
Benjamin Fry 2018-04-08 23:11:52 -07:00
parent 635cf44da3
commit 19a3963569
10 changed files with 104 additions and 63 deletions

74
Cargo.lock generated
View File

@ -594,6 +594,14 @@ name = "proc-macro-hack-impl"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "proc-macro2"
version = "0.3.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "quick-error"
version = "1.2.1"
@ -604,6 +612,14 @@ name = "quote"
version = "0.3.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "quote"
version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"proc-macro2 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "radix_trie"
version = "0.1.3"
@ -802,6 +818,31 @@ dependencies = [
"libc 0.2.40 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "serde"
version = "1.0.37"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "serde_derive"
version = "1.0.37"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"proc-macro2 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
"quote 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_derive_internals 0.23.0 (registry+https://github.com/rust-lang/crates.io-index)",
"syn 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "serde_derive_internals"
version = "0.23.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"proc-macro2 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
"syn 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "slab"
version = "0.4.0"
@ -837,6 +878,16 @@ dependencies = [
"unicode-xid 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "syn"
version = "0.13.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"proc-macro2 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
"quote 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
"unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "synom"
version = "0.11.3"
@ -1046,10 +1097,10 @@ dependencies = [
[[package]]
name = "toml"
version = "0.1.30"
version = "0.4.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@ -1220,11 +1271,12 @@ dependencies = [
"native-tls 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
"rand 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
"rusqlite 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_derive 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)",
"time 0.1.39 (registry+https://github.com/rust-lang/crates.io-index)",
"tokio-core 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)",
"tokio-tls 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
"toml 0.1.30 (registry+https://github.com/rust-lang/crates.io-index)",
"toml 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
"trust-dns 0.13.0",
"trust-dns-native-tls 0.2.0",
"trust-dns-openssl 0.2.0",
@ -1271,6 +1323,11 @@ name = "unicode-xid"
version = "0.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "unicode-xid"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "unreachable"
version = "1.0.0"
@ -1464,8 +1521,10 @@ dependencies = [
"checksum pkg-config 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "3a8b4c6b8165cd1a1cd4b9b120978131389f64bdaf456435caa41e630edba903"
"checksum proc-macro-hack 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3ba8d4f9257b85eb6cdf13f055cea3190520aab1409ca2ab43493ea4820c25f0"
"checksum proc-macro-hack-impl 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d5cb6f960ad471404618e9817c0e5d10b1ae74cfdf01fab89ea0641fe7fb2892"
"checksum proc-macro2 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "49b6a521dc81b643e9a51e0d1cf05df46d5a2f3c0280ea72bcb68276ba64a118"
"checksum quick-error 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "eda5fe9b71976e62bc81b781206aaa076401769b2143379d3eb2118388babac4"
"checksum quote 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6e920b65c65f10b2ae65c831a81a073a89edd28c7cce89475bff467ab4167a"
"checksum quote 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7b0ff51282f28dc1b53fd154298feaa2e77c5ea0dba68e1fd8b03b72fbe13d2a"
"checksum radix_trie 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "03d0d770481e8af620ca61d3d304bf014f965d7f78e923dc58545e6a545070a9"
"checksum rand 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)" = "15a732abf9d20f0ad8eeb6f909bf6868722d9a06e1e50802b6a70351f40b4eb1"
"checksum rand 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "eba5f8cb59cc50ed56be8880a5c7b496bfd9bd26394e176bc67884094145c2c5"
@ -1489,11 +1548,15 @@ dependencies = [
"checksum sct 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1137b767bbe1c4d30656993bdd97422ed41255d9400b105d735f8c7d9e800632"
"checksum security-framework 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)" = "dfa44ee9c54ce5eecc9de7d5acbad112ee58755239381f687e564004ba4a2332"
"checksum security-framework-sys 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)" = "5421621e836278a0b139268f36eee0dc7e389b784dc3f79d8f11aabadf41bead"
"checksum serde 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)" = "d3bcee660dcde8f52c3765dd9ca5ee36b4bf35470a738eb0bd5a8752b0389645"
"checksum serde_derive 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)" = "f1711ab8b208541fa8de00425f6a577d90f27bb60724d2bb5fd911314af9668f"
"checksum serde_derive_internals 0.23.0 (registry+https://github.com/rust-lang/crates.io-index)" = "89b340a48245bc03ddba31d0ff1709c118df90edc6adabaca4aac77aea181cce"
"checksum slab 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fdeff4cd9ecff59ec7e3744cbca73dfe5ac35c2aedb2cfba8a1c715a18912e9d"
"checksum smallvec 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "44db0ecb22921ef790d17ae13a3f6d15784183ff5f2a01aa32098c7498d2b4b9"
"checksum socket2 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "71ebbe82fcdd697244ba7fe6e05e63b5c45910c3927e28469a04947494ff48d8"
"checksum strsim 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bb4f380125926a99e52bc279241539c018323fab05ad6368b56f93d9369ff550"
"checksum syn 0.11.11 (registry+https://github.com/rust-lang/crates.io-index)" = "d3b891b9015c88c576343b9b3e41c2c11a51c219ef067b264bd9c8aa9b441dad"
"checksum syn 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)" = "91b52877572087400e83d24b9178488541e3d535259e04ff17a63df1e5ceff59"
"checksum synom 0.11.3 (registry+https://github.com/rust-lang/crates.io-index)" = "a393066ed9010ebaed60b9eafa373d4b1baac186dd7e008555b0f702b51945b6"
"checksum tempdir 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)" = "15f2b5fb00ccdf689e0149d1b1b3c03fead81c2b37735d812fa8bddbbf41b6d8"
"checksum termcolor 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "adc4587ead41bf016f11af03e55a624c06568b5a19db4e90fde573d805074f83"
@ -1513,13 +1576,14 @@ dependencies = [
"checksum tokio-timer 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "29a89e4ad0c8f1e4c9860e605c38c69bfdad3cccd4ea446e58ff588c1c07a397"
"checksum tokio-tls 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "772f4b04e560117fe3b0a53e490c16ddc8ba6ec437015d91fa385564996ed913"
"checksum tokio-udp 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "137bda266504893ac4774e0ec4c2108f7ccdbcb7ac8dced6305fe9e4e0b5041a"
"checksum toml 0.1.30 (registry+https://github.com/rust-lang/crates.io-index)" = "0590d72182e50e879c4da3b11c6488dae18fccb1ae0c7a3eda18e16795844796"
"checksum toml 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "a0263c6c02c4db6c8f7681f9fd35e90de799ebd4cfdeab77a38f4ff6b3d8c0d9"
"checksum trust-dns 0.11.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3ea4c98414b0e828b5917c93a3e1fc41605d2ff430033ef6cb3b4905688cbeae"
"checksum ucd-util 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "fd2be2d6639d0f8fe6cdda291ad456e23629558d466e2789d2c3e9892bda285d"
"checksum unicode-bidi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "49f2bd0c6468a8230e1db229cff8029217cf623c767ea5d60bfbd42729ea54d5"
"checksum unicode-normalization 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "51ccda9ef9efa3f7ef5d91e8f9b83bbe6955f9bf86aec89d5cce2c874625920f"
"checksum unicode-width 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "bf3a113775714a22dcb774d8ea3655c53a32debae63a063acc00a91cc586245f"
"checksum unicode-xid 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "8c1f860d7d29cf02cb2f3f359fd35991af3d30bac52c57d265a3c461074cb4dc"
"checksum unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc"
"checksum unreachable 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "382810877fe448991dfc7f0dd6e3ae5d58088fd0ea5e35189655f84e6814fa56"
"checksum untrusted 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f392d7819dbe58833e26872f5f6f0d68b7bbbe90fc3667e98731c4a15ad9a7ae"
"checksum url 1.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f808aadd8cfec6ef90e4a14eb46f24511824d1ac596b9682703c87056c8678b7"

View File

@ -4,4 +4,3 @@
// http://apache.org/licenses/LICENSE-2.0> or the MIT license <LICENSE-MIT or
// http://opensource.org/licenses/MIT>, at your option. This file may not be
// copied, modified, or distributed except according to those terms.

View File

@ -71,11 +71,12 @@ futures = "^0.1.17"
lazy_static = "^1.0"
log = "^0.4.1"
rand = "^0.4"
rustc-serialize = "^0.3.18"
rusqlite = { version = "^0.13.0", features = ["bundled"] }
serde = "^1.0"
serde_derive = "^1.0"
time = "^0.1"
tokio-core = "^0.1"
toml = "^0.1"
toml = "^0.4"
trust-dns = { version = "^0.13", path = "../client" }
trust-dns-proto = { version = "^0.3", path = "../proto" }
trust-dns-openssl = { version = "^0.2.0", path = "../openssl", optional = true }

View File

@ -22,7 +22,7 @@ use trust_dns::op::ResponseCode;
pub type UpdateResult<T> = Result<T, ResponseCode>;
/// The type of zone stored in a Catalog
#[derive(RustcDecodable, PartialEq, Eq, Debug, Clone, Copy)]
#[derive(Deserialize, PartialEq, Eq, Debug, Clone, Copy)]
pub enum ZoneType {
/// This authority for a zone, i.e. the Primary
Master,

View File

@ -24,8 +24,7 @@ use std::str::FromStr;
use std::time::Duration;
use log;
use rustc_serialize::Decodable;
use toml::{Decoder, Value};
use toml;
#[cfg(feature = "dnssec")]
use trust_dns::error::*;
@ -35,7 +34,7 @@ use trust_dns::rr::dnssec::{Algorithm, KeyFormat};
use trust_dns_proto::error::ProtoResult;
use authority::ZoneType;
use error::{ConfigError, ConfigErrorKind, ConfigResult};
use error::{ConfigError, ConfigResult};
static DEFAULT_PATH: &'static str = "/var/named"; // TODO what about windows (do I care? ;)
static DEFAULT_PORT: u16 = 53;
@ -43,11 +42,13 @@ static DEFAULT_TLS_PORT: u16 = 853;
static DEFAULT_TCP_REQUEST_TIMEOUT: u64 = 5;
/// Server configuration
#[derive(RustcDecodable, Debug)]
#[derive(Deserialize, Debug)]
pub struct Config {
/// The list of IPv4 addresses to listen on
#[serde(default)]
listen_addrs_ipv4: Vec<String>,
/// This list of IPv6 addresses to listen on
#[serde(default)]
listen_addrs_ipv6: Vec<String>,
/// Port on which to listen (associated to all IPs)
listen_port: Option<u16>,
@ -60,6 +61,7 @@ pub struct Config {
/// Base configuration directory, i.e. root path for zones
directory: Option<String>,
/// List of configurations for zones
#[serde(default)]
zones: Vec<ZoneConfig>,
/// Certificate to associate to TLS connections
tls_cert: Option<TlsCertConfig>,
@ -140,20 +142,19 @@ impl FromStr for Config {
type Err = ConfigError;
fn from_str(toml: &str) -> ConfigResult<Config> {
let value: Value = toml.parse().map_err(ConfigErrorKind::VecParserError)?;
let mut decoder: Decoder = Decoder::new(value);
Ok(Self::decode(&mut decoder)?)
toml::de::from_str(toml).map_err(Into::into)
}
}
/// Configuration for a zone
#[derive(RustcDecodable, PartialEq, Debug)]
#[derive(Deserialize, PartialEq, Debug)]
pub struct ZoneConfig {
zone: String, // TODO: make Domain::Name decodable
zone_type: ZoneType,
file: String,
allow_update: Option<bool>,
enable_dnssec: Option<bool>,
#[serde(default)]
keys: Vec<KeyConfig>,
}
@ -223,7 +224,7 @@ impl ZoneConfig {
/// Key pair configuration for DNSSec keys for signing a zone
#[cfg(feature = "dnssec")]
#[derive(RustcDecodable, PartialEq, Debug)]
#[derive(Deserialize, PartialEq, Debug)]
pub struct KeyConfig {
key_path: String,
password: Option<String>,
@ -282,13 +283,11 @@ impl KeyConfig {
Some("key") => Ok(KeyFormat::Pem), // TODO: deprecate this...
Some("pem") => Ok(KeyFormat::Pem),
Some("pk8") => Ok(KeyFormat::Pkcs8),
e => Err(
ParseErrorKind::Msg(format!(
"extension not understood, '{:?}': {:?}",
e,
self.key_path()
)).into(),
),
e => Err(ParseErrorKind::Msg(format!(
"extension not understood, '{:?}': {:?}",
e,
self.key_path()
)).into()),
}
}
@ -339,11 +338,11 @@ impl KeyConfig {
#[cfg(not(feature = "dnssec"))]
#[allow(missing_docs)]
#[derive(RustcDecodable, PartialEq, Debug)]
#[derive(Deserialize, PartialEq, Debug)]
pub struct KeyConfig {}
/// Configuration for a TLS certificate
#[derive(RustcDecodable, PartialEq, Debug)]
#[derive(Deserialize, PartialEq, Debug)]
pub struct TlsCertConfig {
path: String,
password: Option<String>,

View File

@ -1,22 +1,10 @@
/*
* Copyright (C) 2015 Benjamin Fry <benjaminfry@me.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
use std::io;
// Copyright 2015-2018 Benjamin Fry <benjaminfry@me.com>
//
// Licensed under the Apache License, Version 2.0, <LICENSE-APACHE or
// http://apache.org/licenses/LICENSE-2.0> or the MIT license <LICENSE-MIT or
// http://opensource.org/licenses/MIT>, at your option. This file may not be
// copied, modified, or distributed except according to those terms.
use toml::ParserError;
use toml::DecodeError;
use trust_dns_proto::error::*;
error_chain! {
@ -44,18 +32,12 @@ error_chain! {
//
// This section can be empty.
foreign_links {
io::Error, Io, "io error";
ParserError, Parser, "parser error";
DecodeError, Decode, "decode error";
::std::io::Error, Io, "io error";
::toml::de::Error, TomlDecode, "decode error";
}
// Define additional `ErrorKind` variants. The syntax here is
// the same as `quick_error!`, but the `from()` and `cause()`
// syntax is not supported.
errors {
VecParserError(vec: Vec<ParserError>) {
description("parser errors")
display("parser errors: {:?}", vec)
}
}
errors {}
}

View File

@ -36,7 +36,9 @@ extern crate futures;
#[macro_use]
extern crate log;
extern crate rusqlite;
extern crate rustc_serialize;
extern crate serde;
#[macro_use]
extern crate serde_derive;
extern crate time;
extern crate tokio_core;
extern crate toml;

View File

@ -36,7 +36,6 @@ extern crate chrono;
extern crate clap;
#[macro_use]
extern crate log;
extern crate rustc_serialize;
extern crate trust_dns;
extern crate trust_dns_server;
@ -51,25 +50,20 @@ use std::io::Read;
#[cfg(feature = "dnssec")]
use chrono::Duration;
use clap::{Arg, ArgMatches};
use trust_dns::error::ParseResult;
use trust_dns::serialize::txt::{Lexer, Parser};
use trust_dns::rr::Name;
#[cfg(feature = "dnssec")]
use trust_dns::rr::dnssec::{KeyPair, Signer};
use trust_dns_server::authority::{Authority, Catalog, Journal, ZoneType};
use trust_dns_server::config::{Config, TlsCertConfig, ZoneConfig};
use trust_dns_server::logger;
#[cfg(feature = "dnssec")]
use trust_dns_server::config::KeyConfig;
use trust_dns_server::server::ServerFuture;
#[cfg(feature = "tls")]
use trust_dns_openssl::tls_server::*;

View File

@ -14,7 +14,7 @@ file = "default/127.0.0.1.zone"
[[zones]]
zone = "0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.arpa"
zsone_type = "Master"
zone_type = "Master"
file = "default/ipv6_1.zone"
[[zones]]

View File

@ -14,7 +14,7 @@ file = "default/127.0.0.1.zone"
[[zones]]
zone = "0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.arpa"
zsone_type = "Master"
zone_type = "Master"
file = "default/ipv6_1.zone"
[[zones]]