Skip to main content

Module blocklist

Module blocklist 

Source
Expand description

Runtime IP blocklist middleware.

Unlike crate::ip_filter::IpFilter (configured at startup), Blocklist is mutable at runtime — add and remove IPs while the server is running. The global singleton is accessible from MCP tools, admin handlers, and middleware without passing explicit references.

§Example

use rust_web_server::app::App;
use rust_web_server::core::New;
use rust_web_server::blocklist::{self, BlocklistLayer};

let app = App::new().wrap(BlocklistLayer);

// Block an IP at runtime.
blocklist::global().block("1.2.3.4");

// Unblock later.
blocklist::global().unblock("1.2.3.4");

Structs§

Blocklist
A thread-safe list of blocked IPv4 addresses.
BlocklistLayer
Middleware that checks each request’s client IP against global().

Functions§

global
Return the process-wide Blocklist singleton.