|
Aggie Student Toolkit — Load Balancer CSCE 412 Project 4
Arnav Fotedar · Fall 2026 · C++ load balancer simulation
|
Rejects requests whose source address falls in a blocked IPv4 range. More...
#include <Firewall.h>
Public Member Functions | |
| bool | addRange (const std::string &cidr) |
| Adds a blocked range. | |
| bool | isBlocked (const std::string &ip) const |
| Checks whether an address is blocked. | |
| std::vector< std::string > | ranges () const |
Static Public Member Functions | |
| static bool | parseIpv4 (const std::string &text, std::uint32_t &value) |
| Parses a dotted-quad IPv4 address. | |
Rejects requests whose source address falls in a blocked IPv4 range.
Ranges are written in CIDR notation, for example "45.0.0.0/8". The LoadBalancer consults the firewall in admit() before a request reaches the queue, which models blocking a denial-of-service source at the edge. Blocked requests are counted as rejected and never consume server time.
Definition at line 22 of file Firewall.h.
| bool Firewall::addRange | ( | const std::string & | cidr | ) |
Adds a blocked range.
| cidr | Range such as "203.0.113.0/24". A bare address blocks one host (/32). |
Definition at line 44 of file Firewall.cpp.
| bool Firewall::isBlocked | ( | const std::string & | ip | ) | const |
Checks whether an address is blocked.
| ip | Dotted-quad IPv4 address. |
Definition at line 74 of file Firewall.cpp.
| std::vector< std::string > Firewall::ranges | ( | ) | const |
Definition at line 87 of file Firewall.cpp.
|
static |
Parses a dotted-quad IPv4 address.
| text | Address such as "192.168.1.20". |
| value | Receives the address as a 32-bit number on success. |
Definition at line 11 of file Firewall.cpp.