1 /*
2  * ufdb_globals.h - URLfilterDB
3  *
4  * ufdbGuard is copyrighted (C) 2005-2020 by URLfilterDB with all rights reserved.
5  *
6  * RCS $Id: ufdb_globals.h,v 1.12 2020/08/20 14:52:10 root Exp root $
7  */
8 
9 #ifndef UFDB_UFDB_GLOBALS_H_INCLUDED
10 #define UFDB_UFDB_GLOBALS_H_INCLUDED
11 
12 #include "ufdb.h"
13 
14 #include <stdio.h>
15 #include <sys/types.h>
16 #include <unistd.h>
17 
18 
19 #ifdef __cplusplus
20 "C" {
21 #endif
22 
23 
24 struct ufdbGV
25 {
26    volatile int    status;
27    volatile int    databaseStatus;
28    volatile int    terminating;
29    volatile int    reconfig;
30 	    int    nWorkers;
31 	    int    debug;
32 	    int    debugCoreDump;
33 	    int    crashOnFatal;
34 	    int    logAllRequests;
35 	    int    logPass;
36 	    int    logBlock;
37             int    fastRefresh;
38 	    int    safeSearch;
39 	    int    skipSafeCategory;
40 	    int    peek;
41 	    int    stripDomainFromUsername;
42 	    int    debugRedirect;
43 	    int    uploadStats;
44 	    int    YoutubeEdufilter;
45 	    int    allowGoogleHTTPSusingIP;
46 	    int    fatalError;
47             int    memoryAllocationErrors;
48 
49 	    time_t databaseLoadTime;
50 	    char   dateOfCheckedDB[32];
51 	    char   licenseStatus[512];
52 	    char   redirectHttps[1024];
53 	    char   redirectBumpedHttps[1024];
54             char   peekServerName[128];
55 
56       const char * configFile;
57 	    int    debugSkype;
58 	    int    debugGtalk;
59 	    int    debugYahooMsg;
60 	    int    debugAim;
61 	    int    debugFBchat;
62 	    int    debugCitrixOnline;
63 	    int    AnydeskOverHttps;
64 	    int    TeamviewerOverHttps;
65 	    int    debugHttpd;
66 	    int    debugRegexp;
67 	    int    silentLogMessage;
68 	    int    expressionOptimisation;
69 	    int    refreshUserlistInterval;
70 	    int    refreshIPlistInterval;
71             time_t lastIPcounterResetDate;
72 	    int    refreshDomainlistInterval;
73 	    int    debugExternalScripts;
74 	    char   userName[31+1];
75 	    char * pidFilename;
76 	    char * logDir;
77 	    char * emailServer;
78 	    char * myHostname;
79 	    char * adminEmail;
80 	    char * senderEmail;
81 	    char * externalStatusCommand;
82 	    char * YoutubeEdufilterID;
83 	    int    URLlookupDelayDBreload;
84 	    int    URLlookupResultDBreload;
85 	    int    URLlookupResultFatalError;
86 	    int    analyseUncategorisedURLs;
87 	    int    logUncategorisedURLs;
88 	    int    portNum;
89 	    int    showURLdetails;
90 	    int    logURLdetails;
91 	    int    uploadCrashReports;
92             int    madviseHugePages;
93 	    int    lookupReverseIP;
94 	    int    useAlsoIPv6onWan;
95 	    int    tunnelCheckMethod;
96 	    char * SquidVersion;
97 	    int    SquidHelperProtocol;
98 	    int    SquidUsesActiveBumping;
99 	    int    parseURLparameters;
100 	    int    httpsWithHostname;
101 	    int    httpsOfficialCertificate;
102 	    int    httpsEnforceContentPeek;
103 	    int    SkypeOverHttps;
104 	    int    GtalkOverHttps;
105 	    int    YahooMsgOverHttps;
106 	    int    AimOverHttps;
107 	    int    FBchatOverHttps;
108 	    int    CitrixOnlineOverHttps;
109 	    int    unknownProtocolOverHttps;
110 	    int    httpsNoSSLv2;
111 	    int    httpsNoSSLv3;
112 	    int    httpdPort;
113             char   databaseDirectory[256];
114             char   administrator[256];
115 	    char   httpdInterface[256];
116 	    char   httpdImagesDirectory[256];
117 	    char   interface[256];
118 	    char   CAcertsFile[1024];
119 	    char   CAcertsDir[1024];
120 	    char   fatalErrorRedirect[1024];
121 	    char   loadingDatabaseRedirect[1024];
122 
123 	    struct UFDBmemTable checkedDB;
124 	    struct ufdbRegExp * checkedExpressions;
125 
126 	    unsigned long maxLogfileSize;
127    volatile unsigned long tunnelCounter;
128    volatile long          serialno;
129 
130 	    struct ufdbSetting * lastSetting;           // no longer used
131 	    struct ufdbSetting * setting;               // no longer used
132 
133 	    struct Source * lastSource;
134 	    struct Source * saveSource;                 // no longer used
135             struct Source * sourceList;
136 
137 	    struct Category * lastCat;
138 	    struct Category * catList;
139 
140 	    struct sgRewrite *   lastRewrite;
141 	    struct sgRewrite *   rewrite;
142 	    struct ufdbRegExp *  lastRewriteRegExec;
143 
144 	    struct ufdbTime * lastTime;
145 	    struct ufdbTime * timeList;
146 
147 	    // FILE * errorLog;
148 	    // struct LogFile * logFile;
149 	    // struct LogFileStat * lastLogFileStat;
150 	    // struct LogFileStat * logFileStat;
151 
152 	    struct TimeElement * lastTimeElement;
153 	    struct TimeElement * timeElement;
154 
155 	    struct Acl * lastAcl;
156 	    struct Acl * defaultAcl;
157 	    struct AclCategory * lastAclCategory;
158 	    struct Acl * aclList;
159 
160 	    struct ufdbRegExp * lastRegExpDest;
161 
162 	    char    progname[80];
163 	    char ** Argv;
164 	    char ** Envp;
165 	    int     debugTimeDelta;                     // no longer used
166 	    pid_t   pid;
167 	    int     failsafe_mode;                      // no longer used
168 	    int     sig_hup;
169 	    int     sig_other;
170 	    int     httpsConnectionCacheSize;
171             int     configLogged;
172 };
173 
174 #if !UFDB_GEN_API
175 UFDB_SHARED extern struct ufdbGV ufdbNewGV;
176 UFDB_SHARED extern struct ufdbGV ufdbOldGV;
177 #endif
178 UFDB_SHARED extern struct ufdbGV ufdbGV;    // almost all global variables are in the struct 'ufdbGV'
179 
180 UFDB_SHARED extern FILE * ufdbGlobalLogfile;
181 
182 void UFDBinitializeGV( struct ufdbGV * gv );
183 void UFDBresetGV( struct ufdbGV * gv );
184 void UFDBresetGVcounters( struct ufdbGV * gv );
185 
186 void UFDBfreeGV( struct ufdbGV * gv );
187 
188 void UFDBcopyGV( struct ufdbGV * newgv, struct ufdbGV * oldgv );
189 
190 void ufdbFreeLastBits( struct ufdbGV * gv );
191 void ufdbFreeAllMemory( struct ufdbGV * gv );
192 
193 #ifdef __cplusplus
194 }
195 #endif
196 
197 #endif
198 
199