From 90b8f5899a5881106bdd0873b6741bc747190218 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timo=20Ter=C3=A4s?= Date: Tue, 14 Jun 2011 16:14:52 +0300 Subject: Revert "filter: rename modes to something that makes more sense" This reverts commit a4180db79a80882f81bc8c880ec1e2db5ee9bf6d. --- src/squark-filter.c | 54 +++++++++++++++++++++++++---------------------------- 1 file changed, 25 insertions(+), 29 deletions(-) diff --git a/src/squark-filter.c b/src/squark-filter.c index 5615e9e..db8fb38 100644 --- a/src/squark-filter.c +++ b/src/squark-filter.c @@ -26,8 +26,8 @@ #define FILTER_OVERRIDE_TIMEOUT (15*60) -#define MODE_CATEGORIZE 0 -#define MODE_FILTER 1 +#define MODE_NOAUTH 0 +#define MODE_TRACK 1 #define MODE_CAPTIVE 2 static struct sqdb db; @@ -407,23 +407,22 @@ static void read_input(struct sqdb *db) else category = 0; - if (mode == MODE_CATEGORIZE) { - send_ok(id, get_category_name(db, category), 0); - continue; - } - - token = authdb_get(&adb, &addr, &entry, 1); - if (authdb_check_login(token, &entry, username, now, &adbc)) { - auth_ok = 1; - username = BLOB_STRLEN(entry.p.login_name); - } else if (mode == MODE_FILTER) { + if (mode == MODE_NOAUTH) { auth_ok = 1; - authdb_clear_entry(&entry); - memcpy(entry.p.login_name, username.ptr, username.len); - authdb_commit_login(token, &entry, now, &adbc); } else { - /* mode == MODE_CAPTIVE, and not authenticated */ - auth_ok = 0; + token = authdb_get(&adb, &addr, &entry, 1); + if (authdb_check_login(token, &entry, username, now, &adbc)) { + auth_ok = 1; + username = BLOB_STRLEN(entry.p.login_name); + } else if (mode == MODE_TRACK) { + auth_ok = 1; + authdb_clear_entry(&entry); + memcpy(entry.p.login_name, username.ptr, username.len); + authdb_commit_login(token, &entry, now, &adbc); + } else { + /* mode == MODE_CAPTIVE, and not authenticated */ + auth_ok = 0; + } } if (!auth_ok) { @@ -433,10 +432,9 @@ static void read_input(struct sqdb *db) now > entry.override_time + FILTER_OVERRIDE_TIMEOUT || ((1ULL << category) & entry.p.hard_block_categories))) { send_redirect(BLOB_STR("warning.cgi"), id, url, get_category_name(db, category), username); - } else { + } else send_ok(id, get_category_name(db, category), !!((1ULL << category) & entry.p.block_categories)); - } } if (b.len) { @@ -450,15 +448,13 @@ static void read_input(struct sqdb *db) static int usage(const char *progname) { fprintf(stderr, - "Usage: %s [-m {categorize|filter|captive}]\n" + "Usage: %s [-m {captive|track|nauth}]\n" "\n" "Program arguments:\n" " -m Select authentication mode:\n" - " categorize just analyze URLs and report it to squid\n" - " filter categorization and additionally blocking with\n" - " per-user override possiblity\n" - " captive as filter and require authentication with\n" - " captive portal type login\n" + " captive captive portal authentication enforced\n" + " track squid authentication is tracked if available\n" + " noauth authentication infromation is ignored (filter only)\n", progname); return 1; } @@ -472,10 +468,10 @@ int main(int argc, char **argv) case 'm': if (!strcmp(optarg, "captive")) mode = MODE_CAPTIVE; - else if (!strcmp(optarg, "filter")) - mode = MODE_FILTER; - else if (!strcmp(optarg, "categorize")) - mode = MODE_CATEGORIZE; + else if (!strcmp(optarg, "track")) + mode = MODE_TRACK; + else if (!strcmp(optarg, "noauth")) + mode = MODE_NOAUTH; else return usage(argv[0]); break; -- cgit v1.2.3