mirror of
https://github.com/hinto-janai/cuprate.git
synced 2025-01-31 06:45:54 +00:00
banned
This commit is contained in:
parent
37bcbb5ea0
commit
c7ae795837
1 changed files with 19 additions and 3 deletions
|
@ -469,10 +469,26 @@ async fn banned(
|
||||||
state: CupratedRpcHandler,
|
state: CupratedRpcHandler,
|
||||||
request: BannedRequest,
|
request: BannedRequest,
|
||||||
) -> Result<BannedResponse, Error> {
|
) -> Result<BannedResponse, Error> {
|
||||||
|
let peer = todo!("create Z::Addr from request.address");
|
||||||
|
let ban = address_book::get_ban::<ClearNet>(&mut DummyAddressBook, peer).await?;
|
||||||
|
|
||||||
|
let (banned, seconds) = if let Some(instant) = ban {
|
||||||
|
let seconds = instant
|
||||||
|
.checked_duration_since(Instant::now())
|
||||||
|
.unwrap_or_default()
|
||||||
|
.as_secs()
|
||||||
|
.try_into()
|
||||||
|
.unwrap_or(0);
|
||||||
|
|
||||||
|
(true, seconds)
|
||||||
|
} else {
|
||||||
|
(false, 0)
|
||||||
|
};
|
||||||
|
|
||||||
Ok(BannedResponse {
|
Ok(BannedResponse {
|
||||||
banned: todo!(),
|
banned,
|
||||||
seconds: todo!(),
|
seconds,
|
||||||
status: todo!(),
|
status: Status::Ok,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue