mirror of
https://codeberg.org/YGGverse/psocks.git
synced 2026-03-31 16:35:28 +00:00
reorganize request api
This commit is contained in:
parent
31b701e295
commit
239a85ca47
1 changed files with 20 additions and 11 deletions
|
|
@ -31,11 +31,17 @@ pub struct Sum {
|
||||||
percent: f32,
|
percent: f32,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Serialize)]
|
||||||
|
pub struct Request {
|
||||||
|
total: u64,
|
||||||
|
allowed: Sum,
|
||||||
|
blocked: Sum,
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Serialize)]
|
#[derive(Serialize)]
|
||||||
pub struct Snap {
|
pub struct Snap {
|
||||||
rules: u64,
|
rules: u64,
|
||||||
request: Sum,
|
request: Request,
|
||||||
blocked: Sum,
|
|
||||||
up: Up,
|
up: Up,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -48,17 +54,20 @@ impl Snap {
|
||||||
};
|
};
|
||||||
Self {
|
Self {
|
||||||
rules,
|
rules,
|
||||||
request: Sum {
|
request: Request {
|
||||||
total: request,
|
total: request,
|
||||||
percent: if request == 0 {
|
allowed: Sum {
|
||||||
0.0
|
total: request - blocked,
|
||||||
} else {
|
percent: if request == 0 {
|
||||||
100.0 - blocked_percent
|
0.0
|
||||||
|
} else {
|
||||||
|
100.0 - blocked_percent
|
||||||
|
},
|
||||||
|
},
|
||||||
|
blocked: Sum {
|
||||||
|
total: blocked,
|
||||||
|
percent: blocked_percent,
|
||||||
},
|
},
|
||||||
},
|
|
||||||
blocked: Sum {
|
|
||||||
total: blocked,
|
|
||||||
percent: blocked_percent,
|
|
||||||
},
|
},
|
||||||
up: Up::from_startup_seconds(seconds_from_startup),
|
up: Up::from_startup_seconds(seconds_from_startup),
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue