| 1 |
// For all support, instructions and copyright go to: |
| 2 |
// http://e2guardian.org/ |
| 3 |
// Released under the GPL v2, with the OpenSSL exception described in the README file. |
| 4 |
|
| 5 |
#ifndef __HPP_LOPTIONCONTAINER |
| 6 |
#define __HPP_LOPTIONCONTAINER |
| 7 |
|
| 8 |
// INCLUDES |
| 9 |
|
| 10 |
#include "ContentScanner.hpp" |
| 11 |
#include "DownloadManager.hpp" |
| 12 |
#include "String.hpp" |
| 13 |
#include "HTMLTemplate.hpp" |
| 14 |
#include "ListContainer.hpp" |
| 15 |
#include "ListManager.hpp" |
| 16 |
#include "FOptionContainer.hpp" |
| 17 |
#include "LanguageContainer.hpp" |
| 18 |
#include "ImageContainer.hpp" |
| 19 |
#include "RegExp.hpp" |
| 20 |
#include "Auth.hpp" |
| 21 |
#include "IPList.hpp" |
| 22 |
#include "Queue.hpp" |
| 23 |
|
| 24 |
#include <deque> |
| 25 |
|
| 26 |
#include "CertificateAuthority.hpp" |
| 27 |
|
| 28 |
|
| 29 |
// DECLARATIONS |
| 30 |
struct room_item { |
| 31 |
std::string name; |
| 32 |
IPList *iplist; |
| 33 |
ListContainer *sitelist; |
| 34 |
ListContainer *urllist; |
| 35 |
bool block; |
| 36 |
bool part_block; |
| 37 |
}; |
| 38 |
|
| 39 |
|
| 40 |
class LOptionContainer |
| 41 |
{ |
| 42 |
public: |
| 43 |
//Queue<std::string>* log_Q; |
| 44 |
//Queue<Socket*>* http_worker_Q; |
| 45 |
|
| 46 |
// all our options |
| 47 |
|
| 48 |
std::string name_suffix; // Unused ??? |
| 49 |
|
| 50 |
HTMLTemplate html_template; |
| 51 |
ListContainer filter_groups_list; |
| 52 |
IPList exception_ip_list; |
| 53 |
IPList banned_ip_list; |
| 54 |
ListMeta LMeta; |
| 55 |
StoryBoard StoryA; |
| 56 |
//ListManager lm; |
| 57 |
FOptionContainer **fg = nullptr; |
| 58 |
bool loaded_ok = true; |
| 59 |
bool is_fatal = false; |
| 60 |
bool sb_loaded_ok = true; |
| 61 |
int reload_id; |
| 62 |
int numfg = 0; |
| 63 |
String start_time; |
| 64 |
|
| 65 |
// access denied domain (when using the CGI) |
| 66 |
String access_denied_domain; |
| 67 |
|
| 68 |
void deleteFilterGroups(); |
| 69 |
void deleteFilterGroupsJustListData(); |
| 70 |
int getFgFromName(String &name); // returns -1 if not found |
| 71 |
|
| 72 |
//...and the functions that read them |
| 73 |
|
| 74 |
LOptionContainer(); |
| 75 |
LOptionContainer(int reload_id); |
| 76 |
~LOptionContainer(); |
| 77 |
bool read(std::string& filename, int type, std::string& exception_ip_list_location, |
| 78 |
std::string& banned_ip_list_location); |
| 79 |
void reset(); |
| 80 |
bool inExceptionIPList(const std::string *ip, std::string *&host); |
| 81 |
//bool inBannedIPList(const std::string *ip, std::string *&host); |
| 82 |
bool readFilterGroupConf(); |
| 83 |
// public so fc_controlit can reload filter group config files |
| 84 |
|
| 85 |
// per-room blocking and URL whitelisting: see if given IP is in a room; if it is, return true and put the room name in "room" |
| 86 |
bool inRoom(const std::string &ip, std::string &room, std::string *host, bool *block, bool *part_block, bool *isexception, String url); |
| 87 |
void loadRooms(bool throw_error); |
| 88 |
void deleteRooms(); |
| 89 |
|
| 90 |
bool inSiteList(String &url, ListContainer *lc, bool swsort, bool ip, String &match); |
| 91 |
//char *inURLList(String &url, ListContainer *lc, bool swsort, bool ip, String &match); |
| 92 |
bool inURLList(String &url, ListContainer *lc, bool swsort, bool ip, String &match); |
| 93 |
|
| 94 |
String ISTag() { // unused ?? |
| 95 |
return start_time; |
| 96 |
} |
| 97 |
|
| 98 |
|
| 99 |
private: |
| 100 |
std::string per_room_directory_location; |
| 101 |
std::deque<std::string> conffile; |
| 102 |
std::string conffilename; |
| 103 |
int reporting_level = 0; |
| 104 |
|
| 105 |
std::string html_template_location; |
| 106 |
std::string group_names_list_location; |
| 107 |
|
| 108 |
|
| 109 |
bool precompileregexps(); |
| 110 |
long int findoptionI(const char *option); |
| 111 |
std::string findoptionS(const char *option); |
| 112 |
//bool realitycheck(long int l, long int minl, long int maxl, const char *emessage); |
| 113 |
bool readAnotherFilterGroupConf(const char *filename, const char *groupname, bool &need_html, int fg_no); |
| 114 |
std::deque<String> findoptionM(const char *option); |
| 115 |
|
| 116 |
//bool inIPList(const std::string *ip, ListContainer &list, std::string *&host); |
| 117 |
std::list<room_item> rooms; |
| 118 |
}; |
| 119 |
|
| 120 |
#endif |