Valkyrian Labs logo

DNS filter

FortiGuard category actions on DNS filter profiles.

DNS filter

#include <forti_api/dnsfilter.hpp> adds category helpers to the generated dnsfilter::Profiles endpoint. A profile lists FortiGuard categories in ftgd-dns.filters with an action (block or monitor); a category that is not listed is allowed.

The helpers change the profile in memory and mark only ftgd-dns as modified; send it with Profiles::update():

1using namespace fortiapi;2 3auto profile = dnsfilter::Profiles::get("home");4dnsfilter::block_category(profile, 26);      // malicious websites5dnsfilter::monitor_category(profile, 61);6dnsfilter::allow_category(profile, 30);      // removes the filter, if listed7dnsfilter::Profiles::update(profile);8 9auto action = dnsfilter::category_action(profile, 26);   // "block", "monitor" or std::nullopt

Allowing a category everywhere

1std::vector<std::string> changed = dnsfilter::allow_category_everywhere(200);

Every profile that lists the category is updated to allow it; profiles that do not list it are never written. The names of the updated profiles are returned.