#include "squid.h"
#include "helper/protocol_defines.h"
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
Go to the source code of this file.
Macros | |
#define | KEY_LAST_ACTIVITY "last-activity" |
#define | KEY_PERIOD_START "period-start" |
#define | KEY_PERIOD_LENGTH_CONFIGURED "period-length-configured" |
#define | KEY_TIME_BUDGET_LEFT "time-budget-left" |
#define | KEY_TIME_BUDGET_CONFIGURED "time-budget-configured" |
#define | TQ_BUFFERSIZE 1024 |
Functions | |
static void | open_log (const char *logfilename) |
static void | vlog (const char *level, const char *format, va_list args) |
static void | log_debug (const char *format,...) |
static void | log_info (const char *format,...) |
static void | log_error (const char *format,...) |
static void | log_fatal (const char *format,...) |
static void | init_db (void) |
static void | shutdown_db (void) |
static char * | KeyString (int &len, const char *user_key, const char *sub_key) |
static void | writeTime (const char *user_key, const char *sub_key, time_t t) |
static time_t | readTime (const char *user_key, const char *sub_key) |
static void | parseTime (const char *s, time_t *secs, time_t *start) |
static void | readConfig (const char *filename) |
static void | processActivity (const char *user_key) |
static void | usage (void) |
int | main (int argc, char **argv) |
Variables | |
const char * | db_path = DEFAULT_QUOTA_DB |
const char * | program_name |
TDB_CONTEXT * | db = nullptr |
static int | pauseLength = 300 |
static FILE * | logfile = stderr |
static int | tq_debug_enabled = false |
Macro Definition Documentation
◆ KEY_LAST_ACTIVITY
#define KEY_LAST_ACTIVITY "last-activity" |
Definition at line 57 of file ext_time_quota_acl.cc.
◆ KEY_PERIOD_LENGTH_CONFIGURED
#define KEY_PERIOD_LENGTH_CONFIGURED "period-length-configured" |
Definition at line 59 of file ext_time_quota_acl.cc.
◆ KEY_PERIOD_START
#define KEY_PERIOD_START "period-start" |
Definition at line 58 of file ext_time_quota_acl.cc.
◆ KEY_TIME_BUDGET_CONFIGURED
#define KEY_TIME_BUDGET_CONFIGURED "time-budget-configured" |
Definition at line 61 of file ext_time_quota_acl.cc.
◆ KEY_TIME_BUDGET_LEFT
#define KEY_TIME_BUDGET_LEFT "time-budget-left" |
Definition at line 60 of file ext_time_quota_acl.cc.
◆ TQ_BUFFERSIZE
#define TQ_BUFFERSIZE 1024 |
Maximum size of buffers used to read or display lines.
Definition at line 64 of file ext_time_quota_acl.cc.
Function Documentation
◆ init_db()
|
static |
Definition at line 136 of file ext_time_quota_acl.cc.
References db, db_path, log_fatal(), and log_info().
Referenced by main().
◆ KeyString()
|
static |
Definition at line 151 of file ext_time_quota_acl.cc.
References log_error(), and TQ_BUFFERSIZE.
Referenced by readTime(), and writeTime().
◆ log_debug()
|
static |
Definition at line 98 of file ext_time_quota_acl.cc.
References tq_debug_enabled, and vlog().
Referenced by processActivity(), readConfig(), readTime(), and writeTime().
◆ log_error()
|
static |
Definition at line 118 of file ext_time_quota_acl.cc.
References vlog().
Referenced by KeyString(), parseTime(), readTime(), and usage().
◆ log_fatal()
|
static |
◆ log_info()
|
static |
Definition at line 109 of file ext_time_quota_acl.cc.
References vlog().
Referenced by init_db(), main(), and readConfig().
◆ main()
Definition at line 412 of file ext_time_quota_acl.cc.
References db_path, getopt(), HELPER_INPUT_BUFFER, HLP_MSG, init_db(), log_info(), open_log(), optarg, optind, pauseLength, processActivity(), program_name, readConfig(), SEND_BH, shutdown_db(), tq_debug_enabled, and usage().
◆ open_log()
|
static |
Definition at line 79 of file ext_time_quota_acl.cc.
Referenced by main().
◆ parseTime()
|
static |
Definition at line 212 of file ext_time_quota_acl.cc.
References log_error(), and NULL.
Referenced by readConfig().
◆ processActivity()
|
static |
Definition at line 318 of file ext_time_quota_acl.cc.
References KEY_LAST_ACTIVITY, KEY_PERIOD_LENGTH_CONFIGURED, KEY_PERIOD_START, KEY_TIME_BUDGET_CONFIGURED, KEY_TIME_BUDGET_LEFT, log_debug(), now, NULL, pauseLength, readTime(), SEND_ERR, SEND_OK, TQ_BUFFERSIZE, and writeTime().
Referenced by main().
◆ readConfig()
|
static |
This function parses the time quota file and stores it in memory.
Definition at line 257 of file ext_time_quota_acl.cc.
References KEY_PERIOD_LENGTH_CONFIGURED, KEY_PERIOD_START, KEY_TIME_BUDGET_CONFIGURED, KEY_TIME_BUDGET_LEFT, log_debug(), log_info(), NULL, parseTime(), readTime(), TQ_BUFFERSIZE, and writeTime().
Referenced by main().
◆ readTime()
|
static |
Definition at line 187 of file ext_time_quota_acl.cc.
References db, KeyString(), log_debug(), and log_error().
Referenced by processActivity(), and readConfig().
◆ shutdown_db()
|
static |
◆ usage()
|
static |
Definition at line 398 of file ext_time_quota_acl.cc.
References log_error(), and program_name.
Referenced by main().
◆ vlog()
|
static |
Definition at line 88 of file ext_time_quota_acl.cc.
References logfile, now, NULL, and program_name.
Referenced by log_debug(), log_error(), log_fatal(), and log_info().
◆ writeTime()
|
static |
Definition at line 169 of file ext_time_quota_acl.cc.
References db, KeyString(), and log_debug().
Referenced by processActivity(), and readConfig().
Variable Documentation
◆ db
TDB_CONTEXT* db = nullptr |
Definition at line 55 of file ext_time_quota_acl.cc.
Referenced by Ssl::CertificateDb::addCertAndPrivateKey(), Ssl::CertificateDb::Check(), Ssl::CertificateDb::Create(), Ssl::CertificateDb::deleteByKey(), deleteEntry(), Ssl::CertificateDb::deleteInvalidCertificate(), Ssl::CertificateDb::deleteOldestCertificate(), Ssl::CertificateDb::deleteRow(), fetchKey(), Ssl::CertificateDb::hasRows(), init_db(), Ssl::CertificateDb::load(), processNewRequest(), Ssl::CertificateDb::pure_find(), Ssl::CertificateDb::purgeCert(), readTime(), Ssl::CertificateDb::rebuildSize(), Ssl::CertificateDb::save(), session_login(), shutdown_db(), and writeTime().
◆ db_path
const char* db_path = DEFAULT_QUOTA_DB |
Definition at line 52 of file ext_time_quota_acl.cc.
◆ logfile
|
static |
Definition at line 76 of file ext_time_quota_acl.cc.
Referenced by debugOpenLog(), Log::Format::HttpdCombined(), Log::Format::HttpdCommon(), open_log(), Security::KeyLog::record(), Log::Format::SquidIcap(), Log::Format::SquidNative(), Log::Format::SquidReferer(), Log::Format::SquidUserAgent(), and vlog().
◆ pauseLength
|
static |
If there is more than this given number of seconds between two successive requests, than the second request will be treated as a new request and the time between first and seconds request will be treated as a activity pause.
Otherwise the following request will be treated as belonging to the same activity and the quota will be reduced.
Definition at line 74 of file ext_time_quota_acl.cc.
Referenced by main(), and processActivity().
◆ program_name
const char* program_name |
Definition at line 53 of file ext_time_quota_acl.cc.
◆ tq_debug_enabled
|
static |
Definition at line 77 of file ext_time_quota_acl.cc.
Referenced by log_debug(), and main().