1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
//! 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
//!
//! ```rust,no_run
//! 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");
//! ```
use ;
use crateApplication;
use crate;
use crateMiddleware;
use crateRequest;
use crateResponse;
use crateConnectionInfo;
/// A thread-safe list of blocked IPv4 addresses.
static INSTANCE: = new;
/// Return the process-wide `Blocklist` singleton.
/// Middleware that checks each request's client IP against [`global()`].
///
/// Blocked IPs receive `403 Forbidden`. All other requests pass through
/// to the next layer.
;