mirror of
https://github.com/pldubouilh/blockfast.git
synced 2026-09-01 14:47:42 -04:00
use proper enum return type
This commit is contained in:
+5
-3
@@ -5,6 +5,8 @@ use std::sync::Mutex;
|
||||
|
||||
use anyhow::*;
|
||||
|
||||
use crate::utils::JailStatus;
|
||||
|
||||
pub struct Jail {
|
||||
jailtime: u32,
|
||||
allowance: u8,
|
||||
@@ -91,7 +93,7 @@ impl Jail {
|
||||
})
|
||||
}
|
||||
|
||||
pub fn probe(&self, ip: IpAddr) -> Result<bool> {
|
||||
pub fn probe(&self, ip: IpAddr) -> Result<JailStatus> {
|
||||
let should_ban = {
|
||||
let mut locked_map = self.remand.lock().map_err(|_| anyhow!("cant lock"))?;
|
||||
|
||||
@@ -108,9 +110,9 @@ impl Jail {
|
||||
|
||||
if should_ban {
|
||||
ipset_block(self.jailtime, ip)?;
|
||||
Ok(true)
|
||||
Ok(JailStatus::Jailed(ip))
|
||||
} else {
|
||||
Ok(false)
|
||||
Ok(JailStatus::Remand)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user