Add lastpassed to rdsys-backend-api
This commit is contained in:
parent
a57778a232
commit
d1710d2f80
|
@ -1399,6 +1399,7 @@ name = "rdsys_backend"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bytes",
|
"bytes",
|
||||||
|
"chrono",
|
||||||
"crc64",
|
"crc64",
|
||||||
"futures",
|
"futures",
|
||||||
"futures-util",
|
"futures-util",
|
||||||
|
|
|
@ -19,3 +19,4 @@ reqwest = { version = "0.11", features = ["stream"]}
|
||||||
tokio-stream = "0.1.12"
|
tokio-stream = "0.1.12"
|
||||||
futures = "0.3.27"
|
futures = "0.3.27"
|
||||||
tokio-util = "0.7.7"
|
tokio-util = "0.7.7"
|
||||||
|
chrono = { version = "0.4.26", features = ["serde", "clock"] }
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use sha1::{Digest, Sha1};
|
use sha1::{Digest, Sha1};
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
use chrono::{DateTime, offset::Utc};
|
||||||
|
|
||||||
/// The body of the request for resources made to the rdsys backend
|
/// The body of the request for resources made to the rdsys backend
|
||||||
#[derive(Serialize)]
|
#[derive(Serialize)]
|
||||||
|
@ -14,6 +15,7 @@ pub struct ResourceRequest {
|
||||||
pub struct Resource {
|
pub struct Resource {
|
||||||
pub r#type: String,
|
pub r#type: String,
|
||||||
pub blocked_in: HashMap<String, bool>,
|
pub blocked_in: HashMap<String, bool>,
|
||||||
|
pub last_passed: DateTime<Utc>,
|
||||||
pub protocol: String,
|
pub protocol: String,
|
||||||
pub address: String,
|
pub address: String,
|
||||||
pub port: u16,
|
pub port: u16,
|
||||||
|
@ -60,6 +62,8 @@ pub struct ResourceDiff {
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
|
use chrono::Utc;
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -88,6 +92,7 @@ mod tests {
|
||||||
let bridge = Resource {
|
let bridge = Resource {
|
||||||
r#type: String::from("scramblesuit"),
|
r#type: String::from("scramblesuit"),
|
||||||
blocked_in: HashMap::new(),
|
blocked_in: HashMap::new(),
|
||||||
|
last_passed: "2023-05-30T14:20:28Z".parse::<DateTime<Utc>>().unwrap(),
|
||||||
protocol: String::from("tcp"),
|
protocol: String::from("tcp"),
|
||||||
address: String::from("216.117.3.62"),
|
address: String::from("216.117.3.62"),
|
||||||
port: 63174,
|
port: 63174,
|
||||||
|
@ -102,6 +107,7 @@ mod tests {
|
||||||
{
|
{
|
||||||
"type": "scramblesuit",
|
"type": "scramblesuit",
|
||||||
"blocked_in": {},
|
"blocked_in": {},
|
||||||
|
"last_passed": "2023-05-30T14:20:28.000+00:00",
|
||||||
"protocol": "tcp",
|
"protocol": "tcp",
|
||||||
"address": "216.117.3.62",
|
"address": "216.117.3.62",
|
||||||
"port": 63174,
|
"port": 63174,
|
||||||
|
@ -129,6 +135,7 @@ mod tests {
|
||||||
{
|
{
|
||||||
"type": "obfs2",
|
"type": "obfs2",
|
||||||
"blocked_in": {},
|
"blocked_in": {},
|
||||||
|
"last_passed": "2023-05-30T11:42:28.000+07:00",
|
||||||
"Location": null,
|
"Location": null,
|
||||||
"protocol": "tcp",
|
"protocol": "tcp",
|
||||||
"address": "176.247.216.207",
|
"address": "176.247.216.207",
|
||||||
|
@ -146,6 +153,7 @@ mod tests {
|
||||||
{
|
{
|
||||||
"type": "obfs2",
|
"type": "obfs2",
|
||||||
"blocked_in": {},
|
"blocked_in": {},
|
||||||
|
"last_passed": "2023-05-30T12:20:28.000+07:00",
|
||||||
"protocol": "tcp",
|
"protocol": "tcp",
|
||||||
"address": "133.69.16.145",
|
"address": "133.69.16.145",
|
||||||
"port": 58314,
|
"port": 58314,
|
||||||
|
@ -164,6 +172,7 @@ mod tests {
|
||||||
{
|
{
|
||||||
"type": "scramblesuit",
|
"type": "scramblesuit",
|
||||||
"blocked_in": {},
|
"blocked_in": {},
|
||||||
|
"last_passed": "2023-05-30T14:20:28.000+07:00",
|
||||||
"protocol": "tcp",
|
"protocol": "tcp",
|
||||||
"address": "216.117.3.62",
|
"address": "216.117.3.62",
|
||||||
"port": 63174,
|
"port": 63174,
|
||||||
|
|
Loading…
Reference in New Issue