Aggie Student Toolkit — Load Balancer CSCE 412 Project 4
Arnav Fotedar · Fall 2026 · C++ load balancer simulation
Loading...
Searching...
No Matches
Firewall.h
Go to the documentation of this file.
1
6
7#ifndef FIREWALL_H
8#define FIREWALL_H
9
10#include <cstdint>
11#include <string>
12#include <vector>
13
22class Firewall {
23public:
29 bool addRange(const std::string& cidr);
30
36 bool isBlocked(const std::string& ip) const;
37
39 std::vector<std::string> ranges() const;
40
47 static bool parseIpv4(const std::string& text, std::uint32_t& value);
48
49private:
51 struct Range {
52 std::uint32_t network;
53 std::uint32_t mask;
54 std::string text;
55 };
56
57 std::vector<Range> ranges_;
58};
59
60#endif
Rejects requests whose source address falls in a blocked IPv4 range.
Definition Firewall.h:22
bool addRange(const std::string &cidr)
Adds a blocked range.
Definition Firewall.cpp:44
bool isBlocked(const std::string &ip) const
Checks whether an address is blocked.
Definition Firewall.cpp:74
static bool parseIpv4(const std::string &text, std::uint32_t &value)
Parses a dotted-quad IPv4 address.
Definition Firewall.cpp:11
std::vector< std::string > ranges() const
Definition Firewall.cpp:87