diff options
author | Timo Teräs <timo.teras@iki.fi> | 2010-11-18 16:49:54 +0200 |
---|---|---|
committer | Timo Teräs <timo.teras@iki.fi> | 2010-11-18 16:49:54 +0200 |
commit | 301047f944320fccef17df3431ddd0bd5d1455a0 (patch) | |
tree | 2236d94bc65947758cf62c3205bfc226aa5b68b1 /src | |
parent | afa7bc626af7ee010fbe3604a3ed7a6484be79a7 (diff) | |
download | squark-301047f944320fccef17df3431ddd0bd5d1455a0.tar.bz2 squark-301047f944320fccef17df3431ddd0bd5d1455a0.tar.xz |
filter: return categorization and blocked/overridden status
return the analysis back to squid as urlgroup. it can be then used
in squid config acl's and logging (with patch). ref #447.
Diffstat (limited to 'src')
-rw-r--r-- | src/squark-filter.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/src/squark-filter.c b/src/squark-filter.c index eff88b1..22c8800 100644 --- a/src/squark-filter.c +++ b/src/squark-filter.c @@ -308,12 +308,17 @@ static blob_t get_category_name(struct sqdb *db, int id) return sqdb_get_string_literal(db, c[id]); } -static void send_ok(blob_t tag) +static void send_ok(blob_t tag, blob_t categ, int override) { static char buffer[64]; blob_t b = BLOB_BUF(buffer); blob_push(&b, tag); + blob_push(&b, BLOB_STR(" !")); + blob_push(&b, categ); + if (override) + blob_push(&b, BLOB_STR(",overridden")); + blob_push(&b, BLOB_STR("!")); blob_push(&b, lf); b = blob_pushed(BLOB_BUF(buffer), b); @@ -326,7 +331,9 @@ static void send_redirect(blob_t redirect_page, blob_t tag, blob_t url, blob_t c blob_t b = BLOB_BUF(buffer); blob_push(&b, tag); - blob_push(&b, BLOB_STR(" 302:")); + blob_push(&b, BLOB_STR(" !")); + blob_push(&b, categ); + blob_push(&b, BLOB_STR(",blocked!302:")); blob_push(&b, adbc.redirect_url_base); blob_push(&b, redirect_page); blob_push(&b, BLOB_STR("?REASON=")); @@ -410,7 +417,8 @@ static void read_input(struct sqdb *db) ((1ULL << category) & entry.p.hard_block_categories))) { send_redirect(BLOB_STR("warning.cgi"), id, url, get_category_name(db, category), username); } else - send_ok(id); + send_ok(id, get_category_name(db, category), + !!((1ULL << category) & entry.p.block_categories)); } if (b.len) { |