diff --git a/src/cli/qcmp.rs b/src/cli/qcmp.rs index 9d732ce83f..ce4f72b746 100644 --- a/src/cli/qcmp.rs +++ b/src/cli/qcmp.rs @@ -70,7 +70,7 @@ impl Ping { } }; - let recv_time = chrono::Utc::now().timestamp_nanos(); + let recv_time = chrono::Utc::now().timestamp_nanos_opt().unwrap(); let reply = Protocol::parse(&buf[..size]).unwrap().unwrap(); if ping.nonce() != reply.nonce() { diff --git a/src/protocol.rs b/src/protocol.rs index b0a52f5fa7..5995b973ce 100644 --- a/src/protocol.rs +++ b/src/protocol.rs @@ -50,7 +50,7 @@ pub async fn spawn(port: u16) -> crate::Result<()> { match socket.recv_from(&mut v4_buf, &mut v6_buf).await { Ok((size, source)) => { - let received_at = chrono::Utc::now().timestamp_nanos(); + let received_at = chrono::Utc::now().timestamp_nanos_opt().unwrap(); let contents = match source { SocketAddr::V4(_) => &v4_buf[..size], SocketAddr::V6(_) => &v6_buf[..size], @@ -133,7 +133,7 @@ impl Protocol { pub fn ping_with_nonce(nonce: u8) -> Self { Self::Ping { nonce, - client_timestamp: chrono::Utc::now().timestamp_nanos(), + client_timestamp: chrono::Utc::now().timestamp_nanos_opt().unwrap(), } } @@ -145,7 +145,7 @@ impl Protocol { nonce, client_timestamp, server_start_timestamp, - server_transmit_timestamp: chrono::Utc::now().timestamp_nanos(), + server_transmit_timestamp: chrono::Utc::now().timestamp_nanos_opt().unwrap(), } } diff --git a/src/proxy.rs b/src/proxy.rs index 76aa626b20..46c89373c1 100644 --- a/src/proxy.rs +++ b/src/proxy.rs @@ -72,7 +72,7 @@ impl DownstreamReceiveWorkerConfig { match socket.recv_from(&mut buf).await { Ok((size, source)) => { let packet = DownstreamPacket { - received_at: chrono::Utc::now().timestamp_nanos(), + received_at: chrono::Utc::now().timestamp_nanos_opt().unwrap(), asn_info: crate::maxmind_db::MaxmindDb::lookup(source.ip()), contents: buf[..size].to_vec(), source, diff --git a/src/proxy/sessions.rs b/src/proxy/sessions.rs index df2049c5c8..abc1fa9320 100644 --- a/src/proxy/sessions.rs +++ b/src/proxy/sessions.rs @@ -180,7 +180,7 @@ impl Session { tracing::error!(%error, %source, dest = ?endpoint, "Error receiving packet"); }, Ok((size, recv_addr)) => { - let received_at = chrono::Utc::now().timestamp_nanos(); + let received_at = chrono::Utc::now().timestamp_nanos_opt().unwrap(); if let Some(last_received_at) = last_received_at { crate::metrics::packet_jitter(crate::metrics::WRITE, asn_info).set(received_at - last_received_at); } diff --git a/tests/qcmp.rs b/tests/qcmp.rs index 81b0c2977b..496f746d96 100644 --- a/tests/qcmp.rs +++ b/tests/qcmp.rs @@ -65,7 +65,7 @@ async fn ping(port: u16) { .await .unwrap() .unwrap(); - let recv_time = chrono::Utc::now().timestamp_nanos(); + let recv_time = chrono::Utc::now().timestamp_nanos_opt().unwrap(); let reply = Protocol::parse(&buf[..size]).unwrap().unwrap(); assert_eq!(ping.nonce(), reply.nonce());