diff --git a/Cargo.lock b/Cargo.lock index a57be16..20e3349 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1399,6 +1399,7 @@ name = "rdsys_backend" version = "0.1.0" dependencies = [ "bytes", + "chrono", "crc64", "futures", "futures-util", diff --git a/crates/rdsys-backend-api/Cargo.toml b/crates/rdsys-backend-api/Cargo.toml index 7e8d187..eaf2b3f 100644 --- a/crates/rdsys-backend-api/Cargo.toml +++ b/crates/rdsys-backend-api/Cargo.toml @@ -19,3 +19,4 @@ reqwest = { version = "0.11", features = ["stream"]} tokio-stream = "0.1.12" futures = "0.3.27" tokio-util = "0.7.7" +chrono = { version = "0.4.26", features = ["serde", "clock"] } diff --git a/crates/rdsys-backend-api/src/proto.rs b/crates/rdsys-backend-api/src/proto.rs index 4b21da1..a6c8773 100644 --- a/crates/rdsys-backend-api/src/proto.rs +++ b/crates/rdsys-backend-api/src/proto.rs @@ -1,6 +1,7 @@ use serde::{Deserialize, Serialize}; use sha1::{Digest, Sha1}; use std::collections::HashMap; +use chrono::{DateTime, offset::Utc}; /// The body of the request for resources made to the rdsys backend #[derive(Serialize)] @@ -14,6 +15,7 @@ pub struct ResourceRequest { pub struct Resource { pub r#type: String, pub blocked_in: HashMap, + pub last_passed: DateTime, pub protocol: String, pub address: String, pub port: u16, @@ -60,6 +62,8 @@ pub struct ResourceDiff { #[cfg(test)] mod tests { + use chrono::Utc; + use super::*; #[test] @@ -88,6 +92,7 @@ mod tests { let bridge = Resource { r#type: String::from("scramblesuit"), blocked_in: HashMap::new(), + last_passed: "2023-05-30T14:20:28Z".parse::>().unwrap(), protocol: String::from("tcp"), address: String::from("216.117.3.62"), port: 63174, @@ -102,6 +107,7 @@ mod tests { { "type": "scramblesuit", "blocked_in": {}, + "last_passed": "2023-05-30T14:20:28.000+00:00", "protocol": "tcp", "address": "216.117.3.62", "port": 63174, @@ -129,6 +135,7 @@ mod tests { { "type": "obfs2", "blocked_in": {}, + "last_passed": "2023-05-30T11:42:28.000+07:00", "Location": null, "protocol": "tcp", "address": "176.247.216.207", @@ -146,6 +153,7 @@ mod tests { { "type": "obfs2", "blocked_in": {}, + "last_passed": "2023-05-30T12:20:28.000+07:00", "protocol": "tcp", "address": "133.69.16.145", "port": 58314, @@ -164,6 +172,7 @@ mod tests { { "type": "scramblesuit", "blocked_in": {}, + "last_passed": "2023-05-30T14:20:28.000+07:00", "protocol": "tcp", "address": "216.117.3.62", "port": 63174,