Skip to content
API Documentation
BastionGuard™
FirewallDetector Class Reference

#include <FirewallDetector.hpp>

Static Public Member Functions

static bool isFirewalldPresent ()
static bool isUfwPresent ()
static std::string detectDistro ()
static FirewallType detectFirewall ()

Detailed Description

Definition at line 27 of file FirewallDetector.hpp.

Member Function Documentation

◆ detectDistro()

std::string FirewallDetector::detectDistro ( )
static

Definition at line 34 of file FirewallDetector.cpp.

34 {
35 std::ifstream f("/etc/os-release");
36 if (!f.is_open()) return "unknown";
37
38 std::string line;
39 while (std::getline(f, line)) {
40 if (line.rfind("ID=", 0) == 0)
41 return line.substr(3);
42 }
43 return "unknown";
44}

Referenced by FirewallChoiceDialog::FirewallChoiceDialog().

◆ detectFirewall()

FirewallType FirewallDetector::detectFirewall ( )
static

◆ isFirewalldPresent()

bool FirewallDetector::isFirewalldPresent ( )
static

Definition at line 26 of file FirewallDetector.cpp.

26 {
27 return ((bg_process::exists_on_path("firewall-cmd") ? 0 : 1) == 0);
28}
bool exists_on_path(const std::string &name)

References bg_process::exists_on_path().

Referenced by detectFirewall(), and FirewallChoiceDialog::FirewallChoiceDialog().

◆ isUfwPresent()

bool FirewallDetector::isUfwPresent ( )
static

Definition at line 30 of file FirewallDetector.cpp.

30 {
31 return ((bg_process::exists_on_path("ufw") ? 0 : 1) == 0);
32}

References bg_process::exists_on_path().

Referenced by detectFirewall(), and FirewallChoiceDialog::FirewallChoiceDialog().


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