Aggie Student Toolkit — Load Balancer CSCE 412 Project 4
Arnav Fotedar · Fall 2026 · C++ load balancer simulation
Loading...
Searching...
No Matches
Firewall Class Reference

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.

Detailed Description

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.

Member Function Documentation

◆ addRange()

bool Firewall::addRange ( const std::string & cidr)

Adds a blocked range.

Parameters
cidrRange such as "203.0.113.0/24". A bare address blocks one host (/32).
Returns
False if the text is not a valid IPv4 CIDR range.

Definition at line 44 of file Firewall.cpp.

◆ isBlocked()

bool Firewall::isBlocked ( const std::string & ip) const

Checks whether an address is blocked.

Parameters
ipDotted-quad IPv4 address.
Returns
True if the address is malformed or inside any blocked range.

Definition at line 74 of file Firewall.cpp.

◆ ranges()

std::vector< std::string > Firewall::ranges ( ) const
Returns
The blocked ranges as they were added, for reporting.

Definition at line 87 of file Firewall.cpp.

◆ parseIpv4()

bool Firewall::parseIpv4 ( const std::string & text,
std::uint32_t & value )
static

Parses a dotted-quad IPv4 address.

Parameters
textAddress such as "192.168.1.20".
valueReceives the address as a 32-bit number on success.
Returns
True if the text is a valid address.

Definition at line 11 of file Firewall.cpp.


The documentation for this class was generated from the following files: