Remove Chrono dependency

This commit is contained in:
Benjamin Fry 2021-10-24 08:50:40 -07:00
parent 63fdb84333
commit 7b2e1eb235
18 changed files with 70 additions and 95 deletions

57
Cargo.lock generated
View File

@ -285,19 +285,6 @@ version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
[[package]]
name = "chrono"
version = "0.4.19"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "670ad68c9088c2a963aaa298cb369688cf3f9465ce5e2d4ca10e6e0098a1ce73"
dependencies = [
"libc",
"num-integer",
"num-traits",
"time",
"winapi",
]
[[package]]
name = "clap"
version = "2.33.3"
@ -912,25 +899,6 @@ dependencies = [
"winapi",
]
[[package]]
name = "num-integer"
version = "0.1.44"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d2cc698a63b549a70bc047073d2949cce27cd1c7b0a4a862d08a8031bc2801db"
dependencies = [
"autocfg",
"num-traits",
]
[[package]]
name = "num-traits"
version = "0.2.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9a64b1ec5cda2586e284722486d802acf1f7dbdc623e2bfc57e65ca1cd099290"
dependencies = [
"autocfg",
]
[[package]]
name = "num_cpus"
version = "1.13.0"
@ -1240,13 +1208,13 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6e2aebd07fccf5c0d3f1458219965b0861d45f5db9f9b2617277fa7f85179213"
dependencies = [
"bitflags",
"chrono",
"fallible-iterator",
"fallible-streaming-iterator",
"hashlink",
"libsqlite3-sys",
"memchr",
"smallvec",
"time",
]
[[package]]
@ -1481,14 +1449,21 @@ dependencies = [
[[package]]
name = "time"
version = "0.1.43"
version = "0.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ca8a50ef2360fbd1eeb0ecd46795a87a19024eb4b53c5dc916ca1fd95fe62438"
checksum = "cde1cf55178e0293453ba2cca0d5f8392a922e52aa958aee9c28ed02becc6d03"
dependencies = [
"itoa",
"libc",
"winapi",
"time-macros",
]
[[package]]
name = "time-macros"
version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "25eb0ca3468fc0acc11828786797f6ef9aa1555e4a211a60d64cc8e4d1be47d6"
[[package]]
name = "tinyvec"
version = "1.3.1"
@ -1612,7 +1587,6 @@ dependencies = [
name = "trust-dns"
version = "0.21.0-alpha.4"
dependencies = [
"chrono",
"clap",
"env_logger",
"futures",
@ -1620,6 +1594,7 @@ dependencies = [
"native-tls",
"regex",
"rustls",
"time",
"tokio",
"trust-dns-client",
"trust-dns-proto",
@ -1633,7 +1608,6 @@ name = "trust-dns-client"
version = "0.21.0-alpha.4"
dependencies = [
"cfg-if",
"chrono",
"data-encoding",
"futures",
"futures-channel",
@ -1647,6 +1621,7 @@ dependencies = [
"rustls",
"serde",
"thiserror",
"time",
"tokio",
"trust-dns-proto",
"webpki",
@ -1656,12 +1631,12 @@ dependencies = [
name = "trust-dns-compatibility"
version = "0.21.0-alpha.4"
dependencies = [
"chrono",
"data-encoding",
"env_logger",
"futures",
"openssl",
"rand",
"time",
"trust-dns-client",
]
@ -1677,7 +1652,6 @@ name = "trust-dns-integration"
version = "0.21.0-alpha.4"
dependencies = [
"async-trait",
"chrono",
"env_logger",
"futures",
"lazy_static",
@ -1686,6 +1660,7 @@ dependencies = [
"rand",
"rusqlite",
"rustls",
"time",
"tokio",
"trust-dns-client",
"trust-dns-proto",
@ -1790,7 +1765,6 @@ dependencies = [
"async-trait",
"bytes",
"cfg-if",
"chrono",
"enum-as-inner",
"env_logger",
"futures-executor",
@ -1803,6 +1777,7 @@ dependencies = [
"rustls",
"serde",
"thiserror",
"time",
"tokio",
"tokio-openssl",
"tokio-rustls",

View File

@ -71,11 +71,11 @@ name = "named"
path = "src/named.rs"
[dependencies]
chrono = "0.4"
clap = "2.33"
futures = { version = "0.3.5", default-features = false, features = ["std"] }
log = "0.4"
rustls = { version = "0.19", optional = true }
time = "0.3"
tokio = { version = "1.0", features = ["time"] }
trust-dns-client = { version = "0.21.0-alpha.4", path = "../crates/client" }
trust-dns-proto = { version = "0.21.0-alpha.4", path = "../crates/proto" }

View File

@ -68,7 +68,6 @@ path = "src/lib.rs"
[dependencies]
cfg-if = "1"
chrono = "0.4"
data-encoding = "2.2.0"
futures-channel = { version = "0.3.5", default-features = false, features = ["std"] }
futures-util = { version = "0.3.5", default-features = false, features = ["std"] }
@ -81,6 +80,7 @@ ring = { version = "0.16", optional = true, features = ["std"]}
rustls = { version = "0.19", optional = true }
serde = { version = "1.0", features = ["derive"], optional = true }
thiserror = "1.0.20"
time = "0.3"
tokio = { version = "1.0", features = ["rt"] }
trust-dns-proto = { version = "0.21.0-alpha.4", path = "../proto"}
webpki = { version = "0.21", optional = true }

View File

@ -148,7 +148,7 @@
//! use std::net::Ipv4Addr;
//! use std::str::FromStr;
//!
//! use chrono::Duration;
//! use time::Duration;
//! # #[cfg(feature = "openssl")]
//! use openssl::rsa::Rsa;
//! use trust_dns_client::client::{Client, SyncClient};
@ -197,7 +197,7 @@
//! // Now we can send updates... let's create a new Record
//! let mut record = Record::with(Name::from_str("new.example.com").unwrap(),
//! RecordType::A,
//! Duration::minutes(5).num_seconds() as u32);
//! Duration::minutes(5).whole_seconds() as u32);
//! record.set_rdata(RData::A(Ipv4Addr::new(100, 10, 100, 10)));
//!
//! // the server must be authoritative for this zone

View File

@ -7,7 +7,7 @@
//! signer is a structure for performing many of the signing processes of the DNSSec specification
#[cfg(feature = "dnssec")]
use chrono::Duration;
use time::Duration;
use crate::op::{Message, MessageFinalizer, MessageVerifier};
use crate::proto::error::{ProtoErrorKind, ProtoResult};
@ -291,7 +291,7 @@ impl SigSigner {
key,
algorithm,
signer_name,
sig_duration: Duration::zero(),
sig_duration: Duration::ZERO,
is_zone_signing_key: false,
}
}

View File

@ -76,7 +76,6 @@ path = "src/lib.rs"
async-trait = "0.1.42"
bytes = "1"
cfg-if = "1"
chrono = "0.4"
enum-as-inner = "0.3"
env_logger = "0.9"
futures-executor = { version = "0.3.5", default-features = false, features = ["std"] }
@ -85,10 +84,11 @@ h2 = { version = "0.3.0", features = ["stream"], optional = true }
http = { version = "0.2", optional = true }
log = "0.4"
openssl = { version = "0.10", features = ["v102", "v110"], optional = true }
rusqlite = { version = "0.26.0", features = ["bundled", "chrono"], optional = true }
rusqlite = { version = "0.26.0", features = ["bundled", "time"], optional = true }
rustls = { version = "0.19", optional = true }
serde = { version = "1.0.114", features = ["derive"] }
thiserror = "1.0.20"
time = "0.3"
tokio = { version = "1.0", features = ["net"] }
tokio-openssl = { version = "0.6.0", optional = true }
tokio-rustls = { version = "0.22", optional = true }

View File

@ -261,9 +261,9 @@ impl TlsCertConfig {
fn load_key(zone_name: Name, key_config: &KeyConfig) -> Result<SigSigner, String> {
use log::info;
use chrono::Duration;
use std::fs::File;
use std::io::Read;
use time::Duration;
let key_path = key_config.key_path();
let algorithm = key_config

View File

@ -11,10 +11,10 @@ use std::env;
use std::fmt::Display;
use std::io::{self, Write};
use chrono::Utc;
use env_logger;
use env_logger::fmt::Formatter;
use log;
use time::OffsetDateTime;
fn format<L, M, LN, A>(
fmt: &mut Formatter,
@ -29,8 +29,8 @@ where
LN: Display,
A: Display,
{
let now = Utc::now();
let now_secs = now.format("%s%.6f");
let now = OffsetDateTime::now_utc();
let now_secs = now.unix_timestamp();
writeln!(fmt, "{}:{}:{}:{}:{}", now_secs, level, module, line, args)
}

View File

@ -733,9 +733,9 @@ impl InnerInMemory {
) -> DnsSecResult<()> {
use crate::client::rr::dnssec::tbs;
use crate::client::rr::rdata::SIG;
use chrono::Utc;
use time::OffsetDateTime;
let inception = Utc::now();
let inception = OffsetDateTime::now_utc();
rr_set.clear_rrsigs();
@ -758,8 +758,8 @@ impl InnerInMemory {
rr_set.record_type(),
signer.algorithm(),
rr_set.ttl(),
expiration.timestamp() as u32,
inception.timestamp() as u32,
expiration.unix_timestamp() as u32,
inception.unix_timestamp() as u32,
signer.calculate_key_tag()?,
signer.signer_name(),
// TODO: this is a nasty clone... the issue is that the vec
@ -799,9 +799,9 @@ impl InnerInMemory {
// original_ttl: u32,
rr_set.ttl(),
// sig_expiration: u32,
expiration.timestamp() as u32,
expiration.unix_timestamp() as u32,
// sig_inception: u32,
inception.timestamp() as u32,
inception.unix_timestamp() as u32,
// key_tag: u16,
signer.calculate_key_tag()?,
// signer_name: Name,

View File

@ -11,10 +11,10 @@ use std::iter::Iterator;
use std::path::Path;
use std::sync::{Mutex, MutexGuard};
use chrono;
use log::error;
use rusqlite::types::ToSql;
use rusqlite::{self, Connection};
use time;
use crate::error::{PersistenceErrorKind, PersistenceResult};
use crate::proto::rr::Record;
@ -87,7 +87,7 @@ impl Journal {
record.emit(&mut encoder)?;
}
let timestamp = chrono::Utc::now();
let timestamp = time::OffsetDateTime::now_utc();
let client_id: i64 = 0; // TODO: we need better id information about the client, like pub_key
let soa_serial: i64 = i64::from(soa_serial);

View File

@ -46,10 +46,10 @@ name = "trust_dns_compatibility"
path = "src/lib.rs"
[dependencies]
chrono = "0.4"
data-encoding = "2.2.0"
env_logger = "0.9"
futures = "0.3.5"
openssl = { version = "0.10", features = ["v102", "v110"] }
rand = "0.8"
time = "0.3"
trust-dns-client= { version = "0.21.0-alpha.4", path="../../crates/client", features = ["dnssec-openssl"] }

View File

@ -12,9 +12,9 @@ use std::io::Read;
use std::net::{IpAddr, Ipv4Addr, SocketAddr};
use std::str::FromStr;
#[cfg(not(feature = "none"))]
use chrono::Duration;
use openssl::rsa::Rsa;
#[cfg(not(feature = "none"))]
use time::Duration;
#[cfg(not(feature = "none"))]
use trust_dns_client::client::Client;
@ -104,7 +104,7 @@ fn test_create() {
let mut record = Record::with(
Name::from_str("new.example.com.").unwrap(),
RecordType::A,
Duration::minutes(5).num_seconds() as u32,
Duration::minutes(5).whole_seconds() as u32,
);
record.set_rdata(RData::A(Ipv4Addr::new(100, 10, 100, 10)));

View File

@ -13,7 +13,7 @@ use std::io::Read;
use std::net::{IpAddr, Ipv4Addr, SocketAddr};
use std::str::FromStr;
use chrono::Duration;
use time::Duration;
use trust_dns_client::client::Client;
use trust_dns_client::client::{ClientConnection, SyncClient};
@ -64,7 +64,7 @@ fn test_create() {
let mut record = Record::with(
Name::from_str("new.example.net.").unwrap(),
RecordType::A,
Duration::minutes(5).num_seconds() as u32,
Duration::minutes(5).whole_seconds() as u32,
);
record.set_rdata(RData::A(Ipv4Addr::new(100, 10, 100, 10)));

View File

@ -11,7 +11,7 @@ use std::net::{IpAddr, Ipv4Addr, SocketAddr};
use std::str::FromStr;
#[cfg(not(feature = "none"))]
use chrono::Duration;
use time::Duration;
#[cfg(not(feature = "none"))]
use trust_dns_client::client::{Client, SyncClient};
@ -67,7 +67,7 @@ fn test_zone_transfer() {
let mut record = Record::with(
Name::from_str("new.example.net.").unwrap(),
RecordType::A,
Duration::minutes(5).num_seconds() as u32,
Duration::minutes(5).whole_seconds() as u32,
);
record.set_rdata(RData::A(Ipv4Addr::new(100, 10, 100, 10)));

View File

@ -70,7 +70,6 @@ sqlite = ["trust-dns-server/sqlite"]
[dependencies]
async-trait = "0.1.42"
chrono = "0.4"
env_logger = "0.9"
lazy_static = "1.0"
log = "0.4"
@ -79,6 +78,7 @@ openssl = { version = "0.10", features = ["v102", "v110"] }
rand = "0.8"
rusqlite = { version = "0.26.0", features = ["bundled"] }
rustls = "0.19"
time = "0.3"
tokio = { version = "1.0", features = ["time", "rt"] }
trust-dns-client= { version = "0.21.0-alpha.4", path = "../../crates/client" }
trust-dns-proto = { version = "0.21.0-alpha.4", path = "../../crates/proto", features = ["testing"] }

View File

@ -190,8 +190,8 @@ pub fn create_example() -> InMemoryAuthority {
#[cfg(feature = "dnssec")]
#[allow(unused)]
pub fn create_secure_example() -> InMemoryAuthority {
use chrono::Duration;
use openssl::rsa::Rsa;
use time::Duration;
use trust_dns_client::rr::dnssec::*;
use trust_dns_server::authority::{Authority, DnssecAuthority};

View File

@ -4,9 +4,9 @@ use std::{
sync::{Arc, Mutex as StdMutex},
};
#[cfg(feature = "dnssec")]
use chrono::Duration;
use futures::{Future, FutureExt, TryFutureExt};
#[cfg(feature = "dnssec")]
use time::Duration;
use tokio::{
net::{TcpStream as TokioTcpStream, UdpSocket as TokioUdpSocket},
runtime::Runtime,
@ -303,7 +303,7 @@ async fn create_sig0_ready_client() -> (
let mut auth_key = Record::with(
trusted_name,
RecordType::KEY,
Duration::minutes(5).num_seconds() as u32,
Duration::minutes(5).whole_seconds() as u32,
);
auth_key.set_rdata(RData::DNSSEC(DNSSECRData::KEY(sig0_key)));
authority.upsert_mut(auth_key, 0);
@ -332,7 +332,7 @@ fn test_create() {
let mut record = Record::with(
Name::from_str("new.example.com").unwrap(),
RecordType::A,
Duration::minutes(5).num_seconds() as u32,
Duration::minutes(5).whole_seconds() as u32,
);
record.set_rdata(RData::A(Ipv4Addr::new(100, 10, 100, 10)));
let record = record;
@ -376,7 +376,7 @@ fn test_create_multi() {
let mut record = Record::with(
Name::from_str("new.example.com").unwrap(),
RecordType::A,
Duration::minutes(5).num_seconds() as u32,
Duration::minutes(5).whole_seconds() as u32,
);
record.set_rdata(RData::A(Ipv4Addr::new(100, 10, 100, 10)));
let record = record;
@ -430,7 +430,7 @@ fn test_append() {
let mut record = Record::with(
Name::from_str("new.example.com").unwrap(),
RecordType::A,
Duration::minutes(5).num_seconds() as u32,
Duration::minutes(5).whole_seconds() as u32,
);
record.set_rdata(RData::A(Ipv4Addr::new(100, 10, 100, 10)));
let record = record;
@ -498,7 +498,7 @@ fn test_append_multi() {
let mut record = Record::with(
Name::from_str("new.example.com").unwrap(),
RecordType::A,
Duration::minutes(5).num_seconds() as u32,
Duration::minutes(5).whole_seconds() as u32,
);
record.set_rdata(RData::A(Ipv4Addr::new(100, 10, 100, 10)));
@ -572,7 +572,7 @@ fn test_compare_and_swap() {
let mut record = Record::with(
Name::from_str("new.example.com").unwrap(),
RecordType::A,
Duration::minutes(5).num_seconds() as u32,
Duration::minutes(5).whole_seconds() as u32,
);
record.set_rdata(RData::A(Ipv4Addr::new(100, 10, 100, 10)));
let record = record;
@ -630,7 +630,7 @@ fn test_compare_and_swap_multi() {
let mut current = RecordSet::with_ttl(
Name::from_str("new.example.com").unwrap(),
RecordType::A,
Duration::minutes(5).num_seconds() as u32,
Duration::minutes(5).whole_seconds() as u32,
);
let current1 = current
@ -700,7 +700,7 @@ fn test_delete_by_rdata() {
let mut record1 = Record::with(
Name::from_str("new.example.com").unwrap(),
RecordType::A,
Duration::minutes(5).num_seconds() as u32,
Duration::minutes(5).whole_seconds() as u32,
);
record1.set_rdata(RData::A(Ipv4Addr::new(100, 10, 100, 10)));
@ -752,7 +752,7 @@ fn test_delete_by_rdata_multi() {
let mut rrset = RecordSet::with_ttl(
Name::from_str("new.example.com").unwrap(),
RecordType::A,
Duration::minutes(5).num_seconds() as u32,
Duration::minutes(5).whole_seconds() as u32,
);
let record1 = rrset
@ -785,7 +785,7 @@ fn test_delete_by_rdata_multi() {
let mut rrset = RecordSet::with_ttl(
Name::from_str("new.example.com").unwrap(),
RecordType::A,
Duration::minutes(5).num_seconds() as u32,
Duration::minutes(5).whole_seconds() as u32,
);
let record1 = rrset.new_record(record1.rdata()).clone();
@ -829,7 +829,7 @@ fn test_delete_rrset() {
let mut record = Record::with(
Name::from_str("new.example.com").unwrap(),
RecordType::A,
Duration::minutes(5).num_seconds() as u32,
Duration::minutes(5).whole_seconds() as u32,
);
record.set_rdata(RData::A(Ipv4Addr::new(100, 10, 100, 10)));
@ -876,7 +876,7 @@ fn test_delete_all() {
let mut record = Record::with(
Name::from_str("new.example.com").unwrap(),
RecordType::A,
Duration::minutes(5).num_seconds() as u32,
Duration::minutes(5).whole_seconds() as u32,
);
record.set_rdata(RData::A(Ipv4Addr::new(100, 10, 100, 10)));

View File

@ -4,9 +4,9 @@ use std::pin::Pin;
use std::str::FromStr;
use std::sync::{Arc, Mutex as StdMutex};
#[cfg(feature = "dnssec")]
use chrono::Duration;
use futures::Future;
#[cfg(feature = "dnssec")]
use time::Duration;
use trust_dns_client::client::Signer;
#[cfg(feature = "dnssec")]
@ -448,7 +448,7 @@ fn create_sig0_ready_client(mut catalog: Catalog) -> (SyncClient<TestClientConne
Algorithm::RSASHA256,
key,
Name::from_str("trusted.example.com").unwrap(),
Duration::max_value(),
Duration::MAX,
true,
true,
);
@ -457,7 +457,7 @@ fn create_sig0_ready_client(mut catalog: Catalog) -> (SyncClient<TestClientConne
let mut auth_key = Record::with(
Name::from_str("trusted.example.com").unwrap(),
RecordType::KEY,
Duration::minutes(5).num_seconds() as u32,
Duration::minutes(5).whole_seconds() as u32,
);
auth_key.set_rdata(RData::DNSSEC(DNSSECRData::KEY(KEY::new(
Default::default(),
@ -485,7 +485,7 @@ fn test_create() {
let mut record = Record::with(
Name::from_str("new.example.com").unwrap(),
RecordType::A,
Duration::minutes(5).num_seconds() as u32,
Duration::minutes(5).whole_seconds() as u32,
);
record.set_rdata(RData::A(Ipv4Addr::new(100, 10, 100, 10)));
@ -525,7 +525,7 @@ fn test_append() {
let mut record = Record::with(
Name::from_str("new.example.com").unwrap(),
RecordType::A,
Duration::minutes(5).num_seconds() as u32,
Duration::minutes(5).whole_seconds() as u32,
);
record.set_rdata(RData::A(Ipv4Addr::new(100, 10, 100, 10)));
@ -604,7 +604,7 @@ fn test_compare_and_swap() {
let mut record = Record::with(
Name::from_str("new.example.com").unwrap(),
RecordType::A,
Duration::minutes(5).num_seconds() as u32,
Duration::minutes(5).whole_seconds() as u32,
);
record.set_rdata(RData::A(Ipv4Addr::new(100, 10, 100, 10)));
@ -670,7 +670,7 @@ fn test_delete_by_rdata() {
let mut record = Record::with(
Name::from_str("new.example.com").unwrap(),
RecordType::A,
Duration::minutes(5).num_seconds() as u32,
Duration::minutes(5).whole_seconds() as u32,
);
record.set_rdata(RData::A(Ipv4Addr::new(100, 10, 100, 10)));
@ -724,7 +724,7 @@ fn test_delete_rrset() {
let mut record = Record::with(
Name::from_str("new.example.com").unwrap(),
RecordType::A,
Duration::minutes(5).num_seconds() as u32,
Duration::minutes(5).whole_seconds() as u32,
);
record.set_rdata(RData::A(Ipv4Addr::new(100, 10, 100, 10)));
@ -770,7 +770,7 @@ fn test_delete_all() {
let mut record = Record::with(
Name::from_str("new.example.com").unwrap(),
RecordType::A,
Duration::minutes(5).num_seconds() as u32,
Duration::minutes(5).whole_seconds() as u32,
);
record.set_rdata(RData::A(Ipv4Addr::new(100, 10, 100, 10)));