|
- //////////////////////////////////////////////////////////////////////
- // Dump Black Listed whole domain (*.domain.tld) entries
- // Written by Jonathan A. Foster <jon@jfpossibilities.com>
- // Started December 28th, 2021
- // Copyright JF Possibilities, Inc. All rights reserved.
- //
- // Read the "dns_wild" table and dump all black listed domain names as
- // "address" entries for a dnsmasq.conf file. This will black list the
- // whole domain, subdomains, hosts and all.
- //////////////////////////////////////////////////////////////////////
- #include <string>
- #include <map>
- #include <iostream>
- #include <stdio.h>
- #include <libgen.h>
-
- #include "../strutil.h"
- #include "appbase.h"
- using namespace std;
-
-
-
- //////////////////////////////////////////////////////////////////////
- // Connection Report Generator Application Class
- //////////////////////////////////////////////////////////////////////
-
- struct DomainBlackList: BlackListBaseApp {
-
- int main() {
- cppdb::result qry;
- string s;
- int x;
-
- /// SETUP & VALIDATE CLI ///
-
- if(x=BlackListBaseApp::main()) return x; // Parse CLI args, open conf & db
-
- /// Query & load data ///
-
- qry = db <<
- "SELECT name "
- "FROM dns_wild "
- "WHERE status=2 " // 2 = blocked... need this doc'd somewhere...
- "ORDER BY name";
- while(qry.next()) {
- qry >> s;
- if(ipv4!="") cout << "address=/" << s << '/' << ipv4 << '\n';
- if(ipv6!="") cout << "address=/" << s << '/' << ipv6 << '\n';
- }
- return 0;
- }
-
- };
-
-
-
- //////////////////////////////////////////////////////////////////////
- // Lets run the report and dump it out
- //////////////////////////////////////////////////////////////////////
-
- MAIN(DomainBlackList)
|