@@ -42,7 +42,7 @@ thread-safe by contract.
4242- External event-loop integration (` run ` , ` run_wait ` , ` get_fdset ` , ` add_connection ` )
4343- Daemon introspection (bound port, active connections, listen FD)
4444- Turbo mode, TCP_FASTOPEN, suppressed ` Date ` headers, configurable backlog
45- - IP blocking with wildcard ranges ( ` block_ip ` / ` unblock_ip ` ), IPv4 & IPv6
45+ - IP access control with wildcard ranges — deny list ( ` deny_ip ` ) and allow list ( ` allow_ip ` ), IPv4 & IPv6
4646- Architecture contracts you can rely on: threading (DR-008 / §5.1) and error propagation (DR-009 / §5.2)
4747
4848This README is a guided reference: it walks the v2.0 API surface section by
@@ -568,8 +568,10 @@ The rest of this section is a reference of every group of options.
568568* **`.pedantic(bool = true)`** — strict HTTP-RFC parsing.
569569* **`.regex_checking(bool = true)`** — validate path regexes at
570570 registration. Default `true`.
571- * **`.ban_system(bool = true)`** — enable the IP block-list machinery
572- used by `block_ip` / `unblock_ip`. Default `true`.
571+ * **`.ip_access_control(bool = true)`** — enable the IP access-control
572+ machinery used by `deny_ip` / `allow_ip` (and their `remove_*`
573+ counterparts). Default `true`. When `false`, every connection is
574+ admitted and both lists are ignored.
573575* **`.post_process(bool = true)`** — auto-parse `application/x-www-form-urlencoded`
574576 and `multipart/form-data` bodies into the request's argument map.
575577 Default `true`.
@@ -691,11 +693,13 @@ httpserver::webserver ws{cfg};
691693
692694These dovetail with the runtime methods covered under [ Daemon
693695introspection and external event loops] ( #daemon-introspection-and-external-event-loops ) .
694- The ` default_policy ` controls the IP block list semantics:
696+ The ` default_policy ` selects which list is the exception list — i.e. what
697+ happens to an address on neither list:
695698
696699* ** ` .default_policy(http::http_utils::policy_T p) ` ** — ` ACCEPT ` (default)
697- treats ` block_ip ` as a deny list; ` REJECT ` flips the semantics so
698- ` block_ip ` becomes an allow list.
700+ admits every address except those on the deny list (` deny_ip ` ); ` REJECT `
701+ refuses every address except those on the allow list (` allow_ip ` ). Under
702+ either policy an allow entry overrides a matching deny entry.
699703
700704### Runtime operations on ` webserver `
701705
@@ -1089,16 +1093,22 @@ The only requirement for IPv6 is that it is enabled on the underlying
10891093server — set ` use_ipv6(true) ` on ` create_webserver ` (or ` use_dual_stack(true) `
10901094for both stacks on the same socket).
10911095
1092- You can explicitly block or unblock IP addresses (or wildcard ranges)
1093- at runtime using these methods on ` webserver ` :
1094-
1095- * ** ` void block_ip(std::string_view ip) ` ** — add one IP (or a range,
1096- e.g. ` "127.0.0.*" ` ) to the block list. Connections from a matching
1097- address are refused at the policy callback. Intended for use under the
1098- default ` ACCEPT ` policy.
1099- * ** ` void unblock_ip(std::string_view ip) ` ** — remove one IP (or a
1100- range) from the block list. Idempotent: removing an entry that is not
1101- currently blocked is a no-op.
1096+ You can populate the deny list and the allow list (with individual IPs or
1097+ wildcard ranges) at runtime using these methods on ` webserver ` :
1098+
1099+ * ** ` void deny_ip(std::string_view ip) ` ** — add one IP (or a range,
1100+ e.g. ` "127.0.0.*" ` ) to the deny list. Connections from a matching
1101+ address are refused at the policy callback. This is the exception list
1102+ under the default ` ACCEPT ` policy.
1103+ * ** ` void remove_denied_ip(std::string_view ip) ` ** — remove one IP (or a
1104+ range) from the deny list. Idempotent: removing an entry that is not
1105+ currently denied is a no-op.
1106+ * ** ` void allow_ip(std::string_view ip) ` ** — add one IP (or a range) to
1107+ the allow list. This is the exception list under the ` REJECT ` policy
1108+ (permit only these). Under ` ACCEPT ` , an allow entry overrides a
1109+ matching ` deny_ip ` entry.
1110+ * ** ` void remove_allowed_ip(std::string_view ip) ` ** — remove one IP (or a
1111+ range) from the allow list. Idempotent.
11021112
11031113### IP string format
11041114
@@ -1120,19 +1130,19 @@ Examples of valid IPs include:
11201130
11211131### Allow-list mode
11221132
1123- By default, ` block_ip ` defines a deny list under the ` ACCEPT ` policy.
1124- To flip the semantics so ` block_ip ` defines an * allow* list under a
1125- default-deny policy, set the policy on the builder:
1133+ By default (` ACCEPT ` policy) the deny list is the exception list: use
1134+ ` deny_ip ` to refuse specific addresses and admit everyone else. To invert
1135+ this into an allow list — refuse everyone except specific addresses — set
1136+ the default policy to ` REJECT ` and populate the allow list with ` allow_ip ` :
11261137
11271138``` cpp
11281139webserver ws{create_webserver (8080)
11291140 .default_policy(http::http_utils::REJECT)};
1130- ws.block_ip ("192.168.0.* "); // permits 192.168.0.0/24, blocks everything else
1141+ ws.allow_ip ("192.168.0.* "); // permits 192.168.0.0/24, refuses everything else
11311142```
11321143
1133- See [`examples/minimal_ip_ban.cpp`](examples/minimal_ip_ban.cpp) for a
1134- worked example of `block_ip` and `unblock_ip` under the default
1135- `ACCEPT` policy.
1144+ See [`examples/minimal_ip_access_control.cpp`](examples/minimal_ip_access_control.cpp)
1145+ for a worked example of both modes.
11361146
11371147[Back to TOC](#table-of-contents)
11381148
@@ -1605,8 +1615,8 @@ worked example.
16051615
16061616### Examples
16071617
1608- * [ ` examples/banned_ip_log .cpp ` ] ( examples/banned_ip_log .cpp ) — log every
1609- banned -IP rejection via a single ` accept_decision ` hook.
1618+ * [ ` examples/denied_ip_log .cpp ` ] ( examples/denied_ip_log .cpp ) — log every
1619+ denied -IP rejection via a single ` accept_decision ` hook.
16101620* [ ` examples/early_413.cpp ` ] ( examples/early_413.cpp ) — return 413 from
16111621 a ` request_received ` hook before the body is consumed.
16121622* [ ` examples/clf_access_log.cpp ` ] ( examples/clf_access_log.cpp ) — write
@@ -1780,10 +1790,11 @@ try {
17801790}
17811791```
17821792
1783- Block lists, IP-allow handling, and similar features that do not depend
1784- on external libraries are always available: ` webserver::block_ip(addr) `
1785- and ` webserver::unblock_ip(addr) ` install and clear per-server blocks at
1786- runtime regardless of build flags.
1793+ Deny lists, IP-allow handling, and similar features that do not depend
1794+ on external libraries are always available: ` webserver::deny_ip(addr) ` /
1795+ ` webserver::remove_denied_ip(addr) ` and ` webserver::allow_ip(addr) ` /
1796+ ` webserver::remove_allowed_ip(addr) ` install and clear per-server access
1797+ rules at runtime regardless of build flags.
17871798
17881799[ Back to TOC] ( #table-of-contents )
17891800
@@ -1864,8 +1875,8 @@ to the canonical example for each topic covered in this manual.
18641875
18651876### Lifecycle hooks
18661877
1867- * [ ` examples/banned_ip_log .cpp ` ] ( examples/banned_ip_log .cpp ) — log every
1868- banned -IP rejection from a single ` accept_decision ` hook (issue #332 ).
1878+ * [ ` examples/denied_ip_log .cpp ` ] ( examples/denied_ip_log .cpp ) — log every
1879+ denied -IP rejection from a single ` accept_decision ` hook (issue #332 ).
18691880* [ ` examples/early_413.cpp ` ] ( examples/early_413.cpp ) — short-circuit
18701881 oversized uploads with 413 before any body bytes are consumed via a
18711882 ` request_received ` hook (issue #273 ).
@@ -1885,8 +1896,8 @@ to the canonical example for each topic covered in this manual.
18851896 drive ` EXTERNAL_SELECT ` from the application's loop via ` run_wait ` .
18861897* [ ` examples/custom_access_log.cpp ` ] ( examples/custom_access_log.cpp ) —
18871898 server-wide access-log callback.
1888- * [ ` examples/minimal_ip_ban .cpp ` ] ( examples/minimal_ip_ban .cpp ) —
1889- ` block_ip ` / ` unblock_ip ` under the default ` ACCEPT ` policy .
1899+ * [ ` examples/minimal_ip_access_control .cpp ` ] ( examples/minimal_ip_access_control .cpp ) —
1900+ ` deny_ip ` / ` allow_ip ` under the ` ACCEPT ` and ` REJECT ` policies .
18901901* [ ` examples/turbo_mode.cpp ` ] ( examples/turbo_mode.cpp ) — turbo,
18911902 suppressed Date header, fastopen queue, listen backlog.
18921903* [ ` examples/service.cpp ` ] ( examples/service.cpp ) — kitchen-sink
0 commit comments