/* * ufdb.h - URLfilterDB * * ufdbGuard is copyrighted (C) 2005-2020 by URLfilterDB B.V. and others with all rights reserved. * * Parts of the ufdbGuard daemon are based on squidGuard. * This module is NOT based on squidGuard. * * RCS $Id: ufdb.h.in,v 1.103 2020/10/22 07:13:03 root Exp root $ */ /* * An ordered table looks like this: * * UNIVERSE * com * foobar * girls * boys * pools * youtube * /watch?v=id1 * /watch?v=id2 * /watch?v=idN * zazu * net * zazu * zombie * * The ordered table is implemented with a tree and each node in the tree * has nNextLevels children. * * "UNIVERSE" 0xSUBLEVEL * "com" 0xSUBLEVEL "foobar" 0xSUBLEVEL "girls" 0xSAMELEVEL * "boys" 0xPREVLEVEL * "pools" 0xSAMELEVEL * "youtube" 0xSUBLEVEL "/watch" 0xSUBLEVEL "?" 0xSUBLEVEL "v" 0xSUBLEVEL "id1" 0xSAMELEVEL * "id2" 0xSAMELEVEL * "idN" 0xPREVLEVEL * 0xPREVLEVEL 0xPREVLEVEL 0xPREVLEVEL 0xPREVLEVEL * "zazu" 0xPREVLEVEL * "net" 0xSUBLEVEL "zazu" 0xSAMELEVEL * "zombie" 0xPREVLEVEL * 0xPREVLEVEL * 0xENDTABLE * * The idea behind this is that the whole table can be loaded into 1 malloc-ed area * and that the 0xXXXX tokens can be substitued by a '\0' in memory. * Database layout version 2.2 does not do this any more and each tag is terminated with a \0. * The levelTag pointer will point into the table without malloc-ing memory which * will save a lot on malloc overhead, memory and CPU time to load the table. * * The major drawback is that the number of children of a node is unknown when * a table is loaded and the arrays of child nodes (nextLevel[]) must be reallocated * many times. This implies a relatively large malloc()/realloc() overhead. * * To get rid of the malloc() overhead, the number of child nodes (nNextLevels) is * coded into the file. This is a new feature for database file format 1.2. * * Database format 2.0 does not include the number of child nodes so it must be counted when * the database table is loaded into memory * Database format 2.1+ includes codes for the number of children per node: * UFDBsubLevel1-UFDBsubLevel7 1-7 children * UFDBsubLevel 8-255 children * UFDBsubLevelNNN 256-65535 children * UFDBsubLevelNNNNN 65536-4B children * Database format 2.2 has * \0-terminated tags. * support for matching URL paramaters: example.com/foo.cgi?a=val&b&pp=bar * | at end of a database URL means only match if the browser URL terminates there. * New in ufdbguard 1.34.x: a database URL that starts with "|." matches a browser URL that * has not a subdomain other than www[0-9][0-9]. So |.example.com matches www.example.com but not * foo.example.com. */ #ifndef UFDB_UFDB_H_INCLUDED #define UFDB_UFDB_H_INCLUDED #ifdef __cplusplus extern "C" { #endif #ifndef UFDB_NEED_FORTIFIED_CODE #undef _FORTIFY_SOURCE #endif #ifndef _REENTRANT #define _REENTRANT #endif /* on AIX systems we must define _ALL_SOURCE in order to get the symbol NI_NAMEREQD used by getnameinfo() */ #ifdef _AIX #define _ALL_SOURCE 1 #endif #ifndef _XOPEN_SOURCE___ #ifdef __sun #define _XOPEN_SOURCE___ 600 #else #define _XOPEN_SOURCE___ 600 #endif #endif #if __sun && !defined(__EXTENSIONS__) #define __EXTENSIONS__ 1 #endif #if 0 #ifndef _POSIX_C_SOURCE #define _POSIX_C_SOURCE 200112L #endif #endif #if 0 #ifndef _XOPEN_SOURCE____EXTENDED #define _XOPEN_SOURCE____EXTENDED 1 #endif #endif #ifndef _DEFAULT_SOURCE #define _DEFAULT_SOURCE 1 #endif #ifndef _BSD_SOURCE #define _BSD_SOURCE 1 #endif #ifndef UFDB_MALLOC_IS_THREADSAFE #define UFDB_MALLOC_IS_THREADSAFE 1 #endif #define UFDB_DO_NOT_STRIP_FTP 1 #define UFDB_VERSION "@PACKAGE_VERSION@" #define UFDB_SSL_SUPPORT @ufdb_with_ssl@ // ZLIB_SUPPORT: 0 disabled, 1 use standard library, 2 use own library #define UFDB_ZLIB_SUPPORT @ufdb_with_zlib@ #if UFDB_ZLIB_SUPPORT == 2 #define UFDB_OWN_ZLIB_SUPPORT 1 // #define deflate z_deflate // #define deflateInit z_deflateInit // #define deflateEnd z_deflateEnd #endif #define UFDB_BZ2LIB_SUPPORT @ufdb_with_bz2lib@ #define UFDB_PTHREAD_SUPPORT @ufdb_with_pthread@ #define UFDB_FUTEX_SUPPORT @ufdb_with_futex@ #define UFDB_SPINLOCK_SUPPORT @ufdb_with_spinlock@ #define UFDB_CVMX_SPINLOCK_SUPPORT @ufdb_with_cvmx_spinlock@ #define UFDB_BARE_METAL_SUPPORT @ufdb_bare_metal@ #define UFDB_DPDK_SUPPORT @ufdb_dpdk@ #define UFDB_REGEX_SUPPORT @ufdb_regex_support@ #define UFDB_VERIFY_CERTS @ufdb_verify_certs@ #if __OCTEON__ || __ppc__ #define UFDB_CACHELINE_SIZE 128 #else #define UFDB_CACHELINE_SIZE 64 #endif // #ifndef _GNU_SOURCE // #define _GNU_SOURCE // #endif #undef UFDB_64BITS #if defined(__x86_64__) || defined(__amd64__) || __SIZEOF_POINTER__ == 8 #define UFDB_64BITS 1 #endif #if defined(__GNUC__) && defined(__OPTIMIZE__) #define UFDB_GCC_INLINE __inline__ #else #define UFDB_GCC_INLINE #endif #if UFDB_BARE_METAL_SUPPORT && __OCTEON__ #include "cvmx-platform.h" #define UFDB_SHARED CVMX_SHARED #else #define UFDB_SHARED /**/ #endif #if defined(__GNUC__) /* malloc attribute exists since gcc 2.96 */ #define UFDB_GCC_MALLOC_ATTR __attribute__ ((malloc)) #else #define UFDB_GCC_MALLOC_ATTR /**/ #endif #if defined(__GNUC__) && ((__GNUC__ > 3) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3))) #if UFDB_CACHELINE_SIZE == 128 #define UFDB_GCC_ALIGN_CL __attribute__ ((aligned(128))) #else #define UFDB_GCC_ALIGN_CL __attribute__ ((aligned(64))) #endif #else #define UFDB_GCC_ALIGN_CL /**/ #endif #if defined(__GNUC__) #define UFDB_GCC_NORETURN __attribute__ ((noreturn)) #define UFDB_GCC_UNUSED __attribute__ ((unused)) #else #define UFDB_GCC_NORETURN #define UFDB_GCC_UNUSED #endif #if defined(UFDB_64BITS) && defined(__GNUC__) && ((__GNUC__ > 3) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3))) #define UFDB_GCC_DEPRECATED __attribute__ ((deprecated)) #define UFDB_GCC_ALIGN64 __attribute__ ((aligned(64))) #else #define UFDB_GCC_DEPRECATED /**/ #define UFDB_GCC_ALIGN64 /**/ #endif #if defined(UFDB_64BITS) && defined(__GNUC__) && ((__GNUC__ > 3) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3))) #define UFDB_GCC_REGPARM1 __attribute__ ((regparm(1))) #define UFDB_GCC_REGPARM2 __attribute__ ((regparm(2))) #define UFDB_GCC_REGPARM3 __attribute__ ((regparm(3))) #else #define UFDB_GCC_REGPARM1 /**/ #define UFDB_GCC_REGPARM2 /**/ #define UFDB_GCC_REGPARM3 /**/ #endif #if defined(__GNUC__) && ((__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 3))) #define UFDB_GCC_HOT __attribute__ ((hot)) #define UFDB_GCC_COLD __attribute__ ((cold)) #else #define UFDB_GCC_HOT /**/ #define UFDB_GCC_COLD /**/ #endif #include #include "config.h" #include "version.h" #include "ufdblocks.h" #include "ufdb-api-private.h" #if !defined(UFDB_API_NO_THREADS) && UFDB_PTHREAD_SUPPORT #include #endif #if !UFDB_BARE_METAL_SUPPORT #if UFDB_REGEX_SUPPORT && HAVE_REGCOMP != 1 #error The C library does not have the regcomp function. #endif #if HAVE_SIGACTION != 1 #error The C library does not have the sigaction function. #endif #endif #include #include #include #ifdef UFDB_USE_PCREPOSIX #include #else #include #endif #define UFDB_GDB_PATH "@GDB@" #define UFDB_WGET_PATH "@WGET@" #define UFDB_CURL_PATH "@CURL@" #define DEFAULT_DBHOME "@ufdb_dbhome@" #define DEFAULT_IMAGESDIR "@ufdb_images_dir@" #define DEFAULT_BINDIR "@ufdb_bindir@" #define DEFAULT_PIDDIR "@ufdb_piddir@" #define DEFAULT_LOGDIR "@ufdb_logdir@" #define DEFAULT_LOGFILE "ufdbGuard.log" #define DEFAULT_CONFIGFILE "@ufdb_config@/ufdbGuard.conf" #define UFDB_SYSTEM_CONFIG "@ufdb_sysconfigfile@" #define UFDB_DEFAULT_SQUID_VERSION "4.0" #define UFDB_SQUID_HELPER_PROTOCOL1 0 /* 2.x */ #define UFDB_SQUID_HELPER_PROTOCOL2 1 /* 3.0 - 3.3 */ #define UFDB_SQUID_HELPER_PROTOCOL3 2 /* 3.4 - */ #define UFDB_LICENSE_STATUS_FILENAME "license-status" #define UFDB_USER_AGENT "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0)" #define UFDB_ROTATE_LOG_FILES #define UFDB_MAX_INITIAL_LOGFILE_SIZE (200*1024*1024) #define UFDB_MAX_LOGFILE_SIZE (200*1024*1024) #define UFDB_MAX_LOGMSG_SZ (10*1024) #define UFDB_RECONFIGR_NONE 0 #define UFDB_RECONFIGR_INIT 1 #define UFDB_RECONFIGR_FINISH 2 #define UFDB_RECONFIGR_HUP 3 #define UFDB_RECONFIGR_RELOAD 4 #define UFDB_RECONFIGR_TERM 5 #define UFDB_RECONFIGR_ABORT 6 #define UFDB_RECONFIGR_BADSIG 7 #define UFDB_RECONFIGR_FATAL 8 #define UFDB_RECONFIGR_STACK 9 #define UFDB_RECONFIGR_FORTIFY 10 #define UFDB_DEFAULT_REFRESH_USERLIST 15 /* minutes */ #define UFDB_DEFAULT_REFRESH_IPLIST 15 /* minutes */ #define UFDB_DEFAULT_REFRESH_DOMAINLIST 15 /* minutes */ #if UFDB_GEN_API #define UFDB_UUE_MAXURLS 75000 #define UFDB_UUE_HASHSIZE 99371 #else #define UFDB_UUE_MAXURLS 20000 #define UFDB_UUE_HASHSIZE 25643 #endif #ifndef UFDB_UPLOAD_UNCATEGORISED_URLS_WEBSITE #define UFDB_UPLOAD_UNCATEGORISED_URLS_WEBSITE "updates.urlfilterdb.com" #endif #ifndef UFDB_UPLOAD_UNCATEGORISED_URLS_CGI #define UFDB_UPLOAD_UNCATEGORISED_URLS_CGI "/cgi-bin/uncat.pl" #endif #ifndef UFDB_UPLOAD_ANALYSE_SQUID_LOG_CGI #define UFDB_UPLOAD_ANALYSE_SQUID_LOG_CGI "/cgi-bin/analyseSquidLog.pl" #endif #ifndef UFDB_EXPLAIN_DENY_REASON_URL #define UFDB_EXPLAIN_DENY_REASON_URL "http://cgibin.urlfilterdb.com/cgi-bin/explain-denial.cgi" #endif #ifndef UFDB_DEFAULT_HTTPS_REDIRECTION_URL #define UFDB_DEFAULT_HTTPS_REDIRECTION_URL "blockedhttps.urlfilterdb.com:443" #endif #ifndef UFDB_DEFAULT_BUMPED_HTTPS_REDIRECTION_URL #define UFDB_DEFAULT_BUMPED_HTTPS_REDIRECTION_URL "https://blockedhttps.urlfilterdb.com/cgi-bin/URLblocked.cgi?clientgroup=%s&category=%t&url=%u" #endif #ifndef UFDB_DEFAULT_HTTP_RETURN_CODE #define UFDB_DEFAULT_HTTP_RETURN_CODE "302" /* in the past HTTP/1.0 used "302" */ #endif #define UFDB_NNODES_INDEX 2048 #define UFDBGUARDD_PID_FILE DEFAULT_PIDDIR "/ufdbguardd.pid" #define UFDBICAP_PID_FILE "/var/run/urlfilterdb/icapd.pid" #define UFDB_USER "@ufdb_user@" #define UFDB_USERQUOTA_SUPPORT 0 /* support 20 instances of squid with each 64 ufdbgclient processes */ #ifndef UFDB_MIN_THREADS #define UFDB_MIN_THREADS (64+1) #endif #ifndef UFDB_MAX_THREADS #define UFDB_MAX_THREADS (20*64+5) #endif #define UFDB_DAEMON_PORT 3977 /* ufdbgclient can support up to concurrency=N queries simultaneously */ #define UFDB_MAX_SQUID_CONCURRENCY 32 /* The HTTP 1.1 spec says that proxies must be able to handle requests * with a very long URI. So what we will do is that ufdbgclient * will support this and truncate the URL to have a maximum length * of UFDB_MAX_URL_LENGTH. */ #define UFDB_HTTP_1_1_MAX_URI_LENGTH 65536 #define UFDB_MAX_URL_LENGTH 8192 #define UFDB_EVAL_OR 0 #define UFDB_EVAL_AND 1 int ufdbReadConfig( const char * file ); void ufdbReloadConfig( void ); void ufdbFree( void * ptr ); void * UFDB_GCC_MALLOC_ATTR ufdbMalloc( size_t n ); void * UFDB_GCC_MALLOC_ATTR ufdbMallocAligned( size_t alignment, size_t n ); void * ufdbRealloc( void * ptr, size_t n ); void * ufdbCalloc( size_t n, size_t num ); #if UFDB_DP_DEV void ufdbMallocInitDPdevelopment( void ); #endif void * ufdbZlibMalloc( void * opaque, unsigned int items, unsigned int size ); void ufdbZlibFree( void * opaque, void * address ); void ufdbGetMallocMutex( char * fn ); void ufdbReleaseMallocMutex( char * fn ); char * ufdbStrdup( const char * s ); int ufdbStrStrEnd( const char * s, const char * end ); #define ufdbStrncpy( dest, src, n ) \ if (memccpy( (void *) (dest), (void *) (src), '\0', (size_t) (n) ) == NULL) \ (dest)[(n)-1] = '\0'; #define UFDB_MAGIC_CATEGORY_IS_LOADED 0x62f87ce9 #ifndef UFDB_MAX_TABLE_AGE #define UFDB_MAX_TABLE_AGE 28 #endif #ifndef UFDB_WARN_TABLE_AGE #define UFDB_WARN_TABLE_AGE 4 #endif typedef enum { UFDBdomain, UFDBurl } UFDBurlType; struct UFDBtable; struct UFDBtable { unsigned char * tag; int nNextLevels; struct UFDBtable * nextLevel; }; struct UFDBfileHeader { char string[99]; /* UFDB version category numEntries key */ }; struct UFDBfileHeader21 { char string[256]; /* UFDB version category numEntries key */ }; struct UFDBfile { struct UFDBfileHeader21 header; struct UFDBtable table; }; #define UFDB_MEMSTATUS_UNKNOWN 0 #define UFDB_MEMSTATUS_MALLOC 1 // malloced, may be freed with ufdbFree() #define UFDB_MEMSTATUS_DP 2 // DP memory may not be freed with ufdbFree() struct UFDBmemTable { void * mem; struct UFDBtable table; struct UFDBtable * index; int numEntries; int indexSize; int hdrSize; int age; int memStatus; size_t madvisedSize; long fileSize; char version[8]; char flags[8]; char key[16]; char date[32]; }; typedef struct { unsigned int x; unsigned int y; unsigned char state[256]; } ufdbCrypt; void ufdbCryptInit( ufdbCrypt * uc, const unsigned char * key, unsigned int keySize, char * version ); void ufdbEncryptText( ufdbCrypt * uc, unsigned char * dest, const unsigned char * src, unsigned int len ); /* space optimisation for database format 2.1: * ufdbsubLevel1 meaning "UFDBsubLevel with only one child" * ufdbsubLevelNNN meaning "UFDBsubLevel with >255 children" */ #define UFDBsubLevel '\001' /* between 8 and 255 children */ #define UFDBsameLevel '\002' #define UFDBprevLevel '\003' #define UFDBsubLevel1 '\004' /* 1 child */ #define UFDBsubLevel2 '\005' /* 2 children */ #define UFDBsubLevel3 '\006' /* 3 children */ #define UFDBsubLevel4 '\007' /* 4 children */ #define UFDBsubLevel5 '\010' /* 5 children */ #define UFDBsubLevel6 '\011' /* 6 children */ #define UFDBsubLevel7 '\012' /* 7 children */ #define UFDBsubLevelNNN '\013' /* until DB2.1: >255 children. DB2.2: >255 && <65536 */ #define UFDBsubLevelNNNNN '\014' /* DB2.2: >65535 children */ #define UFDBsubLevelIndexed '\015' /* >UFDB_NNODES_INDEX children and index follows */ #define UFDBendTable '\020' /* UFDBendTable is also used in in DB format 3.0 */ #define UFDBpadTable '\021' /* skip padding bytes */ #define UFDBmaxDomainNameLength 255 #define UFDBmaxURLsize 512 #if UFDB_DBFORMAT_3 #define UFDBdefaultdbVersion "@ufdb_db_format@" #define UFDBdbVersion "@ufdb_db_format@" /* max DB version */ #else #define UFDBdefaultdbVersion "2.2" #define UFDBdbVersion "2.2" /* max DB version */ #endif #define UFDBtableTag "gYhq-2k8a-8xGx-7zYs-huUj-1jaY" #define UFDBfileSuffix ".ufdb" #ifndef UFDB_REVURL_LABEL_SIZE #define UFDB_REVURL_LABEL_SIZE 256 #endif /* when URL is www.mydomain.com/asubdir/index.html, * urlPart is asubdir/index.html */ typedef unsigned char UFDBurlPart[UFDB_REVURL_LABEL_SIZE-8-4]; struct UFDBrevURL_s; /* for optimal use of the CPU cache we want to have a struct of 256 bytes and pad it if necessary */ typedef struct UFDBrevURL_s { struct UFDBrevURL_s * next; uint32_t hashval; // only used in DB format 3.0 UFDBurlPart part; #if defined(LONG_BIT) && (LONG_BIT == 32) char dummy[4]; #endif } UFDBrevURL; #define MAX_REVURLS 16 typedef struct UFDBthreadAdmin_s { int myArrayUsage[MAX_REVURLS]; // 16*4 = 64 bytes #if UFDB_CACHELINE_SIZE == 128 char dummy[64]; // extra 64 byte so myArray starts on a new cache line #endif UFDBrevURL myArray[MAX_REVURLS]; // 16*256 = 4096 bytes } UFDBthreadAdmin; // 64+64+4096 = 4224 bytes UFDBthreadAdmin * UFDBallocThreadAdmin( void ); void UFDBfreeThreadAdmin( UFDBthreadAdmin * handle ); #define UFDB_ALLOW 0 #define UFDB_DENY 1 #define UFDB_GROUPTYPE_UNIX 1 #define UFDB_GROUPTYPE_LDAP 2 #define UFDB_ACL_ACCESS_BLOCK 0 #define UFDB_ACL_ACCESS_ALLOW 1 #define UFDB_ACL_ACCESS_DUNNO 2 #define UFDB_API_STATUS_VIRGIN 0 #define UFDB_API_STATUS_STARTED_OK 1 #define UFDB_API_STATUS_TERMINATED 2 #define UFDB_API_STATUS_RELOADING 3 #define UFDB_API_STATUS_RELOAD_OK 4 #define UFDB_API_STATUS_FATAL_ERROR 5 #define UFDB_API_STATUS_ROLLING_LOGFILE 6 #define UFDB_API_STATUS_UPDATE 7 #define UFDB_API_STATUS_CRASH_REPORT_UPLOADED 8 #define UFDB_API_STATUS_CRASH_REPORT_NOT_UPLOADED 9 #define UFDB_API_STATUS_DATABASE_OK 0 #define UFDB_API_STATUS_DATABASE_OLD 1 #define UFDB_API_STATUS_DATABASE_EXPIRED 2 #define UFDB_API_OK 0 #define UFDB_API_MATCH 1 #define UFDB_API_ERR_NULL 2 #define UFDB_API_ERR_NOFILE 3 #define UFDB_API_ERR_READ 4 #define UFDB_API_ERR_EXPR 5 #define UFDB_API_ERR_RANGE 6 #define UFDB_API_ERR_ERRNO 7 #define UFDB_API_ERR_SOCKET 8 #define UFDB_API_ERR_NOMEM 9 #define UFDB_API_REQ_QUEUED 10 #define UFDB_API_ERR_TUNNEL 11 #define UFDB_API_ERR_INVALID_CERT 12 #define UFDB_API_ERR_IP_ADDRESS 13 #define UFDB_API_ERR_OLD_TABLE 14 #define UFDB_API_ERR_INVALID_TABLE 15 #define UFDB_API_ERR_INVALID_KEY 16 #define UFDB_API_ERR_IS_SKYPE 17 #define UFDB_API_ERR_FULL 18 #define UFDB_API_ERR_UNKNOWN_PROTOCOL 19 #define UFDB_API_ERR_IS_GTALK 20 #define UFDB_API_ERR_IS_YAHOOMSG 21 #define UFDB_API_ERR_IS_AIM 22 #define UFDB_API_ERR_IS_FBCHAT 23 #define UFDB_API_ERR_IS_CITRIXONLINE 24 #define UFDB_API_ERR_IS_ANYDESK 25 #define UFDB_API_ERR_IS_TEAMVIEWER 26 #define UFDB_API_ERR_CKSUM_NOT_VALID 27 #define UFDB_API_ERR_OUTDATED 28 #define UFDB_API_ERR_FATAL 29 #define UFDB_API_ERR_TLS 30 #define UFDB_API_BEING_VERIFIED 31 #define UFDB_API_MODIFIED_FOR_SAFESEARCH 32 #define UFDB_API_MODIFIED_FOR_YOUTUBE_EDUFILTER 33 /* reasons why a URL is approved/blocked */ #define UFDB_API_BLOCKR_PASS 0 #define UFDB_API_BLOCKR_ACL 1 #define UFDB_API_BLOCKR_ACL_NONE 2 #define UFDB_API_BLOCKR_HTTPS_OPTION 3 #define UFDB_API_BLOCKR_SKYPE 4 #define UFDB_API_BLOCKR_SAFESEARCH 5 #define UFDB_API_BLOCKR_LOADING_DB 6 #define UFDB_API_BLOCKR_FATAL_ERROR 7 #define UFDB_API_BLOCKR_CHECKED 8 #define UFDB_API_BLOCKR_YOUTUBE_EDUFILTER 9 #define UFDB_API_ALLOW_QUEUING 1 #define UFDB_API_VERBOSE_OUTPUT 2 #define UFDB_OPT_HTTPS_WITH_HOSTNAME 4 #define UFDB_OPT_HTTPS_OFFICAL_CERTIFICATE 8 #define UFDB_OPT_SKYPE_OVER_HTTPS 16 #define UFDB_OPT_PROHIBIT_INSECURE_SSLV2 32 #define UFDB_OPT_SAFE_SEARCH 64 #define UFDB_OPT_UNKNOWN_PROTOCOL_OVER_HTTPS 128 #define UFDB_OPT_GTALK_OVER_HTTPS 256 #define UFDB_OPT_YAHOOMSG_OVER_HTTPS 512 #define UFDB_OPT_AIM_OVER_HTTPS 1024 #define UFDB_OPT_FBCHAT_OVER_HTTPS 2048 #define UFDB_OPT_CITRIXONLINE_OVER_HTTPS 4096 #define UFDB_OPT_YOUTUBE_EDUFILTER 8192 #define UFDB_OPT_ANYDESK_OVER_HTTPS 16384 #define UFDB_OPT_TEAMVIEWER_OVER_HTTPS 32768 #define UFDB_OPT_PROHIBIT_INSECURE_SSLV3 65536 #define UFDB_API_HTTPS_CHECK_OFF 0 #define UFDB_API_HTTPS_CHECK_QUEUE_CHECKS 1 #define UFDB_API_HTTPS_CHECK_AGGRESSIVE 2 #define UFDB_API_HTTPS_CHECK_AGRESSIVE UFDB_API_HTTPS_CHECK_AGGRESSIVE #define UFDB_API_HTTPS_LOG_ONLY 3 #define UFDB_ACL_NONE 0 #define UFDB_ACL_WITHIN 1 #define UFDB_ACL_OUTSIDE 2 #define UFDB_ACL_ELSE 3 #define UFDB_PARAM_INIT 1 #define UFDB_PARAM_ALARM 2 #define UFDB_DEF_HTTPS_CONN_CACHE_SIZE 1000 #if UFDB_API_NO_THREADS || UFDB_SMALLSYSTEM || HAVE_PCRE_COMPILE || HAVE_PCRE_COMPILE2 #define UFDB_NREGEX 1 #elif UFDB_GEN_API #define UFDB_NREGEX 8 #else #define UFDB_NREGEX 4 /* best performance when using 4 cores with 8 threads */ #endif /* On Linux, regexec() uses a lock and is therefore not multithreaded. * This is resolved by using multiple copies of compiled regex_t so * at most UFDB_NREGEX threads can work simultaneously on the same RE. */ struct ufdbRegExp { void * compiled[UFDB_NREGEX]; /* regex_t* or pcre* */ int error; int flags; int global; char * pattern; char * substitute; char * httpcode; struct ufdbRegExp * next; #if !(UFDB_API_NO_THREADS || UFDB_SMALLSYSTEM) int next_nregex_i; ufdb_mutex lock; #endif }; struct ufdbRegExp * ufdbNewPatternBuffer( char * pattern, int flags ); int ufdbRegExpMatch( struct ufdbRegExp * regexp, const char * str ); void ufdbSetSignalHandler( int signal, void (*handler)(int) ); int UFDBaddSafeSearch( char * domain, char * strippedURL, char * originalURL ); int UFDBaddYoutubeEdufilter( char * domain, char * strippedURL, char * originalURL ); void ufdbHandleAlarmForTimeEvents( int why ); #include "ufdb_globals.h" #if UFDB_DBFORMAT_3 #include "ufdbdb3.h" #endif #ifdef __cplusplus } #endif #endif