Skip to content

Commit

Permalink
rename bruteforce_shield into ddos_shield
Browse files Browse the repository at this point in the history
Signed-off-by: onur-ozkan <[email protected]>
  • Loading branch information
onur-ozkan committed Sep 19, 2024
1 parent 13fe925 commit 1a3bb84
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions mm2src/mm2_core/src/mm_ctx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ mod healthcheck_defaults {
pub struct Healthcheck {
/// Links the RPC context to the P2P context to handle health check responses.
pub response_handler: AsyncMutex<ExpirableMap<String, oneshot::Sender<()>>>,
/// This is used to record healthcheck sender peers in an expirable manner to prevent brute-force attacks.
pub bruteforce_shield: AsyncMutex<ExpirableMap<String, ()>>,
/// This is used to record healthcheck sender peers in an expirable manner to prevent DDoS attacks.
pub ddos_shield: AsyncMutex<ExpirableMap<String, ()>>,
pub config: HealthcheckConfig,
}

Expand Down Expand Up @@ -235,7 +235,7 @@ impl MmCtx {
async_sqlite_connection: Constructible::default(),
healthcheck: Healthcheck {
response_handler: AsyncMutex::new(ExpirableMap::default()),
bruteforce_shield: AsyncMutex::new(ExpirableMap::default()),
ddos_shield: AsyncMutex::new(ExpirableMap::default()),
config: HealthcheckConfig::default(),
},
}
Expand Down
8 changes: 4 additions & 4 deletions mm2src/mm2_main/src/lp_healthcheck.rs
Original file line number Diff line number Diff line change
Expand Up @@ -300,9 +300,9 @@ pub(crate) async fn process_p2p_healthcheck_message(ctx: &MmArc, message: mm2_li

let sender_peer = data.sender_peer().to_owned();

let mut bruteforce_shield = ctx.healthcheck.bruteforce_shield.lock().await;
bruteforce_shield.clear_expired_entries();
if bruteforce_shield
let mut ddos_shield = ctx.healthcheck.ddos_shield.lock().await;
ddos_shield.clear_expired_entries();
if ddos_shield
.insert(
sender_peer.to_string(),
(),
Expand All @@ -313,7 +313,7 @@ pub(crate) async fn process_p2p_healthcheck_message(ctx: &MmArc, message: mm2_li
log::warn!("Peer '{sender_peer}' exceeded the healthcheck blocking time, skipping their message.");
return;
}
drop(bruteforce_shield);
drop(ddos_shield);

let ctx_c = ctx.clone();

Expand Down

0 comments on commit 1a3bb84

Please sign in to comment.